<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>
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
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;
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;
}
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(
// 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);
}
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;
.getFirstElement();
if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
event.data = de.getWorkspacePath();
- if (log.isDebugEnabled())
- log.debug("Distribution drag for " + event.data);
}
}
}
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);