org.bdware.doip.cluster.util.DoipArgUtil.backup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doip-audit-tool Show documentation
Show all versions of doip-audit-tool Show documentation
doip audit tool developed by bdware
package org.bdware.doip.cluster.util;
import com.google.gson.JsonObject;
import org.bdware.doip.codec.digitalObject.DigitalObject;
import org.bdware.doip.codec.metadata.SearchParameter;
import org.bdware.doip.codec.operations.BasicOperations;
// 根据请求参数,组装RouteInfo的参数Arg
public class DoipArgUtil {
public static JsonObject composeRouteInfoArg(BasicOperations operation, String identifier, SearchParameter sp, String element, boolean includeElementData, DigitalObject digitalObject) {
JsonObject composedRes = new JsonObject();
JsonObject headerProperties = new JsonObject();
headerProperties.addProperty("identifier", identifier);
switch (operation) {
case Hello:
case Delete:
case ListOps:
break;
case Create:
case Update:
// composedRes.addProperty("body", digitalObject.toString());
break;
case Search:
JsonObject searchAttributes = new JsonObject();
searchAttributes.addProperty("query", sp.query);
searchAttributes.addProperty("pageNum", sp.pageNum);
searchAttributes.addProperty("pageSize", sp.pageSize);
searchAttributes.addProperty("type", sp.type);
headerProperties.add("attributes", searchAttributes);
break;
case Retrieve:
JsonObject retrieveAttributes = new JsonObject();
if(element != null) retrieveAttributes.addProperty("element", element);
if(includeElementData) retrieveAttributes.addProperty("includeElementData", "true");
if(!retrieveAttributes.equals(new JsonObject())) headerProperties.add("attributes", retrieveAttributes);
break;
}
composedRes.add("header", headerProperties);
return composedRes;
}
}