Example usage for org.apache.commons.vfs2 FileObject exists

List of usage examples for org.apache.commons.vfs2 FileObject exists

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 FileObject exists.

Prototype

boolean exists() throws FileSystemException;

Source Link

Document

Determines if this file exists.

Usage

From source file:de.innovationgate.wgpublisher.services.WGACoreServicesImpl.java

public void deleteFSDesignResource(RemoteSession session, String path) throws WGAServiceException {
    if (!isAdminServiceEnabled()) {
        throw new WGAServiceException("Administrative services are disabled");
    }//from w  w w.j  a  v a 2s  .c om

    if (!isAdminSession(session)) {
        throw new WGAServiceException("You need an administrative login to access this service.");
    }

    WGADesignSource source = _core.getDesignManager().getDesignSources()
            .get(WGAConfiguration.UID_DESIGNSOURCE_FILESYSTEM);
    if (source instanceof FileSystemDesignSource) {
        FileSystemDesignSource fsSource = (FileSystemDesignSource) source;
        try {
            fsSource.getDir().refresh();
            FileObject resource = fsSource.getDir().resolveFile(path);

            String basePath = fsSource.getDir().getURL().getPath();
            String resourcePath = resource.getURL().getPath();
            if (!resourcePath.startsWith(basePath)) {
                throw new WGAServiceException(
                        new IllegalArgumentException("Illegal design resource path '" + path + "'."));
            }

            if (resource.exists()) {
                resource.delete(new FileSelector() {

                    public boolean includeFile(FileSelectInfo fileInfo) throws Exception {
                        return true;
                    }

                    public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception {
                        return true;
                    }

                });
                clearDesignFileCache(fsSource, fsSource.getDir().getName().getRelativeName(resource.getName()));
            }
        } catch (FileSystemException e) {
            throw new WGAServiceException("Deleting FSDesignResource '" + path + "' failed.", e);
        }
    }
}

From source file:de.innovationgate.wgpublisher.services.WGACoreServicesImpl.java

public DataSource retrieveFSDesignResourceContent(RemoteSession session, FSDesignResourceState state)
        throws WGAServiceException {
    if (!isAdminServiceEnabled()) {
        throw new WGAServiceException("Administrative services are disabled");
    }//w  ww .  j  a va2s.c  o m

    if (!isAdminSession(session)) {
        throw new WGAServiceException("You need an administrative login to access this service.");
    }

    WGADesignSource source = _core.getDesignManager().getDesignSources()
            .get(WGAConfiguration.UID_DESIGNSOURCE_FILESYSTEM);
    if (source instanceof FileSystemDesignSource) {
        FileSystemDesignSource fsSource = (FileSystemDesignSource) source;
        try {
            fsSource.getDir().refresh();
            FileObject resource = fsSource.getDir().resolveFile(state.getPath());

            String basePath = fsSource.getDir().getURL().getPath();
            String resourcePath = resource.getURL().getPath();
            if (!resourcePath.startsWith(basePath)) {
                throw new WGAServiceException(new IllegalArgumentException(
                        "Illegal design resource path '" + state.getPath() + "'."));
            }

            if (resource.exists()) {
                if (resource.getType().equals(FileType.FOLDER)) {
                    throw new WGAServiceException(
                            new IllegalArgumentException("Cannot retrieve content of a folder."));
                } else {
                    return new URLDataSource(resource.getURL());
                }
            }
        } catch (FileSystemException e) {
            throw new WGAServiceException(
                    "Retrieving content of FSDesignResource '" + state.getPath() + "' failed.", e);
        }
    }
    return null;
}

From source file:de.innovationgate.wgpublisher.design.fs.FileSystemDesignManager.java

