コード例 #1
0
  /**
   * Creates a new repository file (with the supplied data) and applies the proper metadata to this
   * file.
   *
   * @param domainId the Domain id associated with this file
   * @param locale the locale associated with this file (or null for a domain file)
   * @param data the data to put in the file
   * @return the repository file created
   */
  protected RepositoryFile createUniqueFile(
      final String domainId, final String locale, final SimpleRepositoryFileData data) {
    // Generate a "unique" filename
    final String filename = UUID.randomUUID().toString();

    // Create the new file
    final RepositoryFile file =
        repository.createFile(
            getMetadataDir().getId(), new RepositoryFile.Builder(filename).build(), data, null);

    // Add metadata to the file
    final Map<String, Serializable> metadataMap = new HashMap<String, Serializable>();
    metadataMap.put(PROPERTY_NAME_DOMAIN_ID, domainId);
    if (StringUtils.isEmpty(locale)) {
      // This is a domain file
      metadataMap.put(PROPERTY_NAME_TYPE, TYPE_DOMAIN);
    } else {
      // This is a locale property file
      metadataMap.put(PROPERTY_NAME_TYPE, TYPE_LOCALE);
      metadataMap.put(PROPERTY_NAME_LOCALE, locale);
    }

    // Update the metadata
    repository.setFileMetadata(file.getId(), metadataMap);
    return file;
  }
コード例 #2
0
 /**
  * Creates a new file in the repository
  *
  * @param bundle
  * @param destinationPath
  * @param bundlePath
  * @param ext
  * @param data
  * @param comment
  */
 protected RepositoryFile createFile(
     final ImportSource.IRepositoryFileBundle bundle,
     final String destinationPath,
     final boolean hidden,
     final IRepositoryFileData data,
     final String comment) {
   final RepositoryFile file =
       new RepositoryFile.Builder(bundle.getFile())
           .hidden(hidden)
           .title(RepositoryFile.DEFAULT_LOCALE, getTitle(bundle.getFile().getName()))
           .versioned(true)
           .build();
   final Serializable parentId = getParentId(destinationPath);
   final RepositoryFileAcl acl = bundle.getAcl();
   if (null == acl) {
     return repository.createFile(parentId, file, data, comment);
   } else {
     return repository.createFile(parentId, file, data, acl, comment);
   }
 }
 public RepositoryFileDto createFile(
     String parentFolderId,
     RepositoryFileDto file,
     NodeRepositoryFileDataDto data,
     String versionMessage) {
   validateEtcWriteAccess(parentFolderId);
   return repositoryFileAdapter.marshal(
       repo.createFile(
           parentFolderId,
           repositoryFileAdapter.unmarshal(file),
           nodeRepositoryFileDataAdapter.unmarshal(data),
           versionMessage));
 }