/** * @param implementation */ public DeploymentWorkspace(BPELImplementation implementation) { super(); this.implementation = implementation; this.workingDir = createWorkingDirectory(); }
public boolean delete() { return deleteFiles(workingDir); }
/** * Gets the directory containing the BPEL process * @return */ static File getDirectory(String location) { File file = getContainer(location); if (file == null) { return null; } File theDir = file.getParentFile(); return theDir; } // end getDirectory
public File getCBPFile() throws IOException { String name = getBPELFile().getName(); int index = name.lastIndexOf('.'); if (index != -1) { name = name.substring(0, index); } return new File(workingDir, name + ".cbp"); }
private File createWorkingDirectory() { String tmpDir = getSystemProperty("java.io.tmpdir"); File root = new File(tmpDir); // Add user name as the prefix. For multiple users on the same Lunix, // there will be permission issue if one user creates the .tuscany folder // first under /tmp with no write permission for others. String userName = getSystemProperty("user.name"); if (userName != null) { root = new File(root, userName); } root = new File(root, ".tuscany/bpel/" + UUID.randomUUID().toString()); if (logger.isLoggable(Level.FINE)) { logger.fine("BPEL working directory: " + root); } return root; }
/** * Gets the File containing the BPEL process definition * @return - the File object containing the BPEL process */ private static File getContainer(String location) { try { File theProcess = null; URI locationURI = createURI(location); String protocol = locationURI.getScheme(); if ("file".equals(protocol)) { theProcess = new File(locationURI); } else if ("jar".equals(protocol) || "wsjar".equals(protocol) || "zip".equals(protocol)) { String uri = locationURI.toString(); // jar contribution uri = uri.substring(protocol.length() + 1, uri.lastIndexOf("!/")); locationURI = createURI(uri); if ("file".equals(locationURI.getScheme())) { theProcess = new File(locationURI); } } return theProcess; } catch (Exception e) { logger.log(Level.SEVERE, "Exception converting BPEL file URL to an URI: " + location, e); } // end try return null; } // end getBPELFile
public synchronized File getBPELFile() throws IOException { if (bpelFile != null) { String location = implementation.getProcessDefinition().getLocation(); String fileName = implementation.getProcessDefinition().getURI(); File file = new File(workingDir, fileName); if (file.isFile()) { bpelFile = file; return file; } URL url = new URL(location); this.bpelFile = copy(url, workingDir, fileName); } return bpelFile; }
/** * @param implementation */ public DeploymentWorkspace(BPELImplementation implementation, File workingDir) { super(); this.implementation = implementation; this.workingDir = workingDir; if (this.workingDir == null) { this.workingDir = createWorkingDirectory(); } }
private static boolean deleteFiles(File file) { boolean result = true; if (file.isFile()) { if (!file.delete()) { result = false; } } else if (file.isDirectory()) { for (File f : file.listFiles()) { if (!deleteFiles(f)) { result = false; } } if (!file.delete()) { result = false; } } return result; }