private ModuleFile resolveModuleFile(FileObject folder, String name, String category, int type)
        throws FileSystemException {

    if (folder == null || !folder.exists() || !folder.getType().equals(FileType.FOLDER)) {
        return null;
    }// w w  w.ja  v  a  2s  . c  o m

    String prefix;
    String baseName;
    String fullName;
    String suffix = getFileStandardSuffix(type, category);
    int lastColon = name.lastIndexOf(":");
    if (lastColon != -1) {
        prefix = name.substring(0, lastColon);
        baseName = name.substring(lastColon + 1);
        fullName = baseName + suffix;
    } else {
        prefix = "";
        baseName = name;
        fullName = name + suffix;
    }

    // Find correct folder
    if (!prefix.equals("")) {
        List<String> path = WGUtils.deserializeCollection(prefix, ":");
        Iterator<String> elems = path.iterator();
        while (elems.hasNext()) {
            String elem = (String) elems.next();
            FileObject matchingChild = findMatchingChild(folder, elem, Collections.singleton(""), true);

            // Use matching child as next folder
            if (matchingChild != null && matchingChild.getType().equals(FileType.FOLDER)) {
                folder = matchingChild;
            }

            // Exit if we did not find a matching folder
            else {
                return null;
            }

        }
    }

    // Find the valid suffixes for the type: Standard plus registered conversions
    Set<String> suffixes = new HashSet<String>();
    suffixes.add(getFileStandardSuffix(type, category));
    for (ModuleDefinition def : _core.getModuleRegistry()
            .getModulesForType(DesignResourceConversionModuleType.class).values()) {
        DesignResourceConversionProperties props = (DesignResourceConversionProperties) def.getProperties();
        if (props.getDesignType() == type
                && (props.getCodeType() == null || props.getCodeType().equals(category))) {
            for (String sfx : props.getSuffixes()) {
                suffixes.add("." + sfx);
            }
        }
    }

    // Find the file
    FileObject file = findMatchingChild(folder, baseName, suffixes, false);
    if (file != null) {
        return new ModuleFile(file, prefix, category, type);
    } else {
        return null;
    }

}

From source file:de.innovationgate.wgpublisher.design.fs.FileSystemDesignManager.java

protected FileObject initialDeployScriptModule(WGCSSJSModule script) throws IOException, InstantiationException,
        IllegalAccessException, WGAPIException, WGDesignSyncException {

    if (script.isMetadataModule()) {
        return null;
    }//from   w w w  .  jav  a2  s.  c o  m

    ScriptInformation info = DesignDirectory.getScriptInformation(script.getCodeType());
    if (info == null) {
        _log.warn("Cannot deploy unknown script code type: " + script.getCodeType());
        return null;
    }

    // Get script type folder
    FileObject scriptTypeFolder = getScriptTypeFolder(info.getFolder());

    // Eventually create intermediate directories
    List<String> path = WGUtils.deserializeCollection(script.getName(), ":", true);
    String localName = (String) path.get(path.size() - 1);
    FileObject currentDir = scriptTypeFolder;
    for (int i = 0; i < path.size() - 1; i++) {
        currentDir = currentDir.resolveFile((String) path.get(i));
        if (!currentDir.exists()) {
            _log.info("Creating script category directory" + getRelativePath(currentDir));
            try {
                currentDir.createFolder();
            } catch (FileSystemException e) {
                throw new WGInitialDeployException(
                        "Could not create script category folder '" + getRelativePath(currentDir) + "'", e);
            }
        } else if (!currentDir.getType().equals(FileType.FOLDER)) {
            throw new WGInitialDeployException(
                    "Cannot deploy " + script.getDocumentKey() + " to sync folder because the directory name '"
                            + path.get(i) + "' is already used by another file");
        }
    }

    // Create code file
    FileObject codeFile = currentDir.resolveFile(localName + info.getSuffix());
    _log.info("Creating script module file " + getRelativePath(codeFile));
    try {
        codeFile.createFile();
    } catch (FileSystemException e) {
        throw new WGInitialDeployException(
                "Could not create script code file '" + codeFile.getName().getPathDecoded() + "'");
    }
    Writer writer = createWriter(codeFile);
    writer.write(script.getCode());
    writer.close();

    // Create metadata file
    ScriptMetadata metaData = new ScriptMetadata(script);
    FileObject metadataDir = currentDir.resolveFile(DesignDirectory.NAME_METADATADIR);
    if (!metadataDir.exists()) {
        _log.info("Creating script metadata directory " + getRelativePath(metadataDir));
        try {
            metadataDir.createFolder();
        } catch (FileSystemException e) {
            throw new WGInitialDeployException(
                    "Could not create metadata folder '" + getRelativePath(metadataDir) + "'");
        }
    }
    FileObject metadataFile = metadataDir.resolveFile(localName + DesignDirectory.SUFFIX_METADATA);
    _log.info("Creating script metadata file " + getRelativePath(metadataFile));
    writer = createWriter(metadataFile);
    writer.write(_xstream.toXML(metaData.getInfo()));
    writer.close();

    return codeFile;
}

From source file:com.yenlo.synapse.transport.vfs.VFSTransportSender.java

/**
 * Send the given message over the VFS transport
 *
 * @param msgCtx the axis2 message context
 * @throws AxisFault on error/*from   w w w.jav a2 s  . c  om*/
 */
