/** * @see org.opencms.main.CmsException#createException(org.opencms.i18n.CmsMessageContainer, java.lang.Throwable) */ @Override public CmsException createException(CmsMessageContainer container, Throwable cause) { return new CmsVfsException(container, cause); } }
LOG.error(e.getLocalizedMessage(), e); } finally { cms.getRequestContext().setSiteRoot(originalSiteRoot);
/** * @see org.opencms.main.CmsException#createException(org.opencms.i18n.CmsMessageContainer, java.lang.Throwable) */ @Override public CmsException createException(CmsMessageContainer container, Throwable cause) { return new CmsVfsException(container, cause); } }
/** * Stores the import resource in an Object member variable.<p> * @throws CmsVfsException if the file to import is no valid zipfile */ private void getImportResource() throws CmsVfsException { // get the import resource m_importResource = new File(m_importFolderName); // check if this is a folder or a ZIP file if (m_importResource.isFile()) { try { m_zipStreamIn = new ZipInputStream(new FileInputStream(m_importResource)); } catch (IOException e) { // if file but no ZIP file throw an exception throw new CmsVfsException(Messages.get().container( Messages.ERR_NO_ZIPFILE_1, m_importResource.getName()), e); } } }
/** * Stores the import resource in an Object member variable.<p> * @throws CmsVfsException if the file to import is no valid zipfile */ private void getImportResource() throws CmsVfsException { // get the import resource m_importResource = new File(m_importFolderName); // check if this is a folder or a ZIP file if (m_importResource.isFile()) { try { m_zipStreamIn = new ZipInputStream(new FileInputStream(m_importResource)); } catch (IOException e) { // if file but no ZIP file throw an exception throw new CmsVfsException( Messages.get().container(Messages.ERR_NO_ZIPFILE_1, m_importResource.getName()), e); } } }
/** * Returns an exception of the same type as <code>throwable</code>, if <code>throwable</code> is an OpenCms Exception * with the message as a {@link CmsMessageContainer} and the <code>throwable</code> as a cause.<p> * * @param message the message container for the exception to create * @param throwable the cause of the exception * * @throws CmsException if the <code>throwable</code> parameter is not <code>null</code> and a {@link CmsException} * @throws CmsVfsException if the <code>throwable</code> parameter is not <code>null</code> and no {@link CmsException} */ public void throwException(CmsMessageContainer message, Throwable throwable) throws CmsVfsException, CmsException { if (throwable instanceof CmsException) { throw ((CmsException)throwable).createException(message, throwable); } else if (throwable instanceof CmsRuntimeException) { throw ((CmsRuntimeException)throwable).createException(message, throwable); } else { throw new CmsVfsException(message, throwable); } } }
/** * Returns an Exception of the same type as throwable if throwable is an OpenCms Exception * with the message as a MessageContainer and the throwable as a cause.<p> * * @param message the MessageContainer for the Exception to create * @param throwable the cause of the exception * * @throws CmsVfsException if throwable is not an OpenCms Exception * @throws CmsException of the same type as throwable if throwable is an OpenCms Exception */ void throwException(CmsMessageContainer message, Throwable throwable) throws CmsVfsException, CmsException { if (throwable instanceof CmsException) { throw ((CmsException)throwable).createException(message, throwable); } else if (throwable instanceof CmsRuntimeException) { throw ((CmsRuntimeException)throwable).createException(message, throwable); } else { throw new CmsVfsException(message, throwable); } } }
/** * Tries to add sub-resources of moved folders to the publish list and throws an exception if the publish list still does * not contain some sub-resources of the moved folders.<p> * * @param cms the current CMS context * @param dbc the current database context * @param pubList the publish list * @throws CmsException if something goes wrong */ protected void ensureSubResourcesOfMovedFoldersPublished(CmsObject cms, CmsDbContext dbc, CmsPublishList pubList) throws CmsException { List<CmsResource> topMovedFolders = pubList.getTopMovedFolders(cms); Iterator<CmsResource> folderIt = topMovedFolders.iterator(); while (folderIt.hasNext()) { CmsResource folder = folderIt.next(); addSubResources(dbc, pubList, folder); } List<CmsResource> missingSubResources = pubList.getMissingSubResources(cms, topMovedFolders); if (missingSubResources.isEmpty()) { return; } StringBuffer pathBuffer = new StringBuffer(); for (CmsResource missing : missingSubResources) { pathBuffer.append(missing.getRootPath()); pathBuffer.append(" "); } throw new CmsVfsException( Messages.get().container(Messages.RPT_CHILDREN_OF_MOVED_FOLDER_NOT_PUBLISHED_1, pathBuffer.toString())); }
/** * Import that will read from a ZIP file.<p> * * @param content the zip file to import * @param importPath the path to the OpenCms VFS to import to * @param cms a OpenCms context to provide the permissions * @param noSubFolder if <code>true</code> no sub folders will be created, if <code>false</code> the content of the * zip file is created 1:1 inclusive sub folders * * @throws CmsException if something goes wrong */ public void importZip(byte[] content, String importPath, CmsObject cms, boolean noSubFolder) throws CmsException { m_importPath = importPath; m_cms = cms; try { // open the import resource m_zipStreamIn = new ZipInputStream(new ByteArrayInputStream(content)); m_cms.readFolder(importPath, CmsResourceFilter.IGNORE_EXPIRATION); // import the resources importZipResource(m_zipStreamIn, m_importPath, noSubFolder); } catch (Exception e) { throw new CmsVfsException(Messages.get().container(Messages.ERR_IMPORT_FOLDER_1, importPath), e); } }
/** * Constructor for a new CmsImportFolder that will read from a ZIP file.<p> * * @param content the zip file to import * @param importPath the path to the OpenCms VFS to import to * @param cms a OpenCms context to provide the permissions * @param noSubFolder if false no sub folder will be created * @throws CmsException if something goes wrong */ public CmsImportFolder(byte[] content, String importPath, CmsObject cms, boolean noSubFolder) throws CmsException { m_importPath = importPath; m_cms = cms; try { // open the import resource m_zipStreamIn = new ZipInputStream(new ByteArrayInputStream(content)); m_cms.readFolder(importPath, CmsResourceFilter.IGNORE_EXPIRATION); // import the resources importZipResource(m_zipStreamIn, m_importPath, noSubFolder); } catch (Exception e) { throw new CmsVfsException(Messages.get().container(Messages.ERR_IMPORT_FOLDER_1, importPath), e); } }
throw new CmsVfsException( Messages.get().container(Messages.RPT_PARENT_FOLDER_NOT_PUBLISHED_1, parentFolderName));
throw new CmsVfsException(Messages.get().container( Messages.RPT_PARENT_FOLDER_NOT_PUBLISHED_1, parentFolderName));
throw new CmsVfsException( Messages.get().container( Messages.ERR_CHANGE_RESOURCES_IN_FOLDER_WITH_PROP_4,
/** * Checks if the project in the given database context is not the "Online" project, * and throws an Exception if this is the case.<p> * * This is used to ensure a user is in an "Offline" project * before write access to VFS resources is granted.<p> * * @param dbc the current OpenCms users database context * * @throws CmsVfsException if the project in the given database context is the "Online" project */ public void checkOfflineProject(CmsDbContext dbc) throws CmsVfsException { if (dbc.currentProject().isOnlineProject()) { throw new CmsVfsException(org.opencms.file.Messages.get().container( org.opencms.file.Messages.ERR_NOT_ALLOWED_IN_ONLINE_PROJECT_0)); } }
/** * Checks if the project in the given database context is not the "Online" project, * and throws an Exception if this is the case.<p> * * This is used to ensure a user is in an "Offline" project * before write access to VFS resources is granted.<p> * * @param dbc the current OpenCms users database context * * @throws CmsVfsException if the project in the given database context is the "Online" project */ public void checkOfflineProject(CmsDbContext dbc) throws CmsVfsException { if (dbc.currentProject().isOnlineProject()) { throw new CmsVfsException( org.opencms.file.Messages.get().container( org.opencms.file.Messages.ERR_NOT_ALLOWED_IN_ONLINE_PROJECT_0)); } }
throw new CmsVfsException(Messages.get().container( Messages.ERR_CHANGE_RESOURCES_IN_FOLDER_WITH_PROP_4, new Object[] {propertyDefinition, oldValue, newValue, resource.getRootPath()}), e);
/** * @see org.opencms.file.types.I_CmsResourceType#moveResource(org.opencms.file.CmsObject, org.opencms.db.CmsSecurityManager, org.opencms.file.CmsResource, java.lang.String) */ @Override public void moveResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, String destination) throws CmsException, CmsIllegalArgumentException { String dest = cms.getRequestContext().addSiteRoot(destination); if (!CmsResource.isFolder(dest)) { // ensure folder name end's with a / (required for the following comparison) dest = dest.concat("/"); } if (resource.getRootPath().equals(dest)) { // move to target with same name is not allowed throw new CmsVfsException(org.opencms.file.Messages.get().container( org.opencms.file.Messages.ERR_MOVE_SAME_NAME_1, destination)); } if (dest.startsWith(resource.getRootPath())) { // move of folder inside itself is not allowed throw new CmsVfsException(org.opencms.file.Messages.get().container( org.opencms.file.Messages.ERR_MOVE_SAME_FOLDER_2, cms.getSitePath(resource), destination)); } // first validate the destination name dest = validateFoldername(dest); securityManager.moveResource(cms.getRequestContext(), resource, dest); }
/** * Undelete the resource.<p> * * @param dbc the current database context * @param resource the name of the resource to apply this operation to * * @throws CmsException if something goes wrong * * @see CmsObject#undeleteResource(String, boolean) * @see I_CmsResourceType#undelete(CmsObject, CmsSecurityManager, CmsResource, boolean) */ public void undelete(CmsDbContext dbc, CmsResource resource) throws CmsException { if (!resource.getState().isDeleted()) { throw new CmsVfsException(Messages.get().container( Messages.ERR_UNDELETE_FOR_RESOURCE_DELETED_1, dbc.removeSiteRoot(resource.getRootPath()))); } // set the state to changed resource.setState(CmsResourceState.STATE_CHANGED); // perform the changes updateState(dbc, resource, false); // clear the cache m_monitor.clearResourceCache(); // fire change event HashMap data = new HashMap(2); data.put(I_CmsEventListener.KEY_RESOURCE, resource); data.put(I_CmsEventListener.KEY_CHANGE, new Integer(CHANGED_RESOURCE)); OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_RESOURCE_MODIFIED, data)); }
keyValidationSet.add(property.getName()); } else { throw new CmsVfsException(Messages.get().container( Messages.ERR_VFS_INVALID_PROPERTY_LIST_1, property.getName()));
throw new CmsVfsException( Messages.get().container(Messages.ERR_IMPORT_FOLDER_2, importFolderName, importPath), e);