Package org.maqetta.server

Examples of org.maqetta.server.IVResource


            foundFiles = user.findFiles(pathStr, ignoreCase, workspaceOnly);
        }
        String ret = "[";
        String delem = " ";
        for (int i = 0; i < foundFiles.length; i++) {
        IVResource f = foundFiles[i];
          InputStream in = null;
          try {
              in = f.getInputStreem();
              String output = this.fromStream(in);
            JSONObject j = new JSONObject(output);
            j.append("path", f.getPath());
            ret = ret + delem + j.toString();
            delem = ", ";
        }
        catch(JSONException ex) {
        theLogger.logp(Level.SEVERE, GetThemes.class.getName(), "handleCommand", f.getPath() + " not valid json", ex);
        } finally {
        if (in != null)
          in.close();
        }
        }
View Full Code Here


        ArrayList<String> fileNames = new ArrayList<String>();
        try {
            // Parse the request
            List<FileItem> items = upload.parseRequest(request);
            Iterator<FileItem> iter = items.iterator();
            IVResource userDirectory = user.getResource(path);
            while (iter.hasNext()) {
                FileItem item = iter.next();

                if (!item.isFormField()) {
                    String fileName = item.getName();
                    InputStream is = new BufferedInputStream(item.getInputStream());;
                    OutputStream os = null;
                    byte[] buffer = new byte[8192];

                try {
                      if(explodeZip && ("application/zip".equals(item.getContentType()) || fileName.endsWith(".zip"))){
              ZipInputStream zis = new ZipInputStream(is);
              ZipEntry entry;
                int bytesIn;
              is = zis;
           
                  while ((entry = zis.getNextEntry()) != null) {
                    String zipFileName = entry.getName();

//                    theLogger.finest("Uploading zip: " + fileName + " entry: " + zipFileName);

                    if(!zipFileName.endsWith("/")) {
                      // Odd that create dir seems to do a recursive create, but file does not
                      userDirectory.create(new Path(zipFileName).removeLastSegments(1).toString()+"/");
 
                      IVResource uploaded = userDirectory.create(zipFileName);
                            os = uploaded.getOutputStreem();
                  while ((bytesIn = zis.read(buffer)) != -1) {
                    os.write(buffer, 0, bytesIn);
                  }
                  os.flush();
                  os.close();
                            uploaded.flushWorkingCopy();
                    }
                          fileNames.add(zipFileName);
              }
            } else {
              //FIXME: common with above code
                        IVResource uploaded = userDirectory.create(fileName);
                        os = uploaded.getOutputStreem();
              while (true) {
                int bytesRead = -1;
                bytesRead = is.read(buffer);
                if (bytesRead == -1) {
                  break;
                }
                os.write(buffer, 0, bytesRead);
              }
                        fileNames.add(fileName);
                        uploaded.flushWorkingCopy();
            }
          } finally {
                  is.close();
                  if (os != null) {
                      os.flush();
View Full Code Here

      url = scanSrcLibs(ipath, removecount, projectLibs);
      if (url != null) {
        return url;
      }
    }
    IVResource resource = user.getResource(ipath.toString());
    if (resource != null) {
      try {
        if (logger.isLoggable(Level.FINEST)) {
          logger.logp(Level.FINEST, getClass().getName(), "_getResource", "resource ["+path +"] loaded from project");
        }
        return resource.getURI().toURL();
      } catch (MalformedURLException e) {
        e.printStackTrace();
      } catch (URISyntaxException e) {
        e.printStackTrace();
      }
View Full Code Here

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

      String path = req.getParameter("path");
        IVResource file = user.getResource(path);
        if (file != null) {
          /* have to force garbage collection, or on windows the resource is never deleted */
            file.removeWorkingCopy();
        }
    }
View Full Code Here

      String src = req.getParameter("source");
        String des = req.getParameter("dest");
        boolean recurse = Boolean.parseBoolean(req.getParameter("recurse"));

        IVResource source = user.getResource(src);
        IVResource newResource = user.createResource(des, source.isDirectory());

        if (source.isDirectory()) {
            newResource.mkdir();
            VResourceUtils.copyDirectory(source, newResource, recurse);
        } else {
            VResourceUtils.copyFile(source, newResource);
        }
        this.responseString = "ok";
View Full Code Here

  public void rebuildWorkspace() {
    this.workspace = newWorkspaceRoot();
    IStorage[] userFiles = this.userDirectory.listFiles();
    for(int j=0;j<userFiles.length;j++){
      if(isConfig(userFiles[j].getName()) || !userFiles[j].isDirectory()) continue;
      IVResource workspace = this.workspace;
     
      IVResource firstFolder = new VStorageDirectory(userFiles[j], workspace, userFiles[j].getName());
      this.workspace.add(firstFolder);
    }
  }
View Full Code Here

 
  public IVResource createEclipseProject(String projectName) throws IOException {
    return createEclipseProject(projectName, "", "");
  }
  public IVResource createEclipseProject(String projectName, String projectToClone, String projectTemplateDirectoryName ) throws IOException {
    IVResource project = createProject(projectName, projectToClone, projectTemplateDirectoryName, "WebContent", true);
    /*
     * Load the initial user files extension point and copy the files to the projects root
     */

          
         Hashtable eclipseConfig = EclipseProjectUtil.getEclipseConfig(projectName);
         Iterator keys = eclipseConfig.keySet().iterator();
         while(keys.hasNext()){
            Object key = keys.next();
             String filePath = (String)key;
             String xml = (String)eclipseConfig.get(key);
             IPath resourcePath = new Path(project.getPath()).append(filePath);
             IVResource resource = this.createResource(resourcePath.toString(), false);
            
             VResourceUtils.setText(resource, xml);
            
          }
        /* modify the library settings with the WebContent folder */
 
View Full Code Here

  /* (non-Javadoc)
   * @see org.davinci.server.user.IUser#createProject(java.lang.String, java.lang.String, boolean)
   */
  public IVResource createProject(String projectName, String projectToClone, String projectTemplateName,
      String basePath, boolean initFiles) throws IOException {
    IVResource project = createResource(projectName + "/", true);
    /*
     * Load the initial user files extension point and copy the files to the projects root
     */
    try {
      if(!isValid(new File(project.getURI()).getAbsolutePath() + "/" + basePath )) return null;
    } catch (URISyntaxException e1) {
      // TODO Auto-generated catch block
      return null;
    }
    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 = null;
        try {
         
          file = new StorageFileSystem(project.getURI().getPath()+ "/" + basePath);
          if(!isValid(file.getAbsolutePath())) return null;
        } catch (URISyntaxException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
View Full Code Here

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

  /* (non-Javadoc)
   * @see org.davinci.server.user.IUser#getResource(java.lang.String)
   */
  public IVResource getResource(String path) {

      IVResource r1 = getUserFile(path);
        if (r1 != null) {
            return r1;
        }
        /* add links */
        /*
 
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.