[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:
Olivier Lamy 2012-10-22 14:49:23 +00:00
parent 555d674987
commit 0af1bd62e7
13 changed files with 306 additions and 92 deletions

View File

@ -32,8 +32,6 @@
/** /**
* ManagedRepositoryContent interface for interacting with a managed repository in an abstract way, * 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. * without the need for processing based on filesystem paths, or working with the database.
*
*
*/ */
public interface ManagedRepositoryContent public interface ManagedRepositoryContent
{ {
@ -57,13 +55,22 @@ void deleteArtifact( ArtifactReference artifactReference )
throws ContentNotFoundException; throws ContentNotFoundException;
/** /**
* @since 1.4-M3
* @param groupId * @param groupId
* @throws ContentNotFoundException * @throws ContentNotFoundException
* @since 1.4-M3
*/ */
void deleteGroupId( String groupId ) void deleteGroupId( String groupId )
throws ContentNotFoundException; throws ContentNotFoundException;
/**
*
* @param namespace groupId for maven
* @param projectId artifactId for maven
* @throws ContentNotFoundException
*/
void deleteProject( String namespace, String projectId )
throws RepositoryException;
/** /**
* <p> * <p>
* Convenience method to get the repository id. * Convenience method to get the repository id.

View File

@ -19,16 +19,16 @@
* under the License. * 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.RepositoryPathTranslator;
import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider; import org.apache.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
import org.apache.archiva.metadata.repository.storage.maven2.Maven2RepositoryPathTranslator; 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.ArchivaArtifact;
import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference; import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.layout.LayoutException; import org.apache.archiva.repository.layout.LayoutException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -38,8 +38,6 @@
/** /**
* AbstractDefaultRepositoryContent - common methods for working with default (maven 2) layout. * AbstractDefaultRepositoryContent - common methods for working with default (maven 2) layout.
*
*
*/ */
public abstract class AbstractDefaultRepositoryContent public abstract class AbstractDefaultRepositoryContent
{ {
@ -120,9 +118,13 @@ public String toPath( ArtifactReference reference )
{ {
throw new IllegalArgumentException( "Artifact reference cannot be null" ); throw new IllegalArgumentException( "Artifact reference cannot be null" );
} }
if ( reference.getVersion() != null )
String baseVersion = VersionUtil.getBaseVersion( reference.getVersion() ); {
return toPath( reference.getGroupId(), reference.getArtifactId(), baseVersion, reference.getVersion(), 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() ); reference.getClassifier(), reference.getType() );
} }

View File

@ -29,6 +29,7 @@
import org.apache.archiva.model.VersionedReference; import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.ContentNotFoundException;
import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.layout.LayoutException; import org.apache.archiva.repository.layout.LayoutException;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -45,17 +46,15 @@
/** /**
* ManagedDefaultRepositoryContent * ManagedDefaultRepositoryContent
*
*
*/ */
@Service( "managedRepositoryContent#default" ) @Service ("managedRepositoryContent#default")
@Scope( "prototype" ) @Scope ("prototype")
public class ManagedDefaultRepositoryContent public class ManagedDefaultRepositoryContent
extends AbstractDefaultRepositoryContent extends AbstractDefaultRepositoryContent
implements ManagedRepositoryContent implements ManagedRepositoryContent
{ {
@Inject @Inject
@Named( value = "fileTypes" ) @Named (value = "fileTypes")
private FileTypes filetypes; private FileTypes filetypes;
private ManagedRepository repository; 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 ) public void deleteArtifact( ArtifactReference artifactReference )
{ {
String path = toPath( artifactReference ); String path = toPath( artifactReference );

View File

@ -28,6 +28,7 @@
import org.apache.archiva.model.VersionedReference; import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.ContentNotFoundException; import org.apache.archiva.repository.ContentNotFoundException;
import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.layout.LayoutException; import org.apache.archiva.repository.layout.LayoutException;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; 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 ) private void deleteSupportFiles( File repoFile )
{ {
deleteSupportFile( repoFile, ".sha1" ); deleteSupportFile( repoFile, ".sha1" );

View File

@ -20,13 +20,13 @@
*/ */
import org.apache.archiva.maven2.model.Artifact; 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.redback.authorization.RedbackAuthorization;
import org.apache.archiva.repository.scanner.RepositoryScanStatistics; import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
import org.apache.archiva.rest.api.model.ArtifactTransferRequest; import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
import org.apache.archiva.security.common.ArchivaRoleConstants; import org.apache.archiva.security.common.ArchivaRoleConstants;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
@ -34,67 +34,66 @@
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.List;
/** /**
* @author Olivier Lamy * @author Olivier Lamy
* @since 1.4-M1 * @since 1.4-M1
*/ */
@Path ( "/repositoriesService/" ) @Path ("/repositoriesService/")
public interface RepositoriesService public interface RepositoriesService
{ {
@Path ( "scanRepository" ) @Path ("scanRepository")
@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)
/** /**
* index repository * index repository
*/ */
Boolean scanRepository( @QueryParam ( "repositoryId" ) String repositoryId, Boolean scanRepository( @QueryParam ("repositoryId") String repositoryId,
@QueryParam ( "fullScan" ) boolean fullScan ) @QueryParam ("fullScan") boolean fullScan )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ( "scanRepositoryDirectoriesNow/{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)
/** /**
* scan directories * scan directories
* @since 1.4-M3 * @since 1.4-M3
*/ */
RepositoryScanStatistics scanRepositoryDirectoriesNow( @PathParam ( "repositoryId" ) String repositoryId ) RepositoryScanStatistics scanRepositoryDirectoriesNow( @PathParam ("repositoryId") String repositoryId )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ( "alreadyScanning/{repositoryId}" ) @Path ("alreadyScanning/{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)
Boolean alreadyScanning( @PathParam ( "repositoryId" ) String repositoryId ) Boolean alreadyScanning( @PathParam ("repositoryId") String repositoryId )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ( "removeScanningTaskFromQueue/{repositoryId}" ) @Path ("removeScanningTaskFromQueue/{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)
Boolean removeScanningTaskFromQueue( @PathParam ( "repositoryId" ) String repositoryId ) Boolean removeScanningTaskFromQueue( @PathParam ("repositoryId") String repositoryId )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ( "scanRepositoryNow" ) @Path ("scanRepositoryNow")
@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)
Boolean scanRepositoryNow( @QueryParam ( "repositoryId" ) String repositoryId, Boolean scanRepositoryNow( @QueryParam ("repositoryId") String repositoryId,
@QueryParam ( "fullScan" ) boolean fullScan ) @QueryParam ("fullScan") boolean fullScan )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ( "copyArtifact" ) @Path ("copyArtifact")
@POST @POST
@Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Consumes ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
@RedbackAuthorization ( noPermission = true ) @RedbackAuthorization (noPermission = true)
/** /**
* permissions are checked in impl * permissions are checked in impl
* will copy an artifact from the source repository to the target repository * 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 ) Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ( "scheduleDownloadRemoteIndex" ) @Path ("scheduleDownloadRemoteIndex")
@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)
Boolean scheduleDownloadRemoteIndex( @QueryParam ( "repositoryId" ) String repositoryId, Boolean scheduleDownloadRemoteIndex( @QueryParam ("repositoryId") String repositoryId,
@QueryParam ( "now" ) boolean now, @QueryParam ("now") boolean now,
@QueryParam ( "fullDownload" ) boolean fullDownload ) @QueryParam ("fullDownload") boolean fullDownload )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ( "deleteArtifact" ) @Path ("deleteArtifact")
@POST @POST
@Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Consumes ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
@RedbackAuthorization ( noPermission = true ) @RedbackAuthorization (noPermission = true)
/** /**
* <b>permissions are checked in impl</b> * <b>permissions are checked in impl</b>
* @since 1.4-M2 * @since 1.4-M2
@ -124,25 +123,35 @@ Boolean scheduleDownloadRemoteIndex( @QueryParam ( "repositoryId" ) String repos
Boolean deleteArtifact( Artifact artifact ) Boolean deleteArtifact( Artifact artifact )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ( "isAuthorizedToDeleteArtifacts/{repositoryId}" ) @Path ("isAuthorizedToDeleteArtifacts/{repositoryId}")
@GET @GET
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
@RedbackAuthorization ( noPermission = true, noRestriction = true ) @RedbackAuthorization (noPermission = true, noRestriction = true)
Boolean isAuthorizedToDeleteArtifacts( @PathParam ( "repositoryId" ) String repoId ) Boolean isAuthorizedToDeleteArtifacts( @PathParam ("repositoryId") String repoId )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path ( "deleteGroupId" ) @Path ("deleteGroupId")
@GET @GET
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
@RedbackAuthorization ( noPermission = true ) @RedbackAuthorization (noPermission = true)
/** /**
* <b>permissions are checked in impl</b> * <b>permissions are checked in impl</b>
* @since 1.4-M3 * @since 1.4-M3
*/ */
Boolean deleteGroupId( @QueryParam ( "groupId" ) String groupId, Boolean deleteGroupId( @QueryParam ("groupId") String groupId, @QueryParam ("repositoryId") String repositoryId )
@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; throws ArchivaRestServiceException;
} }

View File

@ -851,7 +851,7 @@ public Boolean deleteGroupId( String groupId, String repositoryId )
if ( StringUtils.isEmpty( groupId ) ) 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(); RepositorySession repositorySession = repositorySessionFactory.createSession();
@ -886,6 +886,70 @@ public Boolean deleteGroupId( String groupId, String repositoryId )
return true; 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 ) public Boolean isAuthorizedToDeleteArtifacts( String repoId )
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {

View File

@ -176,37 +176,37 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
var self = this; var self = this;
this.artifactMenuItems = ko.observableArray([ this.artifactMenuItems = ko.observableArray([
{ text : $.i18n.prop('menu.artifacts') , id: null}, { 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.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.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.upload') , id: "menu-find-upload-a", href: "#upload" , redback: "{permissions: ['archiva-upload-repository']}", func: function(){displayUploadArtifact(true)}}
]); ]);
this.administrationMenuItems = ko.observableArray([ this.administrationMenuItems = ko.observableArray([
{ text : $.i18n.prop('menu.administration') , id: null}, { 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.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.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') , 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.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.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.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.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.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.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.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.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.reports') , id: "menu-report-list-a" , href: "#reports" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayReportsPage()}}
]); ]);
this.usersMenuItems = ko.observableArray([ this.usersMenuItems = ko.observableArray([
{ text : $.i18n.prop('menu.users') , id: null}, { 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.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.roles') , id: "menu-roles-list-a", href: "#roles" , redback: "{permissions: ['archiva-manage-users']}", func: function(){displayRolesGrid()}}
]); ]);
this.docsMenuItems = ko.observableArray([ this.docsMenuItems = ko.observableArray([
{ text : $.i18n.prop('menu.docs') , id: null}, { 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.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.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(); this.activeMenuId = ko.observable();

View File

@ -195,6 +195,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
} }
this.save=function(){ this.save=function(){
$.log('managedrepo save');
var valid = $("#main-content").find("#managed-repository-edit-form").valid(); var valid = $("#main-content").find("#managed-repository-edit-form").valid();
if (valid==false) { if (valid==false) {
return; return;

View File

@ -86,6 +86,55 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
return hasKarma('archiva-delete-artifact'); 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){ deleteGroupId=function(groupId){
var repoId=getSelectedBrowsingRepository(); var repoId=getSelectedBrowsingRepository();
@ -129,7 +178,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
$.i18n.prop('cancel'), $.i18n.prop('cancel'),
$.i18n.prop('groupId.delete.confirm.title'), $.i18n.prop('groupId.delete.confirm.title'),
$.i18n.prop('groupId.delete.confirm.save',groupId)); $.i18n.prop('groupId.delete.confirm.save',groupId));
}
} }
calculateBreadCrumbEntries=function(groupId){ calculateBreadCrumbEntries=function(groupId){

View File

@ -53,7 +53,7 @@
{{if browseResultEntry.project}} {{if browseResultEntry.project}}
{{if deleteKarma}} {{if deleteKarma}}
<li class="browse-list-project"> <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> <a href="#" data-bind="click:function(){displayProjectEntry(browseResultEntry.name)}">${displayEntry(browseResultEntry.name)}</a>
</li> </li>
{{else}} {{else}}

View File

@ -160,13 +160,12 @@ Collection<String> getProjectVersions( String repoId, String namespace, String p
throws MetadataResolutionException; throws MetadataResolutionException;
/** /**
*
* @param repoId * @param repoId
* @param namespace * @param namespace
* @param projectId * @param projectId
* @param projectVersion * @param projectVersion
* @since 1.4-M4
* @throws MetadataResolutionException * @throws MetadataResolutionException
* @since 1.4-M4
*/ */
void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException; throws MetadataRepositoryException;
@ -175,6 +174,18 @@ Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, Stri
String projectVersion ) String projectVersion )
throws MetadataResolutionException; 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 save();
void close() void close()

View File

@ -1162,6 +1162,11 @@ public Collection<String> getProjectVersions( String repoId, String namespace, S
return projectVersions; 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 ) public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException throws MetadataRepositoryException

View File

@ -62,6 +62,7 @@
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; 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 ) public List<String> getMetadataFacets( String repositoryId, String facetId )
throws MetadataRepositoryException throws MetadataRepositoryException
{ {