Search in sources :

Example 1 with ApiSelectItem

use of org.entando.entando.apsadmin.api.model.ApiSelectItem in project entando-core by entando.

the class ApiServiceFinderAction method addService.

private void addService(String groupCode, ApiService apiService, Map<String, List<ApiSelectItem>> groups) {
    List<ApiSelectItem> group = groups.get(groupCode);
    if (null == group) {
        group = new ArrayList<ApiSelectItem>();
        groups.put(groupCode, group);
    }
    String description = super.getTitle(apiService.getKey(), apiService.getDescription());
    ApiSelectItem item = new ApiSelectItem(apiService.getKey(), description, groupCode);
    item.setActiveItem(apiService.isActive());
    item.setPublicItem(!apiService.isHidden());
    group.add(item);
}
Also used : ApiSelectItem(org.entando.entando.apsadmin.api.model.ApiSelectItem)

Example 2 with ApiSelectItem

use of org.entando.entando.apsadmin.api.model.ApiSelectItem in project entando-core by entando.

the class ApiServiceFinderAction method updateAllStatusOfGroup.

public String updateAllStatusOfGroup() {
    try {
        if (this.getServiceGroup() == null) {
            this.addActionMessage(this.getText("error.service.group.required"));
            return INPUT;
        }
        Map<String, List<ApiSelectItem>> groups = this.getServiceFlavours();
        List<ApiSelectItem> group = groups.get(this.getServiceGroup());
        if (group == null) {
            this.addActionMessage(this.getText("error.service.group.invalid"));
            return INPUT;
        }
        for (int i = 0; i < group.size(); i++) {
            ApiSelectItem serviceItem = group.get(i);
            ApiService service = this.getApiCatalogManager().getApiService(serviceItem.getKey());
            boolean activeService = (this.getRequest().getParameter(service.getKey() + "_active") != null);
            boolean publicService = (this.getRequest().getParameter(service.getKey() + "_public") != null);
            if (activeService != service.isActive() || publicService != !service.isHidden()) {
                service.setActive(activeService);
                service.setHidden(!publicService);
                this.getApiCatalogManager().updateService(service);
                this.addActionMessage(this.getText("message.service.status.updated", new String[] { serviceItem.getKey(), serviceItem.getValue() }));
                _logger.info("Updated api service status - Service Key '{}'", serviceItem.getKey());
            }
        }
    } catch (Throwable t) {
        _logger.error("error in updateAllStatusOfGroup", t);
        // ApsSystemUtils.logThrowable(t, this, "updateAllStatusOfGroup");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ApiService(org.entando.entando.aps.system.services.api.model.ApiService) ArrayList(java.util.ArrayList) List(java.util.List) ApiSelectItem(org.entando.entando.apsadmin.api.model.ApiSelectItem)

Example 3 with ApiSelectItem

use of org.entando.entando.apsadmin.api.model.ApiSelectItem in project entando-core by entando.

the class ApiServiceFinderAction method getServiceFlavours.

public Map<String, List<ApiSelectItem>> getServiceFlavours() {
    Map<String, List<ApiSelectItem>> groups = new HashMap<String, List<ApiSelectItem>>();
    try {
        this.buildServiceGroups(groups);
        Iterator<List<ApiSelectItem>> groupIter = groups.values().iterator();
        while (groupIter.hasNext()) {
            List<ApiSelectItem> group = groupIter.next();
            BeanComparator comparator = new BeanComparator("value");
            Collections.sort(group, comparator);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting Flavours services", t);
        // ApsSystemUtils.logThrowable(t, this, "getServiceFlavours");
        throw new RuntimeException("Error extracting Flavours services", t);
    }
    return groups;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ApiSelectItem(org.entando.entando.apsadmin.api.model.ApiSelectItem) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Aggregations

ApiSelectItem (org.entando.entando.apsadmin.api.model.ApiSelectItem)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HashMap (java.util.HashMap)1 BeanComparator (org.apache.commons.beanutils.BeanComparator)1 ApiService (org.entando.entando.aps.system.services.api.model.ApiService)1