Search in sources :

Example 1 with IAdminWriter

use of org.netbeans.lib.cvsclient.admin.IAdminWriter in project intellij-community by JetBrains.

the class DirectoryPruner method pruneEmptyDirectory.

// Utils ==================================================================
private boolean pruneEmptyDirectory(DirectoryObject directoryObject) throws IOException {
    final ILocalFileReader localFileReader = clientEnvironment.getLocalFileReader();
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    final IAdminWriter adminWriter = clientEnvironment.getAdminWriter();
    final IAdminReader adminReader = clientEnvironment.getAdminReader();
    directoriesToScan.remove(directoryObject);
    if (!localFileReader.exists(directoryObject, cvsFileSystem)) {
        return true;
    }
    final List fileNames = new ArrayList();
    final List directoryNames = new ArrayList();
    localFileReader.listFilesAndDirectories(directoryObject, fileNames, directoryNames, cvsFileSystem);
    if (fileNames.size() > 0) {
        return false;
    }
    if (hasFileEntry(directoryObject, cvsFileSystem, adminReader)) {
        return false;
    }
    for (Iterator it = directoryNames.iterator(); it.hasNext(); ) {
        final String directoryName = (String) it.next();
        if (!pruneEmptyDirectory(DirectoryObject.createInstance(directoryObject, directoryName))) {
            return false;
        }
    }
    if (adminReader.hasCvsDirectory(directoryObject, cvsFileSystem)) {
        try {
            adminWriter.removeEntryForFile(directoryObject, cvsFileSystem);
        } catch (FileNotFoundException ex) {
            // ignore
            return false;
        }
        adminWriter.pruneDirectory(directoryObject, cvsFileSystem);
        return true;
    }
    return false;
}
Also used : ILocalFileReader(org.netbeans.lib.cvsclient.file.ILocalFileReader) ICvsFileSystem(org.netbeans.lib.cvsclient.file.ICvsFileSystem) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) FileNotFoundException(java.io.FileNotFoundException) IAdminReader(org.netbeans.lib.cvsclient.admin.IAdminReader) IAdminWriter(org.netbeans.lib.cvsclient.admin.IAdminWriter) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with IAdminWriter

use of org.netbeans.lib.cvsclient.admin.IAdminWriter in project intellij-community by JetBrains.

the class DefaultResponseHandler method processClearStickyResponse.

public void processClearStickyResponse(String relativeLocalDirectory, String repositoryFilePath, IClientEnvironment clientEnvironment) throws IOException {
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    final DirectoryObject directoryObject = cvsFileSystem.getDirectoryObject(relativeLocalDirectory, repositoryFilePath);
    final IAdminWriter adminWriter = clientEnvironment.getAdminWriter();
    adminWriter.ensureCvsDirectory(directoryObject, repositoryFilePath, clientEnvironment.getCvsRoot(), cvsFileSystem);
    adminWriter.setStickyTagForDirectory(directoryObject, null, cvsFileSystem);
}
Also used : IAdminWriter(org.netbeans.lib.cvsclient.admin.IAdminWriter)

Example 3 with IAdminWriter

use of org.netbeans.lib.cvsclient.admin.IAdminWriter in project intellij-community by JetBrains.

the class DefaultResponseHandler method processSetStaticDirectoryResponse.

public void processSetStaticDirectoryResponse(String relativeLocalDirectory, String repositoryFilePath, IResponseServices responseServices, IClientEnvironment clientEnvironment) throws IOException {
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    final DirectoryObject directoryObject = cvsFileSystem.getDirectoryObject(relativeLocalDirectory, repositoryFilePath);
    final IAdminWriter adminWriter = clientEnvironment.getAdminWriter();
    adminWriter.ensureCvsDirectory(directoryObject, repositoryFilePath, clientEnvironment.getCvsRoot(), cvsFileSystem);
    adminWriter.setEntriesDotStatic(directoryObject, true, cvsFileSystem);
    responseServices.getEventSender().notifyDirectoryListeners(directoryObject, true);
}
Also used : IAdminWriter(org.netbeans.lib.cvsclient.admin.IAdminWriter)

Example 4 with IAdminWriter

use of org.netbeans.lib.cvsclient.admin.IAdminWriter in project intellij-community by JetBrains.

the class DefaultResponseHandler method processClearStaticDirectoryResponse.

public void processClearStaticDirectoryResponse(String relativeLocalDirectory, String repositoryDirectoryPath, IResponseServices responseServices, IClientEnvironment clientEnvironment) throws IOException {
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    final DirectoryObject directoryObject = cvsFileSystem.getDirectoryObject(relativeLocalDirectory, repositoryDirectoryPath);
    final IAdminWriter adminWriter = clientEnvironment.getAdminWriter();
    adminWriter.ensureCvsDirectory(directoryObject, repositoryDirectoryPath, clientEnvironment.getCvsRoot(), cvsFileSystem);
    adminWriter.setEntriesDotStatic(directoryObject, false, cvsFileSystem);
    responseServices.getEventSender().notifyDirectoryListeners(directoryObject, false);
}
Also used : IAdminWriter(org.netbeans.lib.cvsclient.admin.IAdminWriter)

Example 5 with IAdminWriter

use of org.netbeans.lib.cvsclient.admin.IAdminWriter in project intellij-community by JetBrains.

the class DefaultResponseHandler method processUpdatedMergedResponse.

// Utils ==================================================================
private static void processUpdatedMergedResponse(IClientEnvironment clientEnvironment, String relativeLocalDirectory, String repositoryFilePath, String entryLine, IResponseServices responseServices, String mode, int fileLength, IConnectionStreams connectionStreams, boolean merged) throws IOException {
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    final FileObject fileObject = cvsFileSystem.getFileObject(relativeLocalDirectory, repositoryFilePath);
    final Entry entry = Entry.createEntryForLine(entryLine);
    final ILocalFileWriter localFileWriter = clientEnvironment.getLocalFileWriter();
    localFileWriter.setNextFileDate(responseServices.getNextFileDate());
    // TODO: really???
    localFileWriter.setNextFileMode(mode);
    final boolean binary = entry.isBinary();
    final boolean readOnly = FileUtils.isReadOnlyMode(mode);
    final Charset charSet = entry.isUnicode() ? Charset.forName("UTF-16LE") : null;
    writeFile(fileObject, fileLength, connectionStreams.getInputStream(), connectionStreams.getReaderFactory(), binary, readOnly, clientEnvironment, charSet);
    updateEntriesFileTime(fileObject, entry, cvsFileSystem, merged);
    final IAdminWriter adminWriter = clientEnvironment.getAdminWriter();
    adminWriter.ensureCvsDirectory(fileObject.getParent(), repositoryFilePath, clientEnvironment.getCvsRoot(), cvsFileSystem);
    adminWriter.setEntry(fileObject.getParent(), entry, cvsFileSystem);
    responseServices.getEventSender().notifyEntryListeners(fileObject, entry);
    responseServices.getEventSender().notifyFileInfoListeners(new UpdatedFileInfo(fileObject, cvsFileSystem.getLocalFileSystem().getFile(fileObject), merged ? UpdatedFileInfo.UpdatedType.MERGED : UpdatedFileInfo.UpdatedType.UPDATED, entry));
}
Also used : UpdatedFileInfo(org.netbeans.lib.cvsclient.command.update.UpdatedFileInfo) Entry(org.netbeans.lib.cvsclient.admin.Entry) Charset(java.nio.charset.Charset) IAdminWriter(org.netbeans.lib.cvsclient.admin.IAdminWriter)

Aggregations

IAdminWriter (org.netbeans.lib.cvsclient.admin.IAdminWriter)5 FileNotFoundException (java.io.FileNotFoundException)1 Charset (java.nio.charset.Charset)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Entry (org.netbeans.lib.cvsclient.admin.Entry)1 IAdminReader (org.netbeans.lib.cvsclient.admin.IAdminReader)1 UpdatedFileInfo (org.netbeans.lib.cvsclient.command.update.UpdatedFileInfo)1 ICvsFileSystem (org.netbeans.lib.cvsclient.file.ICvsFileSystem)1 ILocalFileReader (org.netbeans.lib.cvsclient.file.ILocalFileReader)1