public void sendMessage(MessageContext msgCtx, String targetAddress, OutTransportInfo outTransportInfo)
        throws AxisFault {

    if (waitForSynchronousResponse(msgCtx)) {
        throw new AxisFault("The VFS transport doesn't support synchronous responses. "
                + "Please use the appropriate (out only) message exchange pattern.");
    }

    VFSOutTransportInfo vfsOutInfo = null;

    if (targetAddress != null) {
        vfsOutInfo = new VFSOutTransportInfo(targetAddress, globalFileLockingFlag);
    } else if (outTransportInfo != null && outTransportInfo instanceof VFSOutTransportInfo) {
        vfsOutInfo = (VFSOutTransportInfo) outTransportInfo;
    }

    if (vfsOutInfo != null) {
        FileObject replyFile = null;
        try {

            boolean wasError = true;
            int retryCount = 0;
            int maxRetryCount = vfsOutInfo.getMaxRetryCount();
            long reconnectionTimeout = vfsOutInfo.getReconnectTimeout();
            boolean append = vfsOutInfo.isAppend();

            while (wasError) {

                try {
                    retryCount++;
                    replyFile = fsManager.resolveFile(vfsOutInfo.getOutFileURI());

                    if (replyFile == null) {
                        log.error("replyFile is null");
                        throw new FileSystemException("replyFile is null");
                    }
                    wasError = false;

                } catch (FileSystemException e) {
                    log.error("cannot resolve replyFile", e);
                    if (maxRetryCount <= retryCount) {
                        handleException("cannot resolve replyFile repeatedly: " + e.getMessage(), e);
                    }
                }

                if (wasError) {
                    try {
                        Thread.sleep(reconnectionTimeout);
                    } catch (InterruptedException e2) {
                        e2.printStackTrace();
                    }
                }
            }

            if (replyFile.exists()) {

                if (replyFile.getType() == FileType.FOLDER) {
                    // we need to write a file containing the message to this folder
                    FileObject responseFile = fsManager.resolveFile(replyFile,
                            VFSUtils.getFileName(msgCtx, vfsOutInfo));

                    // if file locking is not disabled acquire the lock
                    // before uploading the file
                    if (vfsOutInfo.isFileLockingEnabled()) {
                        acquireLockForSending(responseFile, vfsOutInfo);
                        if (!responseFile.exists()) {
                            responseFile.createFile();
                        }
                        populateResponseFile(responseFile, msgCtx, append, true);
                        VFSUtils.releaseLock(fsManager, responseFile);
                    } else {
                        if (!responseFile.exists()) {
                            responseFile.createFile();
                        }
                        populateResponseFile(responseFile, msgCtx, append, false);
                    }

                } else if (replyFile.getType() == FileType.FILE) {

                    // if file locking is not disabled acquire the lock
                    // before uploading the file
                    if (vfsOutInfo.isFileLockingEnabled()) {
                        acquireLockForSending(replyFile, vfsOutInfo);
                        populateResponseFile(replyFile, msgCtx, append, true);
                        VFSUtils.releaseLock(fsManager, replyFile);
                    } else {
                        populateResponseFile(replyFile, msgCtx, append, false);
                    }

                } else {
                    handleException("Unsupported reply file type : " + replyFile.getType() + " for file : "
                            + vfsOutInfo.getOutFileURI());
                }
            } else {
                // if file locking is not disabled acquire the lock before uploading the file
                if (vfsOutInfo.isFileLockingEnabled()) {
                    acquireLockForSending(replyFile, vfsOutInfo);
                    replyFile.createFile();
                    populateResponseFile(replyFile, msgCtx, append, true);
                    VFSUtils.releaseLock(fsManager, replyFile);
                } else {
                    replyFile.createFile();
                    populateResponseFile(replyFile, msgCtx, append, false);
                }
            }
        } catch (FileSystemException e) {
            handleException("Error resolving reply file : " + vfsOutInfo.getOutFileURI(), e);
        } finally {
            if (replyFile != null) {
                try {
                    replyFile.close();
                } catch (FileSystemException ignore) {
                }
            }
        }
    } else {
        handleException("Unable to determine out transport information to send message");
    }
}

From source file:fr.cls.atoll.motu.processor.iso19139.ServiceMetadata.java

