use of com.agiletec.aps.system.common.entity.model.attribute.AttributeRole in project entando-core by entando.
the class ContentPreviewDispenser method getBaseRenderizationInfo.
@Override
public ContentRenderizationInfo getBaseRenderizationInfo(PublicContentAuthorizationInfo authInfo, String contentId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx) {
ContentRenderizationInfo renderInfo = null;
try {
List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
if (authInfo.isUserAllowed(userGroups)) {
Content contentOnSession = this.extractContentOnSession(reqCtx);
String renderedContent = this.buildRenderedContent(contentOnSession, modelId, langCode, reqCtx);
if (null != renderedContent && renderedContent.trim().length() > 0) {
List<AttributeRole> roles = this.getContentManager().getAttributeRoles();
renderInfo = new ContentRenderizationInfo(contentOnSession, renderedContent, modelId, langCode, roles);
}
}
} catch (Throwable t) {
_logger.error("Error while rendering content {}", contentId, t);
return null;
}
return renderInfo;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeRole in project entando-core by entando.
the class AttributeRoleDOM method extractRoles.
private Map<String, AttributeRole> extractRoles(Document document) {
Map<String, AttributeRole> roles = new HashMap<>();
List<Element> roleElements = document.getRootElement().getChildren("role");
for (int i = 0; i < roleElements.size(); i++) {
Element roleElement = roleElements.get(i);
String name = roleElement.getChildText("name");
String description = roleElement.getChildText("description");
String allowedTypesCSV = roleElement.getChildText("allowedTypes");
String[] array = allowedTypesCSV.split(",");
List<String> allowedTypes = Arrays.asList(array);
AttributeRole role = new AttributeRole(name, description, allowedTypes);
String formFieldTypeText = roleElement.getChildText("formFieldType");
if (null != formFieldTypeText) {
role.setFormFieldType(Enum.valueOf(AttributeRole.FormFieldTypes.class, formFieldTypeText.toUpperCase()));
}
roles.put(name, role);
}
return roles;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeRole in project entando-core by entando.
the class ApsEntityManager method getOrderedAttributeRoles.
private List<AttributeRole> getOrderedAttributeRoles() {
List<AttributeRole> roles = new ArrayList<>(this.attributeRoles.size());
Iterator<AttributeRole> iter = this.attributeRoles.values().iterator();
while (iter.hasNext()) {
AttributeRole role = iter.next();
roles.add(role.clone());
}
BeanComparator comparator = new BeanComparator("name");
Collections.sort(roles, comparator);
return roles;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeRole in project entando-core by entando.
the class ExtraAttributeRolesWrapper method executeLoading.
public void executeLoading(Map<String, AttributeRole> collectionToFill, IEntityManager entityManager) throws ApsSystemException {
String managerName = ((IManager) entityManager).getName();
if (!managerName.equals(super.getEntityManagerNameDest())) {
return;
}
AttributeRoleDOM dom = new AttributeRoleDOM();
try {
String xml = super.extractXml();
Map<String, AttributeRole> attributeRoles = dom.extractRoles(xml, this.getDefsFilePath());
List<AttributeRole> roles = new ArrayList<>(attributeRoles.values());
for (int i = 0; i < roles.size(); i++) {
AttributeRole role = roles.get(i);
if (collectionToFill.containsKey(role.getName())) {
_logger.warn("You can't override existing attribute role : {} - {}", role.getName(), role.getDescription());
} else {
collectionToFill.put(role.getName(), role);
_logger.info("Added new attribute role : {} - {}", role.getName(), role.getDescription());
}
}
} catch (Throwable t) {
// ApsSystemUtils.logThrowable(t, this, "executeLoading", "Error loading extra attribute Roles");
_logger.error("Error loading extra attribute Roles", t);
}
}
Aggregations