Package org.maqetta.server

Examples of org.maqetta.server.IVResource


      this.store=storage;
  }

  public IVResource create(String path) throws IOException {
    IPath ps = new Path(path);
    IVResource parent = this;
   
    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);
       
      }
View Full Code Here


            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));
View Full Code Here

      path = "";
    }
   
    /* list all files given a path, dont recurse. */
    /* add users actual workspace files */
    IVResource r1 = getResource(path);
    if (r1 != null) {
      if (r1.isDirectory()) {
        found = r1.listFiles();
      }
    }
    r1 = getLibFile(path);
        if (r1 != null) {
            if (r1.isDirectory()) {
                IVResource[] list = r1.listFiles();
                found = VResourceUtils.merge(found, list);
            }
        }
     return found;
   }
View Full Code Here

  public IVResource createProject(String projectName, String projectToClone, String projectTemplateDirectoryName,
      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);
      }

View Full Code Here

    }
    */
//    IStorage directory = this.userDirectory.newInstance(path);
    /* make sure the new resoruce is within the user directory */
   
    IVResource userFile = this.workspace.create(path);
    if(isFolder){
      userFile.mkdir();
    }else{
      userFile.createNewInstance();
    }
    return userFile;
  }
View Full Code Here

      }
      boolean isWorkingCopy = (path.indexOf(IDavinciServerConstants.WORKING_COPY_EXTENSION) > -1);
      if ( isWorkingCopy ) {
        path = path.substring(0, path.indexOf(IDavinciServerConstants.WORKING_COPY_EXTENSION));
      }
      IVResource file = user.getResource(path);
      if (file == null) {
        theLogger.warning("DavinciPageServlet:doPut user.getResource("+path+") returned Null for user: " + user.getUserID());
        resp.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;
      }
      /* user is trying to save over a library path */
      if ( file.isVirtual() ) {
        file = user.createResource(path, file.isDirectory());
        if(file.isDirectory())
          file.mkdir();
        else
           file.createNewInstance();
      }
      if ( file.exists() ) {
        OutputStream os = file.getOutputStreem();
        transferStreams(req.getInputStream(), os, false);
        if ( !isWorkingCopy ) {
          // flush the working copy
          file.flushWorkingCopy();
        }
 
      } else {
        resp.sendError(HttpServletResponse.SC_NOT_FOUND);
      }
View Full Code Here

        resp.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;
      }
    }

    IVResource userFile = user.getResource(path.toString());

    if ( userFile != null && !userFile.exists() ) {
      if ( path.getFileExtension() == null ) {
        userFile = user.getResource(path.addFileExtension("html").toString());
      }
      if ( !userFile.exists() ) {
        theLogger.warning("user file not found: " + path);
        resp.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;
      }
    } else {
View Full Code Here

    }
  }

  protected boolean handleLibraryRequest(HttpServletRequest req, HttpServletResponse resp, IPath path, IUser user)
      throws ServletException, IOException {
    IVResource libraryURL = user.getResource(path.toString());
    if (libraryURL != null) {
      CacheHeaders caching = libraryURL.readOnly() ? CacheHeaders.CACHE : CacheHeaders.NO_CACHE;
      writePage(req, resp, libraryURL, caching);
      return true;
    }
    return false;
  }
View Full Code Here

    public void handleCommand(HttpServletRequest req, HttpServletResponse resp, IUser user) throws IOException {
      // SECURITY, VALIDATION
      //   'path': checked by User.getResouce()

        String path = req.getParameter("path");
        IVResource file = user.getResource(path);
        if (file.isDirectory()) {
            deleteDir(file);
        } else {
            if (file.delete()) {
                responseString = "OK";
            } else {
                errorString = "Problem deleting file: " + file.getPath();
            }
        }
        user.rebuildWorkspace();
    }
View Full Code Here

      //   'newName': checked by User.createResource()

        String oldName = req.getParameter("oldName");
        String newName = req.getParameter("newName");

        IVResource source = user.getResource(oldName);
        IVResource newResource = user.createResource(newName, source.isDirectory());
        if (source.isDirectory()) {
            newResource.mkdir();
            VResourceUtils.copyDirectory(source, newResource, true);
        } else {
            VResourceUtils.copyFile(source, newResource);
        }
        source.delete();
View Full Code Here

TOP

Related Classes of org.maqetta.server.IVResource

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.