use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiResourceAction method updateMethodStatus.
public String updateMethodStatus() {
try {
String result = this.checkMethod();
if (null != result)
return result;
ApiMethod method = this.extractMethod();
String requiredAuthority = this.getRequest().getParameter(method.getHttpMethod().toString() + "_methodAuthority");
String active = this.getRequest().getParameter(method.getHttpMethod().toString() + "_active");
String hidden = this.getRequest().getParameter(method.getHttpMethod().toString() + "_hidden");
if (null == requiredAuthority) {
// TODO MANAGE
return SUCCESS;
}
this.updateMethodStatus(method, requiredAuthority, active, hidden);
} catch (Throwable t) {
_logger.error("Error updating method status", t);
// ApsSystemUtils.logThrowable(t, this, "updateMethodStatus", "Error updating method status");
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiServiceAction method copyFromWidget.
/**
* Copy an exist widget (physic and with parameters, joined with a exist api
* method) and value the form of creation of new api service.
*
* @return The result code.
*/
public String copyFromWidget() {
try {
String check = this.checkMasterMethod(this.getNamespace(), this.getResourceName());
if (null != check) {
return check;
}
ApiMethod masterMethod = this.getMethod(this.getNamespace(), this.getResourceName());
// TODO Verify if DRAFT/ONLINE
IPage page = this.getPageManager().getOnlinePage(this.getPageCode());
if (null == page) {
this.addFieldError("pageCode", this.getText("error.service.paste.invalidPageCode", new String[] { this.getPageCode() }));
return INPUT;
}
Widget[] widgets = page.getWidgets();
if (null == this.getFramePos() || this.getFramePos() > widgets.length || null == widgets[this.getFramePos()]) {
String framePosString = (null != this.getFramePos()) ? this.getFramePos().toString() : "null";
this.addFieldError("framePos", this.getText("error.service.paste.invalidFramePos", new String[] { this.getPageCode(), framePosString }));
return INPUT;
}
Widget masterWidget = widgets[this.getFramePos()];
WidgetType type = (masterWidget.getType().isLogic()) ? masterWidget.getType().getParentType() : masterWidget.getType();
if (null == masterMethod.getRelatedWidget() || !masterMethod.getRelatedWidget().getWidgetCode().equals(type.getCode())) {
this.addFieldError("framePos", this.getText("error.service.paste.invalidWidget", new String[] { masterWidget.getType().getCode(), masterMethod.getResourceName() }));
return INPUT;
}
ApsProperties parameters = this.extractParametersFromWidget(masterMethod.getRelatedWidget(), masterWidget);
this.setApiParameterValues(parameters);
this.setApiParameters(masterMethod.getParameters());
this.setStrutsAction(ApsAdminSystemConstants.PASTE);
this.setServiceKey(this.buildTempKey(masterMethod.getResourceName()));
} catch (Throwable t) {
_logger.error("error in copyFromWidget", t);
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiServiceAction method checkMasterMethod.
protected String checkMasterMethod(String namespace, String resourceName) throws Throwable {
if (resourceName == null) {
this.addActionError(this.getText("error.service.new.masterApiMethod.required"));
return INPUT;
}
ApiMethod masterMethod = this.getMethod(namespace, resourceName);
if (masterMethod == null) {
this.addActionError(this.getText("error.service.new.masterApiMethod.invalid"));
return INPUT;
}
if (!masterMethod.isCanSpawnOthers()) {
if (null != namespace) {
String[] args = { masterMethod.getResourceName(), masterMethod.getNamespace() };
this.addActionError(this.getText("error.service.new.masterApiMethod.unspawnable2", args));
} else {
String[] args = { masterMethod.getResourceName() };
this.addActionError(this.getText("error.service.new.masterApiMethod.unspawnable", args));
}
return INPUT;
}
return null;
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiResourceFinderAction method includeIntoMapping.
@Override
protected boolean includeIntoMapping(ApiResource apiResource) {
ApiMethod GETMethod = apiResource.getGetMethod();
ApiMethod POSTMethod = apiResource.getPostMethod();
ApiMethod PUTMethod = apiResource.getPutMethod();
ApiMethod DELETEMethod = apiResource.getDeleteMethod();
return (this.isVisible(GETMethod) || this.isVisible(POSTMethod) || this.isVisible(PUTMethod) || this.isVisible(DELETEMethod));
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class SelfRestCaller method executePostProcess.
@Override
public int executePostProcess(IPostProcess postProcess) throws InvalidPostProcessResultException, ApsSystemException {
if (!(postProcess instanceof SelfRestCallPostProcess)) {
return 0;
}
SelfRestCallPostProcess selfRestCall = (SelfRestCallPostProcess) postProcess;
IResponseBuilder responseBuilder = this.getResponseBuilder();
try {
Object result = null;
ApiMethod method = responseBuilder.extractApiMethod(selfRestCall.getMethod(), selfRestCall.getNamespace(), selfRestCall.getResourceName());
Properties properties = this.extractParameters(selfRestCall);
if (method.getHttpMethod().equals(ApiMethod.HttpMethod.GET) || method.getHttpMethod().equals(ApiMethod.HttpMethod.DELETE)) {
result = responseBuilder.createResponse(method, properties);
} else {
String contentBody = this.getContentBody(selfRestCall);
Object bodyObject = UnmarshalUtils.unmarshal(method, contentBody, selfRestCall.getContentType());
result = responseBuilder.createResponse(method, bodyObject, properties);
}
Response.Status responseStatus = this.extractResponseStatusCode(result);
if (selfRestCall.isPrintResponse()) {
this.printResponse(selfRestCall, result, responseStatus, method, properties);
}
} catch (InvalidPostProcessResultException t) {
_logger.error("error in executePostProcess", t);
// ApsSystemUtils.logThrowable(t, this, "executePostProcess", t.getMessage());
throw t;
} catch (Throwable t) {
_logger.error("Error invoking api method", t);
// ApsSystemUtils.logThrowable(t, this, "executePostProcess", "Error invoking api method");
throw new ApsSystemException("Error invoking api method", t);
}
return 1;
}
Aggregations