Package org.exist.util.io

Examples of org.exist.util.io.Resource


    private static final void createLocalDir(Resource aNewDir, Resource[] localFiles, String[] fileContents){
        if (!aNewDir.mkdirs()) {
            error("failed to create a new directory '" + aNewDir.getAbsolutePath() + "'.", null);
        }
        for(int i=0; i < localFiles.length; i++){
          Resource aNewFile = localFiles[i];
            try {
              if (!aNewFile.createNewFile()) {
                  error("failed to create a new file '"
                          + aNewFile.getAbsolutePath() + "'.", null);
              }
          } catch (IOException ioe) {
              aNewFile.delete();
              error("error while creating a new file '"
                      + aNewFile.getAbsolutePath() + "'", ioe);
          }
 
          String contents = null;
          if(i > fileContents.length-1){
              continue;
          }
            contents = fileContents[i];
         
          /*
           * writing a text into the file
           */
          OutputStream fos = null;
          try {
            fos = aNewFile.getOutputStream();
              fos.write(contents.getBytes());
          } catch (FileNotFoundException fnfe) {
              error("the file '" + aNewFile.getAbsolutePath() + "' is not found", fnfe);
          } catch (IOException ioe) {
              error("error while writing into the file '"
                      + aNewFile.getAbsolutePath() + "'", ioe);
          } finally {
              if (fos != null) {
                  try {
                      fos.close();
                  } catch (IOException ioe) {
View Full Code Here


      String uri = params[0];
      String destPath = params[1];

      WorkingCopy wc = new WorkingCopy("", "");

        Resource wcDir = new Resource(collection.append(destPath));
        if (wcDir.exists()) {
          throw new CommandException(
            "the destination directory '" + wcDir.getAbsolutePath() + "' already exists!");
        }
        wcDir.mkdirs();
       
      try {
        out().println( wc.checkout(SVNURL.parseURIEncoded(uri), SVNRevision.HEAD, wcDir, true) );
    } catch (SVNException svne) {
      throw new CommandException(
View Full Code Here

      WorkingCopy wc = new WorkingCopy("", "");
     
      String destPath = params[0];
     
        Resource wcDir = new Resource(collection.append(destPath));

      try {
      wc.addEntry(wcDir);
    } catch (SVNException e) {
      throw new CommandException(e);
View Full Code Here

  public void process(XmldbURI collection, String[] params) throws CommandException {
        String user = params[0];
        String password = params[1];
        String comment = params[2];
       
        Resource wcDir = new Resource(collection);

        try {
          WorkingCopy wc = new WorkingCopy(user, password);

          out().println( wc.commit(wcDir, false, comment) );
View Full Code Here

  public Update() {
    names = new String[] {"update"};
  }
 
  public void process(XmldbURI collection, String[] params) throws CommandException {
        Resource wcDir = new Resource(collection);

        try {
          WorkingCopy wc = new WorkingCopy("", "");

          out().println( wc.update(wcDir, SVNRevision.HEAD, true) );
View Full Code Here

      SVNRepositoryFactoryImpl.setup();
    SVNClientManager manager = SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(false), userName, password);
    SVNStatusClient statusClient = manager.getStatusClient();
//    SVNWCClient wcClient = manager.getWCClient();
    try {
      statusClient.doStatus(new Resource(collection), SVNRevision.HEAD, SVNDepth.getInfinityOrFilesDepth(true), true, true, false, false,  new AddStatusHandler(), null);
    } catch (SVNException e) {
      e.printStackTrace();
      throw new CommandException(e);
    }
  }
View Full Code Here

     */
    public Date getWorkingPropertiesDate() {
        if (myLocalPropertiesDate == null) {
            File propFile = null;
            if (getFile() != null && getKind() == SVNNodeKind.DIR) {
                propFile = new Resource(getFile().getAbsoluteFile().getParentFile(), SVNFileUtil.getAdminDirectoryName());
                propFile = new Resource(propFile, "dir-props");
            } else if (getFile() != null && getKind() == SVNNodeKind.FILE) {
                propFile = new Resource(getFile().getAbsoluteFile().getParentFile(), SVNFileUtil.getAdminDirectoryName());
                propFile = new Resource(propFile, "props/" + getFile().getName() + ".svn-work");
            }
            myLocalPropertiesDate = propFile != null ? new Date(propFile.lastModified()) : new Date(0);
        }
        return myLocalPropertiesDate;
    }
View Full Code Here

      WorkingCopy wc = new WorkingCopy(user, password);
     
      long update = -1;
     
      try {
        update = wc.update(new Resource(uri), SVNRevision.HEAD, true);
      } catch (SVNException e) {
            throw new XPathException(this, e.getMessage(), e);
    }
   
      return new IntegerValue(update);
View Full Code Here

        }
       
        if (SVNWCManager.ensureAdminAreaExists(childDir, myCurrentDirectory.URL, rootURL, null,
                myTargetRevision, myCurrentDirectory.myAmbientDepth)) {
            // hack : remove created lock file.
            SVNFileUtil.deleteFile(new Resource(childDir, SVNFileUtil.getAdminDirectoryName() + "/lock"));
        }
        SVNAdminArea childArea = myWCAccess.open(childDir, true, 0);
        myWCAccess.registerCleanupHandler(childArea, myCurrentDirectory);
        if (!myCurrentDirectory.isAddExisted) {
            SVNEvent event = SVNEventFactory.createSVNEvent(parentArea.getFile(entry.getName()),
View Full Code Here

        if (dstEntry.getRepositoryRoot() == null || dstEntry.getURL() == null) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_COPYFROM_PATH_NOT_FOUND,
                    "Destination directory of add-with-history is missing a URL");
            SVNErrorManager.error(err, SVNLogType.WC);
        }
        dstDir = new Resource(SVNPathUtil.validateFilePath(dstDir.getAbsolutePath())).getAbsoluteFile();
        String dstReposPath = SVNPathUtil.getPathAsChild(dstEntry.getRepositoryRootURL().toDecodedString(),
                dstEntry.getSVNURL().toDecodedString());
        if (dstReposPath == null) {
            if (dstEntry.getURL().equals(dstEntry.getRepositoryRoot())) {
                dstReposPath = "";
            } else {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_COPYFROM_PATH_NOT_FOUND,
                        "Destination URLs are broken");
                SVNErrorManager.error(err, SVNLogType.WC);
            }
        }
       
        dstReposPath = "/" + dstReposPath;
        dstReposPath = SVNPathUtil.canonicalizePath(dstReposPath);
        String copyFromParent = SVNPathUtil.removeTail(copyFromPath);
        String ancestorPath = SVNPathUtil.getCommonPathAncestor(dstReposPath, copyFromParent);
        if ("".equals(ancestorPath)) {
            return null;
        }
       
        int levelsUP = SVNPathUtil.getSegmentsCount(dstReposPath) - SVNPathUtil.getSegmentsCount(ancestorPath);
        File currentWD = dstDir;
        for (int i = 0; i < levelsUP && currentWD != null; i++) {
            currentWD = currentWD.getParentFile();
        }
        if (currentWD == null) {
            return null;
        }
        SVNFileType kind = SVNFileType.getType(currentWD);
        if (kind != SVNFileType.DIRECTORY) {
            return null;
        }
       
        SVNWCAccess ancestorAccess = SVNWCAccess.newInstance(null);
        SVNAdminArea ancestorArea = null;
        try {
            ancestorArea = ancestorAccess.open(currentWD, false, 0);
        } catch (SVNException svne) {
            if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.WC_NOT_DIRECTORY) {
                ancestorAccess.close();
                return null;
            }
            throw svne;
        }
       
        SVNEntry ancestorEntry = ancestorArea.getEntry(ancestorArea.getThisDirName(), false);
        if (dstEntry.getUUID() != null && ancestorEntry.getUUID() != null &&
                !dstEntry.getUUID().equals(ancestorEntry.getUUID())) {
            ancestorAccess.close();
            return null;
        }
       
        SVNURL ancestorURL = dstEntry.getRepositoryRootURL().appendPath(ancestorPath, false);
        if (!ancestorURL.equals(ancestorEntry.getSVNURL())) {
            ancestorAccess.close();
            return null;
        }
       
        String extraComponents = SVNPathUtil.getPathAsChild(ancestorPath, copyFromPath);
        currentWD = new Resource(currentWD, extraComponents);
        File currentWDParent = currentWD.getParentFile();
       
        kind = SVNFileType.getType(currentWD);
        if (kind != SVNFileType.FILE) {
            ancestorAccess.close();
View Full Code Here

TOP

Related Classes of org.exist.util.io.Resource

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.