org.jboss.dna.maven.spi
Class JcrMavenUrlProvider

java.lang.Object
  extended by org.jboss.dna.maven.spi.AbstractMavenUrlProvider
      extended by org.jboss.dna.maven.spi.JcrMavenUrlProvider
All Implemented Interfaces:
MavenUrlProvider

public class JcrMavenUrlProvider
extends AbstractMavenUrlProvider

Base class for providers that work against a JCR repository. This class implements all functionality except for creating the repository instance, and it relies upon some other component or subclass to set the repository instance. Typically, this is done by a subclass in it's configure(Properties) method:

 public class MyCustomJcrMavenUrlProvider extends JcrMavenUrlProvider {
     @Override
     public void configure(Properties properties) {
          super.configure(properties);
          properties = super.getProperties();     // always non-null
          Repository repo = ...                   // Construct and configure
          super.setRepository(repo);
      }
 }
 


Field Summary
static String CONTENT_NODE_NAME
           
static String CONTENT_PROPERTY_NAME
           
static String DEFAULT_CREATE_REPOSITORY_PATH
           
static String DEFAULT_PATH_TO_TOP_OF_MAVEN_REPOSITORY
           
static String PASSWORD
           
static String REPOSITORY_PATH
           
static String USERNAME
           
static String WORKSPACE_NAME
           
 
Constructor Summary
JcrMavenUrlProvider()
           
 
Method Summary
 void configure(Properties properties)
          Configure this provider given the configuration properties.
 javax.jcr.Credentials getCredentials()
           
 String getPathToTopOfRepository()
           
 javax.jcr.Repository getRepository()
          Get the JCR repository used by this provider
 URL getUrl(MavenId mavenId, ArtifactType artifactType, SignatureType signatureType, boolean createIfRequired)
          Get the URL for the artifact with the specified type in the given Maven project.
 String getWorkspaceName()
           
 void setContent(MavenUrl mavenUrl, InputStream content)
           
 void setCredentials(javax.jcr.Credentials credentials)
           
 void setPathToTopOfRepository(String pathToTopOfRepository)
           
 void setRepository(javax.jcr.Repository repository)
           
 void setWorkspaceName(String workspaceName)
           
 
Methods inherited from class org.jboss.dna.maven.spi.AbstractMavenUrlProvider
getProperties, setProperties
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USERNAME

public static final String USERNAME
See Also:
Constant Field Values

PASSWORD

public static final String PASSWORD
See Also:
Constant Field Values

WORKSPACE_NAME

public static final String WORKSPACE_NAME
See Also:
Constant Field Values

REPOSITORY_PATH

public static final String REPOSITORY_PATH
See Also:
Constant Field Values

DEFAULT_PATH_TO_TOP_OF_MAVEN_REPOSITORY

public static final String DEFAULT_PATH_TO_TOP_OF_MAVEN_REPOSITORY
See Also:
Constant Field Values

DEFAULT_CREATE_REPOSITORY_PATH

public static final String DEFAULT_CREATE_REPOSITORY_PATH

CONTENT_NODE_NAME

public static final String CONTENT_NODE_NAME
See Also:
Constant Field Values

CONTENT_PROPERTY_NAME

public static final String CONTENT_PROPERTY_NAME
See Also:
Constant Field Values
Constructor Detail

JcrMavenUrlProvider

public JcrMavenUrlProvider()
Method Detail

configure

public void configure(Properties properties)
Configure this provider given the configuration properties. This method is intended to be called by the MavenRepository that instantiates this provider, and only once immediately after instantiation and before any calls to MavenUrlProvider.getUrl(MavenId, ArtifactType, SignatureType, boolean).

Specified by:
configure in interface MavenUrlProvider
Overrides:
configure in class AbstractMavenUrlProvider
Parameters:
properties - the configuration properties

getCredentials

public javax.jcr.Credentials getCredentials()
Returns:
credentials

setCredentials

public void setCredentials(javax.jcr.Credentials credentials)
Parameters:
credentials - Sets credentials to the specified value.

getWorkspaceName

public String getWorkspaceName()
Returns:
workspaceName

setWorkspaceName

public void setWorkspaceName(String workspaceName)
Parameters:
workspaceName - Sets workspaceName to the specified value.

getPathToTopOfRepository

public String getPathToTopOfRepository()
Returns:
pathToTopOfRepository

setPathToTopOfRepository

public void setPathToTopOfRepository(String pathToTopOfRepository)
Parameters:
pathToTopOfRepository - Sets pathToTopOfRepository to the specified value.

getRepository

public javax.jcr.Repository getRepository()
Get the JCR repository used by this provider

Returns:
the repository instance

setRepository

public void setRepository(javax.jcr.Repository repository)
Parameters:
repository - Sets repository to the specified value.

getUrl

public URL getUrl(MavenId mavenId,
                  ArtifactType artifactType,
                  SignatureType signatureType,
                  boolean createIfRequired)
           throws MalformedURLException,
                  MavenRepositoryException
Get the URL for the artifact with the specified type in the given Maven project. The resulting URL can be used to connect to the repository to read or write the artifact's content.

Parameters:
mavenId - the ID of the Maven project; may not be null
artifactType - the type of artifact; may be null, but the URL will not be able to be read or written to
signatureType - the type of signature; may be null if the signature file is not desired
createIfRequired - true if the node structure should be created if any part of it does not exist; this always expects that the path to the top of the repository tree exists.
Returns:
the URL to this artifact, or null if the artifact does not exist
Throws:
MalformedURLException - if the supplied information cannot be turned into a valid URL
MavenRepositoryException - if there is a problem connecting to or using the Maven repository, as configured

setContent

public void setContent(MavenUrl mavenUrl,
                       InputStream content)
                throws IOException
Throws:
IOException


Copyright © 2008-2009 JBoss, a division of Red Hat. All Rights Reserved.