diff options
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata')
10 files changed, 0 insertions, 942 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java deleted file mode 100644 index e1e5fe3f..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/AbstractRepositoryMetadata.java +++ /dev/null @@ -1,255 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.File; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; -import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.WriterFactory; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -/** - * Shared methods of the repository metadata handling. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - */ -public abstract class AbstractRepositoryMetadata - implements RepositoryMetadata -{ - private Metadata metadata; - - protected AbstractRepositoryMetadata( Metadata metadata ) - { - this.metadata = metadata; - } - - public String getRemoteFilename() - { - return "maven-metadata.xml"; - } - - public String getLocalFilename( ArtifactRepository repository ) - { - return "maven-metadata-" + repository.getKey() + ".xml"; - } - - public void storeInLocalRepository( ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - throws RepositoryMetadataStoreException - { - try - { - updateRepositoryMetadata( localRepository, remoteRepository ); - } - catch ( IOException e ) - { - throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e ); - } - catch ( XmlPullParserException e ) - { - throw new RepositoryMetadataStoreException( "Error updating group repository metadata", e ); - } - } - - protected void updateRepositoryMetadata( ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - throws IOException, XmlPullParserException - { - MetadataXpp3Reader mappingReader = new MetadataXpp3Reader(); - - Metadata metadata = null; - - File metadataFile = new File( localRepository.getBasedir(), - localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) ); - - if ( metadataFile.length() == 0 ) - { - if ( !metadataFile.delete() ) - { - // sleep for 10ms just in case this is windows holding a file lock - try - { - Thread.sleep( 10 ); - } - catch ( InterruptedException e ) - { - // ignore - } - metadataFile.delete(); // if this fails, forget about it, we'll try to overwrite it anyway so no need - // to delete on exit - } - } - else if ( metadataFile.exists() ) - { - Reader reader = null; - - try - { - reader = ReaderFactory.newXmlReader( metadataFile ); - - metadata = mappingReader.read( reader, false ); - } - finally - { - IOUtil.close( reader ); - } - } - - boolean changed; - - // If file could not be found or was not valid, start from scratch - if ( metadata == null ) - { - metadata = this.metadata; - - changed = true; - } - else - { - changed = metadata.merge( this.metadata ); - } - - // beware meta-versions! - String version = metadata.getVersion(); - if ( version != null && ( Artifact.LATEST_VERSION.equals( version ) || Artifact.RELEASE_VERSION.equals( - version ) ) ) - { - // meta-versions are not valid <version/> values...don't write them. - metadata.setVersion( null ); - } - - if ( changed || !metadataFile.exists() ) - { - Writer writer = null; - try - { - metadataFile.getParentFile().mkdirs(); - writer = WriterFactory.newXmlWriter( metadataFile ); - - MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer(); - - mappingWriter.write( writer, metadata ); - } - finally - { - IOUtil.close( writer ); - } - } - else - { - metadataFile.setLastModified( System.currentTimeMillis() ); - } - } - - public String toString() - { - return "repository metadata for: \'" + getKey() + "\'"; - } - - protected static Metadata createMetadata( Artifact artifact, - Versioning versioning ) - { - Metadata metadata = new Metadata(); - metadata.setGroupId( artifact.getGroupId() ); - metadata.setArtifactId( artifact.getArtifactId() ); - metadata.setVersion( artifact.getVersion() ); - metadata.setVersioning( versioning ); - return metadata; - } - - protected static Versioning createVersioning( Snapshot snapshot ) - { - Versioning versioning = new Versioning(); - versioning.setSnapshot( snapshot ); - versioning.updateTimestamp(); - return versioning; - } - - public void setMetadata( Metadata metadata ) - { - this.metadata = metadata; - } - - public Metadata getMetadata() - { - return metadata; - } - - public void merge( org.apache.maven.repository.legacy.metadata.ArtifactMetadata metadata ) - { - // TODO: not sure that it should assume this, maybe the calls to addMetadata should pre-merge, then artifact replaces? - AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata; - this.metadata.merge( repoMetadata.getMetadata() ); - } - - public void merge( ArtifactMetadata metadata ) - { - // TODO: not sure that it should assume this, maybe the calls to addMetadata should pre-merge, then artifact replaces? - AbstractRepositoryMetadata repoMetadata = (AbstractRepositoryMetadata) metadata; - this.metadata.merge( repoMetadata.getMetadata() ); - } - - public String extendedToString() - { - StringBuilder buffer = new StringBuilder(); - - buffer.append( "\nRepository Metadata\n--------------------------" ); - buffer.append( "\nGroupId: " ).append( getGroupId() ); - buffer.append( "\nArtifactId: " ).append( getArtifactId() ); - buffer.append( "\nMetadata Type: " ).append( getClass().getName() ); - - return buffer.toString(); - } - - public int getNature() - { - return RELEASE; - } - - public ArtifactRepositoryPolicy getPolicy( ArtifactRepository repository ) - { - int nature = getNature(); - if ( ( nature & RepositoryMetadata.RELEASE_OR_SNAPSHOT ) == RepositoryMetadata.RELEASE_OR_SNAPSHOT ) - { - ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( repository.getReleases() ); - policy.merge( repository.getSnapshots() ); - return policy; - } - else if ( ( nature & RepositoryMetadata.SNAPSHOT ) != 0 ) - { - return repository.getSnapshots(); - } - else - { - return repository.getReleases(); - } - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/ArtifactRepositoryMetadata.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/ArtifactRepositoryMetadata.java deleted file mode 100644 index 85fc6018..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/ArtifactRepositoryMetadata.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.Restriction; -import org.apache.maven.artifact.versioning.VersionRange; - -/** - * Metadata for the artifact directory of the repository. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - */ -public class ArtifactRepositoryMetadata - extends AbstractRepositoryMetadata -{ - private Artifact artifact; - - public ArtifactRepositoryMetadata( Artifact artifact ) - { - this( artifact, null ); - } - - public ArtifactRepositoryMetadata( Artifact artifact, - Versioning versioning ) - { - super( createMetadata( artifact, versioning ) ); - this.artifact = artifact; - } - - public boolean storedInGroupDirectory() - { - return false; - } - - public boolean storedInArtifactVersionDirectory() - { - return false; - } - - public String getGroupId() - { - return artifact.getGroupId(); - } - - public String getArtifactId() - { - return artifact.getArtifactId(); - } - - public String getBaseVersion() - { - // Don't want the artifact's version in here, as this is stored in the directory above that - return null; - } - - public Object getKey() - { - return "artifact " + artifact.getGroupId() + ":" + artifact.getArtifactId(); - } - - public boolean isSnapshot() - { - // Don't consider the artifact's version in here, as this is stored in the directory above that - return false; - } - - public int getNature() - { - if ( artifact.getVersion() != null ) - { - return artifact.isSnapshot() ? SNAPSHOT : RELEASE; - } - - VersionRange range = artifact.getVersionRange(); - if ( range != null ) - { - for ( Restriction restriction : range.getRestrictions() ) - { - if ( isSnapshot( restriction.getLowerBound() ) || isSnapshot( restriction.getUpperBound() ) ) - { - return RELEASE_OR_SNAPSHOT; - } - } - } - - return RELEASE; - } - - private boolean isSnapshot( ArtifactVersion version ) - { - return version != null && ArtifactUtils.isSnapshot( version.getQualifier() ); - } - - public ArtifactRepository getRepository() - { - return null; - } - - public void setRepository( ArtifactRepository remoteRepository ) - { - /* - * NOTE: Metadata at the g:a level contains a collection of available versions. After merging, we can't tell - * which repository provides which version so the metadata manager must not restrict the artifact resolution to - * the repository with the most recent updates. - */ - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadata.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadata.java deleted file mode 100644 index 22e3ade8..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadata.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; - -/** - * Describes repository directory metadata. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - * @todo not happy about the store method - they use "this" - */ -public interface RepositoryMetadata - extends org.apache.maven.artifact.metadata.ArtifactMetadata -{ - - int RELEASE = 1; - - int SNAPSHOT = 2; - - int RELEASE_OR_SNAPSHOT = RELEASE | SNAPSHOT; - - /** - * Get the repository the metadata was located in. - * - * @return the repository - */ - ArtifactRepository getRepository(); - - /** - * Set the repository the metadata was located in. - * - * @param remoteRepository the repository - */ - void setRepository( ArtifactRepository remoteRepository ); - - /** - * Get the repository metadata associated with this marker. - * - * @return the metadata, or <code>null</code> if none loaded - */ - Metadata getMetadata(); - - /** - * Set the metadata contents. - * - * @param metadata the metadata - */ - void setMetadata( Metadata metadata ); - - /** - * Whether this represents a snapshot. - * - * @return if it is a snapshot - */ - boolean isSnapshot(); - - /** - * Gets the artifact quality this metadata refers to. One of {@link #RELEASE}, {@link #SNAPSHOT} or - * {@link #RELEASE_OR_SNAPSHOT}. - * - * @return The artifact quality this metadata refers to. - */ - int getNature(); - - /** - * Gets the policy that applies to this metadata regarding the specified repository. - * - * @param repository The repository for which to determine the policy, must not be {@code null}. - * @return The policy, never {@code null}. - */ - ArtifactRepositoryPolicy getPolicy( ArtifactRepository repository ); - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataDeploymentException.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataDeploymentException.java deleted file mode 100644 index 94545650..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataDeploymentException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -/** - * Error while deploying repository metadata. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - */ -public class RepositoryMetadataDeploymentException - extends Throwable -{ - public RepositoryMetadataDeploymentException( String message ) - { - super( message ); - } - - public RepositoryMetadataDeploymentException( String message, - Exception e ) - { - super( message, e ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataInstallationException.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataInstallationException.java deleted file mode 100644 index 55bb57ed..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataInstallationException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -/** - * Error while installing repository metadata. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - */ -public class RepositoryMetadataInstallationException - extends Throwable -{ - public RepositoryMetadataInstallationException( String message ) - { - super( message ); - } - - public RepositoryMetadataInstallationException( String message, - Exception e ) - { - super( message, e ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataManager.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataManager.java deleted file mode 100644 index 35626e58..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataManager.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.util.List; - -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.RepositoryRequest; - -public interface RepositoryMetadataManager -{ - - void resolve( RepositoryMetadata repositoryMetadata, RepositoryRequest repositoryRequest ) - throws RepositoryMetadataResolutionException; - - void resolve( RepositoryMetadata repositoryMetadata, List<ArtifactRepository> repositories, - ArtifactRepository localRepository ) - throws RepositoryMetadataResolutionException; - - void resolveAlways( RepositoryMetadata metadata, ArtifactRepository localRepository, - ArtifactRepository remoteRepository ) - throws RepositoryMetadataResolutionException; - - /** - * Deploy metadata to the remote repository. - * - * @param metadata the metadata to deploy - * @param localRepository the local repository to install to first - * @param deploymentRepository the remote repository to deploy to - */ - void deploy( ArtifactMetadata metadata, ArtifactRepository localRepository, - ArtifactRepository deploymentRepository ) - throws RepositoryMetadataDeploymentException; - - /** - * Install the metadata in the local repository. - * - * @param metadata the metadata - * @param localRepository the local repository - */ - void install( ArtifactMetadata metadata, ArtifactRepository localRepository ) - throws RepositoryMetadataInstallationException; -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataResolutionException.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataResolutionException.java deleted file mode 100644 index 8a6f38d4..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/RepositoryMetadataResolutionException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.artifact.repository.metadata; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -/** - * Error while retrieving repository metadata from the repository. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - */ -public class RepositoryMetadataResolutionException - extends Exception -{ - public RepositoryMetadataResolutionException( String message ) - { - super( message ); - } - - public RepositoryMetadataResolutionException( String message, - Exception e ) - { - super( message, e ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java deleted file mode 100644 index 6a1578d8..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.apache.maven.artifact.repository.metadata.io; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.util.Map; - -import org.apache.maven.artifact.repository.metadata.Metadata; -import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -/** - * Handles deserialization of metadata from some kind of textual format like XML. - * - * @author Benjamin Bentmann - */ -@Component( role = MetadataReader.class ) -public class DefaultMetadataReader - implements MetadataReader -{ - - public Metadata read( File input, Map<String, ?> options ) - throws IOException - { - if ( input == null ) - { - throw new IllegalArgumentException( "input file missing" ); - } - - Metadata metadata = read( ReaderFactory.newXmlReader( input ), options ); - - return metadata; - } - - public Metadata read( Reader input, Map<String, ?> options ) - throws IOException - { - if ( input == null ) - { - throw new IllegalArgumentException( "input reader missing" ); - } - - try - { - MetadataXpp3Reader r = new MetadataXpp3Reader(); - return r.read( input, isStrict( options ) ); - } - catch ( XmlPullParserException e ) - { - throw new MetadataParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); - } - finally - { - IOUtil.close( input ); - } - } - - public Metadata read( InputStream input, Map<String, ?> options ) - throws IOException - { - if ( input == null ) - { - throw new IllegalArgumentException( "input stream missing" ); - } - - try - { - MetadataXpp3Reader r = new MetadataXpp3Reader(); - return r.read( input, isStrict( options ) ); - } - catch ( XmlPullParserException e ) - { - throw new MetadataParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); - } - finally - { - IOUtil.close( input ); - } - } - - private boolean isStrict( Map<String, ?> options ) - { - Object value = ( options != null ) ? options.get( IS_STRICT ) : null; - return value == null || Boolean.parseBoolean( value.toString() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataParseException.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataParseException.java deleted file mode 100644 index e3e141b1..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataParseException.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.apache.maven.artifact.repository.metadata.io; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.IOException; - -/** - * Signals a failure to parse the metadata due to invalid syntax (e.g. non-wellformed XML or unknown elements). - * - * @author Benjamin Bentmann - */ -public class MetadataParseException - extends IOException -{ - - /** - * The one-based index of the line containing the error. - */ - private final int lineNumber; - - /** - * The one-based index of the column containing the error. - */ - private final int columnNumber; - - /** - * Creates a new parser exception with the specified details. - * - * @param message The error message, may be {@code null}. - * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. - * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. - */ - public MetadataParseException( String message, int lineNumber, int columnNumber ) - { - super( message ); - this.lineNumber = lineNumber; - this.columnNumber = columnNumber; - } - - /** - * Creates a new parser exception with the specified details. - * - * @param message The error message, may be {@code null}. - * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. - * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. - * @param cause The nested cause of this error, may be {@code null}. - */ - public MetadataParseException( String message, int lineNumber, int columnNumber, Throwable cause ) - { - super( message ); - initCause( cause ); - this.lineNumber = lineNumber; - this.columnNumber = columnNumber; - } - - /** - * Gets the one-based index of the line containing the error. - * - * @return The one-based index of the line containing the error or a non-positive value if unknown. - */ - public int getLineNumber() - { - return lineNumber; - } - - /** - * Gets the one-based index of the column containing the error. - * - * @return The one-based index of the column containing the error or non-positive value if unknown. - */ - public int getColumnNumber() - { - return columnNumber; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataReader.java b/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataReader.java deleted file mode 100644 index 232246fd..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/MetadataReader.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.apache.maven.artifact.repository.metadata.io; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.util.Map; - -import org.apache.maven.artifact.repository.metadata.Metadata; - -/** - * Handles deserialization of metadata from some kind of textual format like XML. - * - * @author Benjamin Bentmann - */ -public interface MetadataReader -{ - - /** - * The key for the option to enable strict parsing. This option is of type {@link Boolean} and defaults to {@code - * true}. If {@code false}, unknown elements will be ignored instead of causing a failure. - */ - String IS_STRICT = "org.apache.maven.artifact.repository.metadata.io.isStrict"; - - /** - * Reads the metadata from the specified file. - * - * @param input The file to deserialize the metadata from, must not be {@code null}. - * @param options The options to use for deserialization, may be {@code null} to use the default values. - * @return The deserialized metadata, never {@code null}. - * @throws IOException If the metadata could not be deserialized. - * @throws MetadataParseException If the input format could not be parsed. - */ - Metadata read( File input, Map<String, ?> options ) - throws IOException, MetadataParseException; - - /** - * Reads the metadata from the specified character reader. The reader will be automatically closed before the method - * returns. - * - * @param input The reader to deserialize the metadata from, must not be {@code null}. - * @param options The options to use for deserialization, may be {@code null} to use the default values. - * @return The deserialized metadata, never {@code null}. - * @throws IOException If the metadata could not be deserialized. - * @throws MetadataParseException If the input format could not be parsed. - */ - Metadata read( Reader input, Map<String, ?> options ) - throws IOException, MetadataParseException; - - /** - * Reads the metadata from the specified byte stream. The stream will be automatically closed before the method - * returns. - * - * @param input The stream to deserialize the metadata from, must not be {@code null}. - * @param options The options to use for deserialization, may be {@code null} to use the default values. - * @return The deserialized metadata, never {@code null}. - * @throws IOException If the metadata could not be deserialized. - * @throws MetadataParseException If the input format could not be parsed. - */ - Metadata read( InputStream input, Map<String, ?> options ) - throws IOException, MetadataParseException; - -} |