use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class ResourceManager method refreshMasterFileNames.
protected void refreshMasterFileNames(String resourceId) {
try {
ResourceInterface resource = this.loadResource(resourceId);
if (resource.isMultiInstance()) {
ResourceInstance instance = ((AbstractMultiInstanceResource) resource).getInstance(0, null);
String filename = instance.getFileName();
int index = filename.lastIndexOf("_d0.");
String masterFileName = filename.substring(0, index) + filename.substring(index + 3);
resource.setMasterFileName(masterFileName);
} else {
ResourceInstance instance = ((AbstractMonoInstanceResource) resource).getInstance();
resource.setMasterFileName(instance.getFileName());
}
this.updateResource(resource);
} catch (Throwable t) {
logger.error("Error reloading master file name of resource {}", resourceId, t);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class ResourceManager method reloadCategoryReferences.
@Override
public void reloadCategoryReferences(String categoryCode) throws ApsSystemException {
try {
List<String> resources = this.getCategoryUtilizersForReloadReferences(categoryCode);
logger.info("start reload category references for {} resources", resources.size());
ReloadingCategoryReferencesThread th = null;
Thread currentThread = Thread.currentThread();
if (currentThread instanceof ReloadingCategoryReferencesThread) {
th = (ReloadingCategoryReferencesThread) Thread.currentThread();
th.setListSize(resources.size());
}
if (null != resources && !resources.isEmpty()) {
Iterator<String> it = resources.iterator();
while (it.hasNext()) {
String code = it.next();
ResourceInterface resource = this.loadResource(code);
this.getResourceDAO().updateResourceRelations(resource);
if (null != th)
th.setListIndex(th.getListIndex() + 1);
}
}
} catch (Throwable t) {
logger.error("Error searching category utilizers : category code '{}'", categoryCode, t);
throw new ApsSystemException("Error searching category utilizers : category code '" + categoryCode + "'", t);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class AbstractResourceAttribute method getJDOMElement.
@Override
public Element getJDOMElement() {
Element attributeElement = this.createRootElement("attribute");
Iterator<String> langIter = this.getResources().keySet().iterator();
while (langIter.hasNext()) {
String currentLangCode = (String) langIter.next();
ResourceInterface res = this.getResource(currentLangCode);
if (null != res) {
Element resourceElement = new Element("resource");
resourceElement.setAttribute("resourcetype", res.getType());
String resourceId = String.valueOf(res.getId());
resourceElement.setAttribute("id", resourceId);
resourceElement.setAttribute("lang", currentLangCode);
attributeElement.addContent(resourceElement);
}
}
super.addTextElements(attributeElement);
return attributeElement;
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class AbstractResourceAttribute method getReferences.
@Override
public List<CmsAttributeReference> getReferences(List<Lang> systemLangs) {
List<CmsAttributeReference> refs = new ArrayList<>();
for (int i = 0; i < systemLangs.size(); i++) {
Lang lang = systemLangs.get(i);
ResourceInterface res = this.getResource(lang.getCode());
if (null != res) {
CmsAttributeReference ref = new CmsAttributeReference(null, null, res.getId());
refs.add(ref);
}
}
return refs;
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface in project entando-core by entando.
the class AbstractResourceAttribute method appendContentReference.
/**
* Appende, nella stringa rappresentante l'url della risorsa interna ad un
* entità , il riferimento al entità padre con la sintassi
* <baseUrl>/<REFERENCED_RESOURCE_INDICATOR>/<PARENT_CONTENT_ID>/. Tale
* operazione viene effettuata nel caso che la risorsa non sia libera.
*
* @param basePath Il path base della risorsa.
* @return Il path corretto.
*/
protected String appendContentReference(String basePath) {
ResourceInterface res = this.getResource();
if (null == res) {
return "";
}
String resourceGroup = res.getMainGroup();
if (!Group.FREE_GROUP_NAME.equals(resourceGroup) && !this.getParentEntity().getGroups().isEmpty()) {
if (!basePath.endsWith("/")) {
basePath += "/";
}
basePath += REFERENCED_RESOURCE_INDICATOR + "/" + this.getParentEntity().getId() + "/";
}
return basePath;
}
Aggregations