use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute in project entando-core by entando.
the class BaseContentGroupBulkCommand method checkContentReferences.
protected boolean checkContentReferences(Content content) {
List<Lang> systemLangs = this.getSystemLangs();
IPageManager pageManager = this.getPageManager();
SymbolicLinkValidator validator = new SymbolicLinkValidator(this.getApplier(), pageManager);
for (AttributeInterface attribute : content.getAttributeList()) {
if (attribute instanceof IReferenceableAttribute) {
List<CmsAttributeReference> references = ((IReferenceableAttribute) attribute).getReferences(systemLangs);
if (references != null) {
for (CmsAttributeReference reference : references) {
SymbolicLink symbolicLink = this.convertToSymbolicLink(reference);
if (symbolicLink != null) {
String result = validator.scan(symbolicLink, content);
if (ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS.equals(result) || ICmsAttributeErrorCodes.INVALID_RESOURCE_GROUPS.equals(result) || ICmsAttributeErrorCodes.INVALID_PAGE_GROUPS.equals(result)) {
return false;
}
}
}
}
}
}
return true;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute in project entando-core by entando.
the class ContentInspectionAction method getReferencedContentsId.
/**
* Return the list of the id of the referenced contents
* @return The list of content id.
*/
public List<String> getReferencedContentsId() {
List<String> referencedContentsId = new ArrayList<String>();
try {
Content content = this.getContent();
if (null == content)
return referencedContentsId;
EntityAttributeIterator attributeIter = new EntityAttributeIterator(content);
while (attributeIter.hasNext()) {
AttributeInterface currAttribute = (AttributeInterface) attributeIter.next();
if (currAttribute instanceof IReferenceableAttribute) {
IReferenceableAttribute cmsAttribute = (IReferenceableAttribute) currAttribute;
List<CmsAttributeReference> refs = cmsAttribute.getReferences(this.getLangs());
for (int scanRefs = 0; scanRefs < refs.size(); scanRefs++) {
CmsAttributeReference ref = refs.get(scanRefs);
String contentId = ref.getRefContent();
if (null == contentId)
continue;
if (!referencedContentsId.contains(contentId))
referencedContentsId.add(contentId);
}
}
}
} catch (Throwable t) {
_logger.error("Error getting referenced contents id by content {}", this.getContentId(), t);
String msg = "Error getting referenced contents id by content " + this.getContentId();
throw new RuntimeException(msg, t);
}
return referencedContentsId;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute in project entando-core by entando.
the class ContentInspectionAction method getReferencedPages.
public List<IPage> getReferencedPages() {
List<IPage> referencedPages = new ArrayList<IPage>();
try {
Content content = this.getContent();
if (null == content)
return referencedPages;
EntityAttributeIterator attributeIter = new EntityAttributeIterator(content);
while (attributeIter.hasNext()) {
AttributeInterface currAttribute = (AttributeInterface) attributeIter.next();
if (currAttribute instanceof IReferenceableAttribute) {
IReferenceableAttribute cmsAttribute = (IReferenceableAttribute) currAttribute;
List<CmsAttributeReference> refs = cmsAttribute.getReferences(this.getLangs());
for (int scanRefs = 0; scanRefs < refs.size(); scanRefs++) {
CmsAttributeReference ref = refs.get(scanRefs);
if (null == ref.getRefPage())
continue;
IPage page = this.getPageManager().getOnlinePage(ref.getRefPage());
if (null == page)
continue;
if (!referencedPages.contains(page)) {
referencedPages.add(page);
}
}
}
}
} catch (Throwable t) {
_logger.error("Error getting referenced pages by content {}", this.getContentId(), t);
String msg = "Error getting referenced pages by content " + this.getContentId();
throw new RuntimeException(msg, t);
}
return referencedPages;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute in project entando-core by entando.
the class ContentDAO method addContentRelationsRecord.
/**
* Add a record in the table 'contentrelations' for every resource, page,
* other content, role and category associated to the given content).
*
* @param content
* The current content.
* @param conn
* The connection to the database.
* @throws ApsSystemException
* when connection error are detected.
*/
protected void addContentRelationsRecord(Content content, Connection conn) throws ApsSystemException {
PreparedStatement stat = null;
try {
stat = conn.prepareStatement(ADD_CONTENT_REL_RECORD);
this.addCategoryRelationsRecord(content, true, stat);
this.addGroupRelationsRecord(content, stat);
EntityAttributeIterator attributeIter = new EntityAttributeIterator(content);
while (attributeIter.hasNext()) {
AttributeInterface currAttribute = (AttributeInterface) attributeIter.next();
if (currAttribute instanceof IReferenceableAttribute) {
IReferenceableAttribute cmsAttribute = (IReferenceableAttribute) currAttribute;
List<CmsAttributeReference> refs = cmsAttribute.getReferences(this.getLangManager().getLangs());
for (int i = 0; i < refs.size(); i++) {
CmsAttributeReference ref = refs.get(i);
stat.setString(1, content.getId());
stat.setString(2, ref.getRefPage());
stat.setString(3, ref.getRefContent());
stat.setString(4, ref.getRefResource());
stat.setString(5, null);
stat.setString(6, null);
stat.addBatch();
stat.clearParameters();
}
}
}
stat.executeBatch();
} catch (BatchUpdateException e) {
_logger.error("Error saving record into contentrelations {}", content.getId(), e.getNextException());
throw new RuntimeException("Error saving record into contentrelations " + content.getId(), e.getNextException());
} catch (Throwable t) {
_logger.error("Error saving record into contentrelations {}", content.getId(), t);
throw new RuntimeException("Error saving record into contentrelations " + content.getId(), t);
} finally {
closeDaoResources(null, stat);
}
}
Aggregations