mirror of
https://github.com/apache/archiva.git
synced 2025-02-21 01:15:08 +00:00
[MRM-1703] Cannot delete project with the ui.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1400901 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
555d674987
commit
0af1bd62e7
@ -32,8 +32,6 @@
|
||||
/**
|
||||
* ManagedRepositoryContent interface for interacting with a managed repository in an abstract way,
|
||||
* without the need for processing based on filesystem paths, or working with the database.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface ManagedRepositoryContent
|
||||
{
|
||||
@ -57,13 +55,22 @@ void deleteArtifact( ArtifactReference artifactReference )
|
||||
throws ContentNotFoundException;
|
||||
|
||||
/**
|
||||
* @since 1.4-M3
|
||||
* @param groupId
|
||||
* @throws ContentNotFoundException
|
||||
* @since 1.4-M3
|
||||
*/
|
||||
void deleteGroupId( String groupId )
|
||||
throws ContentNotFoundException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param namespace groupId for maven
|
||||
* @param projectId artifactId for maven
|
||||
* @throws ContentNotFoundException
|
||||
*/
|
||||
void deleteProject( String namespace, String projectId )
|
||||
throws RepositoryException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Convenience method to get the repository id.
|
||||
|
@ -19,16 +19,16 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.common.utils.VersionUtil;
|
||||
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
|
||||
import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
|
||||
import org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryPathTranslator;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.archiva.common.utils.VersionUtil;
|
||||
import org.apache.archiva.model.ArchivaArtifact;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.archiva.model.ProjectReference;
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.layout.LayoutException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -38,8 +38,6 @@
|
||||
|
||||
/**
|
||||
* AbstractDefaultRepositoryContent - common methods for working with default (maven 2) layout.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractDefaultRepositoryContent
|
||||
{
|
||||
@ -120,9 +118,13 @@ public String toPath( ArtifactReference reference )
|
||||
{
|
||||
throw new IllegalArgumentException( "Artifact reference cannot be null" );
|
||||
}
|
||||
|
||||
String baseVersion = VersionUtil.getBaseVersion( reference.getVersion() );
|
||||
return toPath( reference.getGroupId(), reference.getArtifactId(), baseVersion, reference.getVersion(),
|
||||
if ( reference.getVersion() != null )
|
||||
{
|
||||
String baseVersion = VersionUtil.getBaseVersion( reference.getVersion() );
|
||||
return toPath( reference.getGroupId(), reference.getArtifactId(), baseVersion, reference.getVersion(),
|
||||
reference.getClassifier(), reference.getType() );
|
||||
}
|
||||
return toPath( reference.getGroupId(), reference.getArtifactId(), null, null,
|
||||
reference.getClassifier(), reference.getType() );
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.layout.LayoutException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -45,17 +46,15 @@
|
||||
|
||||
/**
|
||||
* ManagedDefaultRepositoryContent
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Service( "managedRepositoryContent#default" )
|
||||
@Scope( "prototype" )
|
||||
@Service ("managedRepositoryContent#default")
|
||||
@Scope ("prototype")
|
||||
public class ManagedDefaultRepositoryContent
|
||||
extends AbstractDefaultRepositoryContent
|
||||
implements ManagedRepositoryContent
|
||||
{
|
||||
@Inject
|
||||
@Named( value = "fileTypes" )
|
||||
@Named (value = "fileTypes")
|
||||
private FileTypes filetypes;
|
||||
|
||||
private ManagedRepository repository;
|
||||
@ -78,6 +77,36 @@ public void deleteVersion( VersionedReference reference )
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteProject( String namespace, String projectId )
|
||||
throws RepositoryException, ContentNotFoundException
|
||||
{
|
||||
ArtifactReference artifactReference = new ArtifactReference();
|
||||
artifactReference.setGroupId( namespace );
|
||||
artifactReference.setArtifactId( projectId );
|
||||
String path = toPath( artifactReference );
|
||||
File directory = new File( getRepoRoot(), path );
|
||||
if ( !directory.exists() )
|
||||
{
|
||||
throw new ContentNotFoundException( "cannot found project " + namespace + ":" + projectId );
|
||||
}
|
||||
if ( directory.isDirectory() )
|
||||
{
|
||||
try
|
||||
{
|
||||
FileUtils.deleteDirectory( directory );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RepositoryException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn( "project {}:{} is not a directory", namespace, projectId );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deleteArtifact( ArtifactReference artifactReference )
|
||||
{
|
||||
String path = toPath( artifactReference );
|
||||
|
@ -28,6 +28,7 @@
|
||||
import org.apache.archiva.model.VersionedReference;
|
||||
import org.apache.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.layout.LayoutException;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -128,6 +129,12 @@ private void deleteVersions( File typeDir, VersionedReference reference )
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteProject( String namespace, String projectId )
|
||||
throws RepositoryException
|
||||
{
|
||||
// TODO implements ??
|
||||
}
|
||||
|
||||
private void deleteSupportFiles( File repoFile )
|
||||
{
|
||||
deleteSupportFile( repoFile, ".sha1" );
|
||||
|
@ -20,13 +20,13 @@
|
||||
*/
|
||||
|
||||
import org.apache.archiva.maven2.model.Artifact;
|
||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.redback.authorization.RedbackAuthorization;
|
||||
import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
|
||||
import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
|
||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
@ -34,67 +34,66 @@
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
* @since 1.4-M1
|
||||
*/
|
||||
@Path ( "/repositoriesService/" )
|
||||
@Path ("/repositoriesService/")
|
||||
public interface RepositoriesService
|
||||
{
|
||||
|
||||
@Path ( "scanRepository" )
|
||||
@Path ("scanRepository")
|
||||
@GET
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
|
||||
/**
|
||||
* index repository
|
||||
*/
|
||||
Boolean scanRepository( @QueryParam ( "repositoryId" ) String repositoryId,
|
||||
@QueryParam ( "fullScan" ) boolean fullScan )
|
||||
Boolean scanRepository( @QueryParam ("repositoryId") String repositoryId,
|
||||
@QueryParam ("fullScan") boolean fullScan )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
|
||||
@Path ( "scanRepositoryDirectoriesNow/{repositoryId}" )
|
||||
@Path ("scanRepositoryDirectoriesNow/{repositoryId}")
|
||||
@GET
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
|
||||
/**
|
||||
* scan directories
|
||||
* @since 1.4-M3
|
||||
*/
|
||||
RepositoryScanStatistics scanRepositoryDirectoriesNow( @PathParam ( "repositoryId" ) String repositoryId )
|
||||
RepositoryScanStatistics scanRepositoryDirectoriesNow( @PathParam ("repositoryId") String repositoryId )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
|
||||
@Path ( "alreadyScanning/{repositoryId}" )
|
||||
@Path ("alreadyScanning/{repositoryId}")
|
||||
@GET
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
|
||||
Boolean alreadyScanning( @PathParam ( "repositoryId" ) String repositoryId )
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
|
||||
Boolean alreadyScanning( @PathParam ("repositoryId") String repositoryId )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path ( "removeScanningTaskFromQueue/{repositoryId}" )
|
||||
@Path ("removeScanningTaskFromQueue/{repositoryId}")
|
||||
@GET
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
|
||||
Boolean removeScanningTaskFromQueue( @PathParam ( "repositoryId" ) String repositoryId )
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
|
||||
Boolean removeScanningTaskFromQueue( @PathParam ("repositoryId") String repositoryId )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path ( "scanRepositoryNow" )
|
||||
@Path ("scanRepositoryNow")
|
||||
@GET
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
|
||||
Boolean scanRepositoryNow( @QueryParam ( "repositoryId" ) String repositoryId,
|
||||
@QueryParam ( "fullScan" ) boolean fullScan )
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
|
||||
Boolean scanRepositoryNow( @QueryParam ("repositoryId") String repositoryId,
|
||||
@QueryParam ("fullScan") boolean fullScan )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path ( "copyArtifact" )
|
||||
@Path ("copyArtifact")
|
||||
@POST
|
||||
@Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( noPermission = true )
|
||||
@Consumes ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (noPermission = true)
|
||||
/**
|
||||
* permissions are checked in impl
|
||||
* will copy an artifact from the source repository to the target repository
|
||||
@ -102,21 +101,21 @@ Boolean scanRepositoryNow( @QueryParam ( "repositoryId" ) String repositoryId,
|
||||
Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path ( "scheduleDownloadRemoteIndex" )
|
||||
@Path ("scheduleDownloadRemoteIndex")
|
||||
@GET
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER )
|
||||
Boolean scheduleDownloadRemoteIndex( @QueryParam ( "repositoryId" ) String repositoryId,
|
||||
@QueryParam ( "now" ) boolean now,
|
||||
@QueryParam ( "fullDownload" ) boolean fullDownload )
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER)
|
||||
Boolean scheduleDownloadRemoteIndex( @QueryParam ("repositoryId") String repositoryId,
|
||||
@QueryParam ("now") boolean now,
|
||||
@QueryParam ("fullDownload") boolean fullDownload )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
|
||||
@Path ( "deleteArtifact" )
|
||||
@Path ("deleteArtifact")
|
||||
@POST
|
||||
@Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( noPermission = true )
|
||||
@Consumes ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (noPermission = true)
|
||||
/**
|
||||
* <b>permissions are checked in impl</b>
|
||||
* @since 1.4-M2
|
||||
@ -124,25 +123,35 @@ Boolean scheduleDownloadRemoteIndex( @QueryParam ( "repositoryId" ) String repos
|
||||
Boolean deleteArtifact( Artifact artifact )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path ( "isAuthorizedToDeleteArtifacts/{repositoryId}" )
|
||||
@Path ("isAuthorizedToDeleteArtifacts/{repositoryId}")
|
||||
@GET
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( noPermission = true, noRestriction = true )
|
||||
Boolean isAuthorizedToDeleteArtifacts( @PathParam ( "repositoryId" ) String repoId )
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (noPermission = true, noRestriction = true)
|
||||
Boolean isAuthorizedToDeleteArtifacts( @PathParam ("repositoryId") String repoId )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path ( "deleteGroupId" )
|
||||
@Path ("deleteGroupId")
|
||||
@GET
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( noPermission = true )
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (noPermission = true)
|
||||
/**
|
||||
* <b>permissions are checked in impl</b>
|
||||
* @since 1.4-M3
|
||||
*/
|
||||
Boolean deleteGroupId( @QueryParam ( "groupId" ) String groupId,
|
||||
@QueryParam ( "repositoryId" ) String repositoryId )
|
||||
Boolean deleteGroupId( @QueryParam ("groupId") String groupId, @QueryParam ("repositoryId") String repositoryId )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path ( "project/{repositoryId}/{groupId}/{projectId}" )
|
||||
@DELETE
|
||||
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||
@RedbackAuthorization ( noPermission = true )
|
||||
/**
|
||||
* <b>permissions are checked in impl</b>
|
||||
* @since 1.4-M4
|
||||
*/
|
||||
Boolean deleteProject( @PathParam ( "groupId" ) String groupId, @PathParam ( "projectId" ) String projectId,
|
||||
@PathParam ( "repositoryId" ) String repositoryId )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -851,7 +851,7 @@ public Boolean deleteGroupId( String groupId, String repositoryId )
|
||||
|
||||
if ( StringUtils.isEmpty( groupId ) )
|
||||
{
|
||||
throw new ArchivaRestServiceException( "artifact.groupId cannot be null", 400, null );
|
||||
throw new ArchivaRestServiceException( "groupId cannot be null", 400, null );
|
||||
}
|
||||
|
||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
||||
@ -886,6 +886,70 @@ public Boolean deleteGroupId( String groupId, String repositoryId )
|
||||
return true;
|
||||
}
|
||||
|
||||
public Boolean deleteProject( String groupId, String projectId, String repositoryId )
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
if ( StringUtils.isEmpty( repositoryId ) )
|
||||
{
|
||||
throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null );
|
||||
}
|
||||
|
||||
if ( !isAuthorizedToDeleteArtifacts( repositoryId ) )
|
||||
{
|
||||
throw new ArchivaRestServiceException( "not authorized to delete artifacts", 403, null );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( groupId ) )
|
||||
{
|
||||
throw new ArchivaRestServiceException( "groupId cannot be null", 400, null );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( projectId ) )
|
||||
{
|
||||
throw new ArchivaRestServiceException( "artifactId cannot be null", 400, null );
|
||||
}
|
||||
|
||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
||||
|
||||
try
|
||||
{
|
||||
ManagedRepositoryContent repository = repositoryFactory.getManagedRepositoryContent( repositoryId );
|
||||
|
||||
repository.deleteProject( groupId, projectId );
|
||||
}
|
||||
catch ( ContentNotFoundException e )
|
||||
{
|
||||
log.warn( "skip ContentNotFoundException: {}", e.getMessage() );
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
MetadataRepository metadataRepository = repositorySession.getRepository();
|
||||
|
||||
metadataRepository.removeProject( repositoryId, groupId, projectId );
|
||||
|
||||
metadataRepository.save();
|
||||
}
|
||||
catch ( MetadataRepositoryException e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
throw new ArchivaRestServiceException( "Repository exception: " + e.getMessage(), 500, e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
repositorySession.close();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public Boolean isAuthorizedToDeleteArtifacts( String repoId )
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
|
@ -176,37 +176,37 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
|
||||
|
||||
var self = this;
|
||||
this.artifactMenuItems = ko.observableArray([
|
||||
{ text : $.i18n.prop('menu.artifacts') , id: null},
|
||||
{ text : $.i18n.prop('menu.artifacts.search') , id: "menu-find-search-a", href: "#search" , func: function(){displaySearch(this)}},
|
||||
{ text : $.i18n.prop('menu.artifacts.browse') , id: "menu-find-browse-a", href: "#browse" , func: function(){displayBrowse(true)}},
|
||||
{ text : $.i18n.prop('menu.artifacts.upload') , id: "menu-find-upload-a", href: "#upload" , redback: "{permissions: ['archiva-upload-repository']}", func: function(){displayUploadArtifact(true)}}
|
||||
{ text : $.i18n.prop('menu.artifacts') , id: null},
|
||||
{ text : $.i18n.prop('menu.artifacts.search') , id: "menu-find-search-a", href: "#search" , func: function(){displaySearch(this)}},
|
||||
{ text : $.i18n.prop('menu.artifacts.browse') , id: "menu-find-browse-a", href: "#browse" , func: function(){displayBrowse(true)}},
|
||||
{ text : $.i18n.prop('menu.artifacts.upload') , id: "menu-find-upload-a", href: "#upload" , redback: "{permissions: ['archiva-upload-repository']}", func: function(){displayUploadArtifact(true)}}
|
||||
]);
|
||||
this.administrationMenuItems = ko.observableArray([
|
||||
{ text : $.i18n.prop('menu.administration') , id: null},
|
||||
{ text : $.i18n.prop('menu.repository.groups') , id: "menu-repository-groups-list-a" , href: "#repositorygroup" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoryGroups()}},
|
||||
{ text : $.i18n.prop('menu.repositories') , id: "menu-repositories-list-a" , href: "#repositorylist" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoriesGrid()}},
|
||||
{ text : $.i18n.prop('menu.proxy-connectors') , id: "menu-proxy-connectors-list-a" , href: "#proxyconnectors" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayProxyConnectors()}},
|
||||
{ text : $.i18n.prop('menu.proxy-connectors-rules') , id: "menu.proxy-connectors-rules-list-a" , href: "#proxyconnectorsrules" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayProxyConnectorsRules()}},
|
||||
{ text : $.i18n.prop('menu.network-proxies') , id: "menu-network-proxies-list-a" , href: "#networkproxies" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayNetworkProxies()}},
|
||||
{ text : $.i18n.prop('menu.legacy-artifact-support') , id: "menu-legacy-support-list-a" , href: "#legacy" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayLegacyArtifactPathSupport()}},
|
||||
{ text : $.i18n.prop('menu.repository-scanning') , id: "menu-repository-scanning-list-a" , href: "#scanningList" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoryScanning()}},
|
||||
{ text : $.i18n.prop('menu.network-configuration') , id: "menu-network-configuration-list-a" , href: "#network" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayNetworkConfiguration()}},
|
||||
{ text : $.i18n.prop('menu.system-status') , id: "menu-system-status-list-a" , href: "#status" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displaySystemStatus()}},
|
||||
{ text : $.i18n.prop('menu.appearance-configuration') , id: "menu-appearance-list-a" , href: "#appearance" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayAppearanceConfiguration()}},
|
||||
{ text : $.i18n.prop('menu.ui-configuration') , id: "menu-ui-configuration-list-a" , href: "#uiconfig" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayUiConfiguration()}},
|
||||
{ text : $.i18n.prop('menu.reports') , id: "menu-report-list-a" , href: "#reports" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayReportsPage()}}
|
||||
{ text : $.i18n.prop('menu.administration') , id: null},
|
||||
{ text : $.i18n.prop('menu.repository.groups') , id: "menu-repository-groups-list-a" , href: "#repositorygroup" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoryGroups()}},
|
||||
{ text : $.i18n.prop('menu.repositories') , id: "menu-repositories-list-a" , href: "#repositorylist" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoriesGrid()}},
|
||||
{ text : $.i18n.prop('menu.proxy-connectors') , id: "menu-proxy-connectors-list-a" , href: "#proxyconnectors" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayProxyConnectors()}},
|
||||
{ text : $.i18n.prop('menu.proxy-connectors-rules') , id: "menu.proxy-connectors-rules-list-a" , href: "#proxyconnectorsrules" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayProxyConnectorsRules()}},
|
||||
{ text : $.i18n.prop('menu.network-proxies') , id: "menu-network-proxies-list-a" , href: "#networkproxies" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayNetworkProxies()}},
|
||||
{ text : $.i18n.prop('menu.legacy-artifact-support') , id: "menu-legacy-support-list-a" , href: "#legacy" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayLegacyArtifactPathSupport()}},
|
||||
{ text : $.i18n.prop('menu.repository-scanning') , id: "menu-repository-scanning-list-a" , href: "#scanningList" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoryScanning()}},
|
||||
{ text : $.i18n.prop('menu.network-configuration') , id: "menu-network-configuration-list-a" , href: "#network" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayNetworkConfiguration()}},
|
||||
{ text : $.i18n.prop('menu.system-status') , id: "menu-system-status-list-a" , href: "#status" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displaySystemStatus()}},
|
||||
{ text : $.i18n.prop('menu.appearance-configuration') , id: "menu-appearance-list-a" , href: "#appearance" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayAppearanceConfiguration()}},
|
||||
{ text : $.i18n.prop('menu.ui-configuration') , id: "menu-ui-configuration-list-a" , href: "#uiconfig" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayUiConfiguration()}},
|
||||
{ text : $.i18n.prop('menu.reports') , id: "menu-report-list-a" , href: "#reports" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayReportsPage()}}
|
||||
]);
|
||||
|
||||
this.usersMenuItems = ko.observableArray([
|
||||
{ text : $.i18n.prop('menu.users') , id: null},
|
||||
{ text : $.i18n.prop('menu.users.manage') , id: "menu-users-list-a", href: "#users" , redback: "{permissions: ['archiva-manage-users']}", func: function(){displayUsersGrid()}},
|
||||
{ text : $.i18n.prop('menu.users.roles') , id: "menu-roles-list-a", href: "#roles" , redback: "{permissions: ['archiva-manage-users']}", func: function(){displayRolesGrid()}}
|
||||
{ text : $.i18n.prop('menu.users') , id: null},
|
||||
{ text : $.i18n.prop('menu.users.manage') , id: "menu-users-list-a", href: "#users" , redback: "{permissions: ['archiva-manage-users']}", func: function(){displayUsersGrid()}},
|
||||
{ text : $.i18n.prop('menu.users.roles') , id: "menu-roles-list-a", href: "#roles" , redback: "{permissions: ['archiva-manage-users']}", func: function(){displayRolesGrid()}}
|
||||
]);
|
||||
|
||||
this.docsMenuItems = ko.observableArray([
|
||||
{ text : $.i18n.prop('menu.docs') , id: null},
|
||||
{ text : $.i18n.prop('menu.docs.rest') , id: "menu-docs-rest-list-a", href: "#docs-rest", target: "", func: function(){displayRestDocs()}},
|
||||
{ text : $.i18n.prop('menu.docs.users') , id: "menu-docs-users-list-a", href: "http://archiva.apache.org/docs/"+window.archivaRuntimeInfo.version, target: "_blank", func: function(){displayUsersDocs()}}
|
||||
{ text : $.i18n.prop('menu.docs') , id: null},
|
||||
{ text : $.i18n.prop('menu.docs.rest') , id: "menu-docs-rest-list-a", href: "#docs-rest", target: "", func: function(){displayRestDocs()}},
|
||||
{ text : $.i18n.prop('menu.docs.users') , id: "menu-docs-users-list-a", href: "http://archiva.apache.org/docs/"+window.archivaRuntimeInfo.version, target: "_blank", func: function(){displayUsersDocs()}}
|
||||
]);
|
||||
|
||||
this.activeMenuId = ko.observable();
|
||||
|
@ -195,6 +195,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
|
||||
}
|
||||
|
||||
this.save=function(){
|
||||
$.log('managedrepo save');
|
||||
var valid = $("#main-content").find("#managed-repository-edit-form").valid();
|
||||
if (valid==false) {
|
||||
return;
|
||||
|
@ -86,6 +86,55 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
|
||||
return hasKarma('archiva-delete-artifact');
|
||||
}
|
||||
|
||||
deleteProject=function(groupId,projectId){
|
||||
$.log("deleteProject:"+groupId+"/"+projectId);
|
||||
|
||||
var repoId=getSelectedBrowsingRepository();
|
||||
if(!repoId){
|
||||
var escapedGroupId=escapeDot(groupId );
|
||||
var selected = $("#main-content" ).find("#delete-"+escapedGroupId );
|
||||
selected.attr("data-content",$.i18n.prop('projectId.delete.missing.repoId'))
|
||||
selected.popover({
|
||||
html:true,
|
||||
template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><div class="popover-content"><p></p></div></div></div>',
|
||||
placement:'top',
|
||||
trigger:'manual'});
|
||||
selected.popover('show');
|
||||
selected.mouseover(function(){
|
||||
selected.popover("destroy");
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var previousHash=getUrlHash();
|
||||
$.log("previousHash:"+previousHash);
|
||||
openDialogConfirm(function(){
|
||||
$("#dialog-confirm-modal-ok").button('loading');
|
||||
$.ajax({
|
||||
url:"restServices/archivaServices/repositoriesService/project/"+repoId+"/"+groupId+"/"+projectId,
|
||||
type:"DELETE",
|
||||
dataType:"json",
|
||||
success:function(data){
|
||||
window.sammyArchivaApplication.setLocation(previousHash);
|
||||
refreshContent();
|
||||
displaySuccessMessage( $.i18n.prop("projectId.deleted", groupId,projectId));
|
||||
},
|
||||
error:function(data){
|
||||
displayRestError(data,"user-messages");
|
||||
},
|
||||
complete:function(){
|
||||
$("#dialog-confirm-modal-ok").button('reset');
|
||||
closeDialogConfirm();
|
||||
}
|
||||
});
|
||||
}, $.i18n.prop('ok'),
|
||||
$.i18n.prop('cancel'),
|
||||
$.i18n.prop('projectId.delete.confirm.title'),
|
||||
$.i18n.prop('projectId.delete.confirm.save',groupId));
|
||||
}
|
||||
}
|
||||
|
||||
deleteGroupId=function(groupId){
|
||||
|
||||
var repoId=getSelectedBrowsingRepository();
|
||||
@ -129,7 +178,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
|
||||
$.i18n.prop('cancel'),
|
||||
$.i18n.prop('groupId.delete.confirm.title'),
|
||||
$.i18n.prop('groupId.delete.confirm.save',groupId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
calculateBreadCrumbEntries=function(groupId){
|
||||
|
@ -53,7 +53,7 @@
|
||||
{{if browseResultEntry.project}}
|
||||
{{if deleteKarma}}
|
||||
<li class="browse-list-project">
|
||||
<img id="delete-${browseResultEntry.name}" src="images/trash.png" data-bind="click:function(){deleteGroupId(browseResultEntry.name)}"/>
|
||||
<img id="delete-${browseResultEntry.name}" src="images/trash.png" data-bind="click:function(){deleteProject(groupId,displayEntry(browseResultEntry.name))}"/>
|
||||
<a href="#" data-bind="click:function(){displayProjectEntry(browseResultEntry.name)}">${displayEntry(browseResultEntry.name)}</a>
|
||||
</li>
|
||||
{{else}}
|
||||
|
@ -160,13 +160,12 @@ Collection<String> getProjectVersions( String repoId, String namespace, String p
|
||||
throws MetadataResolutionException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param repoId
|
||||
* @param namespace
|
||||
* @param projectId
|
||||
* @param projectVersion
|
||||
* @since 1.4-M4
|
||||
* @throws MetadataResolutionException
|
||||
* @since 1.4-M4
|
||||
*/
|
||||
void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
|
||||
throws MetadataRepositoryException;
|
||||
@ -175,6 +174,18 @@ Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, Stri
|
||||
String projectVersion )
|
||||
throws MetadataResolutionException;
|
||||
|
||||
/**
|
||||
* remove a project
|
||||
* @param repositoryId
|
||||
* @param namespace
|
||||
* @param projectId
|
||||
* @throws MetadataRepositoryException
|
||||
* @since 1.4-M4
|
||||
*/
|
||||
void removeProject( String repositoryId, String namespace, String projectId )
|
||||
throws MetadataRepositoryException;
|
||||
|
||||
|
||||
void save();
|
||||
|
||||
void close()
|
||||
|
@ -1162,6 +1162,11 @@ public Collection<String> getProjectVersions( String repoId, String namespace, S
|
||||
return projectVersions;
|
||||
}
|
||||
|
||||
public void removeProject( String repositoryId, String namespace, String projectId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
|
||||
throws MetadataRepositoryException
|
||||
|
@ -62,6 +62,7 @@
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -367,6 +368,35 @@ public void updateNamespace( String repositoryId, String namespace )
|
||||
}
|
||||
}
|
||||
|
||||
public void removeProject( String repositoryId, String namespace, String projectId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
try
|
||||
{
|
||||
Node root = getJcrSession().getRootNode();
|
||||
String namespacePath = getNamespacePath( repositoryId, namespace );
|
||||
|
||||
if ( root.hasNode( namespacePath ) )
|
||||
{
|
||||
Iterator<Node> nodeIterator = JcrUtils.getChildNodes( root.getNode( namespacePath ) ).iterator();
|
||||
while ( nodeIterator.hasNext() )
|
||||
{
|
||||
Node node = nodeIterator.next();
|
||||
if ( node.isNodeType( PROJECT_NODE_TYPE ) && projectId.equals( node.getName() ) )
|
||||
{
|
||||
node.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
{
|
||||
throw new MetadataRepositoryException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<String> getMetadataFacets( String repositoryId, String facetId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user