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;
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -58,7 +58,7 @@ managedrepository.delete.content=Delete Content too ?
|
|||
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 Repository {0} updated.
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -93,10 +93,18 @@ public class RepositorySession
|
|||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
repository.close();
|
||||
}
|
||||
catch ( MetadataRepositoryException e )
|
||||
{
|
||||
throw new RuntimeException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void markDirty()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -181,6 +181,7 @@ public class DuplicateArtifactsConsumer
|
|||
}
|
||||
catch ( MetadataRepositoryException e )
|
||||
{
|
||||
repositorySession.close();
|
||||
throw new ConsumerException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue