use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceRecordVO in project entando-core by entando.
the class ResourceManager method loadResource.
/**
* Restituisce la risorsa con l'id specificato.
* @param id L'identificativo della risorsa da caricare.
* @return La risorsa cercata. null se non vi è nessuna risorsa con l'identificativo immesso.
* @throws ApsSystemException in caso di errore.
*/
@Override
public ResourceInterface loadResource(String id) throws ApsSystemException {
ResourceInterface resource = null;
try {
ResourceRecordVO resourceVo = this.getResourceDAO().loadResourceVo(id);
if (null != resourceVo) {
resource = this.createResource(resourceVo);
resource.setMasterFileName(resourceVo.getMasterFileName());
}
} catch (Throwable t) {
logger.error("Error loading resource : id {}", id, t);
throw new ApsSystemException("Error loading resource : id " + id, t);
}
return resource;
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceRecordVO in project entando-core by entando.
the class TestResourceDAO method testAddDeleteResource.
public void testAddDeleteResource() throws Throwable {
DataSource dataSource = (DataSource) this.getApplicationContext().getBean("portDataSource");
MockResourcesDAO mockResourcesDao = new MockResourcesDAO();
mockResourcesDao.setDataSource(dataSource);
ResourceInterface resource = new ImageResource();
resource.setId("temp");
resource.setDescr("temp");
resource.setMainGroup(Group.FREE_GROUP_NAME);
resource.setType("Image");
resource.setFolder("/temp");
// resource.setBaseURL("temp");
ResourceRecordVO resourceRecordVO = null;
try {
mockResourcesDao.deleteResource("temp");
} catch (Throwable t) {
throw t;
}
_resourceDao.addResource(resource);
resourceRecordVO = _resourceDao.loadResourceVo(resource.getId());
assertEquals(resourceRecordVO.getDescr().equals("temp"), true);
_resourceDao.deleteResource(resource.getId());
resourceRecordVO = _resourceDao.loadResourceVo(resource.getId());
assertNull(resourceRecordVO);
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceRecordVO in project entando-core by entando.
the class ResourceDAO method loadResourceVo.
/**
* Carica un record di risorse in funzione dell'id Risorsa. Questo record è
* necessario per l'estrazione della risorse in oggetto tipo
* AbstractResource da parte del ResourceManager.
*
* @param id L'identificativo della risorsa.
* @return Il record della risorsa.
*/
@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'jacms_resource_'.concat(#id)", condition = "null != #id")
public ResourceRecordVO loadResourceVo(String id) {
Connection conn = null;
ResourceRecordVO resourceVo = null;
PreparedStatement stat = null;
ResultSet res = null;
try {
conn = this.getConnection();
stat = conn.prepareStatement(LOAD_RESOURCE_VO);
stat.setString(1, id);
res = stat.executeQuery();
if (res.next()) {
resourceVo = new ResourceRecordVO();
resourceVo.setId(id);
resourceVo.setResourceType(res.getString(1));
resourceVo.setDescr(res.getString(2));
resourceVo.setMainGroup(res.getString(3));
resourceVo.setXml(res.getString(4));
resourceVo.setMasterFileName(res.getString(5));
resourceVo.setCreationDate(res.getDate(6));
resourceVo.setLastModified(res.getDate(7));
}
} catch (Throwable t) {
_logger.error("Errore loading resource {}", id, t);
throw new RuntimeException("Errore loading resource" + id, t);
} finally {
closeDaoResources(res, stat, conn);
}
return resourceVo;
}
Aggregations