/** * Creates a new folder in the given target folder.<p> * * @param targetFolder the target folder * @param folderName the new folder to create in the target folder * @return the created folder * @throws Exception if somthing goes wrong */ public CmsResource createFolder(String targetFolder, String folderName) throws Exception { return m_cms.createResource(targetFolder + folderName, CmsResourceTypeFolder.RESOURCE_TYPE_ID); }
/** * @see org.opencms.file.wrapper.I_CmsResourceWrapper#createResource(org.opencms.file.CmsObject, java.lang.String, int, byte[], java.util.List) */ public CmsResource createResource(CmsObject cms, String resourcename, int type, byte[] content, List properties) throws CmsException, CmsIllegalArgumentException { if (m_isWrappedResource) { return cms.createResource(resourcename, type, content, properties); } return null; }
/** * @see org.opencms.file.wrapper.I_CmsResourceWrapper#createResource(org.opencms.file.CmsObject, java.lang.String, int, byte[], java.util.List) */ public CmsResource createResource( CmsObject cms, String resourcename, int type, byte[] content, List<CmsProperty> properties) throws CmsException, CmsIllegalArgumentException { if (m_isWrappedResource) { return cms.createResource(resourcename, type, content, properties); } return null; }
/** * Creates a new resource of the given resource type with * empty content and no properties.<p> * * @param resourcename the name of the resource to create (full current site relative path) * @param type the type of the resource to create * * @return the created resource * * @throws CmsException if something goes wrong * @throws CmsIllegalArgumentException if the given <code>resourcename</code> is null or of length 0 * * @see #createResource(String, int, byte[], List) */ public CmsResource createResource(String resourcename, int type) throws CmsException, CmsIllegalArgumentException { return createResource(resourcename, type, new byte[0], Collections.EMPTY_LIST); }
/** * Creates a new resource of the given resource type with * empty content and no properties.<p> * * @param resourcename the name of the resource to create (full current site relative path) * @param type the type of the resource to create * * @return the created resource * * @throws CmsException if something goes wrong * @throws CmsIllegalArgumentException if the given <code>resourcename</code> is null or of length 0 * * @see #createResource(String, int, byte[], List) */ public CmsResource createResource(String resourcename, I_CmsResourceType type) throws CmsException, CmsIllegalArgumentException { return createResource(resourcename, type, new byte[0], new ArrayList<CmsProperty>(0)); }
/** * Creates a new resource of the given resource type with * empty content and no properties.<p> * * @param resourcename the name of the resource to create (full current site relative path) * @param type the type of the resource to create * * @return the created resource * * @throws CmsException if something goes wrong * @throws CmsIllegalArgumentException if the given <code>resourcename</code> is null or of length 0 * * @see #createResource(String, int, byte[], List) * * @deprecated * Use {@link #createResource(String, I_CmsResourceType)} instead. * Resource types should always be referenced either by its type class (preferred) or by type name. * Use of int based resource type references will be discontinued in a future OpenCms release. */ @Deprecated public CmsResource createResource(String resourcename, int type) throws CmsException, CmsIllegalArgumentException { return createResource(resourcename, getResourceType(type), new byte[0], new ArrayList<CmsProperty>(0)); }
/** * Creates a new resource of the given resource type * with the provided content and properties.<p> * * @param resourcename the name of the resource to create (full current site relative path) * @param type the type of the resource to create * @param content the contents for the new resource * @param properties the properties for the new resource * * @return the created resource * * @throws CmsException if something goes wrong * @throws CmsIllegalArgumentException if the <code>resourcename</code> argument is null or of length 0 * * @deprecated * Use {@link #createResource(String, I_CmsResourceType, byte[], List)} instead. * Resource types should always be referenced either by its type class (preferred) or by type name. * Use of int based resource type references will be discontinued in a future OpenCms release. */ @Deprecated public CmsResource createResource(String resourcename, int type, byte[] content, List<CmsProperty> properties) throws CmsException, CmsIllegalArgumentException { return createResource(resourcename, getResourceType(type), content, properties); }
/** * Loads a file from the "real" file system to the VFS.<p> * * @param localfile the file upload * @param folder the folder in the VFS to place the file into * @param filename the name of the uploaded file in the VFS * @param type the type of the new file in the VFS * @return the createed file * @throws Exception if something goes wrong * @throws CmsIllegalArgumentException if the concatenation of String arguments * <code>folder</code> and <code>localfile</code> is of length 0 * */ public CmsResource uploadFile(String localfile, String folder, String filename, String type) throws Exception, CmsIllegalArgumentException { I_CmsResourceType t = OpenCms.getResourceManager().getResourceType(type); return m_cms.createResource(folder + filename, t, CmsFileUtil.readFile(new File(localfile)), null); }
/** * Creates all propertyvfsbundle files for the currently loaded translations. * The method is used to convert xmlvfsbundle files into propertyvfsbundle files. * * @throws CmsIllegalArgumentException thrown if resource creation fails. * @throws CmsLoaderException thrown if the propertyvfsbundle type can't be read from the resource manager. * @throws CmsException thrown if creation, type retrieval or locking fails. */ private void createPropertyVfsBundleFiles() throws CmsIllegalArgumentException, CmsLoaderException, CmsException { String bundleFileBasePath = m_sitepath + m_basename + "_"; for (Locale l : m_localizations.keySet()) { CmsResource res = m_cms.createResource( bundleFileBasePath + l.toString(), OpenCms.getResourceManager().getResourceType( CmsMessageBundleEditorTypes.BundleType.PROPERTY.toString())); m_bundleFiles.put(l, res); LockedFile file = LockedFile.lockResource(m_cms, res); file.setCreated(true); m_lockedBundleFiles.put(l, file); } }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#createResource(org.opencms.file.CmsObject, java.lang.String, int, byte[], java.util.List) */ @Override public CmsResource createResource(CmsObject cms, String resourcename, int type, byte[] content, List properties) throws CmsException, CmsIllegalArgumentException { if (checkTypeId(type)) { return cms.createResource( CmsResourceWrapperUtils.removeFileExtension(cms, resourcename, getExtension()), type, content, properties); } return null; }
/** * Creates the folder with the given name if it doesn't already exist, and returns it.<p> * * @param cms the current CMS context * * @return the created folder or the already existing folder * * @throws CmsException if something goes wrong */ public CmsResource createFolder(CmsObject cms) throws CmsException { if (m_folder != null) { return m_folder; } return cms.createResource( m_path, OpenCms.getResourceManager().getResourceType(CmsResourceTypeFolder.RESOURCE_TYPE_NAME).getTypeId()); }
/** * Loads a file from the "real" file system to the VFS.<p> * * @param localfile the file upload * @param folder the folder in the VFS to place the file into * @param filename the name of the uploaded file in the VFS * @param type the type of the new file in the VFS * @return the createed file * @throws Exception if something goes wrong * @throws CmsIllegalArgumentException if the concatenation of String arguments * <code>folder</code> and <code>localfile</code> is of length 0 * */ public CmsResource uploadFile(String localfile, String folder, String filename, String type) throws Exception, CmsIllegalArgumentException { int t = OpenCms.getResourceManager().getResourceType(type).getTypeId(); return m_cms.createResource(folder + filename, t, CmsFileUtil.readFile(new File(localfile)), null); }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#createResource(org.opencms.file.CmsObject, java.lang.String, int, byte[], java.util.List) */ @Override public CmsResource createResource( CmsObject cms, String resourcename, int type, byte[] content, List<CmsProperty> properties) throws CmsException, CmsIllegalArgumentException { if (checkTypeId(type)) { return cms.createResource( CmsResourceWrapperUtils.removeFileExtension(cms, resourcename, getExtension()), type, content, properties); } return null; }
/** * Creates a new folder in the given target folder.<p> * * @param targetFolder the target folder * @param folderName the new folder to create in the target folder * @return the created folder * @throws Exception if somthing goes wrong */ public CmsResource createFolder(String targetFolder, String folderName) throws Exception { if (m_cms.existsResource(targetFolder + folderName)) { m_shell.getOut().println( getMessages().key(Messages.GUI_SHELL_FOLDER_ALREADY_EXISTS_1, targetFolder + folderName)); return null; } return m_cms.createResource(targetFolder + folderName, CmsResourceTypeFolder.getStaticTypeId()); }
/** * Creates a descriptor for the bundle in the same folder where the bundle files are located. * @throws CmsException thrown if creation fails. */ private void createAndLockDescriptorFile() throws CmsException { String sitePath = m_sitepath + m_basename + CmsMessageBundleEditorTypes.Descriptor.POSTFIX; m_desc = m_cms.createResource( sitePath, OpenCms.getResourceManager().getResourceType(CmsMessageBundleEditorTypes.BundleType.DESCRIPTOR.toString())); m_descFile = LockedFile.lockResource(m_cms, m_desc); m_descFile.setCreated(true); }
/** * @see org.opencms.gwt.shared.rpc.I_CmsVfsService#createNewExternalLink(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ public void createNewExternalLink(String title, String link, String resourceName, String parentFolderPath) throws CmsRpcException { CmsObject cms = getCmsObject(); try { CmsProperty titleProp = new CmsProperty(CmsPropertyDefinition.PROPERTY_TITLE, title, null); @SuppressWarnings("deprecation") CmsResource resource = cms.createResource( CmsStringUtil.joinPaths(parentFolderPath, resourceName), CmsResourceTypePointer.getStaticTypeId(), new byte[0], Collections.singletonList(titleProp)); CmsFile file = cms.readFile(resource); file.setContents(link.getBytes(CmsLocaleManager.getResourceEncoding(cms, resource))); cms.writeFile(file); tryUnlock(resource); // update the offline search indices OpenCms.getSearchManager().updateOfflineIndexes(); } catch (Exception e) { error(e); } }
/** * Creates the content directory for this configuration node if possible.<p> * * @throws CmsException if something goes wrong */ protected void createContentDirectory() throws CmsException { if (!isModuleConfiguration()) { String contentFolder = getContentFolderPath(); if (!getCms().existsResource(contentFolder)) { getCms().createResource( contentFolder, OpenCms.getResourceManager().getResourceType(CmsResourceTypeFolder.getStaticTypeName())); } } }
/** * Creates a new edit resource.<p> * * @return the newly created resource * * @throws CmsUgcException if creating the resource fails */ public CmsResource createXmlContent() throws CmsUgcException { checkNotFinished(); checkEditResourceNotSet(); CmsUgcSessionSecurityUtil.checkCreateContent(m_cms, m_configuration); try { I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(m_configuration.getResourceType()); m_editResource = m_cms.createResource(getNewContentName(), type); return m_editResource; } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); throw new CmsUgcException(e, CmsUgcConstants.ErrorCode.errMisc, e.getLocalizedMessage()); } }
/** * Creates the resource using the specified resource name and the newresourcetype parameter.<p> * * @throws JspException if inclusion of error dialog fails */ public void actionCreateResource() throws JspException { try { // calculate the new resource Title property value String title = computeNewTitleProperty(); // create the full resource name String fullResourceName = computeFullResourceName(); // create the Title and Navigation properties if configured I_CmsResourceType resType = OpenCms.getResourceManager().getResourceType(getParamNewResourceType()); List<CmsProperty> properties = createResourceProperties(fullResourceName, resType.getTypeName(), title); // create the resource getCms().createResource(fullResourceName, resType.getTypeId(), null, properties); setParamResource(fullResourceName); setResourceCreated(true); } catch (Throwable e) { // error creating file, show error dialog includeErrorpage(this, e); } }
/** * Creates the resource using the specified resource name and the newresourcetype parameter.<p> * * @throws JspException if inclusion of error dialog fails */ public void actionCreateResource() throws JspException { try { // calculate the new resource Title property value String title = computeNewTitleProperty(); // create the full resource name String fullResourceName = computeFullResourceName(); // create the Title and Navigation properties if configured I_CmsResourceType resType = OpenCms.getResourceManager().getResourceType(getParamNewResourceType()); List properties = createResourceProperties(fullResourceName, resType.getTypeName(), title); // create the resource getCms().createResource(fullResourceName, resType.getTypeId(), null, properties); setParamResource(fullResourceName); setResourceCreated(true); } catch (Throwable e) { // error creating file, show error dialog includeErrorpage(this, e); } }