use of org.wso2.carbon.identity.api.server.application.management.v1.ApplicationTemplatesListItem in project identity-api-server by wso2.
the class ServerApplicationManagementService method listApplicationTemplates.
/**
* List all the application templates of the tenant.
*
* @param limit maximum number of items to be returned.
* @param offset number of records to skip for pagination.
* @return ApplicationTemplatesList containing the list of templates.
*/
public ApplicationTemplatesList listApplicationTemplates(Integer limit, Integer offset, SearchContext searchContext) {
validatePaginationSupport(limit, offset);
try {
List<Template> templateList = getTemplateManager().listTemplates(TemplateMgtConstants.TemplateType.APPLICATION_TEMPLATE.toString(), null, null, getSearchCondition(TemplateMgtConstants.TemplateType.APPLICATION_TEMPLATE.toString(), ContextLoader.getTenantDomainFromContext(), searchContext));
List<ApplicationTemplatesListItem> applicationTemplateList = templateList.stream().map(new TemplateToApplicationTemplateListItem()).collect(Collectors.toList());
ApplicationTemplatesList applicationTemplates = new ApplicationTemplatesList();
applicationTemplates.setTemplates(applicationTemplateList);
return applicationTemplates;
} catch (TemplateManagementException e) {
throw handleTemplateManagementException(e, "Error while listing application templates.");
}
}
use of org.wso2.carbon.identity.api.server.application.management.v1.ApplicationTemplatesListItem in project identity-api-server by wso2.
the class TemplateToApplicationTemplateListItem method apply.
@Override
public ApplicationTemplatesListItem apply(Template template) {
ApplicationTemplatesListItem listItem = new ApplicationTemplatesListItem();
listItem.setName(template.getTemplateName());
listItem.setId(template.getTemplateId());
listItem.setSelf(getApplicationTemplateLocation(template.getTemplateId()));
listItem.setDescription(template.getDescription());
listItem.setImage(template.getImageUrl());
if (template.getPropertiesMap() != null) {
template.getPropertiesMap().forEach((key, value) -> {
if (ApplicationManagementConstants.TemplateProperties.TYPES.equals(key) && StringUtils.isNotBlank(value)) {
listItem.setTypes(Arrays.asList(value.split(",")));
}
if (ApplicationManagementConstants.TemplateProperties.DISPLAY_ORDER.equals(key) && StringUtils.isNotBlank(value)) {
listItem.setDisplayOrder(Integer.parseInt(value));
}
if (ApplicationManagementConstants.TemplateProperties.CATEGORY.equals(key)) {
if (ApplicationTemplatesListItem.CategoryEnum.VENDOR.value().equals(value)) {
listItem.setCategory(ApplicationTemplatesListItem.CategoryEnum.VENDOR);
} else {
listItem.setCategory(ApplicationTemplatesListItem.CategoryEnum.DEFAULT);
}
}
if (ApplicationManagementConstants.TemplateProperties.INBOUND_PROTOCOL.equals(key)) {
listItem.setAuthenticationProtocol(value);
}
if (ApplicationManagementConstants.TemplateProperties.TEMPLATE_GROUP.equals(key)) {
listItem.setTemplateGroup(value);
}
});
}
return listItem;
}
Aggregations