/**
 * Gets the service metadata schema as string.
 * /*from w  ww.  j  a  va 2s  .c om*/
 * @param schemaPath the schema path
 * @param localIso19139SchemaPath the local iso19139 schema path
 * @param localIso19139RootSchemaRelPath the local iso19139 root schema rel path
 * 
 * @return the service metadata schema as string
 * 
 * @throws MotuException the motu exception
 * @throws FileSystemException the file system exception
 */
public String[] getServiceMetadataSchemaAsString(String schemaPath, String localIso19139SchemaPath,
        String localIso19139RootSchemaRelPath) throws MotuException, FileSystemException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getServiceMetadataSchemaAsString(String, String, String) - entering");
    }

    List<String> stringList = new ArrayList<String>();
    String localIso19139RootSchemaPath = String.format("%s%s", localIso19139SchemaPath,
            localIso19139RootSchemaRelPath);

    FileObject dest = Organizer.resolveFile(localIso19139RootSchemaPath);
    boolean hasIso19139asLocalSchema = false;
    if (dest != null) {
        hasIso19139asLocalSchema = dest.exists();
    }

    if (hasIso19139asLocalSchema) {
        dest.close();

    } else {

        URL url = Organizer.findResource(schemaPath);

        FileObject jarFile = Organizer.resolveFile(url.toString());

        // List the children of the Jar file
        // FileObject[] children = null;
        // try {
        // children = jarFile.getChildren();
        // } catch (FileSystemException e) {
        // // TODO Auto-generated catch block
        // e.printStackTrace();
        // }
        // System.out.println("Children of " + jarFile.getName().getURI());
        // for (int i = 0; i < children.length; i++) {
        // System.out.println(children[i].getName().getBaseName());
        // }

        dest = Organizer.resolveFile(localIso19139SchemaPath);
        Organizer.copyFile(jarFile, dest);
    }

    stringList.add(localIso19139RootSchemaPath);
    String[] inS = new String[stringList.size()];
    inS = stringList.toArray(inS);

    if (LOG.isDebugEnabled()) {
        LOG.debug("getServiceMetadataSchemaAsString(String, String, String) - exiting");
    }
    return inS;
}

From source file:com.seer.datacruncher.spring.ConnectionsFileDownloadController.java

private String getFileContent(long connId, ConnectionsEntity connectionEntity) {
    String content = "";
    DefaultFileSystemManager fsManager = null;
    FileObject fileObject = null;
    try {/*  w w  w . j a v a  2 s  .c o m*/

        fsManager = (DefaultFileSystemManager) VFS.getManager();
        int serviceId = connectionEntity.getService();

        String hostName = connectionEntity.getHost();
        String port = connectionEntity.getPort();
        String userName = connectionEntity.getUserName();
        String password = connectionEntity.getPassword();
        String inputDirectory = connectionEntity.getDirectory();
        String fileName = connectionEntity.getFileName();

        log.info("Trying to Server polling at server [" + hostName + ":" + port + "] with user[" + userName
                + "].");

        String url = "";
        if (serviceId == Servers.SAMBA.getDbCode()) {
            if (!fsManager.hasProvider("smb")) {
                fsManager.addProvider("smb", new SmbFileProvider());
            }
            url = "smb://" + userName + ":" + password + "@" + hostName + ":" + port + "/" + inputDirectory
                    + "/" + fileName;
        } else if (serviceId == Servers.HTTP.getDbCode()) {
            if (!fsManager.hasProvider("http")) {
                fsManager.addProvider("http", new HttpFileProvider());
            }
            url = "http://" + hostName + ":" + port + "/" + inputDirectory + "/" + fileName;
        } else if (serviceId == Servers.FTP.getDbCode()) {
            if (!fsManager.hasProvider("ftp")) {
                fsManager.addProvider("ftp", new SmbFileProvider());
            }
            url = "ftp://" + userName + ":" + password + "@" + hostName + ":" + port + "/" + inputDirectory
                    + "/" + fileName;
        }

        fileObject = fsManager.resolveFile(url);

        if (fileObject == null || !fileObject.exists() || fileObject.getType().equals(FileType.IMAGINARY)) {
            return null;
        }

        BufferedReader fileReader = new BufferedReader(
                new InputStreamReader(fileObject.getContent().getInputStream()));
        StringBuilder sb = new StringBuilder();

        String line;
        while ((line = fileReader.readLine()) != null) {
            sb.append(line);
        }

        content = sb.toString();

    } catch (Exception ex) {

    } finally {
        try {
            if (fileObject != null) {
                fileObject.close();
            }
            if (fsManager != null) {
                fsManager.freeUnusedResources();
                fsManager.close();
                fsManager = null;
            }
        } catch (Exception ex) {

        } finally {
            fileObject = null;
            fsManager = null;
        }
    }
    return content;

}

