@Override public void removeResource(ResourceVO resource) throws CapabilityManagerException { try { resourceDAO.delete(resource.getId()); } catch (Exception e) { throw new CapabilityManagerException(e); } }
@Override public void updateResource(ResourceVO resource) throws CapabilityManagerException { try { Resource resourceToUpdate = SecurityEntityValueObjectConverter.toResource(resource); resourceDAO.update(resourceToUpdate); } catch (Exception e) { throw new CapabilityManagerException(e); } }
@Override public List<ResourceVO> findAllResources() throws CapabilityManagerException { List<ResourceVO> resourceVoList; try { List<Resource> resources = resourceDAO.findAllData(); resourceVoList = SecurityEntityValueObjectConverter.toResourceVOList(resources); } catch (Exception e) { throw new CapabilityManagerException(e); } return resourceVoList; }
@Override public ResourceVO addResource(ResourceVO resourceVO) throws CapabilityManagerException { try { Resource resource = SecurityEntityValueObjectConverter.toResource(resourceVO); if (null == resourceVO.getId()) { resource.setId(null); } resourceDAO.create(resource); resourceVO = SecurityEntityValueObjectConverter.toResourceVO(resource); LOG.log(Level.FINE, "resource {0} created", resourceVO); } catch (Exception e) { throw new CapabilityManagerException(e); } return resourceVO; }
@Override public ResourceVO findResourceNamedAs(String resourceName) throws CapabilityManagerException, NonExistentEntityException { ResourceVO resourceVO = null; try { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put(Resource.QUERY_PARAM_RESOURCE_NAME, resourceName); Resource resource = resourceDAO.findUniqueDataUsingNamedQuery( Resource.NAMED_QUERY_FIND_RESOURCE_BY_NAME, parameters); resourceVO = SecurityEntityValueObjectConverter.toResourceVO(resource); } catch (NonExistentEntityException e) { throw e; } catch (Exception e) { throw new CapabilityManagerException(e); } return resourceVO; }