import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
+import java.util.function.Function;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
return mountPath;
}
+ public synchronized <T> T doInAdminSession(Function<Session, T> toDo) {
+ try {
+ return toDo.apply(adminSession);
+ } finally {
+ try {
+ if (adminSession.hasPendingChanges())
+ adminSession.save();
+ } catch (RepositoryException e) {
+ throw new JcrException("Cannot save admin session", e);
+ }
+ }
+ }
+
/*
* NAMESPACE CONTEXT
*/
@Override
- public String getNamespaceURI(String prefix) {
+ public synchronized String getNamespaceURI(String prefix) {
try {
return adminSession.getNamespaceURI(prefix);
} catch (RepositoryException e) {
}
@Override
- public String getPrefix(String namespaceURI) {
+ public synchronized String getPrefix(String namespaceURI) {
try {
return adminSession.getNamespacePrefix(namespaceURI);
} catch (RepositoryException e) {
}
@Override
- public Iterator<String> getPrefixes(String namespaceURI) {
+ public synchronized Iterator<String> getPrefixes(String namespaceURI) {
try {
return Arrays.asList(adminSession.getNamespacePrefix(namespaceURI)).iterator();
} catch (RepositoryException e) {
// } catch (InterruptedException e1) {
// // ignore
// }
-
+
workspaceSession = repository.login(credentials, workspaceName);
}
return workspaceSession;
/**
* Convenience method for adding a single privilege to a principal (user or
- * role), typically jcr:all
+ * role), typically jcr:all. Session is saved.
*/
public synchronized static void addPrivilege(Session session, String path, String principal, String privilege)
throws RepositoryException {