use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class AttachAttribute method getAttachPath.
/**
* Restituisce il path URL dell'attachment.
*
* @return Il path dell'attachment.
*/
public String getAttachPath() {
String attachPath = "";
ResourceInterface res = this.getResource();
if (null != res) {
attachPath = ((AttachResource) res).getAttachPath();
attachPath = this.appendContentReference(attachPath);
}
return attachPath;
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class ImageAttribute method getImagePath.
/**
* Restituisce il path URL dell'immagine
* relativo all'istanza specificata dal size.
* @param size L'istanza della risorsa immagine.
* @return Il path dell'immagine.
*/
public String getImagePath(String size) {
String imagePath = "";
ResourceInterface res = this.getResource();
if (null != res) {
imagePath = ((ImageResource) res).getImagePath(size);
imagePath = this.appendContentReference(imagePath);
}
return imagePath;
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class ResourceAttributeHandler method startResource.
private void startResource(Attributes attributes, String qName) throws SAXException {
String id = extractAttribute(attributes, "id", qName, true);
String langCode = extractAttribute(attributes, "lang", qName, false);
try {
ResourceInterface resource = this.getResourceManager().loadResource(id);
if (null != this.getCurrentAttr() && null != resource) {
((ResourceAttributeInterface) this.getCurrentAttr()).setResource(resource, langCode);
}
} catch (Exception e) {
_logger.error("Error loading resource {}", id, e);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class LinkResolverManager method resolveLink.
@Override
public String resolveLink(SymbolicLink symbolicLink, String contentId, RequestContext reqCtx) {
if (null == symbolicLink) {
_logger.error("Null Symbolic Link");
return "";
}
String url = null;
try {
if (symbolicLink.getDestType() == SymbolicLink.URL_TYPE) {
url = symbolicLink.getUrlDest();
} else if (symbolicLink.getDestType() == SymbolicLink.PAGE_TYPE) {
PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
pageUrl.setPageCode(symbolicLink.getPageDest());
url = pageUrl.getURL();
} else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_ON_PAGE_TYPE) {
PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
pageUrl.setPageCode(symbolicLink.getPageDest());
pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, symbolicLink.getContentDest());
url = pageUrl.getURL();
} else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_TYPE) {
PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
String contentIdDest = symbolicLink.getContentDest();
String pageCode = this.getContentPageMapperManager().getPageCode(contentIdDest);
boolean forwardToDefaultPage = !this.isPageAllowed(reqCtx, pageCode);
if (forwardToDefaultPage) {
String viewPageCode = this.getContentManager().getViewPage(contentIdDest);
pageUrl.setPageCode(viewPageCode);
pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, contentIdDest);
} else {
pageUrl.setPageCode(pageCode);
}
url = pageUrl.getURL();
} else if (symbolicLink.getDestType() == SymbolicLink.RESOURCE_TYPE) {
ResourceInterface resource = this.getResourceManager().loadResource(symbolicLink.getResourceDest());
if (null != resource) {
url = resource.getDefaultUrlPath();
if (!resource.getMainGroup().equals(Group.FREE_GROUP_NAME)) {
if (!url.endsWith("/")) {
url += "/";
}
url += AbstractResourceAttribute.REFERENCED_RESOURCE_INDICATOR + "/" + contentId + "/";
}
}
}
} catch (Throwable t) {
_logger.error("Error resolve link from SymbolicLink", t);
throw new RuntimeException("Error resolve link from SymbolicLink", t);
}
return url;
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class TestResourceAction method testDelete.
/*
* NOTE: we create a fake resource using the manager rather than the most obvious 'save' action.
*
*/
public void testDelete() throws Throwable {
ResourceInterface resource = this._resourceManager.createResourceType("Image");
String resourceId = null;
String result = null;
ResourceAction action = null;
assertNotNull(resource);
try {
this.setUserOnSession("admin");
resource.setMainGroup(Group.FREE_GROUP_NAME);
resource.setDescr("Levò la bocca dal fero pasto quel peccator");
resource.setCategories(new ArrayList<Category>());
this._resourceManager.addResource(resource);
resourceId = resource.getId();
ResourceInterface verify = this._resourceManager.loadResource(resourceId);
assertNotNull(verify);
// test with invalid ID
this.initAction("/do/jacms/Resource", "delete");
result = this.executeAction();
assertEquals(Action.INPUT, result);
action = (ResourceAction) this.getAction();
assertEquals(1, action.getActionErrors().size());
// test with a valid ID
this.initAction("/do/jacms/Resource", "delete");
this.addParameter("resourceId", resourceId);
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
verify = this._resourceManager.loadResource(resourceId);
assertNull(verify);
} catch (Throwable t) {
throw t;
} finally {
this._resourceManager.deleteResource(resource);
}
}
Aggregations