/** * This method returns all languages for a certain repository. * * @param repositoryId * @return * @throws SystemException * @throws Exception */ public List getLanguageVOList(Integer repositoryId, Database db) throws SystemException, Exception { String key = "" + repositoryId + "_allLanguages"; logger.info("key:" + key); List list = (List) CacheController.getCachedObject("languageCache", key); if (list != null) { logger.info("There was an cached list:" + list); } else { list = new ArrayList(); OQLQuery oql = db.getOQLQuery( "SELECT l FROM org.infoglue.cms.entities.management.impl.simple.LanguageImpl l WHERE l.repositoryLanguages.repository = $1 ORDER BY l.repositoryLanguages.sortOrder, l.languageId"); oql.bind(repositoryId); QueryResults results = oql.execute(Database.ReadOnly); while (results.hasMore()) { Language language = (Language) results.next(); list.add(language.getValueObject()); } results.close(); oql.close(); if (list.size() > 0) CacheController.cacheObject("languageCache", key, list); } return list; }
/** * 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; }
public synchronized void run() { try { sleep(50); CacheController.clearCache(Class.forName(entity), new Object[] {entityId}, true); CacheController.clearCaches(entity, entityId, null, true); } catch (Exception e) { logger.error("An error occurred in the PublicationThread:" + e.getMessage()); } }
/** This method return a LanguageVO */ public LanguageVO getLanguageVOWithId(Integer languageId) throws SystemException, Exception { String key = "" + languageId; logger.info("key:" + key); LanguageVO languageVO = (LanguageVO) CacheController.getCachedObject("languageCache", key); if (languageVO != null) { logger.info("There was an cached languageVO:" + languageVO); } else { languageVO = (LanguageVO) getVOWithId(LanguageImpl.class, languageId); CacheController.cacheObject("languageCache", key, languageVO); } return languageVO; }
public int doEndTag() throws JspException { try { CacheController.clearCache(Class.forName(entity), new Object[] {entityId}, true); CacheController.clearCaches(entity, entityId, null, true); // CacheController.clearCaches(null, null, null, true); // CacheUpdateThread cacheUpdateThread = new CacheUpdateThread(); // cacheUpdateThread.start(); } catch (Exception e) { e.printStackTrace(); } return EVAL_PAGE; }
public List getLanguageVOList(Database db) throws SystemException, Bug { String key = "allLanguageVOList"; List languageVOList = (List) CacheController.getCachedObject("languageCache", key); if (languageVOList != null) { if (logger.isInfoEnabled()) logger.info("There was an cached languageVOList:" + languageVOList.size()); } else { languageVOList = getAllVOObjects(LanguageImpl.class, "languageId", db); CacheController.cacheObject("languageCache", key, languageVOList); } return languageVOList; // return getAllVOObjects(LanguageImpl.class, "languageId", db); }
/** The main method that fetches the Value-objects for this use-case */ public String doDeleteProperty() throws Exception { validateSecurityCode(); Map args = new HashMap(); args.put("globalKey", "infoglue"); PropertySet ps = PropertySetManager.getInstance("jdbc", args); ps.remove("serverNode_" + this.getServerNodeId() + "_" + key); try { CacheController.clearServerNodeProperty(true); InfoGlueAuthenticationFilter.initializeCMSProperties(); } catch (SystemException e) { e.printStackTrace(); } NotificationMessage notificationMessage = new NotificationMessage( "ViewServerNodePropertiesAction.doSave():", "ServerNodeProperties", this.getInfoGluePrincipal().getName(), NotificationMessage.SYSTEM, "0", "ServerNodeProperties"); // ChangeNotificationController.getInstance().addNotificationMessage(notificationMessage); RemoteCacheUpdater.getSystemNotificationMessages().add(notificationMessage); return "save"; }
/** * 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, Database db) 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 { Language language = getMasterLanguage(db, repositoryId); if (language != null) { languageVO = language.getValueObject(); CacheController.cacheObject("masterLanguageCache", languageKey, languageVO); } } return languageVO; }
/** * 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 static void restoreSessionFactory(Throwable we) { try { logger.error("Restoring session factory..."); String serverName = "Unknown"; try { InetAddress localhost = InetAddress.getLocalHost(); serverName = localhost.getHostName(); } catch (Exception e) { } String errorMessage = ""; String stacktrace = ""; StringWriter sw = new StringWriter(); if (we != null) { errorMessage = we.getMessage(); we.printStackTrace(new PrintWriter(sw)); stacktrace = sw.toString().replaceAll("(\r\n|\r|\n|\n\r)", "<br/>"); } String subject = "CMS - Restoring session factory on " + serverName; String message = "OS Workflow had problems accessing the database or some other problem occurred. Check why the database went away or the error occurred."; message = message + "\n\n" + errorMessage + "\n\n" + stacktrace; String warningEmailReceiver = CmsPropertyHandler.getWarningEmailReceiver(); if (warningEmailReceiver != null && !warningEmailReceiver.equals("") && warningEmailReceiver.indexOf("@warningEmailReceiver@") == -1) { try { MailServiceFactory.getService() .sendEmail( "text/html", warningEmailReceiver, warningEmailReceiver, null, null, null, null, subject, message, "utf-8"); } catch (Exception e) { logger.error("Could not send mail:" + e.getMessage(), e); } } try { logger.info("Closing:" + hibernateSessionFactory); hibernateSessionFactory.close(); CacheController.clearCache("propertySetCache"); } catch (Exception e) { logger.error( "An error occurred when we tried to close the hibernate session factory:" + e.getMessage()); } hibernateSessionFactory = new Configuration().configure().buildSessionFactory(); logger.info("Opened:" + hibernateSessionFactory); } catch (Exception e) { logger.error( "An error occurred when we tried to restore the hibernate session factory:" + e.getMessage(), e); } }
/** * This method saves all application settings by grabbing the stated parameter values from the * request. */ public String doSave() throws Exception { validateSecurityCode(); Map args = new HashMap(); args.put("globalKey", "infoglue"); PropertySet ps = PropertySetManager.getInstance("jdbc", args); populate(ps, "isPageCacheOn"); populate(ps, "useSelectivePageCacheUpdate"); populate(ps, "expireCacheAutomatically"); populate(ps, "cacheExpireInterval"); populate(ps, "deliverRequestTimeout"); populate(ps, "liveDeliverRequestTimeout"); populate(ps, "killLiveRequestWhichTimedout"); populate(ps, "useHighLoadLimiter"); populate(ps, "maxActiveRequests"); populate(ps, "maxRequestTime"); populate(ps, "session.timeout"); populate(ps, "compressPageCache"); populate(ps, "compressPageResponse"); populate(ps, "disableDecoratedFinalRendering"); populate(ps, "siteNodesToRecacheOnPublishing"); populate(ps, "recachePublishingMethod"); populate(ps, "recacheUrl"); populate(ps, "useUpdateSecurity"); populate(ps, "allowXForwardedIPCheck"); populate(ps, "allowedAdminIP"); String allowedAdminIP = this.getRequest().getParameter("allowedAdminIP"); if (allowedAdminIP != null && !allowedAdminIP.equals("")) ServerNodeController.getController().setAllowedAdminIP(allowedAdminIP); populate(ps, "pageKey"); populate(ps, "componentKey"); populateData(ps, "cacheSettings"); populateData(ps, "extraPublicationPersistentCacheNames"); populate(ps, "cmsBaseUrl"); populate(ps, "cmsFullBaseUrl"); populate(ps, "componentEditorUrl"); populate(ps, "componentRendererUrl"); populate(ps, "componentRendererAction"); populate(ps, "editOnSiteUrl"); populate(ps, "useFreeMarker"); populate(ps, "webServerAddress"); populate(ps, "applicationBaseAction"); populate(ps, "digitalAssetBaseUrl"); populate(ps, "imagesBaseUrl"); populate(ps, "digitalAssetPath"); populate(ps, "urlFormatting"); populate(ps, "enableNiceURI"); populate(ps, "enableNiceURIInWorking"); populate(ps, "enableNiceURIForLanguage"); populate(ps, "enableDiskAssets"); populate(ps, "disableAssetDeletionInWorkThread"); populate(ps, "disableAssetDeletionInLiveThread"); populate(ps, "niceURIEncoding"); populate(ps, "niceURIAttributeName"); populateData(ps, "niceURICharacterReplacingMapping"); populate(ps, "niceURIUseLowerCase"); populate(ps, "niceURIDefaultReplacementCharacter"); populate(ps, "niceURIDisableNiceURIForContent"); populate(ps, "niceURIDefaultReplacementCharacterForContent"); populate(ps, "duplicateAssetsBetweenVersions"); populate(ps, "requestArgumentDelimiter"); populate(ps, "errorHandling"); populate(ps, "errorUrl"); populate(ps, "errorBusyUrl"); populate(ps, "externalThumbnailGeneration"); populate(ps, "URIEncoding"); populate(ps, "workflowEncoding"); populate(ps, "formsEncoding"); populate(ps, "uploadFromEncoding"); populate(ps, "uploadToEncoding"); populate(ps, "assetKeyFromEncoding"); populate(ps, "assetKeyToEncoding"); populate(ps, "enableCustomCharactersParsing"); populate(ps, "customCharactersForConversion"); populate(ps, "useShortTableNames"); populate(ps, "useImprovedContentCategorySearch"); populate(ps, "logDatabaseMessages"); populate(ps, "statistics.enabled"); populate(ps, "statisticsLogPath"); populate(ps, "statisticsLogOneFilePerDay"); populate(ps, "statisticsLogger"); populate(ps, "contactPersonEmailMetaInfoAttribute"); populate(ps, "notifyResponsibleOnReferenceChange"); populate(ps, "enablePortal"); populate(ps, "portletBase"); populate(ps, "mail.smtp.host"); populate(ps, "mail.smtp.port"); populate(ps, "mail.smtp.auth"); populate(ps, "mail.smtp.user"); populate(ps, "mail.smtp.password"); populate(ps, "mail.contentType"); populate(ps, "systemEmailSender"); populate(ps, "warningEmailReceiver"); populate(ps, "emailRecipientLimit"); populate(ps, "loginUrl"); populate(ps, "logoutUrl"); populate(ps, "invalidLoginUrl"); populate(ps, "successLoginBaseUrl"); populate(ps, "authenticatorClass"); populate(ps, "authorizerClass"); populate(ps, "serverName"); populate(ps, "authConstraint"); populate(ps, "extraParametersFile"); populateData(ps, "extraSecurityParameters"); populate(ps, "casValidateUrl"); populate(ps, "casProxyValidateUrl"); populate(ps, "casServiceUrl"); populate(ps, "casLogoutUrl"); populate(ps, "ipAddressesToFallbackToBasicAuth"); populate(ps, "deliver_loginUrl"); populate(ps, "deliver_logoutUrl"); populate(ps, "deliver_invalidLoginUrl"); populate(ps, "deliver_successLoginBaseUrl"); populate(ps, "deliver_authenticatorClass"); populate(ps, "deliver_authorizerClass"); populate(ps, "deliver_serverName"); populate(ps, "deliver_authConstraint"); populate(ps, "deliver_extraParametersFile"); populateData(ps, "deliver_extraSecurityParameters"); populate(ps, "deliver_security.anonymous.username"); populate(ps, "deliver_security.anonymous.password"); populate(ps, "deliver_casValidateUrl"); populate(ps, "deliver_casProxyValidateUrl"); populate(ps, "deliver_casServiceUrl"); populate(ps, "deliver_casLogoutUrl"); populate(ps, "workingStyleInformation"); populate(ps, "finalStyleInformation"); populate(ps, "publishStyleInformation"); populate(ps, "publishedStyleInformation"); populateData(ps, "customContentTypeIcons"); populateData(ps, "shortcuts"); populateData(ps, "WYSIWYGToolbarComboPreviewCSS"); populateData(ps, "WYSIWYGEditorAreaCSS"); populate(ps, "disableImageEditor"); populate(ps, "hideProtectedProperties"); populate(ps, "protectContentTypes"); populate(ps, "protectWorkflows"); populate(ps, "protectCategories"); populate(ps, "internalSearchEngine"); populate(ps, "allowOverrideModifyer"); populate(ps, "useSimpleComponentDialog"); populate(ps, "hideAccessRightsIfNotAllowedToManage"); populate(ps, "onlyAllowFolderType"); populate(ps, "allowedFolderContentTypeNames"); populate(ps, "skipResultDialogIfPossible"); populate(ps, "maxRows"); populate(ps, "maxNumberOfAssetInSearches"); populate(ps, "gaCode"); populate(ps, "componentBindningAssetBrowser"); populate(ps, "prefferedWYSIWYG"); populate(ps, "defaultNumberOfYearsBeforeExpire"); populate(ps, "defaultNumberOfMonthsBeforeRedirectExpire"); populate(ps, "defaultNumberOfMonthsBeforeSystemRedirectExpire"); populate(ps, "enableDateTimeDirectEditing"); populate(ps, "showContentVersionFirst"); populate(ps, "tree"); populate(ps, "treemode"); populate(ps, "disableCustomIcons"); populate(ps, "showComponentsFirst"); populate(ps, "showAllWorkflows"); populate(ps, "editOnSight"); populate(ps, "previewDeliveryUrl"); populate(ps, "stagingDeliveryUrl"); populateData(ps, "internalDeliveryUrls"); populateData(ps, "publicDeliveryUrls"); populateData(ps, "toolLanguages"); populateData(ps, "deploymentServers"); populateData(ps, "vcServers"); populate(ps, "decoratedPageInvoker"); populate(ps, "defaultRepositoryAccessRoles"); populate(ps, "edition.pageSize"); populate(ps, "content.tree.sort"); populate(ps, "structure.tree.sort"); populate(ps, "structure.tree.isHidden"); populate(ps, "content.tree.hideForbidden"); populate(ps, "structure.tree.hideForbidden"); populate(ps, "enforceRigidContentAccess"); populate(ps, "disableEmptyUrls"); populate(ps, "cacheUpdateAction"); populate(ps, "logPath"); populate(ps, "logTransactions"); populate(ps, "enableExtranetCookies"); populate(ps, "useAlternativeBrowserLanguageCheck"); populate(ps, "caseSensitiveRedirects"); populate(ps, "useDNSNameInURI"); populate(ps, "extranetCookieTimeout"); populate(ps, "webServicesBaseUrl"); populate(ps, "livePublicationThreadClass"); populate(ps, "publicationThreadDelay"); populate(ps, "pathsToRecacheOnPublishing"); populate(ps, "disableTemplateDebug"); populate(ps, "exportFormat"); populate(ps, "dbRelease"); populate(ps, "dbUser"); populate(ps, "dbPassword"); populate(ps, "masterServer"); populate(ps, "slaveServer"); populate(ps, "buildName"); populate(ps, "adminToolsPath"); populate(ps, "dbScriptPath"); populate(ps, "digitalAssetUploadPath"); populate(ps, "inputCharacterEncoding"); populate(ps, "deliver_inputCharacterEncoding"); populate(ps, "protectDeliverWorking"); populate(ps, "protectDeliverPreview"); populate(ps, "forceIdentityCheck"); populate(ps, "allowCrossSiteSubmitToPublish"); populate(ps, "usePasswordEncryption"); populate(ps, "helpUrl"); populateData(ps, "headerHTML"); populate(ps, "allowPublicationEventFilter"); populate(ps, "defaultPublicationEventFilter"); populate(ps, "numberOfVersionsToKeepDuringClean"); populate(ps, "keepOnlyOldPublishedVersionsDuringClean"); populate(ps, "minimumTimeBetweenVersionsDuringClean"); populateData(ps, "assetUploadTransformationsSettings"); populate(ps, "setDerivedLastModifiedInLive"); populate(ps, "standardResponseHeaders"); populate(ps, "maxNumberOfVersionsForDerivedLastModifiedInLive"); populate(ps, "allowInternalCallsBasedOnIP"); populate(ps, "assetFileNameForm"); populate(ps, "deriveProtocolWhenUsingProtocolRedirects"); populate(ps, "useAccessBasedProtocolRedirects"); populate(ps, "unprotectedProtocolName"); populate(ps, "protectedProtocolName"); populate(ps, "unprotectedProtocolPort"); populate(ps, "protectedProtocolPort"); populate(ps, "accessBasedProtocolRedirectHTTPCode"); populate(ps, "redirectStatusCode"); populate(ps, "indexDigitalAssetContent"); populate(ps, "allowedDirectLoginNames"); populate(ps, "onlyShowReferenceIfLatestVersion"); populate(ps, "registryContactMailLanguage"); try { UserControllerProxy.getController().updateAnonymousUserPassword(); } catch (SystemException e) { e.printStackTrace(); } try { CacheController.clearServerNodeProperty(true); InfoGlueAuthenticationFilter.initializeCMSProperties(); } catch (SystemException e) { e.printStackTrace(); } NotificationMessage notificationMessage = new NotificationMessage( "ViewServerNodePropertiesAction.doSave():", "ServerNodeProperties", this.getInfoGluePrincipal().getName(), NotificationMessage.SYSTEM, "0", "ServerNodeProperties"); // ChangeNotificationController.getInstance().addNotificationMessage(notificationMessage); RemoteCacheUpdater.getSystemNotificationMessages().add(notificationMessage); return "save"; }
/** 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()); } }