Package org.tmatesoft.svn.core.io

Examples of org.tmatesoft.svn.core.io.SVNRepository


        FSRepositoryFactory.setup();
        // for SVN (over svn and svn+ssh)
        SVNRepositoryFactoryImpl.setup();

        // The factory knows how to create a DAVRepository
        SVNRepository repository;
        try {
            repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));

            ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(username, password);
            repository.setAuthenticationManager(authManager);
        } catch (SVNException e) {
            throw new InvalidWorkspaceException(SVNRepositoryConnectorI18n.workspaceDoesNotExist.text(e.getMessage()));
        }
        return repository;
    }
View Full Code Here


        if (repositoryRootURL == null || repositoryRootURL.trim().length() == 0) {
            I18n msg = SVNRepositoryConnectorI18n.propertyIsRequired;
            throw new RepositorySourceException(getRepositoryRootURL(), msg.text("repositoryRootURL"));
        }

        SVNRepository repos = null;
        // Report the warnings for non-existant predefined workspaces
        boolean reportWarnings = false;
        if (this.availableWorspaceNames == null) {
            // Set up the predefined workspace names ...
            this.availableWorspaceNames = new CopyOnWriteArraySet<String>();
            for (String predefined : this.predefinedWorkspaces) {
                // if exist e.i trunk/ /branches /tags
                this.availableWorspaceNames.add(predefined);
            }
            // Report the warnings for non-existant predefined workspaces and we
            // take it that if no predefined workspace exist
            // we will take the repository root url as a pseudo workspace
            reportWarnings = true;
            for (String url : this.availableWorspaceNames) {
                // check if the predefined workspaces exist.
                if (repos != null) {
                    SVNRepositoryUtil.setNewSVNRepositoryLocation(repos, url, true, sourceName);
                } else {
                    repos = SVNRepositoryUtil.createRepository(url, sourceUsername, sourcePassword);
                }
                if (!SVNRepositoryUtil.exist(repos)) {

                    Logger.getLogger(getClass()).warn(SVNRepositoryConnectorI18n.pathForPredefinedWorkspaceDoesNotExist,
                                                      url,
                                                      name);
                }
                if (!SVNRepositoryUtil.isDirectory(repos, "")) {
                    Logger.getLogger(getClass()).warn(SVNRepositoryConnectorI18n.pathForPredefinedWorkspaceIsNotDirectory,
                                                      url,
                                                      name);
                }
            }
        }

        boolean supportsUpdates = getSupportsUpdates();

        SVNRepository defaultWorkspace = null;
        if (repos != null) {
            SVNRepositoryUtil.setNewSVNRepositoryLocation(repos, getRepositoryRootURL(), true, sourceName);
            defaultWorkspace = repos;
        } else {
            defaultWorkspace = SVNRepositoryUtil.createRepository(getRepositoryRootURL(), sourceUsername, sourcePassword);
        }

        String defaultURL = getDirectoryForDefaultWorkspace();
        if (defaultURL != null) {
            // Look for the entry at this path .....
            SVNRepository repository = SVNRepositoryUtil.createRepository(defaultURL, sourceUsername, sourcePassword);
            I18n warning = null;
            if (!SVNRepositoryUtil.exist(repository)) {
                warning = SVNRepositoryConnectorI18n.pathForPredefinedWorkspaceDoesNotExist;
            } else if (!SVNRepositoryUtil.isDirectory(repository, "")) {
                warning = SVNRepositoryConnectorI18n.pathForPredefinedWorkspaceIsNotDirectory;
View Full Code Here

                                List<Property> properties,
                                List<Location> children,
                                Request request ) {

        // Get the SVNRepository object that represents the workspace ...
        SVNRepository workspaceRoot = getWorkspaceDirectory(workspaceName);
        if (workspaceRoot == null) {
            request.setError(new InvalidWorkspaceException(SVNRepositoryConnectorI18n.workspaceDoesNotExist.text(workspaceName)));
            return false;
        }
        Path requestedPath = getPathFor(myLocation, request);
View Full Code Here

    public void process( VerifyWorkspaceRequest request ) {
        // If the request contains a null name, then we use the default ...
        String workspaceName = request.workspaceName();
        if (workspaceName == null) workspaceName = defaultWorkspace.getLocation().toDecodedString();

        SVNRepository repository = null;
        if (!this.creatingWorkspacesAllowed) {
            // Then the workspace name must be one of the available names ...
            boolean found = false;
            for (String available : this.availableWorkspaceNames) {
                if (workspaceName.equals(available)) {
                    found = true;
                    break;
                }
                repository = SVNRepositoryUtil.createRepository(available, accessData.getUsername(), accessData.getPassword());
                // check if the workspace is conform
                if (SVNRepositoryUtil.isDirectory(repository, "")
                    && repository.getLocation().toDecodedString().equals(workspaceName)) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                request.setError(new InvalidWorkspaceException(
                                                               SVNRepositoryConnectorI18n.workspaceDoesNotExist.text(workspaceName)));
                return;
            }
        }

        // Verify that there is a repos at the path given by the workspace name ...
        repository = SVNRepositoryUtil.createRepository(workspaceName, accessData.getUsername(), accessData.getPassword());
        if (SVNRepositoryUtil.isDirectory(repository, "")) {
            request.setActualWorkspaceName(repository.getLocation().toDecodedString());
            request.setActualRootLocation(Location.create(pathFactory().createRootPath()));
        } else {
            request.setError(new InvalidWorkspaceException(SVNRepositoryConnectorI18n.workspaceDoesNotExist.text(workspaceName)));
        }
    }
View Full Code Here

    @Override
    public void process( GetWorkspacesRequest request ) {
        // Return the set of available workspace names, even if new workspaces can be created ...
        Set<String> names = new HashSet<String>();
        for (String name : this.availableWorkspaceNames) {
            SVNRepository repos = SVNRepositoryUtil.createRepository(name, accessData.getUsername(), accessData.getPassword());
            if (repos != null && SVNRepositoryUtil.isDirectory(repos, "")) {
                names.add(repos.getLocation().toDecodedString());
            } else {
                request.setError(new InvalidWorkspaceException(SVNRepositoryConnectorI18n.workspaceDoesNotExist.text(name)));
            }
        }
        request.setAvailableWorkspaceNames(Collections.unmodifiableSet(names));
View Full Code Here

            request.setError(new InvalidRequestException(msg));
            return;
        }
        // This doesn't create the directory representing the workspace (it must already exist), but it will add
        // the workspace name to the available names ...
        SVNRepository repository = SVNRepositoryUtil.createRepository(workspaceName,
                                                                      accessData.getUsername(),
                                                                      accessData.getPassword());
        if (SVNRepositoryUtil.isDirectory(repository, "")) {
            request.setActualWorkspaceName(repository.getLocation().toDecodedString());
            request.setActualRootLocation(Location.create(pathFactory().createRootPath()));
            availableWorkspaceNames.add(repository.getLocation().toDecodedString());
        } else {
            request.setError(new InvalidWorkspaceException(SVNRepositoryConnectorI18n.workspaceDoesNotExist.text(workspaceName)));
        }

    }
View Full Code Here

            // }
        }
    }

    protected SVNRepository getWorkspaceDirectory( String workspaceName ) {
        SVNRepository repository = defaultWorkspace;
        if (workspaceName != null) {
            SVNRepository repos = SVNRepositoryUtil.createRepository(workspaceName,
                                                                     accessData.getUsername(),
                                                                     accessData.getPassword());
            if (SVNRepositoryUtil.isDirectory(repos, "")) {
                repository = repos;
            } else {
View Full Code Here

    private boolean areFileContentsEqual(String path1, long rev1, String path2, long rev2, SVNProperties props2) throws SVNException {
        SVNProperties props1 = new SVNProperties();
        props2 = props2 == null ? new SVNProperties() : props2;

        SVNRepository repos = getSourceRepository();
        repos.getFile(path1, rev1, props1, null);
        repos.getFile(path2, rev2, props2, null);
        String crc1 = props1.getStringValue(SVNProperty.CHECKSUM);
        String crc2 = props2.getStringValue(SVNProperty.CHECKSUM);
        return crc1 != null && crc1.equals(crc2);
    }
View Full Code Here

            JavaHLObjectFactory.throwException(e, myDelegate);
        }
    }

    private static void setRevisionProperty(String path, Revision rev, String propName, String propValue, boolean bypassPreRevPropChangeHook, boolean bypassPostRevPropChangeHook) throws SVNException {
        SVNRepository repository = SVNRepositoryFactory.create(SVNURL.fromFile(new File(path).getAbsoluteFile()));
        ((FSRepository) repository).setRevisionPropertyValue(JavaHLObjectFactory.getSVNRevision(rev).getNumber(), propName, SVNPropertyValue.create(propValue), bypassPreRevPropChangeHook, bypassPostRevPropChangeHook);
    }
View Full Code Here

        }
        if ((!pegRevision.isValid() || pegRevision == SVNRevision.BASE || pegRevision == SVNRevision.WORKING) &&
                (!revision.isValid() || revision == SVNRevision.BASE || revision == SVNRevision.WORKING)) {
            doGetLocalFileContents(path, dst, revision, expandKeywords);
        } else {
            SVNRepository repos = createRepository(null, path, null, pegRevision, revision, null);
            checkCancelled();
            long revNumber = getRevisionNumber(revision, repos, path);
            SVNNodeKind kind = repos.checkPath("", revNumber);
            if (kind == SVNNodeKind.DIR) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_IS_DIRECTORY,
                        "URL ''{0}'' refers to a directory", repos.getLocation());
                SVNErrorManager.error(err, SVNLogType.WC);
            }
            checkCancelled();
            if (!expandKeywords) {
                repos.getFile("", revNumber, null, new SVNCancellableOutputStream(dst, this));
            } else {
                SVNProperties properties = new SVNProperties();
                repos.getFile("", revNumber, properties, null);
                checkCancelled();

                String keywords = properties.getStringValue(SVNProperty.KEYWORDS);
                String eol = properties.getStringValue(SVNProperty.EOL_STYLE);
                String charset = SVNTranslator.getCharset(properties.getStringValue(SVNProperty.CHARSET), path.getPath(), getOptions());
                if (keywords != null || eol != null || charset != null) {
                    String cmtRev = properties.getStringValue(SVNProperty.COMMITTED_REVISION);
                    String cmtDate = properties.getStringValue(SVNProperty.COMMITTED_DATE);
                    String author = properties.getStringValue(SVNProperty.LAST_AUTHOR);
                    Map keywordsMap = SVNTranslator.computeKeywords(keywords, expandKeywords ? repos.getLocation().toString() : null, author, cmtDate, cmtRev, getOptions());
                    OutputStream translatingStream = SVNTranslator.getTranslatingOutputStream(dst, charset, SVNTranslator.getEOL(eol, getOptions()), false, keywordsMap, expandKeywords);
                    repos.getFile("", revNumber, null, new SVNCancellableOutputStream(translatingStream, getEventDispatcher()));
                    try {
                        translatingStream.close();
                    } catch (IOExceptionWrapper ioew) {
                        throw ioew.getOriginalException();
                    } catch (IOException e) {
                        SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getMessage()), SVNLogType.WC);
                    }
                } else {
                    repos.getFile("", revNumber, null, new SVNCancellableOutputStream(dst, getEventDispatcher()));
                }
            }
            try {
                dst.flush();
            } catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.io.SVNRepository

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.