/** * Creates a copied instance of this localized exception.<p> * * @param container the message container * @param cause the root cause * * @return a copied instance of this localized exception */ public CmsException createException(CmsMessageContainer container, Throwable cause) { return new CmsException(container, cause); }
/** * Creates a copied instance of this localized exception.<p> * * @param container the message container * @param cause the root cause * * @return a copied instance of this localized exception */ public CmsException createException(CmsMessageContainer container, Throwable cause) { return new CmsException(container, cause); }
/** * Returns always true and does nothing else, has to be implemented.<p> * * @see org.opencms.workplace.CmsMultiDialog#performDialogOperation() */ @Override protected boolean performDialogOperation() throws CmsException { throw new CmsException(new CmsMessageContainer(null, "")); } }
/** * Returns always true and does nothing else, has to be implemented.<p> * * @see org.opencms.workplace.CmsMultiDialog#performDialogOperation() */ @Override protected boolean performDialogOperation() throws CmsException { throw new CmsException(new CmsMessageContainer(null, "")); } }
/** * Processes the current database context.<p> * * @throws CmsException if something goes wrong */ public void pop() throws CmsException { if (!isDefaultDbContext()) { throw new CmsException(Messages.get().container(Messages.ERR_PROCESS_DB_CONTEXT_0)); } }
/** * Processes the current database context.<p> * * @throws CmsException if something goes wrong */ public void pop() throws CmsException { if (!isDefaultDbContext()) { throw new CmsException(Messages.get().container(Messages.ERR_PROCESS_DB_CONTEXT_0)); } }
/** * @see org.opencms.search.CmsSearchIndex#addConfigurationParameter(java.lang.String, java.lang.String) */ @Override public void addConfigurationParameter(String key, String value) { if (POST_PROCESSOR.equals(key)) { if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(value)) { try { setPostProcessor((I_CmsSolrPostSearchProcessor)Class.forName(value).newInstance()); } catch (Exception e) { CmsException ex = new CmsException( Messages.get().container(Messages.LOG_SOLR_ERR_POST_PROCESSOR_NOT_EXIST_1, value), e); LOG.error(ex.getMessage(), ex); } } } super.addConfigurationParameter(key, value); }
/** * Returns an initialized macro wrapper that can be used for the paragraph output.<p> * * @return an initialized macro wrapper that can be used for the paragraph output * @throws Exception if the initialization of the wrapper fails */ protected I_CmsMacroWrapper getMacroWrapper() throws Exception { // create path to macro file to use StringBuffer macroFile = new StringBuffer(256); macroFile.append(getPathLayoutElements()); macroFile.append(getColumnLayout()); macroFile.append("_"); macroFile.append(getVariant()); macroFile.append("."); macroFile.append(CmsMacroWrapperFreeMarker.FILE_SUFFIX); String fileName = macroFile.toString(); if (!getCmsObject().existsResource(fileName)) { // macro file not found, log error and throw exception if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_VFS_RESOURCE_1, fileName)); } throw new CmsException(Messages.get().container(Messages.LOG_ERR_VFS_RESOURCE_1, fileName)); } return new CmsMacroWrapperFreeMarker(getCmsObject(), fileName); }
/** * Reads the current element bean from the request.<p> * * @param req the servlet request * * @return the element bean * * @throws CmsException if no current element is set */ public CmsContainerElementBean getCurrentElement(ServletRequest req) throws CmsException { CmsContainerElementBean element = CmsJspStandardContextBean.getInstance(req).getElement(); if (element == null) { throw new CmsException(Messages.get().container(Messages.ERR_READING_ELEMENT_FROM_REQUEST_0)); } return element; }
/** * Set the name of the index to search.<p> * * A former search result will be deleted.<p> * * @param indexName the name of the index * * @throws CmsException if the index was not found */ public void setIndex(String indexName) throws CmsException { if (CmsStringUtil.isEmpty(indexName)) { throw new CmsException(Messages.get().container(Messages.ERR_INDEXSOURCE_CREATE_MISSING_NAME_0)); } CmsSolrIndex index = OpenCms.getSearchManager().getIndexSolr(indexName); if (index == null) { throw new CmsException(Messages.get().container(Messages.ERR_INDEX_NOT_FOUND_1, indexName)); } m_index = index; }
/** * Ensures that the user session is still valid.<p> * * @throws CmsException if the current user is the guest user */ protected void ensureSession() throws CmsException { CmsUser user = getCmsObject().getRequestContext().getCurrentUser(); if (user.isGuestUser()) { throw new CmsException(Messages.get().container(Messages.ERR_SESSION_EXPIRED_0)); } }
/** * Set the name of the index to search.<p> * * @param indexName the name of the index */ public void setIndex(String indexName) { CmsSearchIndex index; if (CmsStringUtil.isNotEmpty(indexName)) { try { index = OpenCms.getSearchManager().getIndex(indexName); if (index == null) { throw new CmsException(Messages.get().container(Messages.ERR_INDEX_NOT_FOUND_1, indexName)); } setSearchIndex(index); } catch (Exception exc) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INDEX_ACCESS_FAILED_1, indexName), exc); } } } }
/** * Set the name of the index to search.<p> * * * @param indexName the name of the index */ public void setIndex(String indexName) { CmsSearchIndex index; if (CmsStringUtil.isNotEmpty(indexName)) { try { index = OpenCms.getSearchManager().getIndex(indexName); if (index == null) { throw new CmsException(Messages.get().container(Messages.ERR_INDEX_NOT_FOUND_1, indexName)); } setSearchIndex(index); } catch (Exception exc) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_INDEX_ACCESS_FAILED_1, indexName), exc); } } } }
/** * Writes the xml content to the vfs and re-initializes the member variables.<p> * * @throws CmsException if writing the file fails */ private void writeContent() throws CmsException { String decodedContent = m_content.toString(); try { m_file.setContents(decodedContent.getBytes(getFileEncoding())); } catch (UnsupportedEncodingException e) { throw new CmsException(Messages.get().container(Messages.ERR_INVALID_CONTENT_ENC_1, getParamResource()), e); } // the file content might have been modified during the write operation m_file = getCloneCms().writeFile(m_file); m_content = CmsXmlContentFactory.unmarshal(getCloneCms(), m_file); } }
/** * @see org.opencms.xml.content.CmsDefaultXmlContentHandler#getCSSHeadIncludes(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ @Override public Set<String> getCSSHeadIncludes(CmsObject cms, CmsResource resource) throws CmsException { Set<String> result = new LinkedHashSet<String>(); List<CmsContainerElementBean> containerElements = loadGroupContainerElements(cms, resource); for (CmsContainerElementBean elementBean : containerElements) { if (elementBean.isGroupContainer(cms) || elementBean.isInheritedContainer(cms)) { throw new CmsException( Messages.get().container( Messages.ERR_ELEMENT_GROUP_REFERENCES_ANOTHER_GROUP_2, resource.getRootPath(), elementBean.getResource().getRootPath())); } CmsResource elementResource = elementBean.getResource(); Set<String> elementIncludes = CmsXmlContentDefinition.getContentHandlerForResource( cms, elementResource).getCSSHeadIncludes(cms, elementResource); result.addAll(elementIncludes); } return result; }
/** * @see org.opencms.xml.content.CmsDefaultXmlContentHandler#getJSHeadIncludes(org.opencms.file.CmsObject, org.opencms.file.CmsResource) */ @Override public Set<String> getJSHeadIncludes(CmsObject cms, CmsResource resource) throws CmsException { Set<String> result = new LinkedHashSet<String>(); List<CmsContainerElementBean> containerElements = loadGroupContainerElements(cms, resource); for (CmsContainerElementBean elementBean : containerElements) { if (elementBean.isGroupContainer(cms) || elementBean.isInheritedContainer(cms)) { throw new CmsException( Messages.get().container( Messages.ERR_ELEMENT_GROUP_REFERENCES_ANOTHER_GROUP_2, resource.getRootPath(), elementBean.getResource().getRootPath())); } CmsResource elementResource = elementBean.getResource(); Set<String> elementIncludes = CmsXmlContentDefinition.getContentHandlerForResource( cms, elementResource).getJSHeadIncludes(cms, elementResource); result.addAll(elementIncludes); } return result; }
/** * Returns the gallery search result list.<p> * * @param params the gallery search parameters * * @return the gallery search result list * * @throws CmsException if the search failed */ public CmsGallerySearchResultList getResult(CmsGallerySearchParameters params) throws CmsException { CmsGallerySearchResultList result = null; if ((m_cms == null) || (m_index == null)) { throw new CmsException(Messages.get().container(Messages.ERR_SEARCH_NOT_INITIALIZED_0)); } result = m_index.gallerySearch(m_cms, params); if (result.size() > 0) { result.calculatePages(params.getResultPage(), params.getMatchesPerPage()); } else { result = new CmsGallerySearchResultList(); } return result; }
/** * Writes the xml content to the vfs and re-initializes the member variables.<p> * * @throws CmsException if writing the file fails */ private void writeContent() throws CmsException { String decodedContent = m_content.toString(); try { m_file.setContents(decodedContent.getBytes(getFileEncoding())); } catch (UnsupportedEncodingException e) { throw new CmsException(Messages.get().container(Messages.ERR_INVALID_CONTENT_ENC_1, getParamResource()), e); } // the file content might have been modified during the write operation CmsObject cloneCms = getCloneCms(); CmsUUID tempProjectId = OpenCms.getWorkplaceManager().getTempFileProjectId(); cloneCms.getRequestContext().setCurrentProject(getCms().readProject(tempProjectId)); m_file = cloneCms.writeFile(m_file); m_content = CmsXmlContentFactory.unmarshal(cloneCms, m_file); } }
/** * @see org.opencms.workplace.CmsMultiDialog#performDialogOperation() */ @Override protected boolean performDialogOperation() throws CmsException { CmsPublishList publishList = getSettings().getPublishList(); if (publishList == null) { throw new CmsException(Messages.get().container( org.opencms.db.Messages.ERR_GET_PUBLISH_LIST_PROJECT_1, getProjectname())); } OpenCms.getPublishManager().publishProject( getCms(), new CmsHtmlReport(getLocale(), getCms().getRequestContext().getSiteRoot()), publishList); // wait 2 seconds, may be it finishes fast OpenCms.getPublishManager().waitWhileRunning(1500); return true; }
/** * @see org.opencms.workplace.CmsMultiDialog#performDialogOperation() */ @Override protected boolean performDialogOperation() throws CmsException { CmsPublishList publishList = getSettings().getPublishList(); if (publishList == null) { throw new CmsException( Messages.get().container(org.opencms.db.Messages.ERR_GET_PUBLISH_LIST_PROJECT_1, getProjectname())); } OpenCms.getPublishManager().publishProject( getCms(), new CmsHtmlReport(getLocale(), getCms().getRequestContext().getSiteRoot()), publishList); // wait 2 seconds, may be it finishes fast OpenCms.getPublishManager().waitWhileRunning(1500); return true; }