Search in sources :

Example 1 with ApiMethodRelatedWidget

use of org.entando.entando.aps.system.services.api.model.ApiMethodRelatedWidget 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;
}
Also used : ApiMethodRelatedWidget(org.entando.entando.aps.system.services.api.model.ApiMethodRelatedWidget) HashMap(java.util.HashMap) ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 2 with ApiMethodRelatedWidget

use of org.entando.entando.aps.system.services.api.model.ApiMethodRelatedWidget 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;
}
Also used : ApiMethodRelatedWidget(org.entando.entando.aps.system.services.api.model.ApiMethodRelatedWidget) ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod)

Aggregations

ApiMethod (org.entando.entando.aps.system.services.api.model.ApiMethod)2 ApiMethodRelatedWidget (org.entando.entando.aps.system.services.api.model.ApiMethodRelatedWidget)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 HashMap (java.util.HashMap)1