public LanguageVO getLanguageVOWithRepositoryLanguageId(Integer repositoryLanguageId) throws ConstraintException, SystemException, Bug { Database db = CastorDatabaseService.getDatabase(); ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); LanguageVO languageVO = null; try { beginTransaction(db); languageVO = getLanguageWithRepositoryLanguageId(repositoryLanguageId, db).getValueObject(); // If any of the validations or setMethods reported an error, we throw them up now before // create. ceb.throwIfNotEmpty(); commitTransaction(db); } catch (Exception e) { logger.error("An error occurred so we should not complete the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } return languageVO; }
public List getLanguageVOList(Integer repositoryId) throws ConstraintException, SystemException { Database db = CastorDatabaseService.getDatabase(); ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); List languageVOList = new ArrayList(); beginTransaction(db); try { languageVOList = getLanguageVOList(repositoryId, db); // If any of the validations or setMethods reported an error, we throw them up now before // create. ceb.throwIfNotEmpty(); commitTransaction(db); } catch (ConstraintException ce) { logger.warn("An error occurred so we should not complete the transaction:" + ce, ce); rollbackTransaction(db); throw ce; } catch (Exception e) { logger.error("An error occurred so we should not complete the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } return languageVOList; }
/** * Returns the LanguageVO with the given languageCode. * * @param code * @return * @throws SystemException * @throws Bug */ public LanguageVO getLanguageVOWithCode(String code) throws SystemException, Bug { String key = "" + code; LanguageVO languageVO = (LanguageVO) CacheController.getCachedObject("languageCache", key); if (languageVO != null) { logger.info("There was an cached languageVO:" + languageVO); } else { Database db = CastorDatabaseService.getDatabase(); try { beginTransaction(db); Language language = getLanguageWithCode(code, db); if (language != null) languageVO = language.getValueObject(); commitTransaction(db); } catch (Exception e) { logger.info("An error occurred so we should not complete the transaction:" + e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } CacheController.cacheObject("languageCache", key, languageVO); } return languageVO; }
/** * This method returns true if the user should have access to the contentTypeDefinition sent in. */ public boolean getIsAccessApproved(String workflowName, InfoGluePrincipal infoGluePrincipal) throws SystemException { final String protectWorkflows = CmsPropertyHandler.getProtectWorkflows(); if (protectWorkflows == null || !protectWorkflows.equalsIgnoreCase("true")) { return true; } logger.info("getIsAccessApproved for " + workflowName + " AND " + infoGluePrincipal); boolean hasAccess = false; Database db = CastorDatabaseService.getDatabase(); beginTransaction(db); try { hasAccess = AccessRightController.getController() .getIsPrincipalAuthorized(db, infoGluePrincipal, "Workflow.Create", workflowName); commitTransaction(db); } catch (Exception e) { logger.error("An error occurred so we should not complete the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } return hasAccess; }
public SystemUserVO update( SystemUserVO systemUserVO, String oldPassword, String[] roleNames, String[] groupNames) throws ConstraintException, SystemException { Database db = CastorDatabaseService.getDatabase(); ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); SystemUser systemUser = null; beginTransaction(db); try { systemUser = update(systemUserVO, oldPassword, roleNames, groupNames, db); commitTransaction(db); } catch (ConstraintException ce) { logger.warn("An error occurred so we should not completes the transaction:" + ce, ce); rollbackTransaction(db); throw ce; } catch (Exception e) { logger.error("An error occurred so we should not completes the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } return systemUser.getValueObject(); }
public void delete(String userName) throws ConstraintException, SystemException { Database db = CastorDatabaseService.getDatabase(); ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); SystemUser systemUser = null; beginTransaction(db); try { // add validation here if needed delete(userName, db); // If any of the validations or setMethods reported an error, we throw them up now before // create. ceb.throwIfNotEmpty(); commitTransaction(db); } catch (ConstraintException ce) { logger.warn("An error occurred so we should not completes the transaction:" + ce, ce); rollbackTransaction(db); throw ce; } catch (Exception e) { logger.error("An error occurred so we should not completes the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } }
public LanguageVO update(LanguageVO languageVO) throws ConstraintException, SystemException { Database db = CastorDatabaseService.getDatabase(); ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); Language language = null; beginTransaction(db); try { // add validation here if needed language = getLanguageWithId(languageVO.getLanguageId(), db); language.setValueObject(languageVO); // If any of the validations or setMethods reported an error, we throw them up now before // create. ceb.throwIfNotEmpty(); commitTransaction(db); } catch (ConstraintException ce) { logger.warn("An error occurred so we should not complete the transaction:" + ce, ce); rollbackTransaction(db); throw ce; } catch (Exception e) { logger.error("An error occurred so we should not complete the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } return language.getValueObject(); }
public List getAllInconsistencies() throws Exception { List inconsistencies = new ArrayList(); Database db = CastorDatabaseService.getDatabase(); try { beginTransaction(db); List registryVOList = RegistryController.getController().getRegistryVOList(db); if (registryVOList != null && registryVOList.size() > 0) { Iterator registryVOListIterator = registryVOList.iterator(); while (registryVOListIterator.hasNext()) { RegistryVO registryVO = (RegistryVO) registryVOListIterator.next(); if (registryVO.getEntityName().equals(Content.class.getName())) { try { ContentVO contentVO = ContentController.getContentController() .getContentVOWithId(new Integer(registryVO.getEntityId()), db); if (contentVO == null) addContentInconsistency(inconsistencies, registryVO, db); // inconsistencies.add(registryVO); } catch (Exception e) { addContentInconsistency(inconsistencies, registryVO, db); // inconsistencies.add(registryVO); } } else if (registryVO.getEntityName().equals(SiteNode.class.getName())) { try { SiteNodeVO siteNodeVO = SiteNodeController.getController() .getSiteNodeVOWithId(new Integer(registryVO.getEntityId()), db); if (siteNodeVO == null) addSiteNodeInconsistency(inconsistencies, registryVO, db); // inconsistencies.add(registryVO); } catch (Exception e) { addSiteNodeInconsistency(inconsistencies, registryVO, db); // inconsistencies.add(registryVO); } } else { logger.error( "The registry contained not supported entities:" + registryVO.getEntityName()); } } } commitTransaction(db); } catch (Exception e) { rollbackTransaction(db); throw new SystemException( "An error occurred when we tried to fetch which sitenode uses a metainfo. Reason:" + e.getMessage(), e); } return inconsistencies; }
/** * Creates a transaction and calls {@link #removeReferences(Integer, InfoGluePrincipal, * Database)}. * * @deprecated This method handles clean up of ContentVersions poorly. Please refer to {@link * #removeContentReferences(Map, InfoGluePrincipal, Database)} and {@link * #removeSiteNodeReferences(Map, InfoGluePrincipal, Database)} instead. */ public void removeReferences(Integer registryId, InfoGluePrincipal infoGluePrincipal) throws SystemException, Exception { Database db = CastorDatabaseService.getDatabase(); try { beginTransaction(db); removeReferences(registryId, infoGluePrincipal, db); commitTransaction(db); } catch (Exception ex) { rollbackTransaction(db); logger.error("Failed to remove references. Message: " + ex.getMessage()); logger.warn("Failed to remove references.", ex); } }
public void updateAnonymousPassword(String userName) throws ConstraintException, SystemException { Database db = CastorDatabaseService.getDatabase(); ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); beginTransaction(db); try { updateAnonymousPassword(userName, db); commitTransaction(db); } catch (Exception e) { logger.error("An error occurred so we should not completes the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } }
/** * This method removes a Language from the system and also cleans out all depending * repositoryLanguages. */ public void delete(LanguageVO languageVO) throws ConstraintException, SystemException { Database db = CastorDatabaseService.getDatabase(); ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); Language language = null; try { beginTransaction(db); delete(db, languageVO); commitTransaction(db); } catch (Exception e) { logger.error("An error occurred so we should not complete the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } }
public SystemUserVO getSystemUserVOWithName(String name) throws SystemException, Bug { SystemUserVO systemUserVO = null; Database db = CastorDatabaseService.getDatabase(); try { beginTransaction(db); systemUserVO = getReadOnlySystemUserVOWithName(name, db); commitTransaction(db); } catch (Exception e) { logger.info("An error occurred so we should not complete the transaction:" + e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } return systemUserVO; }
/** * Returns the LanguageVO with the given name. * * @param name * @return * @throws SystemException * @throws Bug */ public LanguageVO getLanguageVOWithName(String name) throws SystemException, Bug { LanguageVO languageVO = null; Database db = CastorDatabaseService.getDatabase(); try { beginTransaction(db); Language language = getLanguageWithName(name, db); if (language != null) languageVO = language.getValueObject(); commitTransaction(db); } catch (Exception e) { logger.info("An error occurred so we should not complete the transaction:" + e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } return languageVO; }
public List getFilteredSystemUserVOList(String searchString) throws SystemException, Bug { List filteredList = new ArrayList(); Database db = CastorDatabaseService.getDatabase(); try { beginTransaction(db); filteredList = getFilteredSystemUserList(searchString, db); commitTransaction(db); } catch (Exception e) { logger.info("An error occurred so we should not complete the transaction:" + e); rollbackTransaction(db); throw new SystemException( "An error occurred so we should not complete the transaction:" + e, e); } return toVOList(filteredList); }
/** * This method returns the master language. todo - add attribute on repositoryLanguage to be able * to sort them... and then fetch the first */ public LanguageVO getMasterLanguage(Integer repositoryId) throws SystemException, Exception { LanguageVO languageVO = null; String languageKey = "" + repositoryId; logger.info("languageKey:" + languageKey); languageVO = (LanguageVO) CacheController.getCachedObject("masterLanguageCache", languageKey); if (languageVO != null) { logger.info("There was an cached master language:" + languageVO.getName()); } else { Database db = CastorDatabaseService.getDatabase(); ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); Language language = null; beginTransaction(db); try { language = getMasterLanguage(db, repositoryId); // If any of the validations or setMethods reported an error, we throw them up now before // create. ceb.throwIfNotEmpty(); if (language != null) { languageVO = language.getValueObject(); CacheController.cacheObject("masterLanguageCache", languageKey, languageVO); } commitTransaction(db); } catch (Exception e) { logger.error("An error occurred so we should not complete the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } } return languageVO; }
public void updatePassword(String userName, String oldPassword, String newPassword) throws ConstraintException, SystemException { Database db = CastorDatabaseService.getDatabase(); ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); beginTransaction(db); try { // If any of the validations or setMethods reported an error, we throw them up now before // create. ceb.throwIfNotEmpty(); updatePassword(userName, oldPassword, newPassword, db); commitTransaction(db); } catch (ConstraintException ce) { rollbackTransaction(db); throw ce; } catch (Exception e) { logger.error("An error occurred so we should not completes the transaction:" + e, e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } }
/** Gets and precaches all propertycategory-objects. */ public void preCacheAllPropertiesCategoryVOList() throws SystemException, Exception { Database db = CastorDatabaseService.getDatabase(); beginTransaction(db); try { Timer t = new Timer(); Map<Integer, CategoryVO> categoriesMap = new HashMap<Integer, CategoryVO>(); OQLQuery oql1 = db.getOQLQuery( "SELECT c FROM org.infoglue.cms.entities.management.impl.simple.CategoryImpl c ORDER BY c.categoryId"); QueryResults results1 = oql1.execute(Database.ReadOnly); while (results1.hasMore()) { Category category = (Category) results1.next(); categoriesMap.put(category.getId(), category.getValueObject()); } results1.close(); oql1.close(); logger.warn("Categories took: " + t.getElapsedTime()); // getCastorCategory().setLevel(Level.DEBUG); // getCastorJDOCategory().setLevel(Level.DEBUG); OQLQuery oql = db.getOQLQuery( "SELECT c FROM org.infoglue.cms.entities.management.impl.simple.SmallPropertiesCategoryImpl c ORDER BY c.propertiesCategoryId"); QueryResults results = oql.execute(Database.ReadOnly); while (results.hasMore()) { PropertiesCategory propertiesCategory = (PropertiesCategory) results.next(); String key = "categoryVOList_" + propertiesCategory.getAttributeName() + "_" + propertiesCategory.getEntityName() + "_" + propertiesCategory.getEntityId(); List<CategoryVO> categoryVOList = (List<CategoryVO>) CacheController.getCachedObject("propertiesCategoryCache", key); if (categoryVOList == null) { categoryVOList = new ArrayList<CategoryVO>(); CacheController.cacheObject("propertiesCategoryCache", key, categoryVOList); } if (propertiesCategory.getValueObject().getCategoryId() != null) { CategoryVO categoryVO = categoriesMap.get(propertiesCategory.getValueObject().getCategoryId()); if (categoryVO != null) categoryVOList.add(categoryVO); else logger.info( "An inconsistency found. The propertyCategory " + propertiesCategory.getId() + " pointed to a missing categoryID: " + propertiesCategory.getValueObject().getCategoryId()); /* try { CategoryVO categoryVO = CategoryController.getController().findById(propertiesCategory.getValueObject().getCategoryId(), db).getValueObject(); categoryVOList.add(categoryVO); } catch (Exception e) { logger.error("An inconsistency found. The propertyCategory " + propertiesCategory.getId() + " pointed to a missing category:" + e.getMessage()); } */ } /* if(propertiesCategory.getCategory() != null) { categoryVOList.add(propertiesCategory.getCategory().getValueObject()); //System.out.println("Category was ok for: " + key); } //else //System.out.println("Category was null for: " + key); */ } // getCastorCategory().setLevel(Level.WARN); // getCastorJDOCategory().setLevel(Level.WARN); results.close(); oql.close(); CacheController.cacheObject("propertiesCategoryCache", "allValuesCached", true); logger.warn("PropCategories took: " + t.getElapsedTime()); commitTransaction(db); } catch (Exception e) { logger.error("An error occurred when we tried to fetch the list of PropertiesCategory:" + e); rollbackTransaction(db); throw new SystemException(e.getMessage()); } }