Package org.guvnor.common.services.project.model

Examples of org.guvnor.common.services.project.model.GAV


            final String groupId = props.getProperty( "groupId" );
            final String artifactId = props.getProperty( "artifactId" );
            final String version = props.getProperty( "version" );

            return new GAV( groupId,
                            artifactId,
                            version );
        } catch ( IOException e ) {
            log.error( e.getMessage() );
        }
View Full Code Here


        Model model = new MavenXpp3Reader().read( new StringReader( pomAsString ) );

        POM gavModel = new POM(
                model.getName(),
                model.getDescription(),
                new GAV(
                        ( model.getGroupId() == null ? model.getParent().getGroupId() : model.getGroupId() ),
                        ( model.getArtifactId() == null ? model.getParent().getArtifactId() : model.getArtifactId() ),
                        ( model.getVersion() == null ? model.getParent().getVersion() : model.getVersion() )
                )
        );
View Full Code Here

        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload( factory );
        upload.setHeaderEncoding( "UTF-8" );

        FormData data = new FormData();
        GAV emptyGAV = new GAV();
        try {
            List items = upload.parseRequest( request );
            Iterator it = items.iterator();
            while ( it.hasNext() ) {
                FileItem item = (FileItem) it.next();
                if ( !item.isFormField() ) {
                    data.setFile( item );
                }

                if ( item.isFormField() && item.getFieldName().equals( HTMLFileManagerFields.GROUP_ID ) ) {
                    emptyGAV.setGroupId( item.getString() );
                } else if ( item.isFormField() && item.getFieldName().equals( HTMLFileManagerFields.ARTIFACT_ID ) ) {
                    emptyGAV.setArtifactId( item.getString() );
                } else if ( item.isFormField() && item.getFieldName().equals( HTMLFileManagerFields.VERSION_ID ) ) {
                    emptyGAV.setVersion( item.getString() );
                }
            }

            if ( emptyGAV.getArtifactId() == null
                    || "".equals( emptyGAV.getArtifactId() )
                    || emptyGAV.getArtifactId() == null
                    || "".equals( emptyGAV.getArtifactId() )
                    || emptyGAV.getVersion() == null
                    || "".equals( emptyGAV.getVersion() ) ) {
                data.setGav( null );
            } else {
                data.setGav( emptyGAV );
            }
View Full Code Here

        return null;
    }

    private String uploadFile( final FormData uploadItem ) throws IOException {
        InputStream fileData = uploadItem.getFile().getInputStream();
        GAV gav = uploadItem.getGav();

        try {
            if ( gav == null ) {
                if ( !fileData.markSupported() ) {
                    fileData = new BufferedInputStream( fileData );
                }

                // is available() safe?
                fileData.mark( fileData.available() );

                //Attempt to load JAR's POM information from it's pom.xml file
                PomModel pomModel = null;
                try {
                    String pomXML = GuvnorM2Repository.loadPOMFromJar( fileData );
                    if ( pomXML != null ) {
                        pomModel = PomModel.Parser.parse( "pom.xml",
                                                          new ByteArrayInputStream( pomXML.getBytes() ) );
                    }
                } catch ( Exception e ) {
                    log.info( "Failed to parse pom.xml for GAV information. Falling back to pom.properties.",
                              e );
                }

                //Attempt to load JAR's POM information from it's pom.properties file
                if ( pomModel == null ) {
                    try {
                        fileData.reset();
                        String pomProperties = GuvnorM2Repository.loadPOMPropertiesFromJar( fileData );
                        if ( pomProperties != null ) {
                            final ReleaseId releaseId = ReleaseIdImpl.fromPropertiesString( pomProperties );
                            if ( releaseId != null ) {
                                pomModel = new PomModel();
                                pomModel.setReleaseId( releaseId );
                            }
                        }
                    } catch ( Exception e ) {
                        log.info( "Failed to parse pom.properties for GAV information." );
                    }
                }

                //If we were able to get a POM model we can get the GAV
                if ( pomModel != null ) {
                    String groupId = pomModel.getReleaseId().getGroupId();
                    String artifactId = pomModel.getReleaseId().getArtifactId();
                    String version = pomModel.getReleaseId().getVersion();

                    if ( isNullOrEmpty( groupId ) || isNullOrEmpty( artifactId ) || isNullOrEmpty( version ) ) {
                        return NO_VALID_POM;
                    } else {
                        gav = new GAV( groupId,
                                       artifactId,
                                       version );
                    }

                } else {
View Full Code Here

            final String groupId = props.getProperty( "groupId" );
            final String artifactId = props.getProperty( "artifactId" );
            final String version = props.getProperty( "version" );

            return new GAV( groupId,
                            artifactId,
                            version );
        } catch ( IOException e ) {
            log.error( e.getMessage() );
        }
View Full Code Here

        return repository.loadPOMFromJar( path );
    }

    @Override
    public GAV loadGAVFromJar( final String path ) {
        final GAV gav = repository.loadGAVFromJar( path );
        return gav;
    }
View Full Code Here

            jobResultEvent.fire( result );
        }
    }

    private List<String> deployResultToDetailedStringMessages( final BuildResults deployResult ) {
        GAV gav = deployResult.getGAV();
        List<String> result = buildResultsToDetailedStringMessages( deployResult.getErrorMessages() );
        String detailedStringMessage = "artifactID:" + gav.getArtifactId() +
                ", groupId:" + gav.getGroupId() +
                ", version:" + gav.getVersion();
        result.add( detailedStringMessage );
        return result;
    }
View Full Code Here

            + "</plugin>";

    @Test
    public void testPOMContentHandlerNewProject() throws IOException {
        final POMContentHandler handler = new POMContentHandler();
        final GAV gav = new GAV();
        gav.setGroupId( "org.guvnor" );
        gav.setArtifactId( "test" );
        gav.setVersion( "0.0.1" );
        final POM pom = new POM( "name",
                                 "description",
                                 gav );
        final String xml = handler.toString( pom );
View Full Code Here

            groupIdBuilder.append( nameSplit[ i ] );
        }

        String groupId = groupIdBuilder.toString();
        String artifactId = nameSplit[ nameSplit.length - 1 ];
        GAV gav = new GAV( groupId,
                           artifactId,
                           "0.0.1" );
        POM pom = new POM( gav );

        Path modulePath = migrationPathManager.generateRootPath();
View Full Code Here

        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload( factory );
        upload.setHeaderEncoding( "UTF-8" );

        FormData data = new FormData();
        GAV emptyGAV = new GAV();
        try {
            List items = upload.parseRequest( request );
            Iterator it = items.iterator();
            while ( it.hasNext() ) {
                FileItem item = (FileItem) it.next();
                if ( !item.isFormField() ) {
                    data.setFile( item );
                }

                if ( item.isFormField() && item.getFieldName().equals( HTMLFileManagerFields.GROUP_ID ) ) {
                    emptyGAV.setGroupId( item.getString() );
                } else if ( item.isFormField() && item.getFieldName().equals( HTMLFileManagerFields.ARTIFACT_ID ) ) {
                    emptyGAV.setArtifactId( item.getString() );
                } else if ( item.isFormField() && item.getFieldName().equals( HTMLFileManagerFields.VERSION_ID ) ) {
                    emptyGAV.setVersion( item.getString() );
                }
            }

            if ( emptyGAV.getArtifactId() == null
                    || "".equals( emptyGAV.getArtifactId() )
                    || emptyGAV.getArtifactId() == null
                    || "".equals( emptyGAV.getArtifactId() )
                    || emptyGAV.getVersion() == null
                    || "".equals( emptyGAV.getVersion() ) ) {
                data.setGav( null );
            } else {
                data.setGav( emptyGAV );
            }
View Full Code Here

TOP

Related Classes of org.guvnor.common.services.project.model.GAV

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.