Adapt to changes in Commons
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 29 Sep 2016 11:17:29 +0000 (11:17 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 29 Sep 2016 11:17:29 +0000 (11:17 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@9212 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

19 files changed:
demo/slc_demo_rap.properties
demo/slc_localrepo.properties [new file with mode: 0644]
dep/org.argeo.slc.dep.minimal/pom.xml
org.argeo.slc.api/src/org/argeo/slc/SlcConstants.java
org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/commands/NormalizeWorkspace.java
org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java
org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/FetchWizard.java
org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/wizards/RegisterRepoWizard.java
org.argeo.slc.client.ui/META-INF/spring/osgi.xml
org.argeo.slc.core/bnd.bnd
org.argeo.slc.core/src/org/argeo/slc/core/execution/ExecutionThread.java
org.argeo.slc.core/src/org/argeo/slc/core/execution/ProcessThread.java
org.argeo.slc.core/src/org/argeo/slc/jcr/execution/JcrAgent.java
org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit.xml
org.argeo.slc.repo/src/org/argeo/slc/repo/RepoConstants.java
org.argeo.slc.repo/src/org/argeo/slc/repo/RepoSync.java
org.argeo.slc.repo/src/org/argeo/slc/repo/osgi/OsgiFactoryImpl.java
org.argeo.slc.server.repo/META-INF/spring/jcr.xml
pom.xml

index 6906d81d6714ed302572c8abea56144645cb5963..ca7272aeb517313e6c42b93c06821e42d5ddec47 100644 (file)
@@ -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 (file)
index 0000000..499e9e6
--- /dev/null
@@ -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
index 0c445fc0ec4dea2b7bdaf3088eddec5c619233f0..061eb7cfe817f1934422777a8ab8eba8d2cbd5a9 100644 (file)
                        <artifactId>org.argeo.slc.agent.jcr</artifactId>
                        <version>2.1.5-SNAPSHOT</version>
                </dependency>
-               <dependency>
-                       <groupId>org.argeo.slc</groupId>
-                       <artifactId>org.argeo.slc.node.jackrabbit</artifactId>
-                       <version>2.1.5-SNAPSHOT</version>
-               </dependency>
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.slc</groupId> -->
+<!--                   <artifactId>org.argeo.slc.node.jackrabbit</artifactId> -->
+<!--                   <version>2.1.5-SNAPSHOT</version> -->
+<!--           </dependency> -->
 
                <!-- Node -->
                <dependency>
index d11baf12c0bf78cdc299623abc239762700aa81b..7da9708f30f28fd0ea2735678fd2b06bdbe95d5c 100644 (file)
@@ -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";
index db87371eabe4547d5c4157600158bf8268b94f4f..da1af58541be501d5ac09040b65feb4a5e170012 100644 (file)
@@ -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
index 1dd3228644f9b52642967a0cc2fd0a0e2431138a..f541c03d14c416976f7c6f545d72f9bba2730867 100644 (file)
@@ -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();
                                }
                        }
index b354e3f34c6020be6ce57d24dfe347b99132191f..a70877da2b63173910fd639f3542b7530657ec99 100644 (file)
@@ -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())
index a59fd8d5b001883b5f676fbbaec4fccc45c3c0bf..d02a913967dd7cf08fde157bab493922ef5fbaa7 100644 (file)
@@ -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());
index da9f8bc91bad93d73d558a214852012263d59e2a..bedda8da590956d0dab305e1d59ae889aeb072c4 100644 (file)
@@ -12,7 +12,7 @@
 \r
        <!-- REFERENCES -->\r
        <reference id="repository" interface="javax.jcr.Repository"\r
-               filter="(argeo.jcr.repository.alias=slc)" />\r
+               filter="(argeo.jcr.repository.alias=home)" />\r
 \r
        <reference id="agent" interface="org.argeo.slc.execution.SlcAgent" />\r
 \r
index aedf2e57d69d0b612b5c4388066fd59f1762edc3..ffbb7650749a868118a63b3276c4f1d7b3c0fbd3 100644 (file)
@@ -1,4 +1,5 @@
 Import-Package: javax.jcr.nodetype,\
+javax.jcr.security,\
 org.apache.tools.ant.*;resolution:="optional",\
 junit.framework;resolution:="optional",\
 *
index f29e2938fd6fedf22b4c47b81f8d16523e11cb57..31e952d4afd5804cbc1e4e7c3de4bab20ac681a5 100644 (file)
  */
 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<Runnable> destructionCallbacks = new ArrayList<Runnable>();
 
-       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<Void>() {
+
+                                       @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);
                        }
                }
        }
index b17e478f7a172fe458afa2b47d173b9400cdb743..926789677165b760d56d5519a5e3b0ea96ef04cc 100644 (file)
  */
 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<ExecutionThread> executionThreads = Collections
-                       .synchronizedSet(new HashSet<ExecutionThread>());
+       private Set<ExecutionThread> executionThreads = Collections.synchronizedSet(new HashSet<ExecutionThread>());
 
        // 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<Void>() {
+
+                                       @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;
                        }
                }
index 1c00b47fd27a7f339d4de273fea1bf8483e1881c..3f49549303d8150d9071220ceab45c743dafc16b 100644 (file)
@@ -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;
                        }
index 5163a3c66ab574fa9a391bb4ec94c8547ad045f8..bd23e698dd2fa914f3d07d79dfc1693ddd43cf3e 100644 (file)
@@ -19,7 +19,7 @@
                init-method="run">
                <property name="principalPrivileges">
                        <map>
-                               <entry key="jcr:all" value="org.argeo.slc.user" />
+                               <entry key="jcr:all" value="cn=org.argeo.slc.user,ou=roles,ou=node" />
                        </map>
                </property>
                <property name="repository" ref="slcRepository" />
index 4358e9865017ebd99db230f6c6ba554bc98c8086..229defcf5ae2a262e9f60acc07f083996cffa980 100644 (file)
@@ -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";
 }
index b3acaf4fdb97942f23940fc2b19d5ac696f0b496..ba6281917505dc631bdd7647206d2c77b9edba5c 100644 (file)
@@ -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<String> IGNORED_WKSP_LIST = Arrays.asList(
-                       "security", "localrepo");
+       private final static List<String> 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<String, Exception> errors = new HashMap<String, Exception>();
-                       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");
index 92389339eba8817284724865f1e75d49d4a01443..9ff5b81c42925b87f29eaa08f981118beec40119 100644 (file)
@@ -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<String, List<String>> mirrors = new HashMap<String, List<String>>();
 
        private List<String> mavenRepositories = new ArrayList<String>();
-       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 {
index 2ef96232da908cb677cbfd67dd3cd5858b770832..423779b3be40ace617e07a2060ec4381c64a9e16 100644 (file)
@@ -64,7 +64,7 @@
                class="org.argeo.jcr.JcrAuthorizations" init-method="run">\r
                <property name="principalPrivileges">\r
                        <map>\r
-                               <entry key="jcr:all" value="org.argeo.slc.user" />\r
+                               <entry key="jcr:all" value="cn=org.argeo.slc.user,ou=roles,ou=node" />\r
                        </map>\r
                </property>\r
                <property name="workspace" value="*" />\r
diff --git a/pom.xml b/pom.xml
index 7eb3b8f7eca91294d3378ab004ac032924248a96..5ffd6073e501670ee5a71b69e98466e73d02a2ae 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -1,9 +1,10 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
                <groupId>org.argeo.commons</groupId>
                <artifactId>argeo-commons</artifactId>
-               <version>2.1.46-SNAPSHOT</version>
+               <version>2.1.46</version>
        </parent>
        <groupId>org.argeo.slc</groupId>
        <artifactId>argeo-slc</artifactId>
@@ -26,7 +27,7 @@
 
                <!-- Modules -->
                <module>org.argeo.slc.agent</module>
-               <module>org.argeo.slc.node.jackrabbit</module>
+               <!-- <module>org.argeo.slc.node.jackrabbit</module> -->
                <module>org.argeo.slc.agent.jcr</module>
                <module>org.argeo.slc.server.repo</module>
 
@@ -152,15 +153,15 @@ limitations under the License.
                                                <checksumPolicy>warn</checksumPolicy>
                                        </releases>
                                </repository>
-<!--                           <repository> -->
-<!--                                   <id>argeo-tp-extras</id> -->
-<!--                                   <url>http://localhost:7080/data/public/java/argeo-tp-extras-2.1</url> -->
-<!--                                   <releases> -->
-<!--                                           <enabled>true</enabled> -->
-<!--                                           <updatePolicy>daily</updatePolicy> -->
-<!--                                           <checksumPolicy>warn</checksumPolicy> -->
-<!--                                   </releases> -->
-<!--                           </repository> -->
+                               <!-- <repository> -->
+                               <!-- <id>argeo-tp-extras</id> -->
+                               <!-- <url>http://localhost:7080/data/public/java/argeo-tp-extras-2.1</url> -->
+                               <!-- <releases> -->
+                               <!-- <enabled>true</enabled> -->
+                               <!-- <updatePolicy>daily</updatePolicy> -->
+                               <!-- <checksumPolicy>warn</checksumPolicy> -->
+                               <!-- </releases> -->
+                               <!-- </repository> -->
                                <repository>
                                        <id>argeo-commons</id>
                                        <url>http://localhost:7070/data/public/java/argeo-${developmentCycle.argeo-commons}</url>