Search in sources :

Example 1 with LinkedListItem

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

the class ApiWidgetTypeInterface method getWidgetTypes.

public List<LinkedListItem> getWidgetTypes(Properties properties) throws Throwable {
    List<LinkedListItem> list = new ArrayList<LinkedListItem>();
    try {
        List<WidgetType> types = this.getWidgetTypeManager().getWidgetTypes();
        for (int i = 0; i < types.size(); i++) {
            WidgetType widgetType = types.get(i);
            String url = this.getApiResourceUrl(widgetType, properties.getProperty(SystemConstants.API_APPLICATION_BASE_URL_PARAMETER), properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER), (MediaType) properties.get(SystemConstants.API_PRODUCES_MEDIA_TYPE_PARAMETER));
            LinkedListItem item = new LinkedListItem();
            item.setCode(widgetType.getCode());
            item.setUrl(url);
            list.add(item);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting list of widget types", t);
        throw t;
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) LinkedListItem(org.entando.entando.aps.system.services.api.model.LinkedListItem) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 2 with LinkedListItem

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

the class ApiPageModelInterface method getPageModels.

public List<LinkedListItem> getPageModels(Properties properties) throws Throwable {
    List<LinkedListItem> list = new ArrayList<LinkedListItem>();
    try {
        Collection<PageModel> pageModels = this.getPageModelManager().getPageModels();
        if (null != pageModels) {
            Iterator<PageModel> iter = pageModels.iterator();
            while (iter.hasNext()) {
                PageModel pageModel = iter.next();
                String url = this.getApiResourceUrl(pageModel, properties.getProperty(SystemConstants.API_APPLICATION_BASE_URL_PARAMETER), properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER), (MediaType) properties.get(SystemConstants.API_PRODUCES_MEDIA_TYPE_PARAMETER));
                LinkedListItem item = new LinkedListItem();
                item.setCode(pageModel.getCode());
                item.setUrl(url);
                list.add(item);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error extracting list of models", t);
        throw t;
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) LinkedListItem(org.entando.entando.aps.system.services.api.model.LinkedListItem) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel)

Example 3 with LinkedListItem

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

the class ApiGuiFragmentInterface method getGuiFragments.

public List<LinkedListItem> getGuiFragments(Properties properties) throws Throwable {
    List<LinkedListItem> list = new ArrayList<LinkedListItem>();
    try {
        String code = properties.getProperty("code");
        String widgettypecode = properties.getProperty("widgettypecode");
        String plugincode = properties.getProperty("plugincode");
        FieldSearchFilter[] filters = new FieldSearchFilter[0];
        FieldSearchFilter codeFilterToAdd = null;
        if (StringUtils.isNotBlank(code)) {
            codeFilterToAdd = new FieldSearchFilter("code", code, true);
        } else {
            codeFilterToAdd = new FieldSearchFilter("code");
        }
        codeFilterToAdd.setOrder(FieldSearchFilter.Order.ASC);
        filters = this.addFilter(filters, codeFilterToAdd);
        if (StringUtils.isNotBlank(widgettypecode)) {
            FieldSearchFilter filterToAdd = new FieldSearchFilter("widgettypecode", widgettypecode, true);
            filters = this.addFilter(filters, filterToAdd);
        }
        if (StringUtils.isNotBlank(plugincode)) {
            FieldSearchFilter filterToAdd = new FieldSearchFilter("plugincode", plugincode, true);
            filters = this.addFilter(filters, filterToAdd);
        }
        List<String> codes = this.getGuiFragmentManager().searchGuiFragments(filters);
        for (int i = 0; i < codes.size(); i++) {
            String fragmantCode = codes.get(i);
            String url = this.getApiResourceUrl(fragmantCode, properties.getProperty(SystemConstants.API_APPLICATION_BASE_URL_PARAMETER), properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER), (MediaType) properties.get(SystemConstants.API_PRODUCES_MEDIA_TYPE_PARAMETER));
            LinkedListItem item = new LinkedListItem();
            item.setCode(fragmantCode);
            item.setUrl(url);
            list.add(item);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting list of fragments", t);
        throw t;
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) LinkedListItem(org.entando.entando.aps.system.services.api.model.LinkedListItem) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter)

Example 4 with LinkedListItem

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

the class LocalStorageManagerInterface method getListDirectory.

public List<LinkedListItem> getListDirectory(Properties properties) throws Throwable {
    List<LinkedListItem> list = new ArrayList<LinkedListItem>();
    String pathValue = properties.getProperty(PARAM_PATH);
    String protectedValue = properties.getProperty(PARAM_IS_PROTECTED);
    boolean isProtected = StringUtils.equalsIgnoreCase(protectedValue, "true");
    try {
        if (StringUtils.isNotBlank(pathValue))
            pathValue = URLDecoder.decode(pathValue, "UTF-8");
        if (!StorageManagerUtil.isValidDirName(pathValue)) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "The path '" + pathValue + "' does not exists", Response.Status.CONFLICT);
        }
        BasicFileAttributeView[] files = this.getStorageManager().listAttributes(pathValue, isProtected);
        for (int i = 0; i < files.length; i++) {
            BasicFileAttributeView fileAttributeView = files[i];
            String url = this.getApiResourceURLWithParams(properties, fileAttributeView, pathValue, isProtected);
            LinkedListItem item = new LinkedListItem();
            item.setCode(this.buildResourcePath(fileAttributeView, pathValue));
            item.setUrl(url);
            list.add(item);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting storage resources in path: {} and protected flag: {} ", pathValue, isProtected, t);
        throw t;
    }
    return list;
}
Also used : BasicFileAttributeView(org.entando.entando.aps.system.services.storage.BasicFileAttributeView) ArrayList(java.util.ArrayList) LinkedListItem(org.entando.entando.aps.system.services.api.model.LinkedListItem) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Aggregations

ArrayList (java.util.ArrayList)4 LinkedListItem (org.entando.entando.aps.system.services.api.model.LinkedListItem)4 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)1 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)1 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)1 BasicFileAttributeView (org.entando.entando.aps.system.services.storage.BasicFileAttributeView)1 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)1