use of org.glassfish.admin.rest.provider.MethodMetaData in project Payara by payara.
the class CollectionLeafResource method getMethodMetaData.
protected Map<String, MethodMetaData> getMethodMetaData() {
Map<String, MethodMetaData> mmd = new TreeMap<String, MethodMetaData>();
// GET meta data
mmd.put("GET", new MethodMetaData());
// POST meta data
String postCommand = getPostCommand();
if (postCommand != null) {
MethodMetaData postMethodMetaData = ResourceUtil.getMethodMetaData(postCommand, locatorBridge.getRemoteLocator());
mmd.put("POST", postMethodMetaData);
}
// DELETE meta data
String deleteCommand = getDeleteCommand();
if (deleteCommand != null) {
MethodMetaData deleteMethodMetaData = ResourceUtil.getMethodMetaData(deleteCommand, locatorBridge.getRemoteLocator());
mmd.put("DELETE", deleteMethodMetaData);
}
return mmd;
}
use of org.glassfish.admin.rest.provider.MethodMetaData in project Payara by payara.
the class TemplateListOfResource method buildActionReportResult.
protected ActionReportResult buildActionReportResult() {
if (entity == null) {
// wrong resource
String errorMessage = localStrings.getLocalString("rest.resource.erromessage.noentity", "Resource not found.");
return ResourceUtil.getActionReportResult(ActionReport.ExitCode.FAILURE, errorMessage, requestHeaders, uriInfo);
}
RestActionReporter ar = new RestActionReporter();
final String typeKey = (decode(getName(uriInfo.getPath(), '/')));
ar.setActionDescription(typeKey);
OptionsResult optionsResult = new OptionsResult(Util.getResourceName(uriInfo));
Map<String, MethodMetaData> mmd = getMethodMetaData();
optionsResult.putMethodMetaData("GET", mmd.get("GET"));
optionsResult.putMethodMetaData("POST", mmd.get("POST"));
ResourceUtil.addMethodMetaData(ar, mmd);
ar.getExtraProperties().put("childResources", ResourceUtil.getResourceLinks(getEntity(), uriInfo));
ar.getExtraProperties().put("commands", ResourceUtil.getCommandLinks(getCommandResourcesPaths()));
// an internal impl detail, so it can wait
return new ActionReportResult(ar, optionsResult);
}
use of org.glassfish.admin.rest.provider.MethodMetaData in project Payara by payara.
the class TemplateRestResource method buildActionReportResult.
protected ActionReportResult buildActionReportResult(boolean showEntityValues) {
RestActionReporter ar = new RestActionReporter();
ar.setExtraProperties(new Properties());
ConfigBean entity = (ConfigBean) getEntity();
if (childID != null) {
ar.setActionDescription(childID);
} else if (childModel != null) {
ar.setActionDescription(childModel.getTagName());
}
if (showEntityValues) {
if (entity != null) {
ar.getExtraProperties().put("entity", getAttributes(entity));
}
}
OptionsResult optionsResult = new OptionsResult(Util.getResourceName(uriInfo));
Map<String, MethodMetaData> mmd = getMethodMetaData();
optionsResult.putMethodMetaData("GET", mmd.get("GET"));
optionsResult.putMethodMetaData("POST", mmd.get("POST"));
optionsResult.putMethodMetaData("DELETE", mmd.get("DELETE"));
ResourceUtil.addMethodMetaData(ar, mmd);
if (entity != null) {
ar.getExtraProperties().put("childResources", ResourceUtil.getResourceLinks(entity, uriInfo, ResourceUtil.canShowDeprecatedItems(locatorBridge.getRemoteLocator())));
}
ar.getExtraProperties().put("commands", ResourceUtil.getCommandLinks(getCommandResourcesPaths()));
return new ActionReportResult(ar, entity, optionsResult);
}
use of org.glassfish.admin.rest.provider.MethodMetaData in project Payara by payara.
the class TemplateRestResource method getMethodMetaData.
private Map<String, MethodMetaData> getMethodMetaData() {
Map<String, MethodMetaData> map = new TreeMap<String, MethodMetaData>();
// GET meta data
map.put("GET", new MethodMetaData());
// ///optionsResult.putMethodMetaData("POST", new MethodMetaData());
MethodMetaData postMethodMetaData = ResourceUtil.getMethodMetaData(childModel);
map.put("POST", postMethodMetaData);
// DELETE meta data
String command = getDeleteCommand();
if (command != null) {
MethodMetaData deleteMethodMetaData;
if (command.equals("GENERIC-DELETE")) {
deleteMethodMetaData = new MethodMetaData();
} else {
deleteMethodMetaData = ResourceUtil.getMethodMetaData(command, locatorBridge.getRemoteLocator());
// In case of delete operation(command), do not display/provide id attribute.
deleteMethodMetaData.removeParamMetaData("id");
}
map.put("DELETE", deleteMethodMetaData);
}
return map;
}
use of org.glassfish.admin.rest.provider.MethodMetaData in project Payara by payara.
the class ResourceUtil method getMethodMetaData.
/**
* Constructs and returns the resource method meta-data.
*
* @param command the command associated with the resource method
* @param commandParamsToSkip the command parameters for which not to
* include the meta-data.
* @param habitat the habitat
* @param logger the logger to use
* @return MethodMetaData the meta-data store for the resource method.
*/
public static MethodMetaData getMethodMetaData(String command, HashMap<String, String> commandParamsToSkip, ServiceLocator habitat) {
MethodMetaData methodMetaData = new MethodMetaData();
if (command != null) {
Collection<CommandModel.ParamModel> params;
if (commandParamsToSkip == null) {
params = getParamMetaData(command, habitat);
} else {
params = getParamMetaData(command, commandParamsToSkip.keySet(), habitat);
}
if (params != null) {
Iterator<CommandModel.ParamModel> iterator = params.iterator();
CommandModel.ParamModel paramModel;
while (iterator.hasNext()) {
paramModel = iterator.next();
Param param = paramModel.getParam();
ParameterMetaData parameterMetaData = getParameterMetaData(paramModel);
String parameterName = (param.primary()) ? "id" : paramModel.getName();
// If the Param has an alias, use it instead of the name
String alias = param.alias();
if (alias != null && (!alias.isEmpty())) {
parameterName = alias;
}
methodMetaData.putParameterMetaData(parameterName, parameterMetaData);
}
}
}
return methodMetaData;
}
Aggregations