Search in sources :

Example 1 with DirectoryRequest

use of org.netbeans.lib.cvsclient.request.DirectoryRequest in project intellij-community by JetBrains.

the class ImportCommand method addFileRequests.

/**
	 * Adds recursively all request for files and directories in the specified
	 * directory to the specified requestList.
	 */
private void addFileRequests(File directory, Requests requests, IRequestProcessor requestProcessor, IClientEnvironment clientEnvironment) throws IOException {
    final DirectoryObject directoryObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getDirectoryObject(directory);
    final String relativePath = directoryObject.toUnixPath();
    String repository = getRepositoryRoot(clientEnvironment);
    if (!relativePath.equals(".")) {
        repository += '/' + relativePath;
    }
    requests.addRequest(new DirectoryRequest(relativePath, repository));
    final File[] files = directory.listFiles();
    if (files == null) {
        return;
    }
    final List<File> subdirectories = new ArrayList();
    for (final File file : files) {
        if (file.isDirectory()) {
            final DirectoryObject subDirObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getDirectoryObject(file);
            if (clientEnvironment.getIgnoreFileFilter().shouldBeIgnored(subDirObject, clientEnvironment.getCvsFileSystem())) {
                continue;
            }
            subdirectories.add(file);
        } else {
            final FileObject fileObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getFileObject(file);
            if (clientEnvironment.getIgnoreFileFilter().shouldBeIgnored(fileObject, clientEnvironment.getCvsFileSystem())) {
                continue;
            }
            final KeywordSubstitution keywordSubstMode = getKeywordSubstMode(file.getName());
            final boolean writable = clientEnvironment.getLocalFileReader().isWritable(fileObject, clientEnvironment.getCvsFileSystem());
            if (keywordSubstMode != null) {
                requests.addKoptRequest(keywordSubstMode);
            }
            requests.addModifiedRequest(fileObject, keywordSubstMode == KeywordSubstitution.BINARY, writable);
        }
    }
    for (final File subdirectory : subdirectories) {
        addFileRequests(subdirectory, requests, requestProcessor, clientEnvironment);
    }
}
Also used : FileObject(org.netbeans.lib.cvsclient.file.FileObject) DirectoryRequest(org.netbeans.lib.cvsclient.request.DirectoryRequest) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject) File(java.io.File)

Example 2 with DirectoryRequest

use of org.netbeans.lib.cvsclient.request.DirectoryRequest in project intellij-community by JetBrains.

the class ImportCommand method execute.

// Implemented ============================================================
public boolean execute(IRequestProcessor requestProcessor, IEventSender eventManager, ICvsListenerRegistry listenerRegistry, IClientEnvironment clientEnvironment, IProgressViewer progressViewer) throws CommandException, AuthenticationException {
    // check necessary fields
    BugLog.getInstance().assertNotNull(getModule());
    BugLog.getInstance().assertNotNull(getReleaseTag());
    BugLog.getInstance().assertNotNull(getVendorTag());
    final Requests requests;
    try {
        requests = new Requests(CommandRequest.IMPORT, clientEnvironment);
        requests.addArgumentRequest(getVendorBranchNotNull(), "-b");
        requests.addMessageRequests(CommandUtils.getMessageNotNull(getLogMessage()));
        requests.addArgumentRequest(getKeywordSubstitutionOption(), "-k");
        addWrapperRequests(requests, this.wrapperMap);
        requests.addArgumentRequest(getModule());
        requests.addArgumentRequest(getVendorTag());
        requests.addArgumentRequest(getReleaseTag());
        final File rootDirectory = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getRootDirectory();
        addFileRequests(rootDirectory, requests, requestProcessor, clientEnvironment);
        // This is necessary when importing a directory structure with CVS directories.
        // If requests.addLocalPathDirectoryRequest(); would be used, the repository path
        // would be used from the CVS folders.
        requests.addRequest(new DirectoryRequest(".", getRepositoryRoot(clientEnvironment)));
    } catch (IOException ex) {
        throw new IOCommandException(ex);
    }
    return requestProcessor.processRequests(requests, new DummyRequestsProgressHandler());
}
Also used : DummyRequestsProgressHandler(org.netbeans.lib.cvsclient.progress.sending.DummyRequestsProgressHandler) IOException(java.io.IOException) DirectoryRequest(org.netbeans.lib.cvsclient.request.DirectoryRequest) Requests(org.netbeans.lib.cvsclient.request.Requests) File(java.io.File)

Example 3 with DirectoryRequest

use of org.netbeans.lib.cvsclient.request.DirectoryRequest in project intellij-community by JetBrains.

the class CreateModuleCommand method execute.

// Implemented ============================================================
public boolean execute(IRequestProcessor requestProcessor, IEventSender eventManager, ICvsListenerRegistry listenerRegistry, IClientEnvironment clientEnvironment, IProgressViewer progressViewer) throws CommandException, AuthenticationException {
    // check necessary fields
    BugLog.getInstance().assertNotNull(module);
    final String repositoryRoot = FileUtils.removeTrailingSlash(clientEnvironment.getCvsRoot().getRepositoryPath()) + '/' + module;
    final Requests requests = new Requests(CommandRequest.IMPORT, clientEnvironment);
    requests.addArgumentRequest("-b");
    requests.addArgumentRequest("1.1.1");
    requests.addMessageRequests("Create module");
    requests.addArgumentRequest(module);
    requests.addArgumentRequest("vendor-tag");
    requests.addArgumentRequest("release-tag");
    requests.addRequest(new DirectoryRequest(".", repositoryRoot));
    if (!requestProcessor.processRequests(requests, new DummyRequestsProgressHandler())) {
        return false;
    }
    try {
        createCvsDirectory(clientEnvironment, repositoryRoot);
    } catch (IOException ex) {
        throw new IOCommandException(ex);
    }
    return true;
}
Also used : DummyRequestsProgressHandler(org.netbeans.lib.cvsclient.progress.sending.DummyRequestsProgressHandler) IOException(java.io.IOException) DirectoryRequest(org.netbeans.lib.cvsclient.request.DirectoryRequest) Requests(org.netbeans.lib.cvsclient.request.Requests) IOCommandException(org.netbeans.lib.cvsclient.command.IOCommandException)

Aggregations

DirectoryRequest (org.netbeans.lib.cvsclient.request.DirectoryRequest)3 File (java.io.File)2 IOException (java.io.IOException)2 DummyRequestsProgressHandler (org.netbeans.lib.cvsclient.progress.sending.DummyRequestsProgressHandler)2 Requests (org.netbeans.lib.cvsclient.request.Requests)2 IOCommandException (org.netbeans.lib.cvsclient.command.IOCommandException)1 DirectoryObject (org.netbeans.lib.cvsclient.file.DirectoryObject)1 FileObject (org.netbeans.lib.cvsclient.file.FileObject)1