mirror of https://github.com/apache/archiva.git
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. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299735 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
be29e9e81c
commit
5ff0f0ee14
|
@ -54,7 +54,7 @@ public interface RepositoriesService
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
|
||||||
@Path( "scanRepositoryDirectories/{repositoryId}" )
|
@Path( "scanRepositoryDirectoriesNow/{repositoryId}" )
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
|
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
|
||||||
|
@ -62,7 +62,7 @@ public interface RepositoriesService
|
||||||
* scan directories
|
* scan directories
|
||||||
* @since 1.4-M3
|
* @since 1.4-M3
|
||||||
*/
|
*/
|
||||||
RepositoryScanStatistics scanRepositoryDirectories( @PathParam( "repositoryId" ) String repositoryId )
|
RepositoryScanStatistics scanRepositoryDirectoriesNow( @PathParam( "repositoryId" ) String repositoryId )
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -771,7 +771,7 @@ public class DefaultRepositoriesService
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RepositoryScanStatistics scanRepositoryDirectories( String repositoryId )
|
public RepositoryScanStatistics scanRepositoryDirectoriesNow( String repositoryId )
|
||||||
throws ArchivaRestServiceException
|
throws ArchivaRestServiceException
|
||||||
{
|
{
|
||||||
long sinceWhen = RepositoryScanner.FRESH_SCAN;
|
long sinceWhen = RepositoryScanner.FRESH_SCAN;
|
||||||
|
|
|
@ -58,7 +58,7 @@ managedrepository.delete.content=Delete Content too ?
|
||||||
managedrepositories.grid.tab.title=Managed Repositories
|
managedrepositories.grid.tab.title=Managed Repositories
|
||||||
managedrepositories.grid.head=Managed Repositories Management
|
managedrepositories.grid.head=Managed Repositories Management
|
||||||
type=Type
|
type=Type
|
||||||
managedrepository.stats=Stats
|
managedrepository.stats=Managed Repository Stats
|
||||||
snapshots.notincluded=Snapshots not included
|
snapshots.notincluded=Snapshots not included
|
||||||
snapshots.included=Snapshots included
|
snapshots.included=Snapshots included
|
||||||
managedrepository.pomsnippet=Pom Snippet
|
managedrepository.pomsnippet=Pom Snippet
|
||||||
|
@ -80,6 +80,13 @@ managedrepository.updated=Managed Repository {0} updated.
|
||||||
managed.repository.bulk.save.confirm=Are you sure to update {0} Managed Repository(ies)
|
managed.repository.bulk.save.confirm=Are you sure to update {0} Managed Repository(ies)
|
||||||
managed.repository.bulk.save.confirm.title=Network Proxy Bulk Save
|
managed.repository.bulk.save.confirm.title=Network Proxy Bulk Save
|
||||||
managedrepository.scan.started=Scan Started for Managed Repository {0}
|
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
|
# remote repositories screen
|
||||||
remoterepository.downloadremoteindex.now=Download Remote Index Now
|
remoterepository.downloadremoteindex.now=Download Remote Index Now
|
||||||
|
|
|
@ -321,21 +321,21 @@ $(function() {
|
||||||
$.ajax(url,
|
$.ajax(url,
|
||||||
{
|
{
|
||||||
type: "GET",
|
type: "GET",
|
||||||
beforeSend:function(){
|
beforeSend:function(){
|
||||||
displayInfoMessage($.i18n.prop("managedrepository.scan.started",managedRepository.id()));
|
displayInfoMessage($.i18n.prop("managedrepository.scan.started",managedRepository.id()));
|
||||||
closeDialogConfirm();
|
closeDialogConfirm();
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
displaySuccessMessage($.i18n.prop("managedrepository.scanned",managedRepository.name()));
|
displaySuccessMessage($.i18n.prop("managedrepository.scanned",managedRepository.name()));
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
var res = $.parseJSON(data.responseText);
|
var res = $.parseJSON(data.responseText);
|
||||||
displayRestError(res);
|
displayRestError(res);
|
||||||
},
|
},
|
||||||
complete: function(){
|
complete: function(){
|
||||||
removeSmallSpinnerImg();
|
removeSmallSpinnerImg();
|
||||||
closeDialogConfirm();
|
closeDialogConfirm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -415,6 +415,32 @@ $(function() {
|
||||||
$.i18n.prop('managed.repository.bulk.save.confirm',repos.length));
|
$.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){
|
showStats=function(managedRepository){
|
||||||
if ($(calculatePopoverId(managedRepository)).html()){
|
if ($(calculatePopoverId(managedRepository)).html()){
|
||||||
// we ask stats all the time ? if no uncomment return
|
// we ask stats all the time ? if no uncomment return
|
||||||
|
|
|
@ -86,12 +86,13 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<th>Releases</th>
|
<th>Releases</th>
|
||||||
<th>Snapshots</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('edit')}</th>
|
||||||
<th>${$.i18n.prop('delete')}</th>
|
<th>${$.i18n.prop('delete')}</th>
|
||||||
<th>${$.i18n.prop('modified')}</th>
|
<th>${$.i18n.prop('modified')}</th>
|
||||||
<th>${$.i18n.prop('managedrepository.pomsnippet')}</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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -143,6 +144,9 @@
|
||||||
data-bind="event: { mouseover: function(){ showStats(row) }, mouseout: function(){ hideStats(row) },}"
|
data-bind="event: { mouseover: function(){ showStats(row) }, mouseout: function(){ hideStats(row) },}"
|
||||||
id="managedrepository-stats-img-${row.id()}"/>
|
id="managedrepository-stats-img-${row.id()}"/>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="#" data-bind="click: function(){directoriesScan(row)}">Scan directories</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -132,11 +132,13 @@ public interface MetadataRepository
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
void close();
|
void close()
|
||||||
|
throws MetadataRepositoryException;
|
||||||
|
|
||||||
void revert();
|
void revert();
|
||||||
|
|
||||||
boolean canObtainAccess( Class<?> aClass );
|
boolean canObtainAccess( Class<?> aClass );
|
||||||
|
|
||||||
Object obtainAccess( Class<?> aClass );
|
Object obtainAccess( Class<?> aClass )
|
||||||
|
throws MetadataRepositoryException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,10 +94,18 @@ public class RepositorySession
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
repository.close();
|
try
|
||||||
|
{
|
||||||
|
repository.close();
|
||||||
|
}
|
||||||
|
catch ( MetadataRepositoryException e )
|
||||||
|
{
|
||||||
|
throw new RuntimeException( e.getMessage(), e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void markDirty()
|
public void markDirty()
|
||||||
{
|
{
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
private Repository repository;
|
private Repository repository;
|
||||||
|
|
||||||
private Session session;
|
private Session jcrSession;
|
||||||
|
|
||||||
public JcrMetadataRepository( Map<String, MetadataFacetFactory> metadataFacetFactories, Repository repository )
|
public JcrMetadataRepository( Map<String, MetadataFacetFactory> metadataFacetFactories, Repository repository )
|
||||||
throws RepositoryException
|
throws RepositoryException
|
||||||
|
@ -101,9 +101,10 @@ public class JcrMetadataRepository
|
||||||
this.metadataFacetFactories = metadataFacetFactories;
|
this.metadataFacetFactories = metadataFacetFactories;
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
|
|
||||||
session = repository.login( new SimpleCredentials( "admin", "admin".toCharArray() ) );
|
//session = repository.login( new SimpleCredentials( "admin", "admin".toCharArray() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void initialize( Session session )
|
static void initialize( Session session )
|
||||||
throws RepositoryException
|
throws RepositoryException
|
||||||
{
|
{
|
||||||
|
@ -175,8 +176,8 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node node = getOrAddArtifactNode( repositoryId, namespace, projectId, projectVersion,
|
Node node =
|
||||||
artifactMeta.getId() );
|
getOrAddArtifactNode( repositoryId, namespace, projectId, projectVersion, artifactMeta.getId() );
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.setTime( artifactMeta.getFileLastModified() );
|
cal.setTime( artifactMeta.getFileLastModified() );
|
||||||
|
@ -223,8 +224,8 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node versionNode = getOrAddProjectVersionNode( repositoryId, namespace, projectId,
|
Node versionNode =
|
||||||
versionMetadata.getId() );
|
getOrAddProjectVersionNode( repositoryId, namespace, projectId, versionMetadata.getId() );
|
||||||
|
|
||||||
versionNode.setProperty( "name", versionMetadata.getName() );
|
versionNode.setProperty( "name", versionMetadata.getName() );
|
||||||
versionNode.setProperty( "description", versionMetadata.getDescription() );
|
versionNode.setProperty( "description", versionMetadata.getDescription() );
|
||||||
|
@ -268,8 +269,8 @@ public class JcrMetadataRepository
|
||||||
versionNode.setProperty( "mailingList." + i + ".post", mailingList.getPostAddress() );
|
versionNode.setProperty( "mailingList." + i + ".post", mailingList.getPostAddress() );
|
||||||
versionNode.setProperty( "mailingList." + i + ".unsubscribe", mailingList.getUnsubscribeAddress() );
|
versionNode.setProperty( "mailingList." + i + ".unsubscribe", mailingList.getUnsubscribeAddress() );
|
||||||
versionNode.setProperty( "mailingList." + i + ".subscribe", mailingList.getSubscribeAddress() );
|
versionNode.setProperty( "mailingList." + i + ".subscribe", mailingList.getSubscribeAddress() );
|
||||||
versionNode.setProperty( "mailingList." + i + ".otherArchives", join(
|
versionNode.setProperty( "mailingList." + i + ".otherArchives",
|
||||||
mailingList.getOtherArchives() ) );
|
join( mailingList.getOtherArchives() ) );
|
||||||
i++;
|
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
|
// no need to construct node-by-node here, as we'll find in the next instance, the facet names have / and
|
||||||
// are paths themselves
|
// 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
|
// TODO: this is a bit awkward. Might be better to review the purpose of this function - why is the list of
|
||||||
// paths helpful?
|
// paths helpful?
|
||||||
|
@ -409,7 +410,7 @@ public class JcrMetadataRepository
|
||||||
MetadataFacet metadataFacet = null;
|
MetadataFacet metadataFacet = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
Node node = root.getNode( getFacetPath( repositoryId, facetId, name ) );
|
Node node = root.getNode( getFacetPath( repositoryId, facetId, name ) );
|
||||||
|
|
||||||
MetadataFacetFactory metadataFacetFactory = metadataFacetFactories.get( facetId );
|
MetadataFacetFactory metadataFacetFactory = metadataFacetFactories.get( facetId );
|
||||||
|
@ -468,7 +469,7 @@ public class JcrMetadataRepository
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
String path = getFacetPath( repositoryId, facetId );
|
String path = getFacetPath( repositoryId, facetId );
|
||||||
if ( root.hasNode( path ) )
|
if ( root.hasNode( path ) )
|
||||||
{
|
{
|
||||||
|
@ -486,7 +487,7 @@ public class JcrMetadataRepository
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
String path = getFacetPath( repositoryId, facetId, name );
|
String path = getFacetPath( repositoryId, facetId, name );
|
||||||
if ( root.hasNode( path ) )
|
if ( root.hasNode( path ) )
|
||||||
{
|
{
|
||||||
|
@ -525,8 +526,8 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
|
Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
|
||||||
ValueFactory valueFactory = session.getValueFactory();
|
ValueFactory valueFactory = getJcrSession().getValueFactory();
|
||||||
if ( startTime != null )
|
if ( startTime != null )
|
||||||
{
|
{
|
||||||
query.bindValue( "start", valueFactory.createValue( createCalendar( startTime ) ) );
|
query.bindValue( "start", valueFactory.createValue( createCalendar( startTime ) ) );
|
||||||
|
@ -557,7 +558,7 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
if ( root.hasNode( "repositories" ) )
|
if ( root.hasNode( "repositories" ) )
|
||||||
{
|
{
|
||||||
Node node = root.getNode( "repositories" );
|
Node node = root.getNode( "repositories" );
|
||||||
|
@ -591,8 +592,8 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
|
Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
|
||||||
ValueFactory valueFactory = session.getValueFactory();
|
ValueFactory valueFactory = getJcrSession().getValueFactory();
|
||||||
query.bindValue( "checksum", valueFactory.createValue( checksum ) );
|
query.bindValue( "checksum", valueFactory.createValue( checksum ) );
|
||||||
QueryResult result = query.execute();
|
QueryResult result = query.execute();
|
||||||
|
|
||||||
|
@ -615,7 +616,7 @@ public class JcrMetadataRepository
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
String path = getArtifactPath( repositoryId, namespace, projectId, projectVersion, id );
|
String path = getArtifactPath( repositoryId, namespace, projectId, projectVersion, id );
|
||||||
if ( root.hasNode( path ) )
|
if ( root.hasNode( path ) )
|
||||||
{
|
{
|
||||||
|
@ -633,7 +634,7 @@ public class JcrMetadataRepository
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
String path = getRepositoryPath( repositoryId );
|
String path = getRepositoryPath( repositoryId );
|
||||||
if ( root.hasNode( path ) )
|
if ( root.hasNode( path ) )
|
||||||
{
|
{
|
||||||
|
@ -655,7 +656,7 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
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();
|
QueryResult result = query.execute();
|
||||||
|
|
||||||
artifacts = new ArrayList<ArtifactMetadata>();
|
artifacts = new ArrayList<ArtifactMetadata>();
|
||||||
|
@ -687,7 +688,7 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
|
|
||||||
// basically just checking it exists
|
// basically just checking it exists
|
||||||
String path = getProjectPath( repositoryId, namespace, projectId );
|
String path = getProjectPath( repositoryId, namespace, projectId );
|
||||||
|
@ -714,7 +715,7 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
|
|
||||||
String path = getProjectVersionPath( repositoryId, namespace, projectId, projectVersion );
|
String path = getProjectVersionPath( repositoryId, namespace, projectId, projectVersion );
|
||||||
if ( !root.hasNode( path ) )
|
if ( !root.hasNode( path ) )
|
||||||
|
@ -729,8 +730,8 @@ public class JcrMetadataRepository
|
||||||
versionMetadata.setName( getPropertyString( node, "name" ) );
|
versionMetadata.setName( getPropertyString( node, "name" ) );
|
||||||
versionMetadata.setDescription( getPropertyString( node, "description" ) );
|
versionMetadata.setDescription( getPropertyString( node, "description" ) );
|
||||||
versionMetadata.setUrl( getPropertyString( node, "url" ) );
|
versionMetadata.setUrl( getPropertyString( node, "url" ) );
|
||||||
versionMetadata.setIncomplete( node.hasProperty( "incomplete" ) && node.getProperty(
|
versionMetadata.setIncomplete(
|
||||||
"incomplete" ).getBoolean() );
|
node.hasProperty( "incomplete" ) && node.getProperty( "incomplete" ).getBoolean() );
|
||||||
|
|
||||||
// FIXME: decide how to treat these in the content repo
|
// FIXME: decide how to treat these in the content repo
|
||||||
String scmConnection = getPropertyString( node, "scm.connection" );
|
String scmConnection = getPropertyString( node, "scm.connection" );
|
||||||
|
@ -892,7 +893,7 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
|
|
||||||
Node node = root.getNode( getProjectVersionPath( repositoryId, namespace, projectId, projectVersion ) );
|
Node node = root.getNode( getProjectVersionPath( repositoryId, namespace, projectId, projectVersion ) );
|
||||||
|
|
||||||
|
@ -928,7 +929,7 @@ public class JcrMetadataRepository
|
||||||
}
|
}
|
||||||
try
|
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();
|
QueryResult result = query.execute();
|
||||||
|
|
||||||
for ( Node n : JcrUtils.getNodes( result ) )
|
for ( Node n : JcrUtils.getNodes( result ) )
|
||||||
|
@ -996,7 +997,7 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
String path = getProjectVersionPath( repositoryId, namespace, projectId, projectVersion );
|
String path = getProjectVersionPath( repositoryId, namespace, projectId, projectVersion );
|
||||||
|
|
||||||
if ( root.hasNode( path ) )
|
if ( root.hasNode( path ) )
|
||||||
|
@ -1024,7 +1025,7 @@ public class JcrMetadataRepository
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
session.save();
|
getJcrSession().save();
|
||||||
}
|
}
|
||||||
catch ( RepositoryException e )
|
catch ( RepositoryException e )
|
||||||
{
|
{
|
||||||
|
@ -1036,7 +1037,7 @@ public class JcrMetadataRepository
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
session.refresh( false );
|
getJcrSession().refresh( false );
|
||||||
}
|
}
|
||||||
catch ( RepositoryException e )
|
catch ( RepositoryException e )
|
||||||
{
|
{
|
||||||
|
@ -1050,18 +1051,39 @@ public class JcrMetadataRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object obtainAccess( Class<?> aClass )
|
public Object obtainAccess( Class<?> aClass )
|
||||||
|
throws MetadataRepositoryException
|
||||||
{
|
{
|
||||||
if ( aClass == Session.class )
|
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(
|
throw new IllegalArgumentException(
|
||||||
"Access using " + aClass + " is not supported on the JCR metadata storage" );
|
"Access using " + aClass + " is not supported on the JCR metadata storage" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close()
|
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 )
|
private ArtifactMetadata getArtifactFromNode( String repositoryId, Node artifactNode )
|
||||||
|
@ -1152,7 +1174,7 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
|
|
||||||
Node nodeAtPath = root.getNode( path );
|
Node nodeAtPath = root.getNode( path );
|
||||||
|
|
||||||
|
@ -1242,7 +1264,7 @@ public class JcrMetadataRepository
|
||||||
private Node getOrAddRepositoryNode( String repositoryId )
|
private Node getOrAddRepositoryNode( String repositoryId )
|
||||||
throws RepositoryException
|
throws RepositoryException
|
||||||
{
|
{
|
||||||
Node root = session.getRootNode();
|
Node root = getJcrSession().getRootNode();
|
||||||
Node node = JcrUtils.getOrAddNode( root, "repositories" );
|
Node node = JcrUtils.getOrAddNode( root, "repositories" );
|
||||||
node = JcrUtils.getOrAddNode( node, repositoryId );
|
node = JcrUtils.getOrAddNode( node, repositoryId );
|
||||||
return node;
|
return node;
|
||||||
|
@ -1314,7 +1336,14 @@ public class JcrMetadataRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session getJcrSession()
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ public class JcrRepositorySessionFactory
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initialize()
|
public void initialize()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
metadataFacetFactories = applicationContext.getBeansOfType( MetadataFacetFactory.class );
|
metadataFacetFactories = applicationContext.getBeansOfType( MetadataFacetFactory.class );
|
||||||
// olamy with spring the "id" is now "metadataFacetFactory#hint"
|
// olamy with spring the "id" is now "metadataFacetFactory#hint"
|
||||||
|
|
|
@ -181,6 +181,7 @@ public class DuplicateArtifactsConsumer
|
||||||
}
|
}
|
||||||
catch ( MetadataRepositoryException e )
|
catch ( MetadataRepositoryException e )
|
||||||
{
|
{
|
||||||
|
repositorySession.close();
|
||||||
throw new ConsumerException( e.getMessage(), e );
|
throw new ConsumerException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue