<scope>test</scope>
</dependency>
- <!-- Thrid parties (extras) -->
+ <!-- Third parties (extras) -->
+ <dependency>
+ <groupId>org.argeo.tp.misc</groupId>
+ <artifactId>biz.aQute.bnd</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.argeo.tp.misc</groupId>
+ <artifactId>org.junit</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.argeo.tp.extras</groupId>
<artifactId>net.sf.jxl</artifactId>
\r
<beans:bean class="org.argeo.security.core.SimpleRoleRegistration"\r
init-method="run">\r
- <beans:property name="role" value="ROLE_SLC" />\r
+ <beans:property name="role" value="org.argeo.slc.user" />\r
<beans:property name="userAdmin" ref="userAdmin" />\r
<beans:property name="userTransaction" ref="userTransaction" />\r
<!-- <beans:property name="userAdminService" ref="userAdminService" /> -->\r
/** 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";
/** 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;
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 {
return false;
}
- // public void updateStatus(ExecutionProcess process, String oldStatus,
- // String newStatus) {
- // }
- //
- // public void addSteps(ExecutionProcess process, List<ExecutionStep> 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) {
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);
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);
}
// 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
}
@Override
- protected List<Node> filterChildren(List<Node> children)
- throws RepositoryException {
+ protected List<Node> filterChildren(List<Node> children) throws RepositoryException {
for (Iterator<Node> 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);
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
}
}
} catch (RepositoryException e) {
- throw new ArgeoException("Cannot compare " + o1 + " and " + o2,
- e);
+ throw new ArgeoException("Cannot compare " + o1 + " and " + o2, e);
}
return 0;
}
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) {
}
}
- 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);
}
@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;
}
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);
}
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<String> paths = new TreeSet<String>();
- 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<String>(paths), true),
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage();
+ activePage.openEditor(new ProcessEditorInput(new ArrayList<String>(paths), true),
ProcessEditor.ID);
}
}
/** 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 {
}
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();
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');
}
}
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
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);
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);
}
}
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;
}
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) {
}
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<Node> nodes = new ArrayList<Node>();
- for (NodeIterator nit = query.execute().getNodes(); nit
- .hasNext();) {
+ for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
nodes.add(nit.nextNode());
}
return nodes.toArray();
}
- 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)
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";
}
}
@Override
- protected Boolean willProcessInUiThread(List<Event> events)
- throws RepositoryException {
+ protected Boolean willProcessInUiThread(List<Event> events) throws RepositoryException {
for (Event event : events) {
// getLog().debug("Received event " + event);
int eventType = event.getType();
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<Event> events)
- throws RepositoryException {
+ protected void onEventInUiThread(List<Event> 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);
}
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
// LogFactory.getLog(JcrResultTreeView.class);\r
\r
/* DEPENDENCY INJECTION */\r
+ private Repository repository;\r
private Session session;\r
\r
// This page widgets\r
\r
@Override\r
public void createPartControl(Composite parent) {\r
+ try {\r
+ session = repository.login();\r
+ } catch (RepositoryException e1) {\r
+ throw new SlcException("Cannot log in to repository");\r
+ }\r
+\r
parent.setLayout(new FillLayout());\r
// Main layout\r
SashForm sashForm = new SashForm(parent, SWT.VERTICAL);\r
}\r
\r
/* DEPENDENCY INJECTION */\r
- @Deprecated\r
- public void setSession(Session session) {\r
- this.session = session;\r
- }\r
-\r
public void dispose() {\r
// JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver);\r
JcrUtils.logoutQuietly(session);\r
}\r
\r
public void setRepository(Repository repository) {\r
- try {\r
- session = repository.login();\r
- } catch (RepositoryException re) {\r
- throw new SlcException("Unable to log in Repository " + repository,\r
- re);\r
- }\r
+ this.repository = repository;\r
}\r
}
\ No newline at end of file
"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);
http://www.springframework.org/schema/util/spring-util-2.5.xsd">\r
\r
<!-- REFERENCES -->\r
- <reference id="nodeRepository" interface="javax.jcr.Repository"\r
- filter="(argeo.jcr.repository.alias=node)" />\r
+ <reference id="slcRepository" interface="javax.jcr.Repository"\r
+ filter="(argeo.jcr.repository.alias=slc)" />\r
\r
<!-- <reference id="authenticationManager" -->\r
<!-- interface="org.springframework.security.authentication.AuthenticationManager" /> -->\r
\r
<!-- SERVICES -->\r
- <service ref="jcrRepository" interface="javax.jcr.Repository">\r
- <service-properties>\r
- <beans:entry key="argeo.jcr.repository.alias" value="slc" />\r
- </service-properties>\r
- </service>\r
+<!-- <service ref="jcrRepository" interface="javax.jcr.Repository"> -->\r
+<!-- <service-properties> -->\r
+<!-- <beans:entry key="argeo.jcr.repository.alias" value="slc" /> -->\r
+<!-- </service-properties> -->\r
+<!-- </service> -->\r
\r
</beans:beans>
\ No newline at end of file
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">
- <bean id="jcrRepository" class="org.argeo.jackrabbit.JackrabbitWrapper"
- init-method="init" destroy-method="destroy">
- <property name="cndFiles">
- <list>
- <value>/org/argeo/slc/jcr/slc.cnd</value>
- </list>
- </property>
- <property name="repository" ref="nodeRepository" />
- <property name="bundleContext" ref="bundleContext" />
- </bean>
+ <!-- <bean id="jcrRepository" class="org.argeo.jackrabbit.JackrabbitWrapper" -->
+ <!-- init-method="init" destroy-method="destroy"> -->
+ <!-- <property name="cndFiles"> -->
+ <!-- <list> -->
+ <!-- <value>/org/argeo/slc/jcr/slc.cnd</value> -->
+ <!-- </list> -->
+ <!-- </property> -->
+ <!-- <property name="repository" ref="nodeRepository" /> -->
+ <!-- <property name="bundleContext" ref="bundleContext" /> -->
+ <!-- </bean> -->
<!-- Security -->
- <bean class="org.argeo.jackrabbit.JackrabbitAuthorizations"
+ <bean class="org.argeo.jcr.security.JcrAuthorizations"
init-method="run">
<property name="principalPrivileges">
<map>
- <entry key="jcr:all" value="ROLE_SLC" />
+ <entry key="jcr:all" value="org.argeo.slc.user" />
</map>
</property>
- <property name="repository" ref="jcrRepository" />
+ <property name="repository" ref="slcRepository" />
</bean>
<bean
class="org.argeo.security.core.AuthenticatedApplicationContextInitialization">
<description><![CDATA[Executes initialization with a system authentication]]></description>
-<!-- <property name="authenticationManager" ref="authenticationManager" /> -->
+ <!-- <property name="authenticationManager" ref="authenticationManager"
+ /> -->
</bean>
</beans>
\ No newline at end of file
* 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 <b>without</b> using Maven
* @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);
}
/**
* 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<Artifact> artifacts, Artifact parent) {
+ public static String artifactsAsDependencyPom(Artifact pomArtifact, Set<Artifact> artifacts, Artifact parent) {
StringBuffer p = new StringBuffer();
// XML header
p.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- p.append("<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\">\n");
+ p.append(
+ "<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\">\n");
p.append("<modelVersion>4.0.0</modelVersion>\n");
// Artifact
if (parent != null) {
p.append("<parent>\n");
- p.append("<groupId>").append(parent.getGroupId())
- .append("</groupId>\n");
- p.append("<artifactId>").append(parent.getArtifactId())
- .append("</artifactId>\n");
- p.append("<version>").append(parent.getVersion())
- .append("</version>\n");
+ p.append("<groupId>").append(parent.getGroupId()).append("</groupId>\n");
+ p.append("<artifactId>").append(parent.getArtifactId()).append("</artifactId>\n");
+ p.append("<version>").append(parent.getVersion()).append("</version>\n");
p.append("</parent>\n");
}
- p.append("<groupId>").append(pomArtifact.getGroupId())
- .append("</groupId>\n");
- p.append("<artifactId>").append(pomArtifact.getArtifactId())
- .append("</artifactId>\n");
- p.append("<version>").append(pomArtifact.getVersion())
- .append("</version>\n");
+ p.append("<groupId>").append(pomArtifact.getGroupId()).append("</groupId>\n");
+ p.append("<artifactId>").append(pomArtifact.getArtifactId()).append("</artifactId>\n");
+ p.append("<version>").append(pomArtifact.getVersion()).append("</version>\n");
p.append("<packaging>pom</packaging>\n");
// Dependencies
p.append("<dependencies>\n");
for (Artifact a : artifacts) {
p.append("\t<dependency>");
- p.append("<artifactId>").append(a.getArtifactId())
- .append("</artifactId>");
+ p.append("<artifactId>").append(a.getArtifactId()).append("</artifactId>");
p.append("<groupId>").append(a.getGroupId()).append("</groupId>");
if (!a.getExtension().equals("jar"))
p.append("<type>").append(a.getExtension()).append("</type>");
p.append("<dependencies>\n");
for (Artifact a : artifacts) {
p.append("\t<dependency>");
- p.append("<artifactId>").append(a.getArtifactId())
- .append("</artifactId>");
+ p.append("<artifactId>").append(a.getArtifactId()).append("</artifactId>");
p.append("<version>").append(a.getVersion()).append("</version>");
p.append("<groupId>").append(a.getGroupId()).append("</groupId>");
if (a.getExtension().equals("pom")) {
* meant to migrate existing pom registering a lot of artifacts, not to
* replace Maven resolving.
*/
- public static void gatherPomDependencies(AetherTemplate aetherTemplate,
- Set<Artifact> artifacts, Artifact pomArtifact) {
+ public static void gatherPomDependencies(AetherTemplate aetherTemplate, Set<Artifact> 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
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());
}
}
}
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);
}
}
private Map<String, List<String>> mirrors = new HashMap<String, List<String>>();
private List<String> mavenRepositories = new ArrayList<String>();
- private String mavenProxyBase = "/mavenProxy";
+ private String downloadBase = "/download";
+ private String mavenProxyBase = downloadBase + "/maven";
public void init() {
if (workspace == null)
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);
}
}
- 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) {
// silent
}
try {
- loadUrlToPath(url + ".sha1", distSession, path
- + ".sha1");
+ loadUrlToPath(url + ".sha1", distSession, path + ".sha1");
} catch (FileNotFoundException e) {
// silent
}
}
} 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))
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");
}
}
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();
// 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);
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
\r
<!-- JCR repositories -->\r
-<!-- <bean id="javaRepository" parent="template.jcrRepository"> -->\r
-<!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/java" /> -->\r
-<!-- <property name="configuration" value="${slc.repo.jcr.configuration.java}" /> -->\r
-<!-- </bean> -->\r
-<!-- <bean id="distRepository" parent="template.jcrRepository"> -->\r
-<!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/dist" /> -->\r
-<!-- <property name="configuration" value="${slc.repo.jcr.configuration.dist}" /> -->\r
-<!-- </bean> -->\r
-<!-- <bean id="rpmRepository" parent="template.jcrRepository"> -->\r
-<!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/rpm" /> -->\r
-<!-- <property name="configuration" value="${slc.repo.jcr.configuration.rpm}" /> -->\r
-<!-- </bean> -->\r
-<!-- <bean id="docsRepository" parent="template.jcrRepository"> -->\r
-<!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/docs" /> -->\r
-<!-- <property name="configuration" value="${slc.repo.jcr.configuration.docs}" /> -->\r
-<!-- </bean> -->\r
+ <!-- <bean id="javaRepository" parent="template.jcrRepository"> -->\r
+ <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/java" \r
+ /> -->\r
+ <!-- <property name="configuration" value="${slc.repo.jcr.configuration.java}" \r
+ /> -->\r
+ <!-- </bean> -->\r
+ <!-- <bean id="distRepository" parent="template.jcrRepository"> -->\r
+ <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/dist" \r
+ /> -->\r
+ <!-- <property name="configuration" value="${slc.repo.jcr.configuration.dist}" \r
+ /> -->\r
+ <!-- </bean> -->\r
+ <!-- <bean id="rpmRepository" parent="template.jcrRepository"> -->\r
+ <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/rpm" \r
+ /> -->\r
+ <!-- <property name="configuration" value="${slc.repo.jcr.configuration.rpm}" \r
+ /> -->\r
+ <!-- </bean> -->\r
+ <!-- <bean id="docsRepository" parent="template.jcrRepository"> -->\r
+ <!-- <property name="homeDirectory" value="${slc.repo.jcr.reposBase}/docs" \r
+ /> -->\r
+ <!-- <property name="configuration" value="${slc.repo.jcr.configuration.docs}" \r
+ /> -->\r
+ <!-- </bean> -->\r
\r
<!-- JCR authorizations -->\r
<bean parent="template.jcrAuthorizations">\r
</bean>\r
\r
<!-- Templates -->\r
-<!-- <bean id="template.jcrRepository" abstract="true" -->\r
-<!-- class="org.argeo.jackrabbit.JackrabbitContainer" init-method="init" -->\r
-<!-- destroy-method="destroy"> -->\r
-<!-- <property name="variables" value="osgibundle:/repo.properties" /> -->\r
-<!-- <property name="cndFiles"> -->\r
-<!-- <list> -->\r
-<!-- <value>/org/argeo/jcr/argeo.cnd</value> -->\r
-<!-- <value>/org/argeo/slc/jcr/slc.cnd</value> -->\r
-<!-- <value>/org/argeo/slc/repo/repo.cnd</value> -->\r
-<!-- </list> -->\r
-<!-- </property> -->\r
-<!-- <property name="bundleContext" ref="bundleContext" /> -->\r
-<!-- <property name="forceCndImport" value="${slc.repo.jcr.forceCndImport}" /> -->\r
-<!-- </bean> -->\r
+ <!-- <bean id="template.jcrRepository" abstract="true" -->\r
+ <!-- class="org.argeo.jackrabbit.JackrabbitContainer" init-method="init" -->\r
+ <!-- destroy-method="destroy"> -->\r
+ <!-- <property name="variables" value="osgibundle:/repo.properties" /> -->\r
+ <!-- <property name="cndFiles"> -->\r
+ <!-- <list> -->\r
+ <!-- <value>/org/argeo/jcr/argeo.cnd</value> -->\r
+ <!-- <value>/org/argeo/slc/jcr/slc.cnd</value> -->\r
+ <!-- <value>/org/argeo/slc/repo/repo.cnd</value> -->\r
+ <!-- </list> -->\r
+ <!-- </property> -->\r
+ <!-- <property name="bundleContext" ref="bundleContext" /> -->\r
+ <!-- <property name="forceCndImport" value="${slc.repo.jcr.forceCndImport}" \r
+ /> -->\r
+ <!-- </bean> -->\r
\r
<bean id="template.jcrAuthorizations" abstract="true"\r
- class="org.argeo.jackrabbit.JackrabbitAuthorizations" init-method="run">\r
+ class="org.argeo.jcr.security.JcrAuthorizations" init-method="run">\r
<property name="principalPrivileges">\r
<map>\r
- <entry key="jcr:all" value="ROLE_SLC" />\r
+ <entry key="jcr:all" value="org.argeo.slc.user" />\r
</map>\r
</property>\r
<property name="workspace" value="*" />\r
-<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>
<properties>
<developmentCycle.slc>2.1</developmentCycle.slc>
<developmentCycle.startDate>2015-02-12</developmentCycle.startDate>
- <version.slc>2.1.2</version.slc>
+ <version.slc>2.1.2-SNAPSHOT</version.slc>
<!-- Libraries versions -->
<version.argeo-tp-extras>2.1.7</version.argeo-tp-extras>
</properties>
<repositories>
<repository>
<id>argeo-tp</id>
- <url>http://localhost:7080/data/public/java/argeo-tp-${developmentCycle.argeo-commons}/</url>
+ <url>http://localhost:7070/data/public/java/argeo-${developmentCycle.argeo-commons}</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-tp-extras</id>
- <url>http://localhost:7080/data/public/java/argeo-tp-extras-2.1</url>
+ <id>argeo-commons</id>
+ <url>http://localhost:7070/data/public/java/argeo-${developmentCycle.argeo-commons}</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>