Search in sources :

Example 6 with ApiResource

use of org.entando.entando.aps.system.services.api.model.ApiResource in project entando-core by entando.

the class ApiServiceCacheWrapper method buildApiGetMethods.

protected List<ApiMethod> buildApiGetMethods(Map<String, ApiResource> resources) {
    List<ApiMethod> apiGETMethods = new ArrayList<>();
    List<ApiResource> resourceList = new ArrayList<>(resources.values());
    for (int i = 0; i < resourceList.size(); i++) {
        ApiResource apiResource = resourceList.get(i);
        if (null != apiResource.getGetMethod()) {
            apiGETMethods.add(apiResource.getGetMethod());
        }
    }
    return apiGETMethods;
}
Also used : ApiResource(org.entando.entando.aps.system.services.api.model.ApiResource) ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod) ArrayList(java.util.ArrayList)

Example 7 with ApiResource

use of org.entando.entando.aps.system.services.api.model.ApiResource in project entando-core by entando.

the class AbstractApiFinderAction method getResourceFlavoursMapping.

private Map<String, List<ApiResource>> getResourceFlavoursMapping(List<String> pluginCodes) throws Throwable {
    Map<String, List<ApiResource>> finalMapping = new HashMap<String, List<ApiResource>>();
    try {
        Map<String, ApiResource> masterResources = this.getApiCatalogManager().getResources();
        Iterator<ApiResource> resourcesIter = masterResources.values().iterator();
        while (resourcesIter.hasNext()) {
            ApiResource apiResource = resourcesIter.next();
            if (this.includeIntoMapping(apiResource)) {
                List<ApiResource> resources = finalMapping.get(apiResource.getSectionCode());
                if (null == resources) {
                    resources = new ArrayList<ApiResource>();
                    finalMapping.put(apiResource.getSectionCode(), resources);
                }
                resources.add(apiResource);
                String pluginCode = apiResource.getPluginCode();
                if (null != pluginCode && !pluginCodes.contains(pluginCode)) {
                    pluginCodes.add(pluginCode);
                }
            }
        }
        Collections.sort(pluginCodes);
    } catch (Throwable t) {
        _logger.error("Error extracting resource Flavours mapping", t);
        // ApsSystemUtils.logThrowable(t, this, "getResourceFlavoursMapping");
        throw new RuntimeException("Error extracting resource Flavours mapping", t);
    }
    return finalMapping;
}
Also used : ApiResource(org.entando.entando.aps.system.services.api.model.ApiResource) HashMap(java.util.HashMap) List(java.util.List) ArrayList(java.util.ArrayList)

Example 8 with ApiResource

use of org.entando.entando.aps.system.services.api.model.ApiResource in project entando-core by entando.

the class AbstractApiFinderAction method addResourceGroup.

private void addResourceGroup(String groupCode, Map<String, List<ApiResource>> mapping, List<List<ApiResource>> group) {
    List<ApiResource> singleGroup = mapping.get(groupCode);
    if (null != singleGroup) {
        BeanComparator comparator = new BeanComparator("resourceName");
        Collections.sort(singleGroup, comparator);
        group.add(singleGroup);
    }
}
Also used : ApiResource(org.entando.entando.aps.system.services.api.model.ApiResource) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Example 9 with ApiResource

use of org.entando.entando.aps.system.services.api.model.ApiResource in project entando-core by entando.

the class ApiResourceAction method resetAllMethodStatus.

public String resetAllMethodStatus() {
    try {
        ApiResource resource = this.getApiResource();
        this.resetMethodStatus(resource.getGetMethod());
        this.resetMethodStatus(resource.getPostMethod());
        this.resetMethodStatus(resource.getPutMethod());
        this.resetMethodStatus(resource.getDeleteMethod());
    } catch (Throwable t) {
        _logger.error("Error resetting all method status", t);
        // ApsSystemUtils.logThrowable(t, this, "resetAllMethodStatus", "Error resetting all method status");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ApiResource(org.entando.entando.aps.system.services.api.model.ApiResource)

Example 10 with ApiResource

use of org.entando.entando.aps.system.services.api.model.ApiResource in project entando-core by entando.

the class TestApiI18nLabelInterface method testGetLabel.

protected JAXBI18nLabel testGetLabel(MediaType mediaType, String username, String key) throws Throwable {
    ApiResource contentResource = this.getApiCatalogManager().getResource("core", "i18nlabel");
    ApiMethod getMethod = contentResource.getGetMethod();
    Properties properties = super.createApiProperties(username, "en", mediaType);
    properties.put("key", key);
    Object result = this.getResponseBuilder().createResponse(getMethod, properties);
    assertNotNull(result);
    ApiI18nLabelInterface apiLabelInterface = (ApiI18nLabelInterface) this.getApplicationContext().getBean("ApiI18nLabelInterface");
    Object singleResult = apiLabelInterface.getLabel(properties);
    assertNotNull(singleResult);
    String toString = this.marshall(singleResult, mediaType);
    InputStream stream = new ByteArrayInputStream(toString.getBytes());
    JAXBI18nLabel jaxbLabel = (JAXBI18nLabel) UnmarshalUtils.unmarshal(super.getApplicationContext(), JAXBI18nLabel.class, stream, mediaType);
    assertNotNull(jaxbLabel);
    return jaxbLabel;
}
Also used : ApiResource(org.entando.entando.aps.system.services.api.model.ApiResource) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) JAXBI18nLabel(org.entando.entando.aps.system.services.i18n.model.JAXBI18nLabel) ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod) Properties(java.util.Properties) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

ApiResource (org.entando.entando.aps.system.services.api.model.ApiResource)17 ApiMethod (org.entando.entando.aps.system.services.api.model.ApiMethod)8 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)4 Properties (java.util.Properties)4 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 ApsProperties (com.agiletec.aps.util.ApsProperties)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ArrayList (java.util.ArrayList)2 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)2 JAXBI18nLabel (org.entando.entando.aps.system.services.i18n.model.JAXBI18nLabel)2 JAXBContent (org.entando.entando.plugins.jacms.aps.system.services.api.model.JAXBContent)2 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)1 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)1 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Date (java.util.Date)1 List (java.util.List)1