archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1299735 - in /archiva/trunk/archiva-modules: archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/ archi...
Date Mon, 12 Mar 2012 16:43:41 GMT
Author: olamy
Date: Mon Mar 12 16:43:41 2012
New Revision: 1299735

URL: http://svn.apache.org/viewvc?rev=1299735&view=rev
Log:
managed repositories add link to do a directories scan immediate.
Take about correctly close jackrabbit session in case of exception and open session when it's
closed.

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html
    archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
    archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java
    archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
    archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java
    archiva/trunk/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
Mon Mar 12 16:43:41 2012
@@ -54,7 +54,7 @@ public interface RepositoriesService
         throws ArchivaRestServiceException;
 
 
-    @Path( "scanRepositoryDirectories/{repositoryId}" )
+    @Path( "scanRepositoryDirectoriesNow/{repositoryId}" )
     @GET
     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
     @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
@@ -62,7 +62,7 @@ public interface RepositoriesService
      * scan directories
      * @since 1.4-M3
      */
-    RepositoryScanStatistics scanRepositoryDirectories( @PathParam( "repositoryId" ) String
repositoryId )
+    RepositoryScanStatistics scanRepositoryDirectoriesNow( @PathParam( "repositoryId" ) String
repositoryId )
         throws ArchivaRestServiceException;
 
 

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
Mon Mar 12 16:43:41 2012
@@ -771,7 +771,7 @@ public class DefaultRepositoriesService
         return Boolean.TRUE;
     }
 
-    public RepositoryScanStatistics scanRepositoryDirectories( String repositoryId )
+    public RepositoryScanStatistics scanRepositoryDirectoriesNow( String repositoryId )
         throws ArchivaRestServiceException
     {
         long sinceWhen = RepositoryScanner.FRESH_SCAN;

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
Mon Mar 12 16:43:41 2012
@@ -58,7 +58,7 @@ managedrepository.delete.content=Delete 
 managedrepositories.grid.tab.title=Managed Repositories
 managedrepositories.grid.head=Managed Repositories Management
 type=Type
-managedrepository.stats=Stats
+managedrepository.stats=Managed Repository Stats
 snapshots.notincluded=Snapshots not included
 snapshots.included=Snapshots included
 managedrepository.pomsnippet=Pom Snippet
@@ -80,6 +80,13 @@ managedrepository.updated=Managed Reposi
 managed.repository.bulk.save.confirm=Are you sure to update {0} Managed Repository(ies)
 managed.repository.bulk.save.confirm.title=Network Proxy Bulk Save
 managedrepository.scan.started=Scan Started for Managed Repository {0}
+managedrepository.scan.grid.header=Index Scanning
+managedrepository.scan.index=Update your Maven Index.
+managedrepository.stats.grid.header=Stats
+managedrepository.scan.directories=Immediate Full directories transversal scanning.
+managedrepository.scan.directories.grid.header=Directories Scanning
+managedrepository.scan.directories.finished=Managed Repository {0} fully scanned.
+managedrepository.scan.directories.started= Managed Repository {0} full scan started.
 
 # remote repositories screen
 remoterepository.downloadremoteindex.now=Download Remote Index Now

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
Mon Mar 12 16:43:41 2012
@@ -321,21 +321,21 @@ $(function() {
             $.ajax(url,
               {
                 type: "GET",
-                  beforeSend:function(){
-                    displayInfoMessage($.i18n.prop("managedrepository.scan.started",managedRepository.id()));
-                    closeDialogConfirm();
-                  },
-                  success: function(data) {
-                    displaySuccessMessage($.i18n.prop("managedrepository.scanned",managedRepository.name()));
-                  },
-                  error: function(data) {
-                    var res = $.parseJSON(data.responseText);
-                    displayRestError(res);
-                  },
-                  complete: function(){
-                    removeSmallSpinnerImg();
-                    closeDialogConfirm();
-                  }
+                beforeSend:function(){
+                  displayInfoMessage($.i18n.prop("managedrepository.scan.started",managedRepository.id()));
+                  closeDialogConfirm();
+                },
+                success: function(data) {
+                  displaySuccessMessage($.i18n.prop("managedrepository.scanned",managedRepository.name()));
+                },
+                error: function(data) {
+                  var res = $.parseJSON(data.responseText);
+                  displayRestError(res);
+                },
+                complete: function(){
+                  removeSmallSpinnerImg();
+                  closeDialogConfirm();
+                }
               }
             );
           },
@@ -415,6 +415,32 @@ $(function() {
                         $.i18n.prop('managed.repository.bulk.save.confirm',repos.length));
     }
 
+    directoriesScan=function(managedRepository){
+      $.log("directoriesScan:"+managedRepository.id());
+      var url = "restServices/archivaServices/repositoriesService/scanRepositoryDirectoriesNow/"+managedRepository.id();
+      $.ajax(url,
+        {
+          type: "GET",
+          dataType: 'json',
+          beforeSend:function(){
+            displayInfoMessage($.i18n.prop("managedrepository.scan.directories.started",
managedRepository.id()));
+          },
+          success: function(data) {
+            $.log(" scanRepositoryDirectoriesNow finished ");
+            displaySuccessMessage( $.i18n.prop("managedrepository.scan.directories.finished",
managedRepository.id()));
+          },
+          error: function(data) {
+            var res = $.parseJSON(data.responseText);
+            displayRestError(res);
+          },
+          complete: function(){
+            removeSmallSpinnerImg();
+          }
+
+        }
+      );
+    }
+
     showStats=function(managedRepository){
       if ($(calculatePopoverId(managedRepository)).html()){
         // we ask stats all the time ? if no uncomment return

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html
Mon Mar 12 16:43:41 2012
@@ -86,12 +86,13 @@
         {{/each}}
         <th>Releases</th>
         <th>Snapshots</th>
-        <th>Scan</th>
+        <th title="${$.i18n.prop('managedrepository.scan.index')}">${$.i18n.prop('managedrepository.scan.grid.header')}</th>
         <th>${$.i18n.prop('edit')}</th>
         <th>${$.i18n.prop('delete')}</th>
         <th>${$.i18n.prop('modified')}</th>
         <th>${$.i18n.prop('managedrepository.pomsnippet')}</th>
-        <th title="${$.i18n.prop('managedrepository.stats')}">Stats</th>
+        <th title="${$.i18n.prop('managedrepository.stats')}">${$.i18n.prop('managedrepository.stats.grid.header')}</th>
+        <th title="${$.i18n.prop('managedrepository.scan.directories')}">${$.i18n.prop('managedrepository.scan.directories.grid.header')}</th>
       </tr>
   </thead>
   <tbody>
@@ -143,6 +144,9 @@
                    data-bind="event: { mouseover: function(){ showStats(row) }, mouseout:
function(){ hideStats(row) },}"
                    id="managedrepository-stats-img-${row.id()}"/>
             </td>
+            <td>
+              <a href="#" data-bind="click: function(){directoriesScan(row)}">Scan
directories</a>
+            </td>
           </tr>
       {{/each}}
   </tbody>

Modified: archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
(original)
+++ archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
Mon Mar 12 16:43:41 2012
@@ -132,11 +132,13 @@ public interface MetadataRepository
 
     void save();
 
-    void close();
+    void close()
+        throws MetadataRepositoryException;
 
     void revert();
 
     boolean canObtainAccess( Class<?> aClass );
 
-    Object obtainAccess( Class<?> aClass );
+    Object obtainAccess( Class<?> aClass )
+        throws MetadataRepositoryException;
 }

Modified: archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java
(original)
+++ archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySession.java
Mon Mar 12 16:43:41 2012
@@ -94,10 +94,18 @@ public class RepositorySession
         }
         finally
         {
-            repository.close();
+            try
+            {
+                repository.close();
+            }
+            catch ( MetadataRepositoryException e )
+            {
+                throw new RuntimeException( e.getMessage(), e );
+            }
         }
     }
 
+
     public void markDirty()
     {
         this.dirty = true;

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
Mon Mar 12 16:43:41 2012
@@ -93,7 +93,7 @@ public class JcrMetadataRepository
 
     private Repository repository;
 
-    private Session session;
+    private Session jcrSession;
 
     public JcrMetadataRepository( Map<String, MetadataFacetFactory> metadataFacetFactories,
Repository repository )
         throws RepositoryException
@@ -101,9 +101,10 @@ public class JcrMetadataRepository
         this.metadataFacetFactories = metadataFacetFactories;
         this.repository = repository;
 
-        session = repository.login( new SimpleCredentials( "admin", "admin".toCharArray()
) );
+        //session = repository.login( new SimpleCredentials( "admin", "admin".toCharArray()
) );
     }
 
