use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiServiceCacheWrapper method initCache.
@Override
public void initCache(Map<String, ApiResource> resources, IApiCatalogDAO apiCatalogDAO) throws ApsSystemException {
try {
Cache cache = this.getCache();
this.releaseCachedObjects(cache);
List<ApiMethod> apiGETMethods = buildApiGetMethods(resources);
Map<String, ApiService> services = apiCatalogDAO.loadServices(apiGETMethods);
this.insertObjectsOnCache(cache, services);
} catch (Throwable t) {
logger.error("Error bootstrapping ApiCatalog cache", t);
throw new ApsSystemException("Error bootstrapping ApiCatalog cache", t);
}
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiCatalogManager method getRelatedMethod.
@Override
public ApiMethod getRelatedMethod(String showletCode) throws ApsSystemException {
List<ApiMethod> masterMethods = this.getMasterMethods(ApiMethod.HttpMethod.GET);
for (int i = 0; i < masterMethods.size(); i++) {
ApiMethod apiMethod = masterMethods.get(i);
ApiMethodRelatedWidget relatedWidget = apiMethod.getRelatedWidget();
if (null != relatedWidget && relatedWidget.getWidgetCode().equals(showletCode)) {
return apiMethod.clone();
}
}
return null;
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ApiCatalogManager method getRelatedWidgetMethods.
@Override
public Map<String, ApiMethod> getRelatedWidgetMethods() throws ApsSystemException {
Map<String, ApiMethod> mapping = new HashMap<String, ApiMethod>();
try {
List<ApiMethod> masterMethods = this.getMasterMethods(ApiMethod.HttpMethod.GET);
for (int i = 0; i < masterMethods.size(); i++) {
ApiMethod apiMethod = masterMethods.get(i);
ApiMethodRelatedWidget relatedWidget = apiMethod.getRelatedWidget();
if (null != relatedWidget) {
String widgetCode = relatedWidget.getWidgetCode();
if (mapping.containsKey(widgetCode)) {
ApiMethod alreadyMapped = mapping.get(widgetCode);
logger.error("There is more than one method related whith widget '{}' - Actual mapped '{}'; other method '{}'", widgetCode, alreadyMapped.getResourceName(), apiMethod.getResourceName());
} else {
mapping.put(widgetCode, apiMethod.clone());
}
}
}
} catch (Throwable t) {
logger.error("Error loading related widget methods", t);
throw new ApsSystemException("Error loading related widget methods", t);
}
return mapping;
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ResponseBuilder method createResponse.
@Override
@Deprecated
public Object createResponse(String resourceName, Properties parameters) throws ApsSystemException {
Object apiResponse = null;
try {
ApiMethod method = this.extractApiMethod(ApiMethod.HttpMethod.GET, null, resourceName);
apiResponse = this.createResponse(method, parameters);
} catch (ApiException e) {
_logger.error("Error creating response for method GET, resource '{}'", resourceName, e);
if (apiResponse == null) {
apiResponse = new StringApiResponse();
}
((AbstractApiResponse) apiResponse).addErrors(e.getErrors());
}
return apiResponse;
}
use of org.entando.entando.aps.system.services.api.model.ApiMethod in project entando-core by entando.
the class ResponseBuilder method invoke.
@Override
@Deprecated
public Object invoke(String resourceName, Properties parameters) throws ApiException, ApsSystemException {
Object result = null;
try {
ApiMethod api = this.extractApiMethod(ApiMethod.HttpMethod.GET, null, resourceName);
this.checkParameter(api, parameters);
Object bean = this.extractBean(api);
result = this.invokeGetMethod(api, bean, "", parameters, true);
} catch (ApiException ae) {
_logger.error("Error invoking method GET for resource '{}'", resourceName, ae);
throw ae;
} catch (Throwable t) {
_logger.error("Error invoking method GET for resource '{}'", resourceName, t);
throw new ApsSystemException("Error invoking method GET for resource '" + resourceName + "'", t);
}
return result;
}
Aggregations