From source file:com.googlecode.vfsjfilechooser2.accessories.connection.ConnectionDialog.java

private void initListeners() {
    this.portTextField.addKeyListener(new KeyAdapter() {
        @Override//from   w ww .j a  v  a2  s  . c om
        public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();

            if (!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))) {
                getToolkit().beep();
                e.consume();
            } else {
                setPortTextFieldDirty(true);
            }
        }
    });

    this.portTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            JFormattedTextField f = (JFormattedTextField) e.getSource();
            String text = f.getText();

            if (text.length() == 0) {
                f.setValue(null);
            }

            try {
                f.commitEdit();
            } catch (ParseException exc) {
            }
        }
    });

    this.cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (currentWorker != null) {
                if (currentWorker.isAlive()) {
                    currentWorker.interrupt();
                    setCursor(Cursor.getDefaultCursor());
                }
            }

            setVisible(false);
        }
    });

    this.connectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            currentWorker = new Thread() {
                @Override
                public void run() {
                    StringBuilder error = new StringBuilder();
                    FileObject fo = null;

                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                    try {
                        String m_username = usernameTextField.getText();
                        String m_defaultRemotePath = defaultRemotePathTextField.getText();
                        char[] m_password = passwordTextField.getPassword();
                        String m_hostname = hostnameTextField.getText();
                        String m_protocol = protocolList.getSelectedItem().toString();

                        int m_port = -1;

                        if (portTextField.isEditValid() && (portTextField.getValue() != null)) {
                            String s = portTextField.getValue().toString();
                            m_port = Integer.valueOf(s);
                        }

                        Builder credentialsBuilder = Credentials.newBuilder(m_hostname)
                                .defaultRemotePath(m_defaultRemotePath).username(m_username)
                                .password(m_password).protocol(m_protocol).port(m_port);

                        Credentials credentials = credentialsBuilder.build();

                        String uri = credentials.toFileObjectURL();

                        if (isInterrupted()) {
                            setPortTextFieldDirty(false);

                            return;
                        }

                        fo = VFSUtils.resolveFileObject(uri);

                        if ((fo != null) && !fo.exists()) {
                            fo = null;
                        }
                    } catch (Exception err) {
                        error.append(err.getMessage());
                        setCursor(Cursor.getDefaultCursor());
                    }

                    if ((error.length() > 0) || (fo == null)) {
                        error.delete(0, error.length());
                        error.append("Failed to connect!");
                        error.append("\n");
                        error.append("Please check parameters and try again.");

                        JOptionPane.showMessageDialog(ConnectionDialog.this, error, "Error",
                                JOptionPane.ERROR_MESSAGE);
                        setCursor(Cursor.getDefaultCursor());

                        return;
                    }

                    if (isInterrupted()) {
                        return;
                    }

                    fileChooser.setCurrentDirectoryObject(fo);

                    setCursor(Cursor.getDefaultCursor());

                    resetFields();

                    if (bookmarksDialog != null) {
                        String bTitle = fo.getName().getBaseName();

                        if (bTitle.trim().equals("")) {
                            bTitle = fo.getName().toString();
                        }

                        String bURL = fo.getName().getURI();
                        bookmarksDialog.getBookmarks().add(new TitledURLEntry(bTitle, bURL));
                        bookmarksDialog.getBookmarks().save();
                    }

                    setVisible(false);
                }
            };

            currentWorker.setPriority(Thread.MIN_PRIORITY);
            currentWorker.start();
        }
    });

    // add the usual right click popup menu(copy, paste, etc.)
    PopupHandler.installDefaultMouseListener(hostnameTextField);
    PopupHandler.installDefaultMouseListener(portTextField);
    PopupHandler.installDefaultMouseListener(usernameTextField);
    PopupHandler.installDefaultMouseListener(passwordTextField);
    PopupHandler.installDefaultMouseListener(defaultRemotePathTextField);

    this.protocolList.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectPortNumber();
            }
        }
    });

    this.protocolList.setSelectedItem(Protocol.FTP);
}

From source file:de.innovationgate.wgpublisher.design.fs.DesignFileDocument.java

private Data getData() throws FileNotFoundException, IOException, InstantiationException,
        IllegalAccessException, ModuleDependencyException, ModuleInstantiationException, WGException {

    // Look if already retrieved
    if (_data != null) {
        return _data;
    }/* ww  w. ja v a  2  s  . c o  m*/

    // Load Cache
    Data cacheData = _manager.readDesignFileCache(_docKey);

    // Special check in "no background changes" mode. Cache existence is sufficient, no validity checks.
    if (_manager.isNoBackgroundChanges() & cacheData != null) {
        _data = cacheData;
        return cacheData;
    }

    // Check the cache: Last modified time must be calculated and checked against it.
    FileObject mdFile = getMetadataFile();
    long lastModified = determineLastModifiedTime(mdFile);
    if (isDesignCacheValid(cacheData, mdFile, lastModified)) {
        _data = cacheData;
        return cacheData;
    }

    WGOperationKey op = _manager.getDb().obtainOperationKey(WGOperationKey.OP_DESIGN_BACKEND,
            _docKey.toString());
    synchronized (op) {
        try {
            op.setUsed(true);

            // Check cache once again synchronized (double checked locking)
            cacheData = _manager.readDesignFileCache(_docKey);
            mdFile = getMetadataFile();
            lastModified = determineLastModifiedTime(mdFile);
            if (isDesignCacheValid(cacheData, mdFile, lastModified)) {
                _data = cacheData;
                return cacheData;
            }

            // Build a new data object and put it to cache
            DesignMetadata metadata = (DesignMetadata) readMetaData();
            String code = readCode(metadata);
            Map<String, Object> extData = new HashMap<String, Object>();

            code = performDesignConversionPreProcessing(code, extData);

            _data = new Data(_docKey, metadata, getCodeFilePath(), getProperCaseFileName(getCodeFile()), code,
                    lastModified, _manager.getFileEncoding(), mdFile.exists(), extData);
            _manager.writeDesignFileCache(_docKey, _data);

            return _data;

        } finally {
            op.setUsed(false);
        }
    }

}

From source file:fr.cls.atoll.motu.processor.wps.framework.WPSFactory.java

/**
 * Gets the wPS execute request schema as string.
 * /* w  ww  . java2s  .  co m*/
 * @param schemaPath the schema path
 * @param localWPSSchemaPath the local wps schema path
 * @param localWPSRootSchemaRelPath the local wps root schema rel path
 * 
 * @return the wPS execute request schema as string
 * 
 * @throws MotuException the motu exception
 */
public static String[] getWPSExecuteRequestSchemaAsString(String schemaPath, String localWPSSchemaPath,
        String localWPSRootSchemaRelPath) throws MotuException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getWPSExecuteRequestSchemaAsString(String, String, String) - entering");
    }

    String[] inS = null;
    try {
        List<String> stringList = new ArrayList<String>();
        String localWPSRootSchemaPath = String.format("%s%s", localWPSSchemaPath, localWPSRootSchemaRelPath);

        FileObject dest = Organizer.resolveFile(localWPSRootSchemaPath);
        boolean hasWPSasLocalSchema = false;
        if (dest != null) {
            hasWPSasLocalSchema = dest.exists();
        }

        if (hasWPSasLocalSchema) {
            dest.close();

        } else {

            URL url = null;
            if (!WPSUtils.isNullOrEmpty(schemaPath)) {
                url = Organizer.findResource(schemaPath);

            } else {
                url = Organizer.findResource(localWPSRootSchemaRelPath);
                String[] str = url.toString().split(localWPSRootSchemaRelPath);
                url = new URL(str[0]);
            }

            FileObject jarFile = Organizer.resolveFile(url.toString());

            // List the children of the Jar file
            // FileObject[] children = null;
            // try {
            // children = jarFile.getChildren();
            // } catch (FileSystemException e) {
            // // TODO Auto-generated catch block
            // e.printStackTrace();
            // }
            // System.out.println("Children of " + jarFile.getName().getURI());
            // for (int i = 0; i < children.length; i++) {
            // System.out.println(children[i].getName().getBaseName());
            // }

            dest = Organizer.resolveFile(localWPSSchemaPath);
            Organizer.copyFile(jarFile, dest);
        }

        stringList.add(localWPSRootSchemaPath);
        inS = new String[stringList.size()];
        inS = stringList.toArray(inS);

    } catch (Exception e) {
        LOG.error("getWPSExecuteRequestSchemaAsString(String, String, String)", e);

        throw new MotuException("ERROR in WPSFactory#getWPSExecuteRequestSchemaAsString", e);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("getWPSExecuteRequestSchemaAsString(String, String, String) - exiting");
    }
    return inS;
}