Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 1ac11c4059e5d3058558ca3df301b2d8f126864e @adreghiciu adreghiciu committed Feb 28, 2011
Showing with 1,422 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +23 −0 README.md
  3. +136 −0 pom.xml
  4. +16 −0 src/main/advices/advices.xml
  5. +210 −0 src/main/java/org/sonatype/nexus/plugin/rdf/ItemPath.java
  6. +115 −0 src/main/java/org/sonatype/nexus/plugin/rdf/RDFStore.java
  7. +33 −0 src/main/java/org/sonatype/nexus/plugin/rdf/StatementsProducer.java
  8. +63 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/NexusStoppedEventInspector.java
  9. +133 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/RepositoryItemEventInspector.java
  10. +83 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/Utils.java
  11. +55 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/capabilities/RDFCapability.java
  12. +50 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/capabilities/RDFCapabilityDescriptor.java
  13. +25 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/capabilities/RDFCapabilityFactory.java
  14. +68 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/capabilities/RDFConfiguration.java
  15. +29 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/guice/GuiceModule.java
  16. +31 −0 ...n/java/org/sonatype/nexus/plugin/rdf/internal/guice/LocalModelResolverRepositoryPathProvider.java
  17. +31 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/guice/StorageDirProvider.java
  18. +145 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/sp/ArtifactHashStatementsProducer.java
  19. +75 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/sp/ArtifactStatementsProducer.java
  20. +94 −0 src/main/java/org/sonatype/nexus/plugin/rdf/internal/sp/POMStatementsProducer.java
@@ -0,0 +1,7 @@
+.idea
+*.iml
+*.ipr
+.classpath
+.project
+.settings
+target
@@ -0,0 +1,23 @@
+Description
+-----------
+
+Nexus plugin that indexes repositories content as RDF.
+
+Building
+--------
+
+### Requirements
+
+* [Java](http://java.sun.com/) 5
+* [Maven](http://maven.apache.org) 3.x
+* [Maven Setup](https://docs.sonatype.com/display/ENG/Maven+Configuration)
+
+### Check-out:
+
+ git@github.com:sonatype/nexus-rdf-plugin.git
+
+### Build (must use Maven 3):
+ cd nexus-rdf-plugin
+ mvn clean install
+
+
136 pom.xml
@@ -0,0 +1,136 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.sonatype.forge</groupId>
+ <artifactId>forge-parent</artifactId>
+ <version>8</version>
+ </parent>
+
+ <groupId>org.sonatype.nexus.plugins</groupId>
+ <artifactId>nexus-rdf-plugin</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>nexus-plugin</packaging>
+
+ <name>Nexus : Plugins : RDF</name>
+ <description>Nexus RDF Plugin</description>
+
+ <properties>
+ <nexus.version>1.10-SNAPSHOT</nexus.version>
+
+ <sisu.assembler.tags>nexus,nexus-plugins</sisu.assembler.tags>
+ </properties>
+
+ <scm>
+ <connection>scm:git:git@github.com/sonatype/nexus-rdf-plugin.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/nexus-rdf-plugin.git</developerConnection>
+ <url>http://github.com/sonatype/nexus-rdf-plugin</url>
+ </scm>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonatype.nexus</groupId>
+ <artifactId>nexus-api</artifactId>
+ <version>${nexus.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.nexus</groupId>
+ <artifactId>nexus-proxy</artifactId>
+ <version>${nexus.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.nexus</groupId>
+ <artifactId>nexus-app</artifactId>
+ <version>${nexus.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.nexus.plugins</groupId>
+ <artifactId>nexus-capabilities-plugin</artifactId>
+ <type>nexus-plugin</type>
+ <version>${nexus.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>sisu-inject-bean</artifactId>
+ <version>2.1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.sonatype.sisu</groupId>
+ <artifactId>rdf</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-rio-turtle</artifactId>
+ <version>2.3.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonatype.plugins</groupId>
+ <artifactId>app-lifecycle-maven-plugin</artifactId>
+ <version>1.3</version>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>org.sonatype.plugins</groupId>
+ <artifactId>app-lifecycle-nexus</artifactId>
+ <version>1.3</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <componentDependencies>
+ <componentDependency>org.sonatype.sisu:rdf</componentDependency>
+ </componentDependencies>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>assembly</id>
+ <activation>
+ <property>
+ <name>!skipAssembly</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonatype.maven.plugins</groupId>
+ <artifactId>maven-sisu-assembler-plugin</artifactId>
+ <version>1.0.7-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <alternativeArtifact>
+ <classifier>bundle</classifier>
+ <type>zip</type>
+ </alternativeArtifact>
+ <useTransitiveDependencies>false</useTransitiveDependencies>
+ <resolveUpdateSiteArtifacts>true</resolveUpdateSiteArtifacts>
+ <includeScopes>
+ <includeScope>provided</includeScope>
+ </includeScopes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<assembly>
+ <advices>
+
+ <advice>
+ <generateAsItIs />
+ <unit>
+ <provides>
+ <provided namespace='org.apache.maven.artifact.type' name='nexus-plugin' version='1.0.0' />
+ </provides>
+ </unit>
+ </advice>
+
+ </advices>
+</assembly>
@@ -0,0 +1,210 @@
+/**
+ * Copyright (c) 2008-2011 Sonatype, Inc.
+ *
+ * All rights reserved. Includes the third-party code listed at http://www.sonatype.com/products/nexus/attributions.
+ * Sonatype and Sonatype Nexus are trademarks of Sonatype, Inc. Apache Maven is a trademark of the Apache Foundation.
+ * M2Eclipse is a trademark of the Eclipse Foundation. All other trademarks are the property of their respective owners.
+ */
+package org.sonatype.nexus.plugin.rdf;
+
+import java.io.File;
+
+import org.apache.maven.index.artifact.Gav;
+import org.apache.maven.index.artifact.IllegalArtifactCoordinateException;
+import org.sonatype.nexus.proxy.maven.MavenRepository;
+
+/**
+ * Path to an item in a maven repository.
+ *
+ * @author Alin Dreghiciu
+ */
+public class ItemPath
+{
+
+ /**
+ * Name of directory storing metadata.
+ */
+ public static final String METADATA_DIR = "/.meta";
+
+ /**
+ * Maven repository containing the item.
+ */
+ private final MavenRepository m_repository;
+ /**
+ * Path to item in repository.
+ */
+ private final String m_path;
+ /**
+ * Calculated GAV for item (or null if an invalid path).
+ */
+ private final Gav m_gav;
+ /**
+ * Path to file on file system.
+ */
+ private final File m_file;
+
+ /**
+ * Constructor.
+ *
+ * @param repository maven repository containing the item
+ * @param path path to item in repository.
+ */
+ public ItemPath( final MavenRepository repository,
+ final String path )
+ {
+ assert repository != null : "Item repository must be specified (cannot be null)";
+ assert path != null : "Item path must be specified (cannot be null)";
+ assert path.trim().length() != 0 : "Item path must be specified (cannot be empty)";
+
+ m_repository = repository;
+ m_file = new File( path );
+ m_path = path;
+ m_gav = calculateGav();
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param repository maven repository containing the item
+ * @param repositoryRoot repository root file
+ * @param path path to item in repository.
+ */
+ public ItemPath( final MavenRepository repository,
+ final File repositoryRoot,
+ final String path )
+ {
+ assert repository != null : "Item repository must be specified (cannot be null)";
+ assert repositoryRoot != null : "Item repository root must be specified (cannot be null)";
+ assert path != null : "Item path must be specified (cannot be null)";
+ assert path.trim().length() != 0 : "Item path must be specified (cannot be empty)";
+
+ m_repository = repository;
+ m_file = new File(repositoryRoot, path);
+ m_path = path;
+ m_gav = calculateGav();
+ }
+
+ /**
+ * Getter.
+ *
+ * @return item path
+ */
+ public String path()
+ {
+ return m_path;
+ }
+
+ /**
+ * Getter.
+ *
+ * @return true if the path is a path to a custom metadata file.
+ */
+ public boolean isPathOfCustomMetadata()
+ {
+ return m_path.startsWith( METADATA_DIR );
+ }
+
+ /**
+ * Getter.
+ *
+ * @return item repository
+ */
+ public MavenRepository repository()
+ {
+ return m_repository;
+ }
+
+ /**
+ * Getter.
+ *
+ * @return item GAV or null if GAV cannot be calculated
+ */
+ public Gav gav()
+ {
+ return m_gav;
+ }
+
+ /**
+ * @return path to file on file system.
+ */
+ public File file()
+ {
+ return m_file;
+ }
+
+ /**
+ * Calculate the GAV for specified path.
+ *
+ * @return calculated GAV or null if GAV cannot be calculated
+ */
+ private Gav calculateGav()
+ {
+ Gav gav = null;
+ try
+ {
+ if ( m_path.startsWith( METADATA_DIR ) )
+ {
+ gav = m_repository.getGavCalculator().pathToGav( m_path.replace( METADATA_DIR, "" ) );
+ }
+ else
+ {
+ gav = m_repository.getGavCalculator().pathToGav( m_path );
+ }
+ }
+ catch ( IllegalArtifactCoordinateException ignore )
+ {
+ // ignore
+ }
+ return gav;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( !( o instanceof ItemPath ) )
+ {
+ return false;
+ }
+
+ ItemPath itemPath = (ItemPath) o;
+
+ if ( !m_path.equals( itemPath.m_path ) )
+ {
+ return false;
+ }
+ if ( !m_repository.equals( itemPath.m_repository ) )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ int result = m_repository.hashCode();
+ result = 31 * result + m_path.hashCode();
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return String.format( "%s:%s", m_repository.getId(), m_path );
+ }
+
+}
Oops, something went wrong.

0 comments on commit 1ac11c4

Please sign in to comment.