Package org.guvnor.structure.repositories.impl.git

Examples of org.guvnor.structure.repositories.impl.git.GitRepository


            return result;
        }
    }

    private org.guvnor.structure.repositories.Repository makeRepository( final Path repositoryRoot ) {
        return new GitRepository() {
            @Override
            public Path getRoot() {
                return repositoryRoot;
            }
        };
View Full Code Here


                if ( repositoryPath == null ) {
                    result.setStatus( JobStatus.RESOURCE_NOT_EXIST );
                    result.setResult( "Repository [" + repoName + "] does not exist" );
                    return result;
                }
                GitRepository repo = new GitRepository( repoName );
                repositories.add( repo );
            }
            organizationalUnit = organizationalUnitService.createOrganizationalUnit( organizationalUnitName,
                                                                                     organizationalUnitOwner,
                                                                                     repositories );
View Full Code Here

        }

        OrganizationalUnit organizationalUnit = new OrganizationalUnitImpl( organizationalUnitName,
                                                                            null );

        GitRepository repo = new GitRepository( repositoryName );
        try {
            organizationalUnitService.addRepository( organizationalUnit,
                                                     repo );
        } catch ( IllegalArgumentException e ) {
            result.setStatus( JobStatus.BAD_REQUEST );
View Full Code Here

            result.setResult( "Repository [" + repositoryName + "] does not exist" );
            return result;
        }

        OrganizationalUnit organizationalUnit = new OrganizationalUnitImpl( organizationalUnitName, null );
        GitRepository repo = new GitRepository( repositoryName );
        try {
            organizationalUnitService.removeRepository( organizationalUnit,
                                                        repo );
        } catch ( IllegalArgumentException e ) {
            result.setStatus( JobStatus.BAD_REQUEST );
View Full Code Here

                                   pom,
                                   "http://localhost" );
    }

    private org.guvnor.structure.repositories.Repository makeRepository( final Path repositoryRoot ) {
        return new GitRepository() {

            @Override
            public Path getRoot() {
                return repositoryRoot;
            }
View Full Code Here

    public Repository newRepository(ConfigGroup repoConfig, String branch) {
        validate(repoConfig);
        checkNotNull("branch", branch);

        final GitRepository repo = new GitRepository(repoConfig.getName());
        repo.setCurrentBranch(branch);

        for (final ConfigItem item : repoConfig.getItems()) {
            if (item instanceof SecureConfigItem) {
                repo.addEnvironmentParameter(item.getName(), secureService.decrypt(item.getValue().toString()));
            } else {
                repo.addEnvironmentParameter(item.getName(), item.getValue());
            }
        }

        if (!repo.isValid()) {
            throw new IllegalStateException("Repository " + repoConfig.getName() + " not valid");
        }

        FileSystem fs = null;
        URI uri = null;
        try {
            uri = URI.create(repo.getUri());
            fs = ioService.newFileSystem(uri, new HashMap<String, Object>(repo.getEnvironment()) {{
                if (!repo.getEnvironment().containsKey("origin")) {
                    put("init", true);
                }
            }});
        } catch (final FileSystemAlreadyExistsException e) {
            fs = ioService.getFileSystem(uri);
        } catch (final Throwable ex) {
            throw new RuntimeException(ex.getCause().getMessage(), ex);
        }

        org.uberfire.backend.vfs.Path defaultRoot = convert(fs.getRootDirectories().iterator().next());
        Map<String, org.uberfire.backend.vfs.Path> branches = getBranches(fs);
        if (branches.containsKey(branch)) {
            defaultRoot = branches.get(branch);
        }
        repo.setBranches(branches);

        repo.setRoot(defaultRoot);
        final String[] uris = fs.toString().split("\\r?\\n");
        final List<PublicURI> publicURIs = new ArrayList<PublicURI>(uris.length);

        for (final String s : uris) {
            final int protocolStart = s.indexOf("://");
            final PublicURI publicURI;
            if (protocolStart > 0) {
                publicURI = new DefaultPublicURI(s.substring(0, protocolStart), s);
            } else {
                publicURI = new DefaultPublicURI(s);
            }
            publicURIs.add(publicURI);
        }
        repo.setPublicURIs(publicURIs);

        return repo;
    }
View Full Code Here

        String branch = repoConfig.getConfigItemValue( EnvironmentParameters.BRANCH );
        if ( branch == null ) {
            branch = "master";
        }

        final GitRepository repo = new GitRepository( repoConfig.getName() );
        repo.setCurrentBranch( branch );

        for ( final ConfigItem item : repoConfig.getItems() ) {
            if ( item instanceof SecureConfigItem ) {
                repo.addEnvironmentParameter( item.getName(), secureService.decrypt( item.getValue().toString() ) );
            } else {
                repo.addEnvironmentParameter( item.getName(), item.getValue() );
            }
        }

        if ( !repo.isValid() ) {
            throw new IllegalStateException( "Repository " + repoConfig.getName() + " not valid" );
        }

        FileSystem fs = null;
        URI uri = null;
        try {
            uri = URI.create( repo.getUri() );
            fs = ioService.newFileSystem( uri, new HashMap<String, Object>( repo.getEnvironment() ) {{
                if ( !repo.getEnvironment().containsKey( "origin" ) ) {
                    put( "init", true );
                }
            }} );
        } catch ( final FileSystemAlreadyExistsException e ) {
            fs = ioService.getFileSystem( uri );
        } catch ( final Throwable ex ) {
            throw new RuntimeException( ex.getCause().getMessage(), ex );
        }

        Path defaultRoot = fs.getRootDirectories().iterator().next();
        for ( final Path path : fs.getRootDirectories() ) {
            String gitBranch = getBranchName( path );
            if ( gitBranch.equals( branch ) ) {
                defaultRoot = path;
                break;
            }
        }
        Set<String> branches = new HashSet<String>();
        // collect all branches
        for ( final Path path : fs.getRootDirectories() ) {
            String gitBranch = getBranchName( path );
            branches.add( gitBranch );
        }
        repo.setBranches( branches );

        repo.setRoot( convert( defaultRoot ) );
        final String[] uris = fs.toString().split( "\\r?\\n" );
        final List<PublicURI> publicURIs = new ArrayList<PublicURI>( uris.length );

        for ( final String s : uris ) {
            final int protocolStart = s.indexOf( "://" );
            final PublicURI publicURI;
            if ( protocolStart > 0 ) {
                publicURI = new DefaultPublicURI( s.substring( 0, protocolStart ), s );
            } else {
                publicURI = new DefaultPublicURI( s );
            }
            publicURIs.add( publicURI );
        }
        repo.setPublicURIs( publicURIs );

        return repo;
    }
View Full Code Here

        String branch = repoConfig.getConfigItemValue( EnvironmentParameters.BRANCH );
        if ( branch == null ) {
            branch = "master";
        }

        final GitRepository repo = new GitRepository( repoConfig.getName() );
        repo.setCurrentBranch( branch );

        for ( final ConfigItem item : repoConfig.getItems() ) {
            if ( item instanceof SecureConfigItem ) {
                repo.addEnvironmentParameter( item.getName(), secureService.decrypt( item.getValue().toString() ) );
            } else {
                repo.addEnvironmentParameter( item.getName(), item.getValue() );
            }
        }

        if ( !repo.isValid() ) {
            throw new IllegalStateException( "Repository " + repoConfig.getName() + " not valid" );
        }

        FileSystem fs = null;
        URI uri = null;
        try {
            uri = URI.create( repo.getUri() );
            fs = ioService.newFileSystem( uri, new HashMap<String, Object>( repo.getEnvironment() ) {{
                if ( !repo.getEnvironment().containsKey( "origin" ) ) {
                    put( "init", true );
                }
            }} );
        } catch ( final FileSystemAlreadyExistsException e ) {
            fs = ioService.getFileSystem( uri );
        } catch ( final Throwable ex ) {
            throw new RuntimeException( ex.getCause().getMessage(), ex );
        }

        Path defaultRoot = fs.getRootDirectories().iterator().next();
        for ( final Path path : fs.getRootDirectories() ) {
            String gitBranch = getBranchName( path );
            if ( gitBranch.equals( branch ) ) {
                defaultRoot = path;
                break;
            }
        }
        Set<String> branches = new HashSet<String>();
        // collect all branches
        for ( final Path path : fs.getRootDirectories() ) {
            String gitBranch = getBranchName( path );
            branches.add( gitBranch );
        }
        repo.setBranches( branches );

        repo.setRoot( convert( defaultRoot ) );
        final String[] uris = fs.toString().split( "\\r?\\n" );
        final List<PublicURI> publicURIs = new ArrayList<PublicURI>( uris.length );

        for ( final String s : uris ) {
            final int protocolStart = s.indexOf( "://" );
            final PublicURI publicURI;
            if ( protocolStart > 0 ) {
                publicURI = new DefaultPublicURI( s.substring( 0, protocolStart ), s );
            } else {
                publicURI = new DefaultPublicURI( s );
            }
            publicURIs.add( publicURI );
        }
        repo.setPublicURIs( publicURIs );

        return repo;
    }
View Full Code Here

TOP

Related Classes of org.guvnor.structure.repositories.impl.git.GitRepository

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.