Package org.maqetta.server

Examples of org.maqetta.server.IStorage


    }
  }

  public boolean mkdirs() throws IOException {
    try {
      IStorage parent = this.getParentFile();
      if (parent != null && !parent.exists()) {
        parent.mkdirs();
      }
      // if(this.store.fetchInfo().isDirectory())
      this.store.mkdir(EFS.NONE, null);
    } catch (CoreException e) {
      throw new IOException(e);
View Full Code Here


     
      if(original.isDirectory() ){
        // no working copy for directories (java.io.file handled this before
        return original;
      }
      IStorage parent = original.getParentFile();
      IStorage workingCopy;
      if(parent!=null)
        workingCopy = original.newInstance(parent, original.getName() + IDavinciServerConstants.WORKING_COPY_EXTENSION);
      else
        workingCopy = original.newInstance(original.getName() + IDavinciServerConstants.WORKING_COPY_EXTENSION);
      return workingCopy;
View Full Code Here

   
    for(int i=0;i<ps.segmentCount();i++){
      String segment = ps.segment(i);
      IVResource f= parent.get(segment);
      if(f==null ){
        IStorage file = this.store.create(path);
        f = new VOrionResource(file, parent, segment);
       
       
      }else if(f.isVirtual()){
       
        IStorage file = this.store.create(path);
        if(f.isDirectory())
          file.mkdirs();
        f = new VOrionResource(file, parent, segment);
        parent.add(f);
       
      }
      parent = f;
View Full Code Here

      // Trying to create a new instance of a project which doesn't currently exist.  However,
      // since all projects are first created through direct calls to `create()`, a null
      // value here most likely means that we have an invalid URL.

      // Return a dummy storage object which will always return `false` for `exists()`.
      return new IStorage() {
        public boolean exists() {
          return false;
        }
        public String getAbsolutePath() {
          return null;
View Full Code Here

  public boolean exists() {
    return true;
  }

  public IStorage createProject(String name){
    IStorage existing = this.get(name);
    if (existing != null) {
      return existing;
    }
   
    String id = WebProject.nextProjectId();
View Full Code Here

      String basePath, boolean initFiles) throws IOException {
   
    if(isProject(projectName))  return getResource(projectName);
   
    IVResource project = createOrionProject(projectName);
    IStorage userDir = getUserDirectory();
    IStorage projectDir = userDir.newInstance(projectName);
   
    /*
     * Load the initial user files extension point and copy the files to the projects root
     */
   
    if(basePath!=null && !basePath.equals("")){
      project.create(basePath + "/");
    }

    if(initFiles){
      List<?> extensions = ServerManager.getServerManager().getExtensions(IDavinciServerConstants.EXTENSION_POINT_INITIAL_USER_FILES, IDavinciServerConstants.EP_TAG_INITIAL_USER_FILE);
          for (Iterator<?> iterator = extensions.iterator(); iterator.hasNext();) {
              IConfigurationElement libraryElement = (IConfigurationElement) iterator.next();
              String path = libraryElement.getAttribute(IDavinciServerConstants.EP_ATTR_INITIAL_USER_FILE_PATH);
              String name = libraryElement.getDeclaringExtension().getContributor().getName();
              Bundle bundle = Activator.getActivator().getOtherBundle(name);
              IStorage file =this.getStorage().newInstance(project.getPath());
     
          if(basePath!=null && !basePath.equals(""))
            file = file.newInstance(project.getPath()+ "/" + basePath);
       
       
        VResourceUtils.copyDirectory(file, path, bundle);
      }

      IStorage basePathDir;
      if(basePath!=null && !basePath.equals("")){
        basePathDir = projectDir.newInstance(projectDir, basePath);
      }else{
        basePathDir = projectDir;
      }

      if(projectTemplateDirectoryName!=null && !projectTemplateDirectoryName.equals("")){
        IProjectTemplatesManager projectTemplatesManager = ServerManager.getServerManager().getProjectTemplatesManager();
        IStorage projectTemplatesDirectory = projectTemplatesManager.getProjectTemplatesDirectory();
        IStorage templateDir = projectTemplatesDirectory.newInstance(projectTemplatesDirectory, projectTemplateDirectoryName);
        if(templateDir.exists()) {
          IStorage[] files = templateDir.listFiles();
          for (int i = 0; i < files.length; i++) {
            IStorage file = files[i];
            if(file.isDirectory() && file.getName().equals(IDavinciServerConstants.DOT_SETTINGS)){
              IStorage destinationDir = projectDir.newInstance(projectDir, IDavinciServerConstants.DOT_SETTINGS);
              destinationDir.mkdirs();
              IStorage[] dotSettingsFiles = file.listFiles();
              for(int j = 0; j < dotSettingsFiles.length; j++){
                IStorage settingsFile = dotSettingsFiles[j];
                IStorage destination = file.newInstance(file, settingsFile.getName());
                if(settingsFile.getName().equals(IDavinciServerConstants.LIBS_SETTINGS) &&
                    basePath!=null && !basePath.equals("")){
                  // If creating an Eclipse project, add "WebContent/" into library paths in libs.settings before writing out to the template.
                  copyFileAddWebContent(settingsFile, destination);
                }else{
                  copyFile(settingsFile, destination);
                }
              }
            }else if (file.isFile()) {
              IStorage destination = basePathDir.newInstance(basePathDir, file.getName());
              copyFile(file, destination);
            } else if (file.isDirectory()) {
              IStorage destination = basePathDir.newInstance(basePathDir, file.getName());
              copyDirectory(file, destination);
            }
          }
        }
      }

      if(projectToClone!=null && !projectToClone.equals("")){
        IStorage projectToCloneDir = userDir.newInstance(projectToClone);
        IStorage webContentDir = projectToCloneDir.newInstance(projectToCloneDir, IDavinciServerConstants.WEBCONTENT);
        Boolean oldProjectIsEclipse = webContentDir.exists();
        Boolean newProjectIsEclipse = (basePath!=null && !basePath.equals(""));
        if(projectToCloneDir.exists()) {
          IStorage[] files = projectToCloneDir.listFiles();
          for (int i = 0; i < files.length; i++) {
            IStorage file = files[i];
            String filename = file.getPath();
            IPath path = new Path(filename);
            if(file.isFile() && path.segmentCount() > 0 && path.segment(1).equals(IDavinciServerConstants.DOT_PROJECT)){
              // Eclipse projects have a .project file. Don't copy the cloned project's .project file
              // into the new project - if the new project is an Eclipse project, other code adds the .project file.
              continue;
            }else if(file.isDirectory() && file.getName().equals(IDavinciServerConstants.DOT_SETTINGS)){
              IStorage destinationDir = projectDir.newInstance(projectDir, IDavinciServerConstants.DOT_SETTINGS);
              destinationDir.mkdirs();
              IStorage[] dotSettingsFiles = file.listFiles();
              for(int j = 0; j < dotSettingsFiles.length; j++){
                IStorage settingsFile = dotSettingsFiles[j];
                if(settingsFile.getName().equals(IDavinciServerConstants.LIBS_SETTINGS)){
                  IStorage destination = destinationDir.newInstance(destinationDir, settingsFile.getName());
                  if(!oldProjectIsEclipse && newProjectIsEclipse){
                    copyFileAddWebContent(settingsFile, destination);
                  }else if(oldProjectIsEclipse && !newProjectIsEclipse){
                    copyFileStripWebContent(settingsFile, destination);
                  }else{
                    copyFile(settingsFile, destination);
                  }
                }
              }
            }else if(file.isDirectory() && path.segmentCount() > 1 && path.segment(1).equals(IDavinciServerConstants.WEBCONTENT)){
              // Copy the contents of WebContent/* into the base folder for the new project
              copyDirectory(file, basePathDir);
            }else if (file.isFile()) {
              IStorage destination = basePathDir.newInstance(basePathDir, file.getName());
              copyFile(file, destination);
            } else if (file.isDirectory()) {
              IStorage destination = basePathDir.newInstance(basePathDir, file.getName());
              copyDirectory(file, destination);
            }
          }
        }
      }
View Full Code Here

        /*
         * security check, dont want to return a resource BELOW the workspace
         * root
         */
        IStorage parentStorage = this.userDirectory.newInstance(a.toString());
        if (!parentStorage.exists()) {
            IPath a2 = new Path(this.userDirectory.getAbsolutePath()).append(path + IDavinciServerConstants.WORKING_COPY_EXTENSION);
            IStorage workingCopy = this.userDirectory.newInstance(a2.toString());
            if (!workingCopy.exists()) {
                return null;
            }
        }

        IVResource parent = this.workspace;
        IPath halfPath = new Path("");
        for (int i = 1, len = a.segmentCount(); i < len; i++) {
          halfPath = halfPath.append(a.segment(i));
          IStorage f = this.userDirectory.newInstance(halfPath.toString());
            parent = new VOrionResource(f, parent,a.segment(i));
        }
        /*
        if(parent==this.workspace)
            parent = new VFile(this.userDirectory, this.workspace);
View Full Code Here

  public ReviewManager() {
    baseDirectory = ServerManager.getServerManager().getBaseDirectory();
  }

  public void saveDraft(IDesignerUser user, Version version) throws IOException {
    IStorage commentingDir = user.getCommentingDirectory();
    if (!commentingDir.exists()) {
      commentingDir.mkdir();
      (commentingDir.newInstance(commentingDir, "snapshot")).mkdir();
    }
    saveVersionFile(user);
  }
View Full Code Here

    }
    saveVersionFile(user);
  }

  public void publish(IDesignerUser user, Version version) throws IOException {
    IStorage commentingDir = user.getCommentingDirectory();
    if (!commentingDir.exists()) {
      commentingDir.mkdir();
      (commentingDir.newInstance(commentingDir, "snapshot")).mkdir();
    }

    initVersionDir(user, version.getTime());
    saveVersionFile(user);
   
View Full Code Here

      this.saveReviewerVersionFile(reviewer);
    }
  }
 
  private void saveReviewerVersionFile(Reviewer reviewer) throws IOException {
    IStorage versionFile = getReviewerVersionFile(reviewer);
    ReviewerVersionFile file = new ReviewerVersionFile();
    file.save(versionFile, reviewer);
  }
View Full Code Here

TOP

Related Classes of org.maqetta.server.IStorage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.