Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37909817
en ru br
ALT Linux repos
S:2.2.1-alt6_66jpp11
5.0: 2.0.7-alt2_8jpp5
4.1: 2.0.4-alt1_10jpp1.7
4.0: 2.0.4-alt1_10jpp1.7.M40

Group :: Development/Java
RPM: maven2

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

package org.apache.maven.artifact.repository.layout;

/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.io.File;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.xml.sax.InputSource;

/**
* Repository layout for jpackage based repositories.
* This class resolves items for jpp style repos (i.e things located in
* /usr/share/java).
*/

public class JPackageRepositoryLayout
implements ArtifactRepositoryLayout
{
private static Hashtable jppArtifactMap;

private static final char GROUP_SEPARATOR = '.';
private static final char PATH_SEPARATOR = '/';

public String pathOf( Artifact artifact )
{

ArtifactHandler artifactHandler = artifact.getArtifactHandler();
StringBuffer path = new StringBuffer();

String artifactId = artifact.getArtifactId();
String groupId = artifact.getGroupId();
String version = artifact.getVersion();

if (!groupId.startsWith("JPP")) {
MavenJPackageDepmap map = MavenJPackageDepmap.getInstance();
Hashtable newInfo = map.getMappedInfo(groupId, artifactId, version);

groupId = (String) newInfo.get("group");
artifactId = (String) newInfo.get("artifact");
}

if (artifactHandler.getPackaging().equals("pom")) {
path = getPOMPath(groupId, artifactId);
} else if (artifactHandler.getPackaging().equals("signature")) {
path.append( groupId ).append( '/' );
path.append( artifactId ).append( ".signature" );

} else {
path.append( groupId ).append( '/' );
path.append( artifactId ).append( ".jar" );

}

return path.toString();
}

private StringBuffer getPOMPath(String groupId, String artifactId) {
String checkdir;
String fName = groupId.replace(PATH_SEPARATOR, GROUP_SEPARATOR) + "-"
+ artifactId + ".pom";
File f;

// let's try maven 2 repo first
checkdir = "JPP/maven2/poms/";
f = new File("/usr/share/maven2/repository/" + checkdir + fName);
if (f.exists()) {
return new StringBuffer(checkdir + fName);
}

// now maven 3 specific repository
checkdir = "JPP/maven/poms/";
f = new File("/usr/share/maven/repository/" + checkdir + fName);
if (f.exists()) {
return new StringBuffer(checkdir + fName);
}

// now try new path in /usr. This will be the only check after all
// packages are rebuilt
f = new File("/usr/share/maven-poms/" + fName);
if (f.exists()) {
return new StringBuffer(fName);
}

// final fallback to m2 default poms
return new StringBuffer("JPP/maven2/default_poms/" + fName);
}

public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
{
return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) );
}

private String pathOfRepositoryMetadata( ArtifactMetadata metadata, String filename )
{

StringBuffer path = new StringBuffer();

if (filename.substring(filename.length()-4).equals(".pom")) {
path = getPOMPath(metadata.getGroupId(), metadata.getArtifactId());
} else {

// FIXME: If it gets here, something other than a pom was requested.. where are those things located?
path.append(System.getProperty("maven2.jpp.pom.path", "maven2/poms")).append("/").append(filename);
}

return path.toString();
}

public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
{
return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() );
}
}
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin