use of com.agiletec.plugins.jacms.aps.system.services.content.model.ContentRecordVO in project entando-core by entando.
the class ContentInspectionAction method getReferencingContents.
/**
* Return the list of the referencing contents.
* @return the list of the referencing contents.
* @deprecated use getReferencingContentsId() method
*/
public List<ContentRecordVO> getReferencingContents() {
List<ContentRecordVO> referencingContents = new ArrayList<ContentRecordVO>();
try {
List<String> referencingContentsId = this.getReferencingContentsId();
if (null != referencingContentsId) {
for (int i = 0; i < referencingContentsId.size(); i++) {
ContentRecordVO currentReferencedContent = this.getContentManager().loadContentVO(referencingContentsId.get(i));
referencingContents.add(currentReferencedContent);
}
}
} catch (Throwable t) {
_logger.error("Error getting referencing contents by content {}", this.getContentId(), t);
String msg = "Error getting referencing contents by content " + this.getContentId();
throw new RuntimeException(msg, t);
}
return referencingContents;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.ContentRecordVO in project entando-core by entando.
the class ContentLinkAction method joinContentLink.
public String joinContentLink() {
ContentRecordVO contentVo = this.getContentVo(this.getContentId());
if (null == contentVo || !contentVo.isOnLine()) {
_logger.error("Content '{}' does not exists or is not public", this.getContentId());
return FAILURE;
}
if (this.isContentOnPageType()) {
// Fa il forward alla scelta pagina di destinazione
return "configContentOnPageLink";
} else {
String[] destinations = { null, this.getContentId(), null };
this.buildEntryContentAnchorDest();
this.getLinkAttributeHelper().joinLink(destinations, SymbolicLink.CONTENT_TYPE, this.getRequest());
return SUCCESS;
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.ContentRecordVO in project entando-core by entando.
the class PageLinkAction method getContentVo.
public ContentRecordVO getContentVo(String contentId) {
ContentRecordVO contentVo = null;
try {
IContentManager contentManager = (IContentManager) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_MANAGER, this.getRequest());
contentVo = contentManager.loadContentVO(contentId);
} catch (Throwable t) {
_logger.error("error in getContentVo for content {}", contentId, t);
throw new RuntimeException("Errore in caricamento contenuto vo", t);
}
return contentVo;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.ContentRecordVO in project entando-core by entando.
the class ApiContentInterface method deleteContent.
public StringApiResponse deleteContent(Properties properties) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
String id = properties.getProperty("id");
Content masterContent = this.getContentManager().loadContent(id, false);
if (null == masterContent) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Content with code '" + id + "' does not exist", Response.Status.CONFLICT);
}
UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
if (null == user) {
user = this.getUserManager().getGuestUser();
}
if (!this.getContentAuthorizationHelper().isAuth(user, masterContent)) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Content groups makes the new content not allowed for user " + user.getUsername(), Response.Status.FORBIDDEN);
}
List<String> references = ((ContentUtilizer) this.getContentManager()).getContentUtilizers(id);
if (references != null && references.size() > 0) {
boolean found = false;
for (int i = 0; i < references.size(); i++) {
String reference = references.get(i);
ContentRecordVO record = this.getContentManager().loadContentVO(reference);
if (null != record) {
found = true;
response.addError(new ApiError(IApiErrorCodes.API_VALIDATION_ERROR, "Content " + id + " referenced to content " + record.getId() + " - '" + record.getDescr() + "'", Response.Status.CONFLICT));
}
}
if (found) {
response.setResult(IResponseBuilder.FAILURE, null);
return response;
}
}
if (masterContent.isOnLine()) {
this.getContentManager().removeOnLineContent(masterContent);
}
String removeWorkVersionString = properties.getProperty("removeWorkVersion");
boolean removeWorkVersion = (null != removeWorkVersionString) ? Boolean.parseBoolean(removeWorkVersionString) : false;
if (removeWorkVersion) {
this.getContentManager().deleteContent(masterContent);
}
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error deleting content", t);
throw new ApsSystemException("Error deleting content", t);
}
return response;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.ContentRecordVO in project entando-core by entando.
the class ApiResourceInterface method deleteResource.
private StringApiResponse deleteResource(Properties properties, ResourceInterface resource) throws ApiException, Throwable {
StringApiResponse response = new StringApiResponse();
try {
String id = properties.getProperty("id");
if (null == resource) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Resource with code '" + id + "' does not exist", Response.Status.CONFLICT);
}
UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
if (null == user) {
user = this.getUserManager().getGuestUser();
}
if (!this.getAuthorizationManager().isAuthOnGroup(user, resource.getMainGroup())) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Resource not allowed for user '" + user.getUsername() + "' - resource group '" + resource.getMainGroup() + "'", Response.Status.FORBIDDEN);
}
List<String> references = ((ResourceUtilizer) this.getContentManager()).getResourceUtilizers(id);
if (references != null && references.size() > 0) {
boolean found = false;
for (int i = 0; i < references.size(); i++) {
String reference = references.get(i);
ContentRecordVO record = this.getContentManager().loadContentVO(reference);
if (null != record) {
found = true;
response.addError(new ApiError(IApiErrorCodes.API_VALIDATION_ERROR, "Resource " + id + " referenced to content " + record.getId() + " - '" + record.getDescr() + "'", Response.Status.CONFLICT));
}
}
if (found) {
response.setResult(IResponseBuilder.FAILURE, null);
return response;
}
}
this.getResourceManager().deleteResource(resource);
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error deleting resource", t);
// ApsSystemUtils.logThrowable(t, this, "deleteResource");
throw new ApsSystemException("Error deleting resource", t);
}
return response;
}
Aggregations