Centralise keyring
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 26 Oct 2012 22:04:47 +0000 (22:04 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 26 Oct 2012 22:04:47 +0000 (22:04 +0000)
Repair normalise

git-svn-id: https://svn.argeo.org/slc/trunk@5665 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

plugins/org.argeo.slc.client.ui.dist/META-INF/spring/jcr.xml
plugins/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/commands/NormalizeDistribution.java
plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/views/DistributionsView.java

index 51c2109574450f856b920b203b22d0f2cf3dde3c..3ddc3521f4a234526c15394d0f0896e2103ca977 100644 (file)
                <property name="workspace" value="org.argeo.tp-1.3.1" />
        </bean>
 
-       <bean id="nodeSession" class="org.argeo.jcr.spring.ThreadBoundSession">
-               <property name="repository" ref="nodeRepository" />
-       </bean>
+<!--   <bean id="nodeSession" class="org.argeo.jcr.spring.ThreadBoundSession"> -->
+<!--           <property name="repository" ref="nodeRepository" /> -->
+<!--   </bean> -->
 
-       <bean id="keyring" class="org.argeo.security.jcr.JcrKeyring">
-               <property name="session" ref="nodeSession" />
-               <property name="defaultCallbackHandler" ref="defaultCallbackHandler" />
-               <!-- <property name="secreteKeyLength" value="${argeo.keyring.secreteKeyLength}" 
-                       /> -->
-       </bean>
+<!--   <bean id="keyring" class="org.argeo.security.jcr.JcrKeyring"> -->
+<!--           <property name="session" ref="nodeSession" /> -->
+<!--           <property name="defaultCallbackHandler" ref="defaultCallbackHandler" /> -->
+<!--   </bean> -->
 
 </beans>
index 48399342dfe08d629930f4791b975af2ff3179e3..62036aac8439b848bd5352bd539bc295971c15e7 100644 (file)
@@ -12,9 +12,8 @@
                filter="(argeo.jcr.repository.alias=java)" />\r
 \r
        <reference id="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
+       <reference id="keyring" interface="org.argeo.security.crypto.CryptoKeyring" />\r
 \r
        <reference id="nodeRepository" interface="javax.jcr.Repository"\r
                filter="(argeo.jcr.repository.alias=node)" />\r
-\r
-       <reference id="defaultCallbackHandler" interface="javax.security.auth.callback.CallbackHandler" />\r
 </beans:beans>
\ No newline at end of file
index e10e75f506207b79a832b129ce9d8e62f07dee8e..a1809518fe9ccbd4198cfab74fab441c8b10cb44 100644 (file)
@@ -26,6 +26,7 @@ import javax.jcr.util.TraversingItemVisitor;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.dist.DistPlugin;
 import org.argeo.slc.jcr.SlcNames;
 import org.argeo.slc.repo.ArtifactIndexer;
@@ -56,7 +57,12 @@ public class NormalizeDistribution extends AbstractHandler implements SlcNames {
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
                String workspace = event.getParameter(PARAM_WORKSPACE);
-               NormalizeJob job = new NormalizeJob(workspace);
+               NormalizeJob job;
+               try {
+                       job = new NormalizeJob(repository.login(workspace));
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot normalize " + workspace, e);
+               }
                job.setUser(true);
                job.schedule();
                return null;
@@ -67,18 +73,18 @@ public class NormalizeDistribution extends AbstractHandler implements SlcNames {
        }
 
        private class NormalizeJob extends Job {
-               private String workspace;
+               private Session session;
 
-               public NormalizeJob(String workspace) {
+               public NormalizeJob(Session session) {
                        super("Normalize Distribution");
-                       this.workspace = workspace;
+                       this.session = session;
                }
 
                @Override
                protected IStatus run(IProgressMonitor monitor) {
-                       Session session = null;
+                       // Session session = null;
                        try {
-                               session = repository.login(workspace);
+                               // session = repository.login(workspace);
                                // QueryManager qm = session.getWorkspace().getQueryManager();
                                // Query query = qm
                                // .createQuery(
@@ -90,12 +96,14 @@ public class NormalizeDistribution extends AbstractHandler implements SlcNames {
                                // log.debug("Count: " + count);
                                // long count = query.execute().getRows().nextRow()
                                // .getValue("count").getLong();
-                               monitor.beginTask("Normalize " + workspace, -1);
+                               monitor.beginTask("Normalize "
+                                               + session.getWorkspace().getName(), -1);
                                NormalizingTraverser tiv = new NormalizingTraverser(monitor);
                                session.getNode(artifactBasePath).accept(tiv);
                        } catch (Exception e) {
                                return new Status(IStatus.ERROR, DistPlugin.ID,
-                                               "Cannot normalize distribution " + workspace, e);
+                                               "Cannot normalize distribution "
+                                                               + session.getWorkspace().getName(), e);
                        } finally {
                                JcrUtils.logoutQuietly(session);
                        }
index 07d23946bbd2828e0a012e49ee672dcc8ebd148c..0421239b98437b3910739fdece3115eeeb4f0751 100644 (file)
@@ -30,6 +30,8 @@ import javax.jcr.RepositoryException;
 import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 import javax.jcr.nodetype.NodeType;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -479,8 +481,6 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                                                .getFirstElement();
                                if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
                                        event.data = de.getWorkspacePath();
-                                       if (log.isDebugEnabled())
-                                               log.debug("Distribution drag for " + event.data);
                                }
                        }
                }
@@ -589,17 +589,20 @@ public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames
                        long begin = System.currentTimeMillis();
                        try {
                                // Not implemented in Davex Jackrabbit v2.2
-                               // Query countQuery = sourceSession
-                               // .getWorkspace()
+                               // Query countQuery = sourceSession.getWorkspace()
                                // .getQueryManager()
-                               // .createQuery("select count(*) from [nt:file]",
-                               // Query.JCR_SQL2);
+                               // .createQuery("//element(*, nt:file)", Query.XPATH);
                                // QueryResult result = countQuery.execute();
-                               // Long fileCount = result.getRows().nextRow().getValues()[0]
-                               // .getLong();
+                               // Long expectedCount = result.getNodes().getSize();
+
+                                Long expectedCount = JcrUtils.countFiles(sourceSession
+                                .getRootNode());
+                               if (log.isDebugEnabled())
+                                       log.debug("Will copy " + expectedCount + " files...");
 
                                ArgeoMonitor monitor = new EclipseArgeoMonitor(eclipseMonitor);
-                               eclipseMonitor.beginTask("Copy files", ArgeoMonitor.UNKNOWN);
+                               eclipseMonitor
+                                               .beginTask("Copy files", expectedCount.intValue());
 
                                Long count = JcrUtils.copyFiles(sourceSession.getRootNode(),
                                                targetSession.getRootNode(), true, monitor);