How to delete a JCR workspace
This page explains how to delete a JCR workspace on a Magnolia system.
JCR API and Jackrabbit
You cannot delete a JCR workspace programmatically with Magnolia. You must delete it manually.
Apache Jackrabbit, which is the JCR implementation used by Magnolia, doesn’t implement the #deleteWorkpace
method defined in the JCR 2.0 API (see javax.jcr.Workspace).
org.apache.jackrabbit.core.WorkspaceImpl#delete
public void deleteWorkspace(String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
this.context.getRepository().getWorkspaceInfo(name);
this.context.getAccessManager().checkRepositoryPermission(32768);
throw new UnsupportedRepositoryOperationException("not yet implemented");
}
For more information, see ApacheJackrabbit - Frequently Asked Questions.
Deleting a workspace manually
Before starting:
-
Note that deletion cannot be reverted.
-
Ensure that the workspace you want to delete doesn’t contain content you still require.
-
Shut down the application server (such as Tomcat) before manually deleting. You can’t delete a workspace on a running system.
Overview
There are two main steps involved in deleting a workspace manually:
-
Delete the folder
$magnolia.repositories.home/magnolia/workspaces/$workspace-name
. -
Delete database tables with table names containing the workspace name.
On embedded databases such as H2, you can skip step 2.
Deleting the workspace folder in the repository folder
For every JCR workspace, there is a folder on the file system.
The value of the magnolia.repositories.home
property defines the location of these folders.
-
Check the value for your system:
-
If your system is still running, use the About app to look up the property.
-
Alternatively, check the
magnolia.properties
files where the property is defined.
-
-
Determine the path for
$magnolia.repositories.home/magnolia/workspaces/$workspace-name
and delete the folder.
|
|
Workspace name |
|
Folder to delete |
|
Deleting database tables
You should delete all tables which contain the JCR workspace name.
Your approach when deleting these tables depends on the persistence layer. Some examples of persistence layers are:
The value of the Magnolia property magnolia.repositories.jackrabbit.config
gives an indication of the persistence layer in use.
Jackrabbit persistence layer |
MySQL (Version 14.14, Distribution 5.7.20, for Linux (x86_64)) |
Workspace name |
|
Table names in MySQL DB |
|
Multiple instances and clustering
Depending on how your Magnolia instances are set up and if you use clustering, you must delete a workspace in one or several locations.
Make sure you delete the workspace on both the author instance and on all public instances. |