protected void mergeLicense_Url( License target, License source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getUrl(); if ( src != null ) { if ( sourceDominant || target.getUrl() == null ) { target.setUrl( src ); target.setLocation( "url", source.getLocation( "url" ) ); } } }
properties.put( "license." + i + ".url", license.getUrl() ); properties.put( "license." + i + ".comments", license.getComments() ); properties.put( "license." + i + ".distribution", license.getDistribution() );
public static License cloneLicense( License src ) { if ( src == null ) { return null; } License result = new License(); result.setComments( src.getComments() ); result.setDistribution( src.getDistribution() ); result.setName( src.getName() ); result.setUrl( src.getUrl() ); return result; }
/** * Method writeLicense. * * @param license * @param serializer * @param tagName * @throws java.io.IOException */ private void writeLicense( License license, String tagName, XmlSerializer serializer ) throws java.io.IOException { serializer.startTag( NAMESPACE, tagName ); if ( license.getName() != null ) { serializer.startTag( NAMESPACE, "name" ).text( license.getName() ).endTag( NAMESPACE, "name" ); } if ( license.getUrl() != null ) { serializer.startTag( NAMESPACE, "url" ).text( license.getUrl() ).endTag( NAMESPACE, "url" ); } if ( license.getDistribution() != null ) { serializer.startTag( NAMESPACE, "distribution" ).text( license.getDistribution() ).endTag( NAMESPACE, "distribution" ); } if ( license.getComments() != null ) { serializer.startTag( NAMESPACE, "comments" ).text( license.getComments() ).endTag( NAMESPACE, "comments" ); } serializer.endTag( NAMESPACE, tagName ); } //-- void writeLicense( License, String, XmlSerializer )
/** * Method writeLicense. * * @param license * @param serializer * @param tagName * @throws java.io.IOException */ private void writeLicense( License license, String tagName, XmlSerializer serializer ) throws java.io.IOException { serializer.startTag( NAMESPACE, tagName ); if ( license.getName() != null ) { serializer.attribute( NAMESPACE, "name", license.getName() ); } if ( license.getUrl() != null ) { serializer.attribute( NAMESPACE, "url", license.getUrl() ); } if ( license.getDistribution() != null ) { serializer.attribute( NAMESPACE, "distribution", license.getDistribution() ); } if ( license.getComments() != null ) { serializer.attribute( NAMESPACE, "comments", license.getComments() ); } serializer.endTag( NAMESPACE, tagName ); } //-- void writeLicense( License, String, XmlSerializer )
private static StringBuffer printLicenses( List<License> licenses ) { if ( licenses == null || licenses.size() == 0 ) return null; StringBuffer sb = new StringBuffer(); String del = ""; for ( Iterator<License> i = licenses.iterator(); i.hasNext(); ) { License l = i.next(); String url = l.getUrl(); if ( url == null ) continue; sb.append( del ); sb.append( url ); del = ", "; } if ( sb.length() == 0 ) return null; return sb; }
private URL transformURIToPath( final License license) throws MalformedURLException { final Log log = this.getLog(); final URI uri = URI.create(license.getUrl()); if (uri.getScheme() == null && uri.getPath() != null) { log.debug( "License URI has no scheme and no path; transforming to local file path"); final String result = "file:///" + new File(this.project.getBasedir(), uri.getPath()); log.debug("License URL: " + result); return new URL(result); } return uri.toURL(); }
protected void mergeLicense_Url( License target, License source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getUrl(); if ( src != null ) { if ( sourceDominant || target.getUrl() == null ) { target.setUrl( src ); target.setLocation( "url", source.getLocation( "url" ) ); } } }
private List<org.apache.archiva.metadata.model.License> convertLicenses( List<License> licenses ) { List<org.apache.archiva.metadata.model.License> l = new ArrayList<>(); for ( License license : licenses ) { org.apache.archiva.metadata.model.License newLicense = new org.apache.archiva.metadata.model.License(); newLicense.setName( license.getName() ); newLicense.setUrl( license.getUrl() ); l.add( newLicense ); } return l; }
private List<org.apache.archiva.metadata.model.License> convertLicenses( List<License> licenses ) { List<org.apache.archiva.metadata.model.License> l = new ArrayList<>(); for ( License license : licenses ) { org.apache.archiva.metadata.model.License newLicense = new org.apache.archiva.metadata.model.License(); newLicense.setName( license.getName() ); newLicense.setUrl( license.getUrl() ); l.add( newLicense ); } return l; }
/** * Equivalent to {@code new ProjectLicense( license.getName(), license.getUrl(), license.getDistribution(), * license.getComments(), null )} * * @param license the license to get name, URL, ditribution and comments from */ public ProjectLicense( License license ) { this( license.getName(), license.getUrl(), license.getDistribution(), license.getComments(), null ); }
@Override public void invoke(MavenProject mavenProject, Map<String, Object> models, ResultCollector resultCollector) { final List<License> licenses = mavenProject.getLicenses(); if (licenses.isEmpty()) { InputLocation location = mavenProject.getOriginalModel().getLocation("licences"); resultCollector.addViolation(mavenProject, this, "missing <licenses/> information", location == null ? getEmptyLocation(mavenProject) : location); } else { for (License license : licenses) { if (StringUtils.isEmpty(license.getName())) { resultCollector.addViolation(mavenProject, this, "missing <name> in <license/> information", license.getLocation("")); } if (StringUtils.isEmpty(license.getUrl())) { resultCollector.addViolation(mavenProject, this, "missing <url> in <license/> information", license.getLocation("")); } } } }
/** * Adds information about references licenses. * * @param pomDescriptor * The descriptor for the current POM. * @param model * The Maven Model. * @param store * The database. */ private void addLicenses(MavenPomDescriptor pomDescriptor, Model model, Store store) { List<License> licenses = model.getLicenses(); for (License license : licenses) { MavenLicenseDescriptor licenseDescriptor = store.create(MavenLicenseDescriptor.class); licenseDescriptor.setUrl(license.getUrl()); licenseDescriptor.setComments(license.getComments()); licenseDescriptor.setName(license.getName()); licenseDescriptor.setDistribution(license.getDistribution()); pomDescriptor.getLicenses().add(licenseDescriptor); } }
/** * Method updateLicense * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense(License value, String xmlTag, Counter counter, Element element) { Element root = element; Counter innerCount = new Counter(counter.getDepth() + 1); findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); findAndReplaceSimpleElement(innerCount, root, "distribution", value.getDistribution(), null); findAndReplaceSimpleElement(innerCount, root, "comments", value.getComments(), null); } //-- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense( License value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); findAndReplaceSimpleElement( innerCount, root, "distribution", value.getDistribution(), null ); findAndReplaceSimpleElement( innerCount, root, "comments", value.getComments(), null ); } // -- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense( License value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); findAndReplaceSimpleElement( innerCount, root, "distribution", value.getDistribution(), null ); findAndReplaceSimpleElement( innerCount, root, "comments", value.getComments(), null ); } // -- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense. * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense(License value, String xmlTag, Counter counter, Element element) { Element root = element; Counter innerCount = new Counter(counter.getDepth() + 1); findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); findAndReplaceSimpleElement(innerCount, root, "distribution", value.getDistribution(), null); findAndReplaceSimpleElement(innerCount, root, "comments", value.getComments(), null); } //-- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense. * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense(License value, String xmlTag, Counter counter, Element element) { Element root = element; Counter innerCount = new Counter(counter.getDepth() + 1); findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); findAndReplaceSimpleElement(innerCount, root, "distribution", value.getDistribution(), null); findAndReplaceSimpleElement(innerCount, root, "comments", value.getComments(), null); } // -- void updateLicense(License, String, Counter, Element)
/** * Method updateLicense. * * @param value * @param element * @param counter * @param xmlTag */ protected void updateLicense( License value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null ); findAndReplaceSimpleElement( innerCount, root, "distribution", value.getDistribution(), null ); findAndReplaceSimpleElement( innerCount, root, "comments", value.getComments(), null ); } // -- void updateLicense(License, String, Counter, Element)