From 2a00e308e58352d94abdd740415ca5ed34e7bdfb Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Thu, 29 Sep 2016 11:17:29 +0000 Subject: [PATCH] Adapt to changes in Commons git-svn-id: https://svn.argeo.org/slc/trunk@9212 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- demo/slc_demo_rap.properties | 1 - demo/slc_localrepo.properties | 42 ++++++ dep/org.argeo.slc.dep.minimal/pom.xml | 10 +- .../src/org/argeo/slc/SlcConstants.java | 2 +- .../ui/dist/commands/NormalizeWorkspace.java | 53 +++---- .../controllers/DistTreeContentProvider.java | 23 +-- .../client/ui/dist/wizards/FetchWizard.java | 3 +- .../ui/dist/wizards/RegisterRepoWizard.java | 6 +- .../META-INF/spring/osgi.xml | 2 +- org.argeo.slc.core/bnd.bnd | 1 + .../slc/core/execution/ExecutionThread.java | 79 +++++----- .../slc/core/execution/ProcessThread.java | 69 ++++++--- .../org/argeo/slc/jcr/execution/JcrAgent.java | 30 ++-- .../META-INF/spring/jackrabbit.xml | 2 +- .../src/org/argeo/slc/repo/RepoConstants.java | 33 ++-- .../src/org/argeo/slc/repo/RepoSync.java | 142 ++++++------------ .../argeo/slc/repo/osgi/OsgiFactoryImpl.java | 8 +- .../META-INF/spring/jcr.xml | 2 +- pom.xml | 25 +-- 19 files changed, 267 insertions(+), 266 deletions(-) create mode 100644 demo/slc_localrepo.properties diff --git a/demo/slc_demo_rap.properties b/demo/slc_demo_rap.properties index 6906d81d6..ca7272aeb 100644 --- a/demo/slc_demo_rap.properties +++ b/demo/slc_demo_rap.properties @@ -14,7 +14,6 @@ argeo.osgi.start.4.workbench=\ org.eclipse.equinox.http.registry,\ argeo.osgi.start.5.slc=\ -org.argeo.slc.node.jackrabbit,\ org.argeo.slc.agent,\ org.argeo.slc.agent.jcr,\ org.argeo.slc.server.repo,\ diff --git a/demo/slc_localrepo.properties b/demo/slc_localrepo.properties new file mode 100644 index 000000000..499e9e6d8 --- /dev/null +++ b/demo/slc_localrepo.properties @@ -0,0 +1,42 @@ +argeo.osgi.start.2.http=\ +org.eclipse.equinox.http.servlet,\ +org.eclipse.equinox.http.jetty,\ +org.eclipse.equinox.cm,\ +org.eclipse.rap.rwt.osgi + +argeo.osgi.start.3.node=\ +org.argeo.cms + +argeo.osgi.start.4.apps=\ +org.eclipse.gemini.blueprint.extender + +argeo.osgi.start.4.workbench=\ +org.eclipse.equinox.http.registry,\ + +argeo.osgi.start.5.slc=\ +org.argeo.slc.agent,\ +org.argeo.slc.agent.jcr,\ +org.argeo.slc.server.repo,\ + +slc.executionModules=org.argeo.tp.factory.core,\ +org.argeo.tp.factory.extras + +argeo.node.repo.type=localfs + +org.osgi.framework.security=osgi +java.security.policy=file:../../all.policy + +org.osgi.service.http.port=7080 +org.eclipse.equinox.http.jetty.log.stderr.threshold=info + +log4j.configuration=file:../../log4j.properties +org.eclipse.rap.workbenchAutostart=false + +# DON'T CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING +eclipse.ignoreApp=true +osgi.noShutdown=true +org.eclipse.equinox.http.jetty.autostart=false +org.eclipse.rap.workbenchAutostart=false + +# Avoid errors logs (see https://issues.apache.org/jira/browse/JCR-2226) +org.apache.jackrabbit.core.statementcache=false \ No newline at end of file diff --git a/dep/org.argeo.slc.dep.minimal/pom.xml b/dep/org.argeo.slc.dep.minimal/pom.xml index 0c445fc0e..061eb7cfe 100644 --- a/dep/org.argeo.slc.dep.minimal/pom.xml +++ b/dep/org.argeo.slc.dep.minimal/pom.xml @@ -74,11 +74,11 @@ org.argeo.slc.agent.jcr 2.1.5-SNAPSHOT - - org.argeo.slc - org.argeo.slc.node.jackrabbit - 2.1.5-SNAPSHOT - + + + + + diff --git a/org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java b/org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java index d11baf12c..7da9708f3 100644 --- a/org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java +++ b/org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java @@ -3,7 +3,7 @@ package org.argeo.slc; /** Constants useful across all SLC components */ public interface SlcConstants { /** Read-write role. */ - public final static String ROLE_SLC = "org.argeo.slc.user"; + public final static String ROLE_SLC = "cn=org.argeo.slc.user,ou=roles,ou=node"; /** Read only unlogged user */ public final static String USER_ANONYMOUS = "anonymous"; diff --git a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java index db87371ea..da1af5854 100644 --- a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java +++ b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java @@ -61,8 +61,7 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { private final static Log log = LogFactory.getLog(NormalizeWorkspace.class); public final static String ID = DistPlugin.PLUGIN_ID + ".normalizeWorkspace"; - public final static ImageDescriptor DEFAULT_ICON = DistPlugin - .getImageDescriptor("icons/normalize.gif"); + public final static ImageDescriptor DEFAULT_ICON = DistPlugin.getImageDescriptor("icons/normalize.gif"); public final static String PARAM_WORKSPACE_NAME = "workspaceName"; public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath"; @@ -88,25 +87,20 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { Session currSession = null; NormalizeJob job; try { - String msg = "Your are about to normalize workspace: " - + wkspName + String msg = "Your are about to normalize workspace: " + wkspName + ".\nThis will index OSGi bundles and Maven artifacts, " + "it will also convert Maven sources to PDE Sources if needed.\n" - + "Note that no information will be overwritten: " - + "all existing information are kept." + + "Note that no information will be overwritten: " + "all existing information are kept." + "\n\n Do you really want to proceed ?"; - if (!MessageDialog.openConfirm(DistPlugin.getDefault() - .getWorkbench().getDisplay().getActiveShell(), + if (!MessageDialog.openConfirm(DistPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(), "Confirm workspace normalization", msg)) return null; currSession = repository.login(); Node repoNode = currSession.getNode(targetRepoPath); - Repository repository = RepoUtils.getRepository(repositoryFactory, - keyring, repoNode); - Credentials credentials = RepoUtils.getRepositoryCredentials( - keyring, repoNode); + Repository repository = RepoUtils.getRepository(repositoryFactory, keyring, repoNode); + Credentials credentials = RepoUtils.getRepositoryCredentials(keyring, repoNode); job = new NormalizeJob(repository.login(credentials, wkspName)); job.setUser(true); @@ -132,28 +126,21 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { try { JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor); // Normalize artifacts - Query countQuery = session - .getWorkspace() - .getQueryManager() - .createQuery("select file from [nt:file] as file", - Query.JCR_SQL2); + Query countQuery = session.getWorkspace().getQueryManager() + .createQuery("select file from [nt:file] as file", Query.JCR_SQL2); QueryResult result = countQuery.execute(); Long expectedCount = result.getNodes().getSize(); - monitor.beginTask("Normalize artifacts of " - + session.getWorkspace().getName(), + monitor.beginTask("Normalize artifacts of " + session.getWorkspace().getName(), expectedCount.intValue()); NormalizingTraverser tiv = new NormalizingTraverser(monitor); Node artifactBaseNode = session.getNode(artifactBasePath); artifactBaseNode.accept(tiv); } catch (Exception e) { - log.error("Error normalizing workspace " - + session.getWorkspace().getName() + ": " - + e.getMessage()); + log.error("Error normalizing workspace " + session.getWorkspace().getName() + ": " + e.getMessage()); if (log.isErrorEnabled()) e.printStackTrace(); return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID, - "Cannot normalize distribution " - + session.getWorkspace().getName(), e); + "Cannot normalize distribution " + session.getWorkspace().getName(), e); } finally { JcrUtils.logoutQuietly(session); } @@ -170,13 +157,14 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { } @Override - protected void entering(Property property, int level) - throws RepositoryException { + protected void entering(Property property, int level) throws RepositoryException { } @Override - protected void entering(Node node, int level) - throws RepositoryException { + protected void entering(Node node, int level) throws RepositoryException { + if (node.getPath().startsWith(RepoConstants.DIST_DOWNLOAD_BASEPATH)) + return; + if (node.isNodeType(NodeType.NT_FILE)) { if (node.getName().endsWith("-sources.jar")) { monitor.subTask(node.getName()); @@ -195,8 +183,7 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { if (node.getSession().hasPendingChanges()) { node.getSession().save(); if (log.isDebugEnabled()) - log.debug("Processed jar artifact " - + node.getPath()); + log.debug("Processed jar artifact " + node.getPath()); } monitor.worked(1); } @@ -209,8 +196,7 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { if (node.getSession().hasPendingChanges()) { node.getSession().save(); if (log.isDebugEnabled()) - log.debug("Processed pom artifact " - + node.getPath()); + log.debug("Processed pom artifact " + node.getPath()); } monitor.worked(1); } else { @@ -220,8 +206,7 @@ public class NormalizeWorkspace extends AbstractHandler implements SlcNames { } @Override - protected void leaving(Property property, int level) - throws RepositoryException { + protected void leaving(Property property, int level) throws RepositoryException { } @Override diff --git a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java index 1dd322864..f541c03d1 100644 --- a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java +++ b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java @@ -46,8 +46,7 @@ public class DistTreeContentProvider implements ITreeContentProvider { dispose(); nodeSession = nodeRepository.login(); - String reposPath = NodeUtils.getUserHome(nodeSession).getPath() - + RepoConstants.REPOSITORIES_BASE_PATH; + String reposPath = NodeUtils.getUserHome(nodeSession).getPath() + RepoConstants.REPOSITORIES_BASE_PATH; if (!nodeSession.itemExists(reposPath)) initializeModel(nodeSession); @@ -56,11 +55,9 @@ public class DistTreeContentProvider implements ITreeContentProvider { while (repos.hasNext()) { Node repoNode = repos.nextNode(); if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) { - String label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode - .getProperty(Property.JCR_TITLE).getString() - : repoNode.getName(); - repositories.add(new RepoElem(repositoryFactory, keyring, - repoNode, label)); + String label = repoNode.isNodeType(NodeType.MIX_TITLE) + ? repoNode.getProperty(Property.JCR_TITLE).getString() : repoNode.getName(); + repositories.add(new RepoElem(repositoryFactory, keyring, repoNode, label)); } } } catch (RepositoryException e) { @@ -109,23 +106,19 @@ public class DistTreeContentProvider implements ITreeContentProvider { throw new SlcException("User must be authenticated."); // make sure base directory is available - Node repos = JcrUtils.mkdirs(nodeSession, homeNode.getPath() - + RepoConstants.REPOSITORIES_BASE_PATH); + Node repos = JcrUtils.mkdirs(homeNode, RepoConstants.REPOSITORIES_BASE_PATH,null); if (nodeSession.hasPendingChanges()) nodeSession.save(); // register default local java repository String alias = RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS; - Repository javaRepository = NodeUtils.getRepositoryByAlias( - repositoryFactory, alias); + Repository javaRepository = NodeUtils.getRepositoryByAlias(repositoryFactory, alias); if (javaRepository != null) { if (!repos.hasNode(alias)) { - Node repoNode = repos.addNode(alias, - ArgeoTypes.ARGEO_REMOTE_REPOSITORY); + Node repoNode = repos.addNode(alias, ArgeoTypes.ARGEO_REMOTE_REPOSITORY); repoNode.setProperty(ArgeoNames.ARGEO_URI, "vm:///" + alias); repoNode.addMixin(NodeType.MIX_TITLE); - repoNode.setProperty(Property.JCR_TITLE, - RepoConstants.DEFAULT_JAVA_REPOSITORY_LABEL); + repoNode.setProperty(Property.JCR_TITLE, RepoConstants.DEFAULT_JAVA_REPOSITORY_LABEL); nodeSession.save(); } } diff --git a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java index b354e3f34..a70877da2 100644 --- a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java +++ b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java @@ -589,7 +589,8 @@ public class FetchWizard extends Wizard { // reset workspace list wkspViewer.setAllChecked(false); workspaces.clear(); - session = currSourceRepo.login(currSourceCred); + // FIXME make it more generic + session = currSourceRepo.login(currSourceCred,RepoConstants.DEFAULT_DEFAULT_WORKSPACE); // remove unvalid elements for (String name : session.getWorkspace() .getAccessibleWorkspaceNames()) diff --git a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java index a59fd8d5b..d02a91396 100644 --- a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java +++ b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java @@ -254,14 +254,12 @@ public class RegisterRepoWizard extends Wizard { URI checkedUri = new URI(uri.getText()); String checkedUriStr = checkedUri.toString(); Repository repository = NodeUtils.getRepositoryByUri(repositoryFactory, checkedUriStr); - // FIXME make it more generic - String defaultWorkspace = "main"; if (username.getText().trim().equals("")) {// anonymous - session = repository.login(defaultWorkspace); + session = repository.login(RepoConstants.DEFAULT_DEFAULT_WORKSPACE); } else { char[] pwd = password.getTextChars(); SimpleCredentials sc = new SimpleCredentials(username.getText(), pwd); - session = repository.login(sc, defaultWorkspace); + session = repository.login(sc, RepoConstants.DEFAULT_DEFAULT_WORKSPACE); } } else {// alias Repository repository = NodeUtils.getRepositoryByAlias(repositoryFactory, uri.getText()); diff --git a/org.argeo.slc.client.ui/META-INF/spring/osgi.xml b/org.argeo.slc.client.ui/META-INF/spring/osgi.xml index da9f8bc91..bedda8da5 100644 --- a/org.argeo.slc.client.ui/META-INF/spring/osgi.xml +++ b/org.argeo.slc.client.ui/META-INF/spring/osgi.xml @@ -12,7 +12,7 @@ + filter="(argeo.jcr.repository.alias=home)" /> diff --git a/org.argeo.slc.core/bnd.bnd b/org.argeo.slc.core/bnd.bnd index aedf2e57d..ffbb76507 100644 --- a/org.argeo.slc.core/bnd.bnd +++ b/org.argeo.slc.core/bnd.bnd @@ -1,4 +1,5 @@ Import-Package: javax.jcr.nodetype,\ +javax.jcr.security,\ org.apache.tools.ant.*;resolution:="optional",\ junit.framework;resolution:="optional",\ * diff --git a/org.argeo.slc.core/src/org/argeo/slc/core/execution/ExecutionThread.java b/org.argeo.slc.core/src/org/argeo/slc/core/execution/ExecutionThread.java index f29e2938f..31e952d4a 100644 --- a/org.argeo.slc.core/src/org/argeo/slc/core/execution/ExecutionThread.java +++ b/org.argeo.slc.core/src/org/argeo/slc/core/execution/ExecutionThread.java @@ -15,11 +15,18 @@ */ package org.argeo.slc.core.execution; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.List; +import javax.security.auth.Subject; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.argeo.slc.SlcException; import org.argeo.slc.execution.ExecutionFlowDescriptor; import org.argeo.slc.execution.ExecutionModulesManager; import org.argeo.slc.execution.ExecutionStep; @@ -32,65 +39,70 @@ public class ExecutionThread extends Thread { private ExecutionModulesManager executionModulesManager; private final RealizedFlow realizedFlow; + private final AccessControlContext accessControlContext; private List destructionCallbacks = new ArrayList(); - public ExecutionThread(ProcessThreadGroup processThreadGroup, - ExecutionModulesManager executionModulesManager, + public ExecutionThread(ProcessThreadGroup processThreadGroup, ExecutionModulesManager executionModulesManager, RealizedFlow realizedFlow) { - super(processThreadGroup, "Flow " - + realizedFlow.getFlowDescriptor().getName()); + super(processThreadGroup, "Flow " + realizedFlow.getFlowDescriptor().getName()); this.realizedFlow = realizedFlow; this.executionModulesManager = executionModulesManager; + accessControlContext = AccessController.getContext(); } public void run() { // authenticate thread -// Authentication authentication = getProcessThreadGroup() -// .getAuthentication(); -// if (authentication == null) -// throw new SlcException("Can only execute authenticated threads"); -// SecurityContextHolder.getContext().setAuthentication(authentication); + // Authentication authentication = getProcessThreadGroup() + // .getAuthentication(); + // if (authentication == null) + // throw new SlcException("Can only execute authenticated threads"); + // SecurityContextHolder.getContext().setAuthentication(authentication); // Retrieve execution flow descriptor - ExecutionFlowDescriptor executionFlowDescriptor = realizedFlow - .getFlowDescriptor(); + ExecutionFlowDescriptor executionFlowDescriptor = realizedFlow.getFlowDescriptor(); String flowName = executionFlowDescriptor.getName(); getProcessThreadGroup().dispatchAddStep( - new ExecutionStep(realizedFlow.getModuleName(), - ExecutionStep.PHASE_START, "Flow " + flowName)); + new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.PHASE_START, "Flow " + flowName)); try { - String autoUpgrade = System - .getProperty(SYSPROP_EXECUTION_AUTO_UPGRADE); - if (autoUpgrade != null && autoUpgrade.equals("true")) - executionModulesManager.upgrade(realizedFlow - .getModuleNameVersion()); - executionModulesManager.start(realizedFlow.getModuleNameVersion()); - // - // START FLOW - // - executionModulesManager.execute(realizedFlow); - // END FLOW + Subject subject = Subject.getSubject(accessControlContext); + try { + Subject.doAs(subject, new PrivilegedExceptionAction() { + + @Override + public Void run() throws Exception { + String autoUpgrade = System.getProperty(SYSPROP_EXECUTION_AUTO_UPGRADE); + if (autoUpgrade != null && autoUpgrade.equals("true")) + executionModulesManager.upgrade(realizedFlow.getModuleNameVersion()); + executionModulesManager.start(realizedFlow.getModuleNameVersion()); + // + // START FLOW + // + executionModulesManager.execute(realizedFlow); + // END FLOW + return null; + } + + }); + } catch (PrivilegedActionException privilegedActionException) { + throw (Exception) privilegedActionException.getCause(); + } } catch (FlowConfigurationException e) { - String msg = "Configuration problem with flow " + flowName + ":\n" - + e.getMessage(); + String msg = "Configuration problem with flow " + flowName + ":\n" + e.getMessage(); log.error(msg); getProcessThreadGroup().dispatchAddStep( - new ExecutionStep(realizedFlow.getModuleName(), - ExecutionStep.ERROR, msg + " " + e.getMessage())); + new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.ERROR, msg + " " + e.getMessage())); } catch (Exception e) { // TODO: re-throw exception ? String msg = "Execution of flow " + flowName + " failed."; log.error(msg, e); getProcessThreadGroup().dispatchAddStep( - new ExecutionStep(realizedFlow.getModuleName(), - ExecutionStep.ERROR, msg + " " + e.getMessage())); + new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.ERROR, msg + " " + e.getMessage())); } finally { getProcessThreadGroup().dispatchAddStep( - new ExecutionStep(realizedFlow.getModuleName(), - ExecutionStep.PHASE_END, "Flow " + flowName)); + new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.PHASE_END, "Flow " + flowName)); processDestructionCallbacks(); } } @@ -100,8 +112,7 @@ public class ExecutionThread extends Thread { try { destructionCallbacks.get(i).run(); } catch (Exception e) { - log.warn("Could not process destruction callback " + i - + " in thread " + getName(), e); + log.warn("Could not process destruction callback " + i + " in thread " + getName(), e); } } } diff --git a/org.argeo.slc.core/src/org/argeo/slc/core/execution/ProcessThread.java b/org.argeo.slc.core/src/org/argeo/slc/core/execution/ProcessThread.java index b17e478f7..926789677 100644 --- a/org.argeo.slc.core/src/org/argeo/slc/core/execution/ProcessThread.java +++ b/org.argeo.slc.core/src/org/argeo/slc/core/execution/ProcessThread.java @@ -15,14 +15,21 @@ */ package org.argeo.slc.core.execution; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import javax.security.auth.Subject; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.argeo.slc.SlcException; import org.argeo.slc.execution.ExecutionModulesManager; import org.argeo.slc.execution.ExecutionProcess; import org.argeo.slc.execution.ExecutionStep; @@ -39,48 +46,64 @@ public class ProcessThread extends Thread { private final ExecutionProcess process; private final ProcessThreadGroup processThreadGroup; - private Set executionThreads = Collections - .synchronizedSet(new HashSet()); + private Set executionThreads = Collections.synchronizedSet(new HashSet()); // private Boolean hadAnError = false; private Boolean killed = false; - public ProcessThread(ThreadGroup processesThreadGroup, - ExecutionModulesManager executionModulesManager, + private final AccessControlContext accessControlContext; + + public ProcessThread(ThreadGroup processesThreadGroup, ExecutionModulesManager executionModulesManager, ExecutionProcess process) { super(processesThreadGroup, "SLC Process #" + process.getUuid()); this.executionModulesManager = executionModulesManager; this.process = process; processThreadGroup = new ProcessThreadGroup(process); + accessControlContext = AccessController.getContext(); } public final void run() { // authenticate thread -// Authentication authentication = getProcessThreadGroup() -// .getAuthentication(); -// if (authentication == null) -// throw new SlcException("Can only execute authenticated threads"); -// SecurityContextHolder.getContext().setAuthentication(authentication); + // Authentication authentication = getProcessThreadGroup() + // .getAuthentication(); + // if (authentication == null) + // throw new SlcException("Can only execute authenticated threads"); + // SecurityContextHolder.getContext().setAuthentication(authentication); - log.info("\n##\n## SLC Process #" + process.getUuid() - + " STARTED\n##\n"); + log.info("\n##\n## SLC Process #" + process.getUuid() + " STARTED\n##\n"); // Start logging new LoggingThread().start(); process.setStatus(ExecutionProcess.RUNNING); try { - process(); + Subject subject = Subject.getSubject(accessControlContext); + try { + Subject.doAs(subject, new PrivilegedExceptionAction() { + + @Override + public Void run() throws Exception { + process(); + return null; + } + + }); + } catch (PrivilegedActionException privilegedActionException) { + Throwable cause = privilegedActionException.getCause(); + if (cause instanceof InterruptedException) + throw (InterruptedException) cause; + else + throw new SlcException("Cannot process", cause); + } + // process(); } catch (InterruptedException e) { die(); return; } catch (Exception e) { - String msg = "Process " + getProcess().getUuid() - + " failed unexpectedly."; + String msg = "Process " + getProcess().getUuid() + " failed unexpectedly."; log.error(msg, e); - getProcessThreadGroup().dispatchAddStep( - new ExecutionStep("Process", ExecutionStep.ERROR, msg + " " - + e.getMessage())); + getProcessThreadGroup() + .dispatchAddStep(new ExecutionStep("Process", ExecutionStep.ERROR, msg + " " + e.getMessage())); } // waits for all execution threads to complete (in case they were @@ -111,8 +134,7 @@ public class ProcessThread extends Thread { process.setStatus(ExecutionProcess.COMPLETED); // executionModulesManager.dispatchUpdateStatus(process, oldStatus, // process.getStatus()); - log.info("\n## SLC Process #" + process.getUuid() + " " - + process.getStatus() + "\n"); + log.info("\n## SLC Process #" + process.getUuid() + " " + process.getStatus() + "\n"); } /** Called when being killed */ @@ -143,13 +165,11 @@ public class ProcessThread extends Thread { } /** @return the (distinct) thread used for this execution */ - protected final void execute(RealizedFlow realizedFlow, Boolean synchronous) - throws InterruptedException { + protected final void execute(RealizedFlow realizedFlow, Boolean synchronous) throws InterruptedException { if (killed) return; - ExecutionThread thread = new ExecutionThread(processThreadGroup, - executionModulesManager, realizedFlow); + ExecutionThread thread = new ExecutionThread(processThreadGroup, executionModulesManager, realizedFlow); executionThreads.add(thread); thread.start(); @@ -201,8 +221,7 @@ public class ProcessThread extends Thread { break; } - if (!ProcessThread.this.isAlive() - && processThreadGroup.getSteps().size() == 0) + if (!ProcessThread.this.isAlive() && processThreadGroup.getSteps().size() == 0) run = false; } } diff --git a/org.argeo.slc.core/src/org/argeo/slc/jcr/execution/JcrAgent.java b/org.argeo.slc.core/src/org/argeo/slc/jcr/execution/JcrAgent.java index 1c00b47fd..3f4954930 100644 --- a/org.argeo.slc.core/src/org/argeo/slc/jcr/execution/JcrAgent.java +++ b/org.argeo.slc.core/src/org/argeo/slc/jcr/execution/JcrAgent.java @@ -23,8 +23,10 @@ import javax.jcr.Node; import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; +import javax.jcr.security.Privilege; import org.argeo.jcr.JcrUtils; +import org.argeo.slc.SlcConstants; import org.argeo.slc.SlcException; import org.argeo.slc.core.execution.DefaultAgent; import org.argeo.slc.core.execution.ProcessThread; @@ -52,17 +54,15 @@ public class JcrAgent extends DefaultAgent implements SlcNames { session = repository.login(); String agentFactoryPath = getAgentFactoryPath(); - Node vmAgentFactoryNode = JcrUtils.mkdirsSafe(session, - agentFactoryPath, SlcTypes.SLC_AGENT_FACTORY); + Node vmAgentFactoryNode = JcrUtils.mkdirsSafe(session, agentFactoryPath, SlcTypes.SLC_AGENT_FACTORY); + JcrUtils.addPrivilege(session, SlcJcrConstants.SLC_BASE_PATH, SlcConstants.ROLE_SLC, Privilege.JCR_ALL); if (!vmAgentFactoryNode.hasNode(agentNodeName)) { String uuid = UUID.randomUUID().toString(); - Node agentNode = vmAgentFactoryNode.addNode(agentNodeName, - SlcTypes.SLC_AGENT); + Node agentNode = vmAgentFactoryNode.addNode(agentNodeName, SlcTypes.SLC_AGENT); agentNode.setProperty(SLC_UUID, uuid); } session.save(); - return vmAgentFactoryNode.getNode(agentNodeName) - .getProperty(SLC_UUID).getString(); + return vmAgentFactoryNode.getNode(agentNodeName).getProperty(SLC_UUID).getString(); } catch (RepositoryException e) { JcrUtils.discardQuietly(session); throw new SlcException("Cannot find JCR agent UUID", e); @@ -80,15 +80,12 @@ public class JcrAgent extends DefaultAgent implements SlcNames { * SLC AGENT */ @Override - protected ProcessThread createProcessThread( - ThreadGroup processesThreadGroup, + protected ProcessThread createProcessThread(ThreadGroup processesThreadGroup, ExecutionModulesManager modulesManager, ExecutionProcess process) { if (process instanceof JcrExecutionProcess) - return new JcrProcessThread(processesThreadGroup, modulesManager, - (JcrExecutionProcess) process); + return new JcrProcessThread(processesThreadGroup, modulesManager, (JcrExecutionProcess) process); else - return super.createProcessThread(processesThreadGroup, - modulesManager, process); + return super.createProcessThread(processesThreadGroup, modulesManager, process); } /* @@ -104,13 +101,10 @@ public class JcrAgent extends DefaultAgent implements SlcNames { String agentFactoryPath; if (isRemote) { InetAddress localhost = InetAddress.getLocalHost(); - agentFactoryPath = SlcJcrConstants.AGENTS_BASE_PATH + "/" - + localhost.getCanonicalHostName(); + agentFactoryPath = SlcJcrConstants.AGENTS_BASE_PATH + "/" + localhost.getCanonicalHostName(); - if (agentFactoryPath - .equals(SlcJcrConstants.VM_AGENT_FACTORY_PATH)) - throw new SlcException("Unsupported hostname " - + localhost.getCanonicalHostName()); + if (agentFactoryPath.equals(SlcJcrConstants.VM_AGENT_FACTORY_PATH)) + throw new SlcException("Unsupported hostname " + localhost.getCanonicalHostName()); } else {// local agentFactoryPath = SlcJcrConstants.VM_AGENT_FACTORY_PATH; } diff --git a/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit.xml b/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit.xml index 5163a3c66..bd23e698d 100644 --- a/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit.xml +++ b/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit.xml @@ -19,7 +19,7 @@ init-method="run"> - + diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java index 4358e9865..229defcf5 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java @@ -17,21 +17,24 @@ package org.argeo.slc.repo; /** SLC repository constants */ public interface RepoConstants { - public final static String DEFAULT_JAVA_REPOSITORY_ALIAS = "java"; - public final static String DEFAULT_JAVA_REPOSITORY_LABEL = "Internal Java Repository"; + String DEFAULT_JAVA_REPOSITORY_ALIAS = "java"; + String DEFAULT_JAVA_REPOSITORY_LABEL = "Internal Java Repository"; + + + String DEFAULT_ARTIFACTS_BASE_PATH = "/"; + String REPO_BASEPATH = "/slc:repo"; + String PROXIED_REPOSITORIES = REPO_BASEPATH + "/slc:sources"; + String DISTRIBUTIONS_BASE_PATH = REPO_BASEPATH + "/slc:distributions"; + String REPOSITORIES_BASE_PATH = REPO_BASEPATH + "/slc:repositories"; + String DIST_DOWNLOAD_BASEPATH = "/download"; + + String BINARIES_ARTIFACT_ID = "binaries"; + String SOURCES_ARTIFACT_ID = "sources"; + String SDK_ARTIFACT_ID = "sdk"; - public final static String DEFAULT_ARTIFACTS_BASE_PATH = "/"; - public final static String REPO_BASEPATH = "/slc:repo"; - public final static String PROXIED_REPOSITORIES = REPO_BASEPATH - + "/slc:sources"; - public final static String DISTRIBUTIONS_BASE_PATH = REPO_BASEPATH - + "/slc:distributions"; - public final static String REPOSITORIES_BASE_PATH = REPO_BASEPATH - + "/slc:repositories"; - public final static String BINARIES_ARTIFACT_ID = "binaries"; - public final static String SOURCES_ARTIFACT_ID = "sources"; - public final static String SDK_ARTIFACT_ID = "sdk"; - // TODO might exists somewhere else - public final static String SLC_GROUP_ID = "SLC-GroupId"; + String SLC_GROUP_ID = "SLC-GroupId"; + + // TODO find a more generic way + String DEFAULT_DEFAULT_WORKSPACE = "main"; } diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java index b3acaf4fd..ba6281917 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java @@ -62,8 +62,7 @@ public class RepoSync implements Runnable { private final static Log log = LogFactory.getLog(RepoSync.class); // Centralizes definition of workspaces that must be ignored by the sync. - private final static List IGNORED_WKSP_LIST = Arrays.asList( - "security", "localrepo"); + private final static List IGNORED_WKSP_LIST = Arrays.asList("security", "localrepo"); private final Calendar zero; private Session sourceDefaultSession = null; @@ -105,8 +104,8 @@ public class RepoSync implements Runnable { * @param targetRepository * @param targetCredentials */ - public RepoSync(Repository sourceRepository, Credentials sourceCredentials, - Repository targetRepository, Credentials targetCredentials) { + public RepoSync(Repository sourceRepository, Credentials sourceCredentials, Repository targetRepository, + Credentials targetCredentials) { this(); this.sourceRepository = sourceRepository; this.sourceCredentials = sourceCredentials; @@ -120,53 +119,42 @@ public class RepoSync implements Runnable { // Setup if (sourceRepository == null) - sourceRepository = NodeUtils.getRepositoryByUri( - repositoryFactory, sourceRepoUri); + sourceRepository = NodeUtils.getRepositoryByUri(repositoryFactory, sourceRepoUri); if (sourceCredentials == null && sourceUsername != null) - sourceCredentials = new SimpleCredentials(sourceUsername, - sourcePassword); - sourceDefaultSession = sourceRepository.login(sourceCredentials); + sourceCredentials = new SimpleCredentials(sourceUsername, sourcePassword); + // FIXME make it more generic + sourceDefaultSession = sourceRepository.login(sourceCredentials, RepoConstants.DEFAULT_DEFAULT_WORKSPACE); if (targetRepository == null) - targetRepository = NodeUtils.getRepositoryByUri( - repositoryFactory, targetRepoUri); + targetRepository = NodeUtils.getRepositoryByUri(repositoryFactory, targetRepoUri); if (targetCredentials == null && targetUsername != null) - targetCredentials = new SimpleCredentials(targetUsername, - targetPassword); + targetCredentials = new SimpleCredentials(targetUsername, targetPassword); targetDefaultSession = targetRepository.login(targetCredentials); Map errors = new HashMap(); - for (String sourceWorkspaceName : sourceDefaultSession - .getWorkspace().getAccessibleWorkspaceNames()) { + for (String sourceWorkspaceName : sourceDefaultSession.getWorkspace().getAccessibleWorkspaceNames()) { if (monitor != null && monitor.isCanceled()) break; - if (workspaceMap != null - && !workspaceMap.containsKey(sourceWorkspaceName)) + if (workspaceMap != null && !workspaceMap.containsKey(sourceWorkspaceName)) continue; if (IGNORED_WKSP_LIST.contains(sourceWorkspaceName)) continue; Session sourceSession = null; Session targetSession = null; - String targetWorkspaceName = workspaceMap - .get(sourceWorkspaceName); + String targetWorkspaceName = workspaceMap.get(sourceWorkspaceName); try { try { - targetSession = targetRepository.login( - targetCredentials, targetWorkspaceName); + targetSession = targetRepository.login(targetCredentials, targetWorkspaceName); } catch (NoSuchWorkspaceException e) { - targetDefaultSession.getWorkspace().createWorkspace( - targetWorkspaceName); - targetSession = targetRepository.login( - targetCredentials, targetWorkspaceName); + targetDefaultSession.getWorkspace().createWorkspace(targetWorkspaceName); + targetSession = targetRepository.login(targetCredentials, targetWorkspaceName); } - sourceSession = sourceRepository.login(sourceCredentials, - sourceWorkspaceName); + sourceSession = sourceRepository.login(sourceCredentials, sourceWorkspaceName); syncWorkspace(sourceSession, targetSession); } catch (Exception e) { - errors.put("Could not sync workspace " - + sourceWorkspaceName, e); + errors.put("Could not sync workspace " + sourceWorkspaceName, e); if (log.isErrorEnabled()) e.printStackTrace(); @@ -180,8 +168,7 @@ public class RepoSync implements Runnable { log.info("Sync has been canceled by user"); long duration = (System.currentTimeMillis() - begin) / 1000;// s - log.info("Sync " + sourceRepoUri + " to " + targetRepoUri + " in " - + (duration / 60) + log.info("Sync " + sourceRepoUri + " to " + targetRepoUri + " in " + (duration / 60) + "min " + (duration % 60) + "s"); @@ -189,8 +176,7 @@ public class RepoSync implements Runnable { throw new SlcException("Sync failed " + errors); } } catch (RepositoryException e) { - throw new SlcException("Cannot sync " + sourceRepoUri + " to " - + targetRepoUri, e); + throw new SlcException("Cannot sync " + sourceRepoUri + " to " + targetRepoUri, e); } finally { JcrUtils.logoutQuietly(sourceDefaultSession); JcrUtils.logoutQuietly(targetDefaultSession); @@ -201,21 +187,14 @@ public class RepoSync implements Runnable { if (IGNORED_WKSP_LIST.contains(session.getWorkspace().getName())) return 0l; try { - Query countQuery = session - .getWorkspace() - .getQueryManager() - .createQuery( - "select file from [" - + (true ? NodeType.NT_FILE - : NodeType.NT_BASE) + "] as file", - Query.JCR_SQL2); + Query countQuery = session.getWorkspace().getQueryManager().createQuery( + "select file from [" + (true ? NodeType.NT_FILE : NodeType.NT_BASE) + "] as file", Query.JCR_SQL2); QueryResult result = countQuery.execute(); Long expectedCount = result.getNodes().getSize(); return expectedCount; } catch (RepositoryException e) { - throw new SlcException("Unexpected error while computing " - + "the size of the fetch for workspace " + throw new SlcException("Unexpected error while computing " + "the size of the fetch for workspace " + session.getWorkspace().getName(), e); } } @@ -228,19 +207,16 @@ public class RepoSync implements Runnable { } try { - String msg = "Synchronizing workspace: " - + sourceSession.getWorkspace().getName(); + String msg = "Synchronizing workspace: " + sourceSession.getWorkspace().getName(); if (monitor != null) monitor.setTaskName(msg); if (log.isDebugEnabled()) log.debug(msg); if (filesOnly) { - JcrUtils.copyFiles(sourceSession.getRootNode(), - targetSession.getRootNode(), true, monitor); + JcrUtils.copyFiles(sourceSession.getRootNode(), targetSession.getRootNode(), true, monitor); } else { - for (NodeIterator it = sourceSession.getRootNode().getNodes(); it - .hasNext();) { + for (NodeIterator it = sourceSession.getRootNode().getNodes(); it.hasNext();) { Node node = it.nextNode(); if (node.getName().equals("jcr:system")) continue; @@ -251,8 +227,7 @@ public class RepoSync implements Runnable { log.debug("Synced " + sourceSession.getWorkspace().getName()); } catch (Exception e) { e.printStackTrace(); - throw new SlcException("Cannot sync " - + sourceSession.getWorkspace().getName() + " to " + throw new SlcException("Cannot sync " + sourceSession.getWorkspace().getName() + " to " + targetSession.getWorkspace().getName(), e); } } @@ -262,35 +237,28 @@ public class RepoSync implements Runnable { updateMonitor(msg, false); } - protected void syncNode(Node sourceNode, Session targetSession) - throws RepositoryException, SAXException { + protected void syncNode(Node sourceNode, Session targetSession) throws RepositoryException, SAXException { // Boolean singleLevel = singleLevel(sourceNode); try { if (monitor != null && monitor.isCanceled()) { - updateMonitor("Fetched has been canceled, " - + "process is terminating"); + updateMonitor("Fetched has been canceled, " + "process is terminating"); return; } - Node targetParentNode = targetSession.getNode(sourceNode - .getParent().getPath()); + Node targetParentNode = targetSession.getNode(sourceNode.getParent().getPath()); Node targetNode; - if (monitor != null - && sourceNode.isNodeType(NodeType.NT_HIERARCHY_NODE)) + if (monitor != null && sourceNode.isNodeType(NodeType.NT_HIERARCHY_NODE)) monitor.subTask("Process " + sourceNode.getPath()); final Boolean isNew; if (!targetSession.itemExists(sourceNode.getPath())) { isNew = true; - targetNode = targetParentNode.addNode(sourceNode.getName(), - sourceNode.getPrimaryNodeType().getName()); + targetNode = targetParentNode.addNode(sourceNode.getName(), sourceNode.getPrimaryNodeType().getName()); } else { isNew = false; targetNode = targetSession.getNode(sourceNode.getPath()); - if (!targetNode.getPrimaryNodeType().getName() - .equals(sourceNode.getPrimaryNodeType().getName())) - targetNode.setPrimaryType(sourceNode.getPrimaryNodeType() - .getName()); + if (!targetNode.getPrimaryNodeType().getName().equals(sourceNode.getPrimaryNodeType().getName())) + targetNode.setPrimaryType(sourceNode.getPrimaryNodeType().getName()); } // export @@ -311,8 +279,7 @@ public class RepoSync implements Runnable { // mixin and properties for (NodeType nt : sourceNode.getMixinNodeTypes()) { - if (!targetNode.isNodeType(nt.getName()) - && targetNode.canAddMixin(nt.getName())) + if (!targetNode.isNodeType(nt.getName()) && targetNode.canAddMixin(nt.getName())) targetNode.addMixin(nt.getName()); } copyProperties(sourceNode, targetNode); @@ -329,8 +296,7 @@ public class RepoSync implements Runnable { if (sourceNode.isNodeType(NodeType.NT_HIERARCHY_NODE)) { if (targetSession.hasPendingChanges()) { if (sourceNode.isNodeType(NodeType.NT_FILE)) - updateMonitor((isNew ? "Added " : "Updated ") - + targetNode.getPath(), true); + updateMonitor((isNew ? "Added " : "Updated ") + targetNode.getPath(), true); // if (doSave) targetSession.save(); } else { @@ -343,8 +309,7 @@ public class RepoSync implements Runnable { } } - private void copyTimestamps(Node sourceNode, Node targetNode) - throws RepositoryException { + private void copyTimestamps(Node sourceNode, Node targetNode) throws RepositoryException { if (sourceNode.getDefinition().isProtected()) return; if (targetNode.getDefinition().isProtected()) @@ -355,32 +320,24 @@ public class RepoSync implements Runnable { copyTimestamp(sourceNode, targetNode, Property.JCR_LAST_MODIFIED_BY); } - private void copyTimestamp(Node sourceNode, Node targetNode, String property) - throws RepositoryException { + private void copyTimestamp(Node sourceNode, Node targetNode, String property) throws RepositoryException { if (sourceNode.hasProperty(property)) { Property p = sourceNode.getProperty(property); if (p.getDefinition().isProtected()) return; if (targetNode.hasProperty(property) - && targetNode - .getProperty(property) - .getValue() - .equals(sourceNode.getProperty(property).getValue())) + && targetNode.getProperty(property).getValue().equals(sourceNode.getProperty(property).getValue())) return; - targetNode.setProperty(property, sourceNode.getProperty(property) - .getValue()); + targetNode.setProperty(property, sourceNode.getProperty(property).getValue()); } } - private void copyProperties(Node sourceNode, Node targetNode) - throws RepositoryException { - properties: for (PropertyIterator pi = sourceNode.getProperties(); pi - .hasNext();) { + private void copyProperties(Node sourceNode, Node targetNode) throws RepositoryException { + properties: for (PropertyIterator pi = sourceNode.getProperties(); pi.hasNext();) { Property p = pi.nextProperty(); if (p.getDefinition().isProtected()) continue properties; - if (p.getName().equals(Property.JCR_CREATED) - || p.getName().equals(Property.JCR_CREATED_BY) + if (p.getName().equals(Property.JCR_CREATED) || p.getName().equals(Property.JCR_CREATED_BY) || p.getName().equals(Property.JCR_LAST_MODIFIED) || p.getName().equals(Property.JCR_LAST_MODIFIED_BY)) continue properties; @@ -391,22 +348,18 @@ public class RepoSync implements Runnable { if (p.isMultiple()) { if (!targetNode.hasProperty(p.getName()) - || !Arrays.equals( - targetNode.getProperty(p.getName()) - .getValues(), p.getValues())) + || !Arrays.equals(targetNode.getProperty(p.getName()).getValues(), p.getValues())) targetNode.setProperty(p.getName(), p.getValues()); } else { if (!targetNode.hasProperty(p.getName()) - || !targetNode.getProperty(p.getName()).getValue() - .equals(p.getValue())) + || !targetNode.getProperty(p.getName()).getValue().equals(p.getValue())) targetNode.setProperty(p.getName(), p.getValue()); } } } } - private static void copyBinary(Property p, Node targetNode) - throws RepositoryException { + private static void copyBinary(Property p, Node targetNode) throws RepositoryException { InputStream in = null; Binary sourceBinary = null; Binary targetBinary = null; @@ -424,8 +377,7 @@ public class RepoSync implements Runnable { } in = sourceBinary.getStream(); - targetBinary = targetNode.getSession().getValueFactory() - .createBinary(in); + targetBinary = targetNode.getSession().getValueFactory().createBinary(in); targetNode.setProperty(p.getName(), targetBinary); } catch (Exception e) { throw new SlcException("Could not transfer " + p, e); @@ -450,7 +402,7 @@ public class RepoSync implements Runnable { // throws RepositoryException, SAXException { // // // enable cancelation of the current fetch process - // // FIXME insure the repository stays in a stable state + // // fxme insure the repository stays in a stable state // if (monitor != null && monitor.isCanceled()) { // updateMonitor("Fetched has been canceled, " // + "process is terminating"); diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java index 92389339e..9ff5b81c4 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java @@ -16,6 +16,7 @@ import javax.jcr.Node; import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; +import javax.jcr.security.Privilege; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; @@ -27,6 +28,7 @@ import org.argeo.slc.jcr.SlcNames; import org.argeo.slc.jcr.SlcTypes; import org.argeo.slc.repo.NodeIndexer; import org.argeo.slc.repo.OsgiFactory; +import org.argeo.slc.repo.RepoConstants; import org.argeo.slc.repo.maven.MavenConventionsUtils; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.artifact.DefaultArtifact; @@ -45,7 +47,7 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { private Map> mirrors = new HashMap>(); private List mavenRepositories = new ArrayList(); - private String downloadBase = "/download"; + private String downloadBase = RepoConstants.DIST_DOWNLOAD_BASEPATH; private String mavenProxyBase = downloadBase + "/maven"; public void init() { @@ -68,8 +70,8 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { distSession = JcrUtils.loginOrCreateWorkspace(distRepository, workspace); // Privileges - JcrUtils.addPrivilege(javaSession, "/", SlcConstants.ROLE_SLC, "jcr:all"); - JcrUtils.addPrivilege(distSession, "/", SlcConstants.ROLE_SLC, "jcr:all"); + JcrUtils.addPrivilege(javaSession, "/", SlcConstants.ROLE_SLC, Privilege.JCR_ALL); + JcrUtils.addPrivilege(distSession, "/", SlcConstants.ROLE_SLC, Privilege.JCR_ALL); } catch (RepositoryException e) { throw new SlcException("Cannot initialize OSGi Factory " + workspace, e); } finally { diff --git a/org.argeo.slc.server.repo/META-INF/spring/jcr.xml b/org.argeo.slc.server.repo/META-INF/spring/jcr.xml index 2ef96232d..423779b3b 100644 --- a/org.argeo.slc.server.repo/META-INF/spring/jcr.xml +++ b/org.argeo.slc.server.repo/META-INF/spring/jcr.xml @@ -64,7 +64,7 @@ class="org.argeo.jcr.JcrAuthorizations" init-method="run"> - + diff --git a/pom.xml b/pom.xml index 7eb3b8f7e..5ffd6073e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,9 +1,10 @@ - + 4.0.0 org.argeo.commons argeo-commons - 2.1.46-SNAPSHOT + 2.1.46 org.argeo.slc argeo-slc @@ -26,7 +27,7 @@ org.argeo.slc.agent - org.argeo.slc.node.jackrabbit + org.argeo.slc.agent.jcr org.argeo.slc.server.repo @@ -152,15 +153,15 @@ limitations under the License. warn - - - - - - - - - + + + + + + + + + argeo-commons http://localhost:7070/data/public/java/argeo-${developmentCycle.argeo-commons} -- 2.39.2