From 8d1f46ed8783aa1985fac1acf6ef6ef6cdad1314 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Sun, 22 May 2016 11:54:50 +0000 Subject: [PATCH] Adapt to changes in Commons git-svn-id: https://svn.argeo.org/slc/trunk@8933 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- dep/org.argeo.slc.dep.backend/pom.xml | 11 +- org.argeo.slc.agent/META-INF/spring/osgi.xml | 2 +- .../src/org/argeo/slc/SlcConstants.java | 2 +- .../slc/client/ui/editors/ProcessEditor.java | 30 ++--- .../ui/views/JcrExecutionModulesView.java | 123 +++++++----------- .../client/ui/views/JcrResultListView.java | 70 ++++------ .../client/ui/views/JcrResultTreeView.java | 19 ++- .../rpmfactory/core/RpmProxyServiceImpl.java | 2 +- .../META-INF/spring/jackrabbit-osgi.xml | 14 +- .../META-INF/spring/jackrabbit.xml | 29 +++-- .../slc/repo/maven/MavenConventionsUtils.java | 110 +++++++--------- .../argeo/slc/repo/osgi/OsgiFactoryImpl.java | 47 +++---- .../META-INF/spring/jcr.xml | 73 ++++++----- pom.xml | 20 ++- 14 files changed, 242 insertions(+), 310 deletions(-) diff --git a/dep/org.argeo.slc.dep.backend/pom.xml b/dep/org.argeo.slc.dep.backend/pom.xml index eac2815d5..4f9af22ab 100644 --- a/dep/org.argeo.slc.dep.backend/pom.xml +++ b/dep/org.argeo.slc.dep.backend/pom.xml @@ -114,7 +114,16 @@ test - + + + org.argeo.tp.misc + biz.aQute.bnd + + + org.argeo.tp.misc + org.junit + + org.argeo.tp.extras net.sf.jxl diff --git a/org.argeo.slc.agent/META-INF/spring/osgi.xml b/org.argeo.slc.agent/META-INF/spring/osgi.xml index 2b9dee685..42ea0bc77 100644 --- a/org.argeo.slc.agent/META-INF/spring/osgi.xml +++ b/org.argeo.slc.agent/META-INF/spring/osgi.xml @@ -48,7 +48,7 @@ - + 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 2b26e878f..d11baf12c 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 = "ROLE_SLC"; + public final static String ROLE_SLC = "org.argeo.slc.user"; /** Read only unlogged user */ public final static String USER_ANONYMOUS = "anonymous"; diff --git a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java index f70114fd0..b2cb8200a 100644 --- a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java +++ b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java @@ -46,8 +46,11 @@ import org.eclipse.ui.forms.editor.FormEditor; /** Editor for an execution process. */ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { + private static final long serialVersionUID = 509589737739132467L; + public final static String ID = ClientUiPlugin.ID + ".processEditor"; + private Repository repository; private Session session; private Node processNode; private ProcessController processController; @@ -60,6 +63,12 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); + try { + session = repository.login(); + } catch (RepositoryException e1) { + throw new SlcException("Cannot log in to repository"); + } + ProcessEditorInput pei = (ProcessEditorInput) input; String processPath = pei.getProcessPath(); try { @@ -250,27 +259,8 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { return false; } - // public void updateStatus(ExecutionProcess process, String oldStatus, - // String newStatus) { - // } - // - // public void addSteps(ExecutionProcess process, List steps) - // { - // } - - /** Expects one session per editor. */ - @Deprecated - public void setSession(Session session) { - this.session = session; - } - public void setRepository(Repository repository) { - try { - session = repository.login(); - } catch (RepositoryException re) { - throw new SlcException("Unable to log in Repository " + repository, - re); - } + this.repository = repository; } public void setProcessController(ProcessController processController) { diff --git a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java index 71f291e8a..4340f93f2 100644 --- a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java +++ b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java @@ -71,21 +71,25 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; /** JCR based view of the execution modules. */ -public class JcrExecutionModulesView extends ViewPart implements SlcTypes, - SlcNames { - private final static Log log = LogFactory - .getLog(JcrExecutionModulesView.class); +public class JcrExecutionModulesView extends ViewPart implements SlcTypes, SlcNames { + private final static Log log = LogFactory.getLog(JcrExecutionModulesView.class); - public static final String ID = ClientUiPlugin.ID - + ".jcrExecutionModulesView"; + public static final String ID = ClientUiPlugin.ID + ".jcrExecutionModulesView"; private TreeViewer viewer; /* DEPENDENCY INJECTION */ + private Repository repository; private Session session; private ExecutionModulesManager modulesManager; public void createPartControl(Composite parent) { + try { + session = repository.login(); + } catch (RepositoryException e1) { + throw new SlcException("Cannot log in to repository"); + } + viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); EclipseUiSpecificUtils.enableToolTipSupport(viewer); ViewContentProvider contentProvider = new ViewContentProvider(session); @@ -106,16 +110,11 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, viewer.addDragSupport(operations, tt, new ViewDragListener()); try { - String[] nodeTypes = { SlcTypes.SLC_AGENT, - SlcTypes.SLC_AGENT_FACTORY, SlcTypes.SLC_EXECUTION_MODULE }; - session.getWorkspace() - .getObservationManager() - .addEventListener( - new VmAgentObserver(viewer.getTree().getDisplay()), - Event.NODE_ADDED | Event.NODE_REMOVED - | Event.NODE_MOVED, - SlcJcrConstants.VM_AGENT_FACTORY_PATH, true, null, - nodeTypes, false); + String[] nodeTypes = { SlcTypes.SLC_AGENT, SlcTypes.SLC_AGENT_FACTORY, SlcTypes.SLC_EXECUTION_MODULE }; + session.getWorkspace().getObservationManager().addEventListener( + new VmAgentObserver(viewer.getTree().getDisplay()), + Event.NODE_ADDED | Event.NODE_REMOVED | Event.NODE_MOVED, SlcJcrConstants.VM_AGENT_FACTORY_PATH, + true, null, nodeTypes, false); } catch (RepositoryException e) { throw new SlcException("Cannot add observer", e); } @@ -135,10 +134,10 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, // Controllers class ViewContentProvider extends SimpleNodeContentProvider { + private static final long serialVersionUID = 5117887833174813672L; public ViewContentProvider(Session session) { - super(session, - new String[] { SlcJcrConstants.VM_AGENT_FACTORY_PATH }); + super(session, new String[] { SlcJcrConstants.VM_AGENT_FACTORY_PATH }); } @Override @@ -150,16 +149,14 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, } @Override - protected List filterChildren(List children) - throws RepositoryException { + protected List filterChildren(List children) throws RepositoryException { for (Iterator it = children.iterator(); it.hasNext();) { Node node = it.next(); // execution spec definitions if (node.getName().equals(SLC_EXECUTION_SPECS)) it.remove(); // flow values - else if (node.getParent().isNodeType( - SlcTypes.SLC_EXECUTION_FLOW)) + else if (node.getParent().isNodeType(SlcTypes.SLC_EXECUTION_FLOW)) it.remove(); } return super.filterChildren(children); @@ -193,14 +190,11 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, if (node2.getName().equals(SLC_EXECUTION_SPECS)) return 100; - if (node1.isNodeType(SLC_EXECUTION_FLOW) - && node2.isNodeType(SLC_EXECUTION_FLOW)) { + if (node1.isNodeType(SLC_EXECUTION_FLOW) && node2.isNodeType(SLC_EXECUTION_FLOW)) { return node1.getName().compareTo(node2.getName()); - } else if (node1.isNodeType(SLC_EXECUTION_FLOW) - && !node2.isNodeType(SLC_EXECUTION_FLOW)) { + } else if (node1.isNodeType(SLC_EXECUTION_FLOW) && !node2.isNodeType(SLC_EXECUTION_FLOW)) { return 1; - } else if (!node1.isNodeType(SLC_EXECUTION_FLOW) - && node2.isNodeType(SLC_EXECUTION_FLOW)) { + } else if (!node1.isNodeType(SLC_EXECUTION_FLOW) && node2.isNodeType(SLC_EXECUTION_FLOW)) { return -1; } else { // TODO: check title @@ -208,8 +202,7 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, } } } catch (RepositoryException e) { - throw new ArgeoException("Cannot compare " + o1 + " and " + o2, - e); + throw new ArgeoException("Cannot compare " + o1 + " and " + o2, e); } return 0; } @@ -249,8 +242,7 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, if (session.itemExists(path)) { Node parentNode = session.getNode(path);// .getParent(); if (log.isTraceEnabled()) - log.trace("Refresh " + parentNode + " after event " - + event); + log.trace("Refresh " + parentNode + " after event " + event); viewer.refresh(parentNode); } } catch (RepositoryException e) { @@ -263,18 +255,16 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, } } - class ViewLabelProvider extends DefaultNodeLabelProvider implements - ITableLabelProvider { + class ViewLabelProvider extends DefaultNodeLabelProvider implements ITableLabelProvider { + private static final long serialVersionUID = 2410754425574656399L; @Override protected String getText(Node node) throws RepositoryException { - if (node.isNodeType(NodeType.MIX_TITLE) - && node.hasProperty(Property.JCR_TITLE)) + if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_TITLE)) return node.getProperty(Property.JCR_TITLE).getString(); else if (node.getName().equals(SLC_EXECUTION_SPECS)) return "Execution Specifications"; - else if (node.getPath().equals( - SlcJcrConstants.VM_AGENT_FACTORY_PATH)) + else if (node.getPath().equals(SlcJcrConstants.VM_AGENT_FACTORY_PATH)) return "Internal Agents"; return super.getText(node); } @@ -282,8 +272,7 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, @Override public Image getImage(Node node) throws RepositoryException { // we try to optimize a bit by putting deeper nodes first - if (node.getParent().isNodeType( - SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE)) + if (node.getParent().isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE)) return SlcImages.CHOICES; else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE)) return SlcImages.EXECUTION_SPEC_ATTRIBUTE; @@ -307,8 +296,7 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, } public String getToolTipText(Node node) throws RepositoryException { - if (node.isNodeType(NodeType.MIX_TITLE) - && node.hasProperty(Property.JCR_DESCRIPTION)) + if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_DESCRIPTION)) return node.getProperty(Property.JCR_DESCRIPTION).getString(); return super.getToolTipText(node); } @@ -325,37 +313,30 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, class ViewDoubleClickListener implements IDoubleClickListener { public void doubleClick(DoubleClickEvent evt) { - Object obj = ((IStructuredSelection) evt.getSelection()) - .getFirstElement(); + Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement(); try { if (obj instanceof Node) { Node node = (Node) obj; if (node.isNodeType(SLC_EXECUTION_MODULE)) { - ClientUiPlugin.startStopExecutionModule(modulesManager, - node); + ClientUiPlugin.startStopExecutionModule(modulesManager, node); } else { String path = node.getPath(); // TODO factorize with editor - QueryManager qm = node.getSession().getWorkspace() - .getQueryManager(); - String statement = "SELECT * FROM [" - + SlcTypes.SLC_EXECUTION_FLOW - + "] WHERE ISDESCENDANTNODE(['" + path - + "']) OR ISSAMENODE(['" + path + "'])"; + QueryManager qm = node.getSession().getWorkspace().getQueryManager(); + String statement = "SELECT * FROM [" + SlcTypes.SLC_EXECUTION_FLOW + + "] WHERE ISDESCENDANTNODE(['" + path + "']) OR ISSAMENODE(['" + path + "'])"; // log.debug(statement); Query query = qm.createQuery(statement, Query.JCR_SQL2); // order paths SortedSet paths = new TreeSet(); - for (NodeIterator nit = query.execute().getNodes(); nit - .hasNext();) { + for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) { paths.add(nit.nextNode().getPath()); } - IWorkbenchPage activePage = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - activePage.openEditor(new ProcessEditorInput( - new ArrayList(paths), true), + IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage(); + activePage.openEditor(new ProcessEditorInput(new ArrayList(paths), true), ProcessEditor.ID); } } @@ -368,14 +349,14 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, /** Listen to drags */ class ViewDragListener extends DragSourceAdapter { + private static final long serialVersionUID = 250270504802674171L; // Check if the drag action should start. public void dragStart(DragSourceEvent event) { // we only start drag if at least one of the selected elements is // valid boolean doIt = false; - IStructuredSelection selection = (IStructuredSelection) viewer - .getSelection(); + IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); @SuppressWarnings("rawtypes") Iterator it = selection.iterator(); try { @@ -396,8 +377,7 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, } public void dragSetData(DragSourceEvent event) { - IStructuredSelection selection = (IStructuredSelection) viewer - .getSelection(); + IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); StringBuilder buf = new StringBuilder(); @SuppressWarnings("rawtypes") Iterator it = selection.iterator(); @@ -408,10 +388,9 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, if (obj instanceof Node) { Node node = (Node) obj; - if ((node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW) || node - .isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) - && TextTransfer.getInstance().isSupportedType( - event.dataType)) { + if ((node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW) + || node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) + && TextTransfer.getInstance().isSupportedType(event.dataType)) { buf.append(node.getPath()).append('\n'); } } @@ -440,17 +419,7 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, this.modulesManager = modulesManager; } - @Deprecated - public void setSession(Session session) { - this.session = session; - } - public void setRepository(Repository repository) { - try { - session = repository.login(); - } catch (RepositoryException re) { - throw new SlcException("Unable to log in Repository " + repository, - re); - } + this.repository = repository; } } \ No newline at end of file diff --git a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java index 4bfb57c19..7ff0e2002 100644 --- a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java +++ b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultListView.java @@ -65,15 +65,20 @@ public class JcrResultListView extends ViewPart implements SlcNames { private TableViewer viewer; + private Repository repository; private Session session; private EventListener resultsObserver; - private DateFormat dateFormat = new SimpleDateFormat( - "EEE, dd MMM yyyy HH:mm:ss"); + private DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss"); private Integer queryLimit = 2000; public void createPartControl(Composite parent) { + try { + session = repository.login(); + } catch (RepositoryException e1) { + throw new SlcException("Cannot log in to repository"); + } Table table = createTable(parent); viewer = new TableViewer(table); @@ -87,14 +92,11 @@ public class JcrResultListView extends ViewPart implements SlcNames { resultsObserver = new ResultObserver(viewer.getTable().getDisplay()); try { - ObservationManager observationManager = session.getWorkspace() - .getObservationManager(); + ObservationManager observationManager = session.getWorkspace().getObservationManager(); String[] nodeTypes = { SlcTypes.SLC_TEST_RESULT }; // FIXME Will not be notified if empty result is deleted - observationManager.addEventListener(resultsObserver, - Event.PROPERTY_ADDED | Event.NODE_REMOVED, - SlcJcrResultUtils.getSlcResultsBasePath(session), true, - null, nodeTypes, false); + observationManager.addEventListener(resultsObserver, Event.PROPERTY_ADDED | Event.NODE_REMOVED, + SlcJcrResultUtils.getSlcResultsBasePath(session), true, null, nodeTypes, false); } catch (RepositoryException e) { throw new SlcException("Cannot register listeners", e); } @@ -102,8 +104,7 @@ public class JcrResultListView extends ViewPart implements SlcNames { } protected Table createTable(Composite parent) { - int style = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.MULTI; + int style = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI; // does not work with RAP, commented for the time being // | SWT.HIDE_SELECTION; @@ -135,18 +136,14 @@ public class JcrResultListView extends ViewPart implements SlcNames { } protected void processDoubleClick(DoubleClickEvent evt) { - Object obj = ((IStructuredSelection) evt.getSelection()) - .getFirstElement(); + Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement(); try { if (obj instanceof Node) { Node node = (Node) obj; // FIXME: open a default result editor if (node.isNodeType(SlcTypes.SLC_PROCESS)) { - IWorkbenchPage activePage = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - activePage.openEditor( - new ProcessEditorInput(node.getPath()), - ProcessEditor.ID); + IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + activePage.openEditor(new ProcessEditorInput(node.getPath()), ProcessEditor.ID); } } } catch (Exception e) { @@ -159,19 +156,17 @@ public class JcrResultListView extends ViewPart implements SlcNames { } class ViewContentProvider implements IStructuredContentProvider { + private static final long serialVersionUID = -4719077015405546260L; public Object[] getElements(Object inputElement) { try { // TODO filter, optimize with virtual table, ... - String sql = "SELECT * from [" + SlcTypes.SLC_TEST_RESULT - + "] ORDER BY [jcr:lastModified] DESC"; - Query query = session.getWorkspace().getQueryManager() - .createQuery(sql, Query.JCR_SQL2); + String sql = "SELECT * from [" + SlcTypes.SLC_TEST_RESULT + "] ORDER BY [jcr:lastModified] DESC"; + Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2); // TODO paging query.setLimit(queryLimit); List nodes = new ArrayList(); - for (NodeIterator nit = query.execute().getNodes(); nit - .hasNext();) { + for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) { nodes.add(nit.nextNode()); } return nodes.toArray(); @@ -188,8 +183,8 @@ public class JcrResultListView extends ViewPart implements SlcNames { } - class ViewLabelProvider extends ColumnLabelProvider implements - ITableLabelProvider { + class ViewLabelProvider extends ColumnLabelProvider implements ITableLabelProvider { + private static final long serialVersionUID = -6323202576386795247L; public Image getColumnImage(Object obj, int columnIndex) { if (columnIndex != 0) @@ -212,9 +207,7 @@ public class JcrResultListView extends ViewPart implements SlcNames { case 0: if (node.hasProperty(SLC_COMPLETED)) { - return dateFormat - .format(node.getProperty(SLC_COMPLETED) - .getDate().getTime()); + return dateFormat.format(node.getProperty(SLC_COMPLETED).getDate().getTime()); } else { return "OPEN"; } @@ -243,8 +236,7 @@ public class JcrResultListView extends ViewPart implements SlcNames { } @Override - protected Boolean willProcessInUiThread(List events) - throws RepositoryException { + protected Boolean willProcessInUiThread(List events) throws RepositoryException { for (Event event : events) { // getLog().debug("Received event " + event); int eventType = event.getType(); @@ -253,27 +245,20 @@ public class JcrResultListView extends ViewPart implements SlcNames { String path = event.getPath(); int index = path.lastIndexOf('/'); String propertyName = path.substring(index + 1); - if (propertyName.equals(SLC_COMPLETED) - || propertyName.equals(SLC_UUID)) { + if (propertyName.equals(SLC_COMPLETED) || propertyName.equals(SLC_UUID)) { return true; } } return false; } - protected void onEventInUiThread(List events) - throws RepositoryException { + protected void onEventInUiThread(List events) throws RepositoryException { if (getLog().isTraceEnabled()) getLog().trace("Refresh result list"); viewer.refresh(); } } - @Deprecated - public void setSession(Session session) { - this.session = session; - } - public void dispose() { JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver); JcrUtils.logoutQuietly(session); @@ -281,11 +266,6 @@ public class JcrResultListView extends ViewPart implements SlcNames { } public void setRepository(Repository repository) { - try { - session = repository.login(); - } catch (RepositoryException re) { - throw new SlcException("Unable to log in Repository " + repository, - re); - } + this.repository = repository; } } \ No newline at end of file diff --git a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java index 97f78e4bd..1b1f85d40 100644 --- a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java +++ b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrResultTreeView.java @@ -110,6 +110,7 @@ public class JcrResultTreeView extends ViewPart { // LogFactory.getLog(JcrResultTreeView.class); /* DEPENDENCY INJECTION */ + private Repository repository; private Session session; // This page widgets @@ -138,6 +139,12 @@ public class JcrResultTreeView extends ViewPart { @Override public void createPartControl(Composite parent) { + try { + session = repository.login(); + } catch (RepositoryException e1) { + throw new SlcException("Cannot log in to repository"); + } + parent.setLayout(new FillLayout()); // Main layout SashForm sashForm = new SashForm(parent, SWT.VERTICAL); @@ -949,11 +956,6 @@ public class JcrResultTreeView extends ViewPart { } /* DEPENDENCY INJECTION */ - @Deprecated - public void setSession(Session session) { - this.session = session; - } - public void dispose() { // JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver); JcrUtils.logoutQuietly(session); @@ -961,11 +963,6 @@ public class JcrResultTreeView extends ViewPart { } public void setRepository(Repository repository) { - try { - session = repository.login(); - } catch (RepositoryException re) { - throw new SlcException("Unable to log in Repository " + repository, - re); - } + this.repository = repository; } } \ No newline at end of file diff --git a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java index 82d9e553b..d331cc70a 100644 --- a/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java +++ b/org.argeo.slc.factory/src/org/argeo/slc/rpmfactory/core/RpmProxyServiceImpl.java @@ -54,7 +54,7 @@ public class RpmProxyServiceImpl extends AbstractUrlProxy implements "jcr:all"); } catch (AccessControlException e) { if (log.isTraceEnabled()) - log.trace("Cannot give jcr:all privileges to ROLE_SLC"); + log.trace("Cannot give jcr:all privileges to "+SlcConstants.ROLE_SLC); } JcrUtils.mkdirsSafe(session, RepoConstants.PROXIED_REPOSITORIES); diff --git a/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit-osgi.xml b/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit-osgi.xml index c03708206..aca442285 100644 --- a/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit-osgi.xml +++ b/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit-osgi.xml @@ -10,17 +10,17 @@ http://www.springframework.org/schema/util/spring-util-2.5.xsd"> - + - - - - - + + + + + \ No newline at end of file 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 f86c7d7ea..02e8b2e5f 100644 --- a/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit.xml +++ b/org.argeo.slc.node.jackrabbit/META-INF/spring/jackrabbit.xml @@ -3,32 +3,33 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - - - - /org/argeo/slc/jcr/slc.cnd - - - - - + + + + + + + + + + - - + - + - + \ No newline at end of file diff --git a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java index 1ec361ac2..09827885c 100644 --- a/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java +++ b/org.argeo.slc.repo/src/org/argeo/slc/repo/maven/MavenConventionsUtils.java @@ -37,8 +37,7 @@ import org.w3c.dom.NodeList; * based). */ public class MavenConventionsUtils { - private final static Log log = LogFactory - .getLog(MavenConventionsUtils.class); + private final static Log log = LogFactory.getLog(MavenConventionsUtils.class); /** * Path to the file identified by this artifact without using Maven @@ -48,8 +47,8 @@ public class MavenConventionsUtils { * @see MavenConventionsUtils#artifactToFile(String, Artifact) */ public static File artifactToFile(Artifact artifact) { - return artifactToFile(System.getProperty("user.home") + File.separator - + ".m2" + File.separator + "repository", artifact); + return artifactToFile(System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository", + artifact); } /** @@ -62,81 +61,74 @@ public class MavenConventionsUtils { * the artifact */ public static File artifactToFile(String repositoryPath, Artifact artifact) { - return new File(repositoryPath + File.separator - + artifact.getGroupId().replace('.', File.separatorChar) - + File.separator + artifact.getArtifactId() + File.separator - + artifact.getVersion() + File.separator + return new File(repositoryPath + File.separator + artifact.getGroupId().replace('.', File.separatorChar) + + File.separator + artifact.getArtifactId() + File.separator + artifact.getVersion() + File.separator + artifactFileName(artifact)).getAbsoluteFile(); } /** The file name of this artifact when stored */ public static String artifactFileName(Artifact artifact) { - return artifact.getArtifactId() - + '-' - + artifact.getVersion() - + (artifact.getClassifier().equals("") ? "" : '-' + artifact - .getClassifier()) + '.' + artifact.getExtension(); + return artifact.getArtifactId() + '-' + artifact.getVersion() + + (artifact.getClassifier().equals("") ? "" : '-' + artifact.getClassifier()) + '.' + + artifact.getExtension(); } /** Absolute path to the file */ public static String artifactPath(String artifactBasePath, Artifact artifact) { - return artifactParentPath(artifactBasePath, artifact) + '/' - + artifactFileName(artifact); + return artifactParentPath(artifactBasePath, artifact) + '/' + artifactFileName(artifact); + } + + /** Absolute path to the file */ + public static String artifactUrl(String repoUrl, Artifact artifact) { + if (repoUrl.endsWith("/")) + return repoUrl + artifactPath("/", artifact).substring(1); + else + return repoUrl + artifactPath("/", artifact); } /** Absolute path to the directories where the files will be stored */ - public static String artifactParentPath(String artifactBasePath, - Artifact artifact) { - return artifactBasePath + (artifactBasePath.endsWith("/") ? "" : "/") - + artifactParentPath(artifact); + public static String artifactParentPath(String artifactBasePath, Artifact artifact) { + return artifactBasePath + (artifactBasePath.endsWith("/") ? "" : "/") + artifactParentPath(artifact); } /** Absolute path to the directory of this group */ public static String groupPath(String artifactBasePath, String groupId) { - return artifactBasePath + (artifactBasePath.endsWith("/") ? "" : "/") - + groupId.replace('.', '/'); + return artifactBasePath + (artifactBasePath.endsWith("/") ? "" : "/") + groupId.replace('.', '/'); } /** Relative path to the directories where the files will be stored */ public static String artifactParentPath(Artifact artifact) { - return artifact.getGroupId().replace('.', '/') + '/' - + artifact.getArtifactId() + '/' + artifact.getBaseVersion(); + return artifact.getGroupId().replace('.', '/') + '/' + artifact.getArtifactId() + '/' + + artifact.getBaseVersion(); } - public static String artifactsAsDependencyPom(Artifact pomArtifact, - Set artifacts, Artifact parent) { + public static String artifactsAsDependencyPom(Artifact pomArtifact, Set artifacts, Artifact parent) { StringBuffer p = new StringBuffer(); // XML header p.append("\n"); - p.append("\n"); + p.append( + "\n"); p.append("4.0.0\n"); // Artifact if (parent != null) { p.append("\n"); - p.append("").append(parent.getGroupId()) - .append("\n"); - p.append("").append(parent.getArtifactId()) - .append("\n"); - p.append("").append(parent.getVersion()) - .append("\n"); + p.append("").append(parent.getGroupId()).append("\n"); + p.append("").append(parent.getArtifactId()).append("\n"); + p.append("").append(parent.getVersion()).append("\n"); p.append("\n"); } - p.append("").append(pomArtifact.getGroupId()) - .append("\n"); - p.append("").append(pomArtifact.getArtifactId()) - .append("\n"); - p.append("").append(pomArtifact.getVersion()) - .append("\n"); + p.append("").append(pomArtifact.getGroupId()).append("\n"); + p.append("").append(pomArtifact.getArtifactId()).append("\n"); + p.append("").append(pomArtifact.getVersion()).append("\n"); p.append("pom\n"); // Dependencies p.append("\n"); for (Artifact a : artifacts) { p.append("\t"); - p.append("").append(a.getArtifactId()) - .append(""); + p.append("").append(a.getArtifactId()).append(""); p.append("").append(a.getGroupId()).append(""); if (!a.getExtension().equals("jar")) p.append("").append(a.getExtension()).append(""); @@ -149,8 +141,7 @@ public class MavenConventionsUtils { p.append("\n"); for (Artifact a : artifacts) { p.append("\t"); - p.append("").append(a.getArtifactId()) - .append(""); + p.append("").append(a.getArtifactId()).append(""); p.append("").append(a.getVersion()).append(""); p.append("").append(a.getGroupId()).append(""); if (a.getExtension().equals("pom")) { @@ -177,15 +168,14 @@ public class MavenConventionsUtils { * meant to migrate existing pom registering a lot of artifacts, not to * replace Maven resolving. */ - public static void gatherPomDependencies(AetherTemplate aetherTemplate, - Set artifacts, Artifact pomArtifact) { + public static void gatherPomDependencies(AetherTemplate aetherTemplate, Set artifacts, + Artifact pomArtifact) { if (log.isDebugEnabled()) log.debug("Gather dependencies for " + pomArtifact); try { File file = aetherTemplate.getResolvedFile(pomArtifact); - DocumentBuilder documentBuilder = DocumentBuilderFactory - .newInstance().newDocumentBuilder(); + DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = documentBuilder.parse(file); // properties @@ -197,8 +187,7 @@ public class MavenConventionsUtils { for (int i = 0; i < propertiesElems.getLength(); i++) { if (propertiesElems.item(i) instanceof Element) { Element property = (Element) propertiesElems.item(i); - props.put(property.getNodeName(), - property.getTextContent()); + props.put(property.getNodeName(), property.getTextContent()); } } } @@ -207,34 +196,25 @@ public class MavenConventionsUtils { NodeList dependencies = doc.getElementsByTagName("dependency"); for (int i = 0; i < dependencies.getLength(); i++) { Element dependency = (Element) dependencies.item(i); - String groupId = dependency.getElementsByTagName("groupId") - .item(0).getTextContent().trim(); - String artifactId = dependency - .getElementsByTagName("artifactId").item(0) - .getTextContent().trim(); - String version = dependency.getElementsByTagName("version") - .item(0).getTextContent().trim(); + String groupId = dependency.getElementsByTagName("groupId").item(0).getTextContent().trim(); + String artifactId = dependency.getElementsByTagName("artifactId").item(0).getTextContent().trim(); + String version = dependency.getElementsByTagName("version").item(0).getTextContent().trim(); if (version.startsWith("${")) { - String versionKey = version.substring(0, - version.length() - 1).substring(2); + String versionKey = version.substring(0, version.length() - 1).substring(2); if (!props.containsKey(versionKey)) - throw new SlcException("Cannot interpret version " - + version); + throw new SlcException("Cannot interpret version " + version); version = props.getProperty(versionKey); } NodeList scopes = dependency.getElementsByTagName("scope"); - if (scopes.getLength() > 0 - && scopes.item(0).getTextContent().equals("import")) { + if (scopes.getLength() > 0 && scopes.item(0).getTextContent().equals("import")) { // recurse gatherPomDependencies(aetherTemplate, artifacts, - new DefaultArtifact(groupId, artifactId, "pom", - version)); + new DefaultArtifact(groupId, artifactId, "pom", version)); } else { // TODO: deal with scope? // TODO: deal with type String type = "jar"; - Artifact artifact = new DefaultArtifact(groupId, - artifactId, type, version); + Artifact artifact = new DefaultArtifact(groupId, artifactId, type, version); artifacts.add(artifact); } } 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 0f918fdc3..92389339e 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 @@ -45,7 +45,8 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { private Map> mirrors = new HashMap>(); private List mavenRepositories = new ArrayList(); - private String mavenProxyBase = "/mavenProxy"; + private String downloadBase = "/download"; + private String mavenProxyBase = downloadBase + "/maven"; public void init() { if (workspace == null) @@ -63,19 +64,14 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { try { // TODO rather user a JavaRepoManager that will also implicitely // manage the indexing of newly created nodes. - javaSession = JcrUtils.loginOrCreateWorkspace(javaRepository, - workspace); - distSession = JcrUtils.loginOrCreateWorkspace(distRepository, - workspace); + javaSession = JcrUtils.loginOrCreateWorkspace(javaRepository, workspace); + 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, "jcr:all"); + JcrUtils.addPrivilege(distSession, "/", SlcConstants.ROLE_SLC, "jcr:all"); } catch (RepositoryException e) { - throw new SlcException("Cannot initialize OSGi Factory " - + workspace, e); + throw new SlcException("Cannot initialize OSGi Factory " + workspace, e); } finally { JcrUtils.logoutQuietly(javaSession); JcrUtils.logoutQuietly(distSession); @@ -100,19 +96,16 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { } } - public Node getMaven(Session distSession, String coords) - throws RepositoryException { + public Node getMaven(Session distSession, String coords) throws RepositoryException { Artifact artifact = new DefaultArtifact(coords); - String path = MavenConventionsUtils.artifactPath(mavenProxyBase, - artifact); + String path = MavenConventionsUtils.artifactPath(mavenProxyBase, artifact); // exists if (distSession.itemExists(path)) return distSession.getNode(path); for (String mavenRepo : mavenRepositories) { - String url = mavenRepo - + MavenConventionsUtils.artifactPath("/", artifact); + String url = MavenConventionsUtils.artifactUrl(mavenRepo, artifact); try { Node node = loadUrlToPath(url, distSession, path); if (node != null) { @@ -123,8 +116,7 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { // silent } try { - loadUrlToPath(url + ".sha1", distSession, path - + ".sha1"); + loadUrlToPath(url + ".sha1", distSession, path + ".sha1"); } catch (FileNotFoundException e) { // silent } @@ -132,16 +124,14 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { } } catch (FileNotFoundException e) { if (log.isDebugEnabled()) - log.debug("Maven " + coords - + " could not be downloaded from " + url); + log.debug("Maven " + coords + " could not be downloaded from " + url); } } throw new SlcException("Could not download Maven " + coords); } - public Node getDist(Session distSession, String uri) - throws RepositoryException { - String distPath = '/' + JcrUtils.urlAsPath(uri); + public Node getDist(Session distSession, String uri) throws RepositoryException { + String distPath = downloadBase + '/' + JcrUtils.urlAsPath(uri); // already retrieved if (distSession.itemExists(distPath)) @@ -174,8 +164,7 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { return loadUrlToPath(url, distSession, distPath); } catch (FileNotFoundException e) { if (log.isDebugEnabled()) - log.debug("Cannot download " + url - + ", trying another mirror"); + log.debug("Cannot download " + url + ", trying another mirror"); } } @@ -190,8 +179,7 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { InputStream in = null; URLConnection conn = null; - Node folderNode = JcrUtils.mkfolders(distSession, - JcrUtils.parentPath(path)); + Node folderNode = JcrUtils.mkfolders(distSession, JcrUtils.parentPath(path)); try { URL u = new URL(url); conn = u.openConnection(); @@ -200,8 +188,7 @@ public class OsgiFactoryImpl implements OsgiFactory, SlcNames { // byte[] arr = IOUtils.toByteArray(in); // Node fileNode = JcrUtils.copyBytesAsFile(folderNode, // JcrUtils.nodeNameFromPath(path), arr); - Node fileNode = JcrUtils.copyStreamAsFile(folderNode, - JcrUtils.nodeNameFromPath(path), in); + Node fileNode = JcrUtils.copyStreamAsFile(folderNode, JcrUtils.nodeNameFromPath(path), in); fileNode.addMixin(SlcTypes.SLC_KNOWN_ORIGIN); Node origin = fileNode.addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED); JcrUtils.urlToAddressProperties(origin, url); 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 bf901dacb..7ba658464 100644 --- a/org.argeo.slc.server.repo/META-INF/spring/jcr.xml +++ b/org.argeo.slc.server.repo/META-INF/spring/jcr.xml @@ -4,22 +4,30 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -36,26 +44,27 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + class="org.argeo.jcr.security.JcrAuthorizations" init-method="run"> - + diff --git a/pom.xml b/pom.xml index ca239d327..ac4ff9d15 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.argeo.commons @@ -13,7 +14,7 @@ 2.1 2015-02-12 - 2.1.2 + 2.1.2-SNAPSHOT 2.1.7 @@ -175,16 +176,25 @@ limitations under the License. argeo-tp - http://localhost:7080/data/public/java/argeo-tp-${developmentCycle.argeo-commons}/ + http://localhost:7070/data/public/java/argeo-${developmentCycle.argeo-commons} true daily warn + + + + + + + + + - argeo-tp-extras - http://localhost:7080/data/public/java/argeo-tp-extras-2.1 + argeo-commons + http://localhost:7070/data/public/java/argeo-${developmentCycle.argeo-commons} true daily -- 2.39.2