+
     static void initialize( Session session )
         throws RepositoryException
     {
@@ -175,8 +176,8 @@ public class JcrMetadataRepository
 
         try
         {
-            Node node = getOrAddArtifactNode( repositoryId, namespace, projectId, projectVersion,
-                                              artifactMeta.getId() );
+            Node node =
+                getOrAddArtifactNode( repositoryId, namespace, projectId, projectVersion,
artifactMeta.getId() );
 
             Calendar cal = Calendar.getInstance();
             cal.setTime( artifactMeta.getFileLastModified() );
@@ -223,8 +224,8 @@ public class JcrMetadataRepository
 
         try
         {
-            Node versionNode = getOrAddProjectVersionNode( repositoryId, namespace, projectId,
-                                                           versionMetadata.getId() );
+            Node versionNode =
+                getOrAddProjectVersionNode( repositoryId, namespace, projectId, versionMetadata.getId()
);
 
             versionNode.setProperty( "name", versionMetadata.getName() );
             versionNode.setProperty( "description", versionMetadata.getDescription() );
@@ -268,8 +269,8 @@ public class JcrMetadataRepository
                 versionNode.setProperty( "mailingList." + i + ".post", mailingList.getPostAddress()
);
                 versionNode.setProperty( "mailingList." + i + ".unsubscribe", mailingList.getUnsubscribeAddress()
);
                 versionNode.setProperty( "mailingList." + i + ".subscribe", mailingList.getSubscribeAddress()
);
-                versionNode.setProperty( "mailingList." + i + ".otherArchives", join(
-                    mailingList.getOtherArchives() ) );
+                versionNode.setProperty( "mailingList." + i + ".otherArchives",
+                                         join( mailingList.getOtherArchives() ) );
                 i++;
             }
 
@@ -368,7 +369,7 @@ public class JcrMetadataRepository
         {
             // no need to construct node-by-node here, as we'll find in the next instance,
the facet names have / and
             // are paths themselves
-            Node node = session.getRootNode().getNode( getFacetPath( repositoryId, facetId
) );
+            Node node = getJcrSession().getRootNode().getNode( getFacetPath( repositoryId,
facetId ) );
 
             // TODO: this is a bit awkward. Might be better to review the purpose of this
function - why is the list of
             //   paths helpful?
@@ -409,7 +410,7 @@ public class JcrMetadataRepository
         MetadataFacet metadataFacet = null;
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
             Node node = root.getNode( getFacetPath( repositoryId, facetId, name ) );
 
             MetadataFacetFactory metadataFacetFactory = metadataFacetFactories.get( facetId
);
@@ -468,7 +469,7 @@ public class JcrMetadataRepository
     {
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
             String path = getFacetPath( repositoryId, facetId );
             if ( root.hasNode( path ) )
             {
@@ -486,7 +487,7 @@ public class JcrMetadataRepository
     {
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
             String path = getFacetPath( repositoryId, facetId, name );
             if ( root.hasNode( path ) )
             {
@@ -525,8 +526,8 @@ public class JcrMetadataRepository
 
         try
         {
-            Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2
);
-            ValueFactory valueFactory = session.getValueFactory();
+            Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q,
Query.JCR_SQL2 );
+            ValueFactory valueFactory = getJcrSession().getValueFactory();
             if ( startTime != null )
             {
                 query.bindValue( "start", valueFactory.createValue( createCalendar( startTime
) ) );
@@ -557,7 +558,7 @@ public class JcrMetadataRepository
 
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
             if ( root.hasNode( "repositories" ) )
             {
                 Node node = root.getNode( "repositories" );
@@ -591,8 +592,8 @@ public class JcrMetadataRepository
 
         try
         {
-            Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2
);
-            ValueFactory valueFactory = session.getValueFactory();
+            Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q,
Query.JCR_SQL2 );
+            ValueFactory valueFactory = getJcrSession().getValueFactory();
             query.bindValue( "checksum", valueFactory.createValue( checksum ) );
             QueryResult result = query.execute();
 
@@ -615,7 +616,7 @@ public class JcrMetadataRepository
     {
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
             String path = getArtifactPath( repositoryId, namespace, projectId, projectVersion,
id );
             if ( root.hasNode( path ) )
             {
@@ -633,7 +634,7 @@ public class JcrMetadataRepository
     {
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
             String path = getRepositoryPath( repositoryId );
             if ( root.hasNode( path ) )
             {
@@ -655,7 +656,7 @@ public class JcrMetadataRepository
 
         try
         {
-            Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2
);
+            Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q,
Query.JCR_SQL2 );
             QueryResult result = query.execute();
 
             artifacts = new ArrayList<ArtifactMetadata>();
@@ -687,7 +688,7 @@ public class JcrMetadataRepository
 
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
 
             // basically just checking it exists
             String path = getProjectPath( repositoryId, namespace, projectId );
@@ -714,7 +715,7 @@ public class JcrMetadataRepository
 
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
 
             String path = getProjectVersionPath( repositoryId, namespace, projectId, projectVersion
);
             if ( !root.hasNode( path ) )
@@ -729,8 +730,8 @@ public class JcrMetadataRepository
             versionMetadata.setName( getPropertyString( node, "name" ) );
             versionMetadata.setDescription( getPropertyString( node, "description" ) );
             versionMetadata.setUrl( getPropertyString( node, "url" ) );
-            versionMetadata.setIncomplete( node.hasProperty( "incomplete" ) && node.getProperty(
-                "incomplete" ).getBoolean() );
+            versionMetadata.setIncomplete(
+                node.hasProperty( "incomplete" ) && node.getProperty( "incomplete"
).getBoolean() );
 
             // FIXME: decide how to treat these in the content repo
             String scmConnection = getPropertyString( node, "scm.connection" );
@@ -892,7 +893,7 @@ public class JcrMetadataRepository
 
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
 
             Node node = root.getNode( getProjectVersionPath( repositoryId, namespace, projectId,
projectVersion ) );
 
@@ -928,7 +929,7 @@ public class JcrMetadataRepository
         }
         try
         {
-            Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2
);
+            Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q,
Query.JCR_SQL2 );
             QueryResult result = query.execute();
 
             for ( Node n : JcrUtils.getNodes( result ) )
@@ -996,7 +997,7 @@ public class JcrMetadataRepository
 
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
             String path = getProjectVersionPath( repositoryId, namespace, projectId, projectVersion
);
 
             if ( root.hasNode( path ) )
@@ -1024,7 +1025,7 @@ public class JcrMetadataRepository
     {
         try
         {
-            session.save();
+            getJcrSession().save();
         }
         catch ( RepositoryException e )
         {
@@ -1036,7 +1037,7 @@ public class JcrMetadataRepository
     {
         try
         {
-            session.refresh( false );
+            getJcrSession().refresh( false );
         }
         catch ( RepositoryException e )
         {
@@ -1050,18 +1051,39 @@ public class JcrMetadataRepository
     }
 
     public Object obtainAccess( Class<?> aClass )
+        throws MetadataRepositoryException
     {
         if ( aClass == Session.class )
         {
-            return session;
+            try
+            {
+                return getJcrSession();
+            }
+            catch ( RepositoryException e )
+            {
+                log.error( e.getMessage(), e );
+                throw new MetadataRepositoryException( e.getMessage(), e );
+            }
         }
         throw new IllegalArgumentException(
             "Access using " + aClass + " is not supported on the JCR metadata storage" );
     }
 
     public void close()
+        throws MetadataRepositoryException
     {
-        session.logout();
+        try
+        {
+            if ( getJcrSession().isLive() )
+            {
+                getJcrSession().logout();
+            }
+        }
+        catch ( RepositoryException e )
+        {
+            log.error( e.getMessage(), e );
+            throw new MetadataRepositoryException( e.getMessage(), e );
+        }
     }
 
     private ArtifactMetadata getArtifactFromNode( String repositoryId, Node artifactNode
)
@@ -1152,7 +1174,7 @@ public class JcrMetadataRepository
 
         try
         {
-            Node root = session.getRootNode();
+            Node root = getJcrSession().getRootNode();
 
             Node nodeAtPath = root.getNode( path );
 
@@ -1242,7 +1264,7 @@ public class JcrMetadataRepository
     private Node getOrAddRepositoryNode( String repositoryId )
         throws RepositoryException
     {
-        Node root = session.getRootNode();
+        Node root = getJcrSession().getRootNode();
         Node node = JcrUtils.getOrAddNode( root, "repositories" );
         node = JcrUtils.getOrAddNode( node, repositoryId );
         return node;
@@ -1314,7 +1336,14 @@ public class JcrMetadataRepository
     }
 
     public Session getJcrSession()
+        throws RepositoryException
     {
-        return session;
+        if ( this.jcrSession == null || !this.jcrSession.isLive() )
+        {
+
+            jcrSession = repository.login( new SimpleCredentials( "admin", "admin".toCharArray()
) );
+
+        }
+        return this.jcrSession;
     }
 }

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java
Mon Mar 12 16:43:41 2012
@@ -85,6 +85,7 @@ public class JcrRepositorySessionFactory
 
     @PostConstruct
     public void initialize()
+        throws Exception
     {
         metadataFacetFactories = applicationContext.getBeansOfType( MetadataFacetFactory.class
);
         // olamy with spring the "id" is now "metadataFacetFactory#hint"

Modified: archiva/trunk/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java?rev=1299735&r1=1299734&r2=1299735&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java
(original)
+++ archiva/trunk/archiva-modules/plugins/problem-reports/src/main/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumer.java
Mon Mar 12 16:43:41 2012
@@ -181,6 +181,7 @@ public class DuplicateArtifactsConsumer
         }
         catch ( MetadataRepositoryException e )
         {
+            repositorySession.close();
             throw new ConsumerException( e.getMessage(), e );
         }
 



Mime
View raw message