**/target/
**/generated/
**/MANIFEST.MF
+/sdk.mk
+/output/
--- /dev/null
+[submodule "sdk/argeo-build"]
+ path = sdk/argeo-build
+ url = http://git.argeo.org/cc0/argeo-build.git
+ branch = testing
</buildSpec>
<natures>
</natures>
- <filteredResources>
- <filter>
- <id>0</id>
- <name>demo/exec</name>
- <type>30</type>
- <matcher>
- <id>org.eclipse.ui.ide.multiFilter</id>
- <arguments>1.0-name-matches-false-false-indexes</arguments>
- </matcher>
- </filter>
- <filter>
- <id>0</id>
- <name>demo/exec</name>
- <type>22</type>
- <matcher>
- <id>org.eclipse.ui.ide.multiFilter</id>
- <arguments>1.0-name-matches-false-false-repos</arguments>
- </matcher>
- </filter>
- </filteredResources>
</projectDescription>
--- /dev/null
+include sdk.mk
+.PHONY: clean all osgi
+
+all: osgi move-ext
+
+A2_CATEGORY = org.argeo.slc
+
+BUNDLES = \
+org.argeo.slc.api \
+org.argeo.slc.factory \
+org.argeo.slc.runtime \
+ext/org.argeo.ext.slf4j \
+
+BOOTSTRAP_BASE=$(SDK_BUILD_BASE)/bootstrap
+
+distribution: bootstrap
+ $(JVM) -cp \
+ $(BOOTSTRAP_BASE)/bndlib.jar:$(BOOTSTRAP_BASE)/slf4j-api.jar:$(BOOTSTRAP_BASE)/org.argeo.slc.api/bin:$(BOOTSTRAP_BASE)/org.argeo.slc.factory/bin \
+ tp/Make.java $(A2_OUTPUT)
+
+bootstrap :
+ mkdir -p $(SDK_BUILD_BASE)/bootstrap
+ wget -c -O $(BOOTSTRAP_BASE)/ecj.jar https://repo1.maven.org/maven2/org/eclipse/jdt/ecj/3.28.0/ecj-3.28.0.jar
+ wget -c -O $(BOOTSTRAP_BASE)/slf4j-api.jar https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.28/slf4j-api-1.7.28.jar
+ wget -c -O $(BOOTSTRAP_BASE)/bndlib.jar https://repo1.maven.org/maven2/biz/aQute/bnd/biz.aQute.bndlib/5.3.0/biz.aQute.bndlib-5.3.0.jar
+ $(JVM) -cp $(BOOTSTRAP_BASE)/ecj.jar org.eclipse.jdt.internal.compiler.batch.Main -11 -nowarn -time -cp \
+ $(BOOTSTRAP_BASE)/bndlib.jar:$(BOOTSTRAP_BASE)/slf4j.jar \
+ org.argeo.slc.api/src[-d $(BOOTSTRAP_BASE)/org.argeo.slc.api/bin] \
+ org.argeo.slc.factory/src[-d $(BOOTSTRAP_BASE)/org.argeo.slc.factory/bin] \
+
+move-ext: osgi
+ mkdir -p $(SDK_BUILD_BASE)/a2/org.argeo.tp
+ cp $(SDK_BUILD_BASE)/a2/$(A2_CATEGORY)/org.argeo.ext.slf4j.$(MAJOR).$(MINOR).jar $(SDK_BUILD_BASE)/a2/org.argeo.tp
+# mv $(SDK_BUILD_BASE)/a2/$(A2_CATEGORY)/org.argeo.ext.equinox.jetty.$(MAJOR).$(MINOR).jar $(SDK_BUILD_BASE)/a2/org.argeo.tp.eclipse.equinox
+
+clean:
+ rm -rf $(BUILD_BASE)
+ rm -rf $(BOOTSTRAP_BASE)
+
+A2_OUTPUT = $(SDK_BUILD_BASE)/a2
+A2_BASE = $(A2_OUTPUT)
+
+VPATH = .:ext
+DEP_CATEGORIES = org.argeo.tp org.argeo.tp.apache org.argeo.tp.sdk org.argeo.tp.jcr
+
+include $(SDK_SRC_BASE)/sdk/argeo-build/osgi.mk
\ No newline at end of file
--- /dev/null
+include $(SDK_SRC_BASE)/cnf/testing.bnd
--- /dev/null
+MAJOR=2
+MINOR=3
+++ /dev/null
--include: ../../cnf/maven.bnd
\ No newline at end of file
Import-Package:\
-org.argeo.api,\
javax.jcr.nodetype,\
+org.apache.commons.logging,\
+org.apache.jackrabbit.*;version="[1,4)",\
+javax.servlet.*;version="[3,5)",\
*
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc-cms</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.cms.integration</artifactId>
- <name>CMS Integration</name>
- <dependencies>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.cms</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.maintenance</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
/** Serialisable wrapper of a {@link Throwable}. */
public class CmsExceptionsChain {
- public final static Log log = LogFactory.getLog(CmsExceptionsChain.class);
+ public final static CmsLog log = CmsLog.getLog(CmsExceptionsChain.class);
private List<SystemException> exceptions = new ArrayList<>();
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.auth.CmsSessionId;
-import org.argeo.cms.auth.HttpRequestCallback;
-import org.argeo.cms.auth.HttpRequestCallbackHandler;
+import org.argeo.api.cms.CmsAuth;
+import org.argeo.api.cms.CmsSessionId;
+import org.argeo.cms.auth.RemoteAuthCallback;
+import org.argeo.cms.auth.RemoteAuthCallbackHandler;
+import org.argeo.cms.servlet.ServletHttpRequest;
+import org.argeo.cms.servlet.ServletHttpResponse;
import org.osgi.service.useradmin.Authorization;
import com.fasterxml.jackson.core.JsonGenerator;
}
@Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
LoginContext lc = null;
- String username = request.getParameter(PARAM_USERNAME);
- String password = request.getParameter(PARAM_PASSWORD);
+ String username = req.getParameter(PARAM_USERNAME);
+ String password = req.getParameter(PARAM_PASSWORD);
+ ServletHttpRequest request = new ServletHttpRequest(req);
+ ServletHttpResponse response = new ServletHttpResponse(resp);
try {
- lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, new HttpRequestCallbackHandler(request, response) {
+ lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_USER, new RemoteAuthCallbackHandler(request, response) {
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (Callback callback : callbacks) {
if (callback instanceof NameCallback && username != null)
((NameCallback) callback).setName(username);
else if (callback instanceof PasswordCallback && password != null)
((PasswordCallback) callback).setPassword(password.toCharArray());
- else if (callback instanceof HttpRequestCallback) {
- ((HttpRequestCallback) callback).setRequest(request);
- ((HttpRequestCallback) callback).setResponse(response);
+ else if (callback instanceof RemoteAuthCallback) {
+ ((RemoteAuthCallback) callback).setRequest(request);
+ ((RemoteAuthCallback) callback).setResponse(response);
}
}
}
Subject subject = lc.getSubject();
CmsSessionId cmsSessionId = extractFrom(subject.getPrivateCredentials(CmsSessionId.class));
if (cmsSessionId == null) {
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
Authorization authorization = extractFrom(subject.getPrivateCredentials(Authorization.class));
cmsSessionId.getUuid().toString(), authorization.getRoles(), authorization.toString(),
locale != null ? locale.toString() : null);
- response.setContentType("application/json");
- JsonGenerator jg = objectMapper.getFactory().createGenerator(response.getWriter());
+ resp.setContentType("application/json");
+ JsonGenerator jg = objectMapper.getFactory().createGenerator(resp.getWriter());
jg.writeObject(cmsSessionDescriptor);
- String redirectTo = redirectTo(request);
+ String redirectTo = redirectTo(req);
if (redirectTo != null)
- response.sendRedirect(redirectTo);
+ resp.sendRedirect(redirectTo);
} catch (LoginException e) {
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
}
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.auth.CmsSessionId;
+import org.argeo.api.cms.CmsAuth;
+import org.argeo.api.cms.CmsSessionId;
import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.auth.HttpRequestCallback;
-import org.argeo.cms.auth.HttpRequestCallbackHandler;
+import org.argeo.cms.auth.RemoteAuthCallback;
+import org.argeo.cms.auth.RemoteAuthCallbackHandler;
+import org.argeo.cms.servlet.ServletHttpRequest;
+import org.argeo.cms.servlet.ServletHttpResponse;
/** Externally authenticate an http session. */
public class CmsLogoutServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
+ ServletHttpRequest httpRequest = new ServletHttpRequest(request);
+ ServletHttpResponse httpResponse = new ServletHttpResponse(response);
LoginContext lc = null;
try {
- lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, new HttpRequestCallbackHandler(request, response) {
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
- for (Callback callback : callbacks) {
- if (callback instanceof HttpRequestCallback) {
- ((HttpRequestCallback) callback).setRequest(request);
- ((HttpRequestCallback) callback).setResponse(response);
+ lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_USER,
+ new RemoteAuthCallbackHandler(httpRequest, httpResponse) {
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ for (Callback callback : callbacks) {
+ if (callback instanceof RemoteAuthCallback) {
+ ((RemoteAuthCallback) callback).setRequest(httpRequest);
+ ((RemoteAuthCallback) callback).setResponse(httpResponse);
+ }
+ }
}
- }
- }
- });
+ });
lc.login();
Subject subject = lc.getSubject();
package org.argeo.cms.integration;
-import static org.argeo.api.NodeConstants.LOGIN_CONTEXT_USER;
-
import java.io.IOException;
import java.security.AccessControlContext;
import java.security.PrivilegedAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.argeo.cms.auth.HttpRequestCallbackHandler;
-import org.argeo.cms.servlet.ServletAuthUtils;
+import org.argeo.api.cms.CmsAuth;
+import org.argeo.cms.auth.RemoteAuthCallbackHandler;
+import org.argeo.cms.auth.RemoteAuthUtils;
+import org.argeo.cms.servlet.ServletHttpRequest;
+import org.argeo.cms.servlet.ServletHttpResponse;
import org.osgi.service.http.context.ServletContextHelper;
/** Manages security access to servlets. */
* the login page.
*/
@Override
- public boolean handleSecurity(final HttpServletRequest request, HttpServletResponse response) throws IOException {
+ public boolean handleSecurity(final HttpServletRequest req, HttpServletResponse resp) throws IOException {
LoginContext lc = null;
+ ServletHttpRequest request = new ServletHttpRequest(req);
+ ServletHttpResponse response = new ServletHttpResponse(resp);
- String pathInfo = request.getPathInfo();
- String servletPath = request.getServletPath();
+ String pathInfo = req.getPathInfo();
+ String servletPath = req.getServletPath();
if ((pathInfo != null && (servletPath + pathInfo).equals(loginPage)) || servletPath.contentEquals(loginServlet))
return true;
try {
- lc = new LoginContext(LOGIN_CONTEXT_USER, new HttpRequestCallbackHandler(request, response));
+ lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_USER, new RemoteAuthCallbackHandler(request, response));
lc.login();
} catch (LoginException e) {
- lc = processUnauthorized(request, response);
+ lc = processUnauthorized(req, resp);
if (lc == null)
return false;
}
@Override
public Void run() {
// TODO also set login context in order to log out ?
- ServletAuthUtils.configureRequestSecurity(request);
+ RemoteAuthUtils.configureRequestSecurity(request);
return null;
}
}
@Override
- public void finishSecurity(HttpServletRequest request, HttpServletResponse response) {
- ServletAuthUtils.clearRequestSecurity(request);
+ public void finishSecurity(HttpServletRequest req, HttpServletResponse resp) {
+ RemoteAuthUtils.clearRequestSecurity(new ServletHttpRequest(req));
}
protected LoginContext processUnauthorized(HttpServletRequest request, HttpServletResponse response) {
import java.util.Set;
import java.util.TreeSet;
-import org.argeo.cms.auth.CmsSession;
+import org.argeo.api.cms.CmsSession;
import org.osgi.service.useradmin.Authorization;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.argeo.api.NodeConstants;
+import org.argeo.api.cms.CmsAuth;
import org.argeo.cms.CmsUserManager;
-import org.argeo.cms.auth.HttpRequestCallback;
-import org.argeo.cms.auth.HttpRequestCallbackHandler;
-import org.argeo.naming.NamingUtils;
+import org.argeo.cms.auth.RemoteAuthCallback;
+import org.argeo.cms.auth.RemoteAuthCallbackHandler;
+import org.argeo.cms.servlet.ServletHttpRequest;
+import org.argeo.cms.servlet.ServletHttpResponse;
+import org.argeo.util.naming.NamingUtils;
import org.osgi.service.useradmin.Authorization;
import com.fasterxml.jackson.core.JsonGenerator;
private ObjectMapper objectMapper = new ObjectMapper();
@Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ ServletHttpRequest request = new ServletHttpRequest(req);
+ ServletHttpResponse response = new ServletHttpResponse(resp);
LoginContext lc = null;
try {
- lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, new HttpRequestCallbackHandler(request, response) {
+ lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_USER, new RemoteAuthCallbackHandler(request, response) {
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (Callback callback : callbacks) {
- if (callback instanceof HttpRequestCallback) {
- ((HttpRequestCallback) callback).setRequest(request);
- ((HttpRequestCallback) callback).setResponse(response);
+ if (callback instanceof RemoteAuthCallback) {
+ ((RemoteAuthCallback) callback).setRequest(request);
+ ((RemoteAuthCallback) callback).setResponse(response);
}
}
}
Subject subject = lc.getSubject();
Authorization authorization = extractFrom(subject.getPrivateCredentials(Authorization.class));
String token = UUID.randomUUID().toString();
- String expiryDateStr = request.getParameter(PARAM_EXPIRY_DATE);
+ String expiryDateStr = req.getParameter(PARAM_EXPIRY_DATE);
ZonedDateTime expiryDate;
if (expiryDateStr != null) {
expiryDate = NamingUtils.ldapDateToZonedDateTime(expiryDateStr);
tokenDescriptor.setExpiryDate(expiryDateStr);
// tokenDescriptor.setRoles(Collections.unmodifiableSortedSet(new TreeSet<>(Arrays.asList(roles))));
- response.setContentType("application/json");
- JsonGenerator jg = objectMapper.getFactory().createGenerator(response.getWriter());
+ resp.setContentType("application/json");
+ JsonGenerator jg = objectMapper.getFactory().createGenerator(resp.getWriter());
jg.writeObject(tokenDescriptor);
} catch (Exception e) {
- new CmsExceptionsChain(e).writeAsJson(objectMapper, response);
+ new CmsExceptionsChain(e).writeAsJson(objectMapper, resp);
}
}
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.jackrabbit.api.JackrabbitNode;
import org.apache.jackrabbit.api.JackrabbitValue;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.osgi.service.http.context.ServletContextHelper;
/** Access a JCR repository via web services. */
public class JcrReadServlet extends HttpServlet {
private static final long serialVersionUID = 6536175260540484539L;
- private final static Log log = LogFactory.getLog(JcrReadServlet.class);
+ private final static CmsLog log = CmsLog.getLog(JcrReadServlet.class);
protected final static String ACCEPT_HTTP_HEADER = "Accept";
protected final static String CONTENT_DISPOSITION_HTTP_HEADER = "Content-Disposition";
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
/** Access a JCR repository via web services. */
public class JcrWriteServlet extends JcrReadServlet {
private static final long serialVersionUID = 17272653843085492L;
- private final static Log log = LogFactory.getLog(JcrWriteServlet.class);
+ private final static CmsLog log = CmsLog.getLog(JcrWriteServlet.class);
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
package org.argeo.cms.websocket;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.List;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.servlet.http.HttpSession;
-import javax.websocket.Extension;
-import javax.websocket.HandshakeResponse;
-import javax.websocket.server.HandshakeRequest;
-import javax.websocket.server.ServerEndpointConfig;
-import javax.websocket.server.ServerEndpointConfig.Configurator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.auth.HttpRequestCallbackHandler;
-import org.osgi.service.http.context.ServletContextHelper;
-
-/** Customises the initialisation of a new web socket. */
-public class CmsWebSocketConfigurator extends Configurator {
- public final static String WEBSOCKET_SUBJECT = "org.argeo.cms.websocket.subject";
-
- private final static Log log = LogFactory.getLog(CmsWebSocketConfigurator.class);
- final static String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate";
-
- @Override
- public boolean checkOrigin(String originHeaderValue) {
- return true;
- }
-
- @Override
- public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
- try {
- return endpointClass.getDeclaredConstructor().newInstance();
- } catch (Exception e) {
- throw new IllegalArgumentException("Cannot get endpoint instance", e);
- }
- }
-
- @Override
- public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) {
- return requested;
- }
-
- @Override
- public String getNegotiatedSubprotocol(List<String> supported, List<String> requested) {
- if ((requested == null) || (requested.size() == 0))
- return "";
- if ((supported == null) || (supported.isEmpty()))
- return "";
- for (String possible : requested) {
- if (possible == null)
- continue;
- if (supported.contains(possible))
- return possible;
- }
- return "";
- }
-
- @Override
- public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
- HttpSession httpSession = (HttpSession) request.getHttpSession();
- if (log.isDebugEnabled() && httpSession != null)
- log.debug("Web socket HTTP session id: " + httpSession.getId());
-
- if (httpSession == null) {
- rejectResponse(response, null);
- }
- try {
- LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER,
- new HttpRequestCallbackHandler(httpSession));
- lc.login();
- if (log.isDebugEnabled())
- log.debug("Web socket logged-in as " + lc.getSubject());
- Subject.doAs(lc.getSubject(), new PrivilegedAction<Void>() {
-
- @Override
- public Void run() {
- sec.getUserProperties().put(ServletContextHelper.REMOTE_USER, AccessController.getContext());
- return null;
- }
-
- });
- } catch (Exception e) {
- rejectResponse(response, e);
- }
- }
-
- /**
- * Behaviour when the web socket could not be authenticated. Throws an
- * {@link IllegalStateException} by default.
- *
- * @param e can be null
- */
- protected void rejectResponse(HandshakeResponse response, Exception e) {
- // violent implementation, as suggested in
- // https://stackoverflow.com/questions/21763829/jsr-356-how-to-abort-a-websocket-connection-during-the-handshake
-// throw new IllegalStateException("Web socket cannot be authenticated");
- }
-}
-
-//if (!webServerConfig.isEmpty()) {
-//webServerConfig.put("customizer.class", KernelConstants.CMS_JETTY_CUSTOMIZER_CLASS);
+/** <strong>Disabled until third party issues are solved.</strong>. Customises the initialisation of a new web socket. */
+public class CmsWebSocketConfigurator {
+//extends Configurator {
+// public final static String WEBSOCKET_SUBJECT = "org.argeo.cms.websocket.subject";
//
-//// TODO centralise with Jetty extender
-//Object webSocketEnabled = webServerConfig.get(InternalHttpConstants.WEBSOCKET_ENABLED);
-//if (webSocketEnabled != null && webSocketEnabled.toString().equals("true")) {
-// bc.registerService(ServerEndpointConfig.Configurator.class, new CmsWebSocketConfigurator(), null);
-// webServerConfig.put(InternalHttpConstants.WEBSOCKET_ENABLED, "true");
-//}
-//}
-
+// private final static CmsLog log = CmsLog.getLog(CmsWebSocketConfigurator.class);
+// final static String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate";
+//
+// @Override
+// public boolean checkOrigin(String originHeaderValue) {
+// return true;
+// }
+//
+// @Override
+// public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
+// try {
+// return endpointClass.getDeclaredConstructor().newInstance();
+// } catch (Exception e) {
+// throw new IllegalArgumentException("Cannot get endpoint instance", e);
+// }
+// }
+//
+// @Override
+// public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) {
+// return requested;
+// }
+//
+// @Override
+// public String getNegotiatedSubprotocol(List<String> supported, List<String> requested) {
+// if ((requested == null) || (requested.size() == 0))
+// return "";
+// if ((supported == null) || (supported.isEmpty()))
+// return "";
+// for (String possible : requested) {
+// if (possible == null)
+// continue;
+// if (supported.contains(possible))
+// return possible;
+// }
+// return "";
+// }
+//
+// @Override
+// public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
+//
+// RemoteAuthSession httpSession = new ServletHttpSession((javax.servlet.http.HttpSession) request.getHttpSession());
+// if (log.isDebugEnabled() && httpSession != null)
+// log.debug("Web socket HTTP session id: " + httpSession.getId());
+//
+// if (httpSession == null) {
+// rejectResponse(response, null);
+// }
+// try {
+// LoginContext lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_USER,
+// new RemoteAuthCallbackHandler(httpSession));
+// lc.login();
+// if (log.isDebugEnabled())
+// log.debug("Web socket logged-in as " + lc.getSubject());
+// Subject.doAs(lc.getSubject(), new PrivilegedAction<Void>() {
+//
+// @Override
+// public Void run() {
+// sec.getUserProperties().put(ServletContextHelper.REMOTE_USER, AccessController.getContext());
+// return null;
+// }
+//
+// });
+// } catch (Exception e) {
+// rejectResponse(response, e);
+// }
+// }
+//
+// /**
+// * Behaviour when the web socket could not be authenticated. Throws an
+// * {@link IllegalStateException} by default.
+// *
+// * @param e can be null
+// */
+// protected void rejectResponse(HandshakeResponse response, Exception e) {
+// // violent implementation, as suggested in
+// // https://stackoverflow.com/questions/21763829/jsr-356-how-to-abort-a-websocket-connection-during-the-handshake
+//// throw new IllegalStateException("Web socket cannot be authenticated");
+// }
+}
import org.apache.commons.exec.Executor;
import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs2.FileContent;
import org.apache.commons.vfs2.FileObject;
+import org.argeo.api.cms.CmsLog;
/**
* Runs an OS command and save its standard output as a file. Typically used for
* MySQL or OpenLDAP dumps.
*/
public class OsCallBackup extends AbstractAtomicBackup {
- private final static Log log = LogFactory.getLog(OsCallBackup.class);
+ private final static CmsLog log = CmsLog.getLog(OsCallBackup.class);
private String command;
private Map<String, String> variables = new HashMap<String, String>();
import java.util.SortedMap;
import java.util.TreeMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.FileSystemOptions;
import org.apache.commons.vfs2.Selectors;
+import org.argeo.api.cms.CmsLog;
/** Simple backup purge which keeps backups only for a given number of days */
public class SimpleBackupPurge implements BackupPurge {
- private final static Log log = LogFactory.getLog(SimpleBackupPurge.class);
+ private final static CmsLog log = CmsLog.getLog(SimpleBackupPurge.class);
private Integer daysKept = 30;
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.Selectors;
import org.apache.commons.vfs2.UserAuthenticator;
import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder;
+import org.argeo.api.cms.CmsLog;
import org.argeo.util.LangUtils;
/**
* remote and local data based on certain criteria.
*/
public class SystemBackup implements Runnable {
- private final static Log log = LogFactory.getLog(SystemBackup.class);
+ private final static CmsLog log = CmsLog.getLog(SystemBackup.class);
private FileSystemManager fileSystemManager;
private UserAuthenticator userAuthenticator = null;
FileSystemOptions opts = new FileSystemOptions();
try {
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, userAuthenticator);
- } catch (FileSystemException e) {
+ } catch (Exception e) {
throw new MaintenanceException("Cannot create authentication", e);
}
import java.util.Scanner;
import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.subsystem.sftp.fs.SftpFileSystemProvider;
import org.apache.sshd.common.util.io.NoCloseInputStream;
import org.apache.sshd.common.util.io.NoCloseOutputStream;
+import org.argeo.api.cms.CmsLog;
@SuppressWarnings("restriction")
abstract class AbstractSsh {
- private final static Log log = LogFactory.getLog(AbstractSsh.class);
+ private final static CmsLog log = CmsLog.getLog(AbstractSsh.class);
private static SshClient sshClient;
private static SftpFileSystemProvider sftpFileSystemProvider;
// sshd.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh", "-i",
// "-l" }));
String[] shellCommand = OS.LOCAL.getDefaultShellCommand();
- sshd.setShellFactory(new ProcessShellFactory(shellCommand));
+ // FIXME transfer args
+// sshd.setShellFactory(new ProcessShellFactory(shellCommand));
+// sshd.setShellFactory(new ProcessShellFactory(shellCommand[0], shellCommand));
sshd.setCommandFactory(new ScpCommandFactory());
sshd.start();
} catch (Exception e) {
import java.util.Scanner;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.sshd.agent.SshAgent;
import org.apache.sshd.agent.SshAgentFactory;
import org.apache.sshd.agent.local.LocalAgentFactory;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.client.subsystem.sftp.fs.SftpFileSystem;
import org.apache.sshd.client.subsystem.sftp.fs.SftpFileSystemProvider;
+import org.argeo.api.cms.CmsLog;
public class SshSync {
- private final static Log log = LogFactory.getLog(SshSync.class);
+ private final static CmsLog log = CmsLog.getLog(SshSync.class);
public static void main(String[] args) {
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+++ /dev/null
-/bin/
-/target/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.ext.equinox.jetty</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-Fragment-Host: org.eclipse.equinox.http.jetty
-
-Import-Package: org.eclipse.jetty.websocket.jsr356,\
-org.eclipse.jetty.websocket.api,\
-org.eclipse.jetty.websocket.common,\
-org.osgi.service.http,\
-*
\ No newline at end of file
+++ /dev/null
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<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.slc</groupId>
- <artifactId>argeo-slc-cms</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.ext.equinox.jetty</artifactId>
- <name>Extension of Equinox Jetty Integration</name>
- <dependencies>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.cms</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.argeo.equinox.jetty;
-
-import java.util.Dictionary;
-
-import javax.servlet.ServletContext;
-import javax.websocket.DeploymentException;
-
-import org.eclipse.equinox.http.jetty.JettyCustomizer;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
-import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
-import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.Configurator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-
-/** Customises the Jetty HTTP server. */
-public class CmsJettyCustomizer extends JettyCustomizer {
- private BundleContext bc = FrameworkUtil.getBundle(CmsJettyCustomizer.class).getBundleContext();
-
- public final static String WEBSOCKET_ENABLED = "websocket.enabled";
-
- @Override
- public Object customizeContext(Object context, Dictionary<String, ?> settings) {
- // WebSocket
- Object webSocketEnabled = settings.get(WEBSOCKET_ENABLED);
- if (webSocketEnabled != null && webSocketEnabled.toString().equals("true")) {
- ServletContextHandler servletContextHandler = (ServletContextHandler) context;
- WebSocketServerContainerInitializer.configure(servletContextHandler, new Configurator() {
-
- @Override
- public void accept(ServletContext servletContext, ServerContainer serverContainer)
- throws DeploymentException {
- bc.registerService(javax.websocket.server.ServerContainer.class, serverContainer, null);
- }
- });
- }
- return super.customizeContext(context, settings);
-
- }
-}
+++ /dev/null
-/** Equinox Jetty extensions. */
-package org.argeo.equinox.jetty;
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1-SNAPSHOT</version>
- </parent>
- <artifactId>argeo-slc-cms</artifactId>
- <packaging>pom</packaging>
- <name>Argeo SLC CMS</name>
- <version>2.1-SNAPSHOT</version>
- <modules>
- <!-- Argeo CMS extensions -->
- <module>org.argeo.cms.integration</module>
- <module>org.argeo.ext.equinox.jetty</module>
-
- </modules>
-</project>
+++ /dev/null
-# Common
-Bundle-Version: ${version.released}${qualifier}
-Private-Package: *.internal.*
-Export-Package: !*.internal.*, *
--consumer-policy : ${range;[==,=+)}
--savemanifest : META-INF/MANIFEST.MF
--includeresource.default : OSGI-INF/=-OSGI-INF/,e4xmi/=-e4xmi/,icons/=-icons/,img/=-img/
--compression STORE
--source true
--removeheaders = Bnd-LastModified,Build-Jdk,Built-By,Tool,Created-By
-Automatic-Module-Name: ${bsn}
-SLC-Category=${category}
--groupid=${category}
-include: \
-${workspace}/cnf/argeo.bnd, \
-${workspace}/cnf/testing.bnd
+${workspace}/cnf/testing.bnd, \
+${workspace}/sdk/argeo-build/argeo.bnd, \
+++ /dev/null
--include: \
-../cnf/argeo.bnd, \
-../cnf/testing.bnd
-version.released=2.1.18
+MAJOR=2
+MINOR=1
+MICRO=18
qualifier=.next
category=org.argeo.slc
-version.released=2.3.0
+MAJOR=2
+MINOR=3
+MICRO=1
qualifier=.next
category=org.argeo.slc
--- /dev/null
+#!/bin/sh
+
+# We build where we are
+SDK_BUILD_BASE=$(pwd -P)/output
+
+# Source are located where this script is
+SDK_SRC_BASE="$(cd "$(dirname "$0")"; pwd -P)"
+
+SDK_MK=$SDK_SRC_BASE/sdk.mk
+
+#echo SDK_BUILD_BASE=$SDK_BUILD_BASE
+#echo SDK_SRC_BASE=$SDK_SRC_BASE
+#echo SDK_MK=$SDK_MK
+
+if [ -f "$SDK_MK" ];
+then
+
+echo "File $SDK_MK already exists. Remove it in order to configure a new build location:"
+echo "rm $SDK_MK"
+exit 1
+
+else
+
+if [ -z "$JAVA_HOME" ]
+then
+echo "Environment variable JAVA_HOME must be set"
+exit 1
+fi
+
+# Create build directory, so that it can be used right away
+# and we check whether we have the rights
+mkdir -p $SDK_BUILD_BASE
+if [ -f "$SDK_MK" ];
+then
+echo "Cannot create $SDK_BUILD_BASE, SDK configuration has failed."
+exit 2
+fi
+
+# Generate sdk.mk
+cat > "$SDK_MK" <<EOF
+SDK_SRC_BASE := $SDK_SRC_BASE
+SDK_BUILD_BASE := $SDK_BUILD_BASE
+JAVA_HOME := $JAVA_HOME
+
+include \$(SDK_SRC_BASE)/branch.mk
+EOF
+
+
+echo SDK was configured.
+echo "JAVA_HOME : $JAVA_HOME"
+echo "Base for sources : $SDK_SRC_BASE"
+echo "Base for builds : $SDK_BUILD_BASE"
+exit 0
+fi
+
+++ /dev/null
-/exec/
-/target/
+++ /dev/null
-grant {
- permission java.security.AllPermission;
-};
\ No newline at end of file
+++ /dev/null
-/krb5.keytab
-/krb5.keytab.old
-/*.p12
-/*.jks
\ No newline at end of file
+++ /dev/null
-dn: cn=admin,ou=roles,ou=node
-objectClass: groupOfNames
-objectClass: top
-cn: admin
-member: uid=root,ou=People,dc=example,dc=com
-
-dn: cn=org.argeo.slc.user,ou=roles,ou=node
-objectClass: groupOfNames
-objectClass: top
-cn: org.argeo.slc.user
-member: uid=root,ou=People,dc=example,dc=com
-member: uid=demo,ou=People,dc=example,dc=com
-
-dn: cn=userAdmin,ou=roles,ou=node
-objectClass: groupOfNames
-objectClass: top
-member: cn=admin,ou=roles,ou=node
-cn: userAdmin
-
+++ /dev/null
-log4j.rootLogger=WARN, development
-
-log4j.logger.org.argeo=DEBUG
-
-## Appenders
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c - [%t]%n
-
-log4j.appender.development=org.apache.log4j.ConsoleAppender
-log4j.appender.development.layout=org.apache.log4j.PatternLayout
-log4j.appender.development.layout.ConversionPattern=%d{ABSOLUTE} %m (%F:%L) [%t] %p %n
+++ /dev/null
-argeo.osgi.start=\
-org.eclipse.equinox.cm,\
-org.argeo.cms,\
-org.eclipse.gemini.blueprint.extender,\
-org.argeo.slc.agent,\
-org.argeo.slc.agent.jcr,\
-
-#org.argeo.slc.support.maven,\
-
-slc.executionModules=org.argeo.slc.demo.ant,\
-org.argeo.slc.demo.basic,\
-org.argeo.slc.demo.minimal,\
-
-argeo.node.repo.type=localfs
-
-log4j.configuration=file:../../log4j.properties
-
-org.osgi.framework.security=osgi
-java.security.policy=file:../../all.policy
+++ /dev/null
-argeo.osgi.start.2.http=\
-org.eclipse.equinox.http.servlet,\
-org.eclipse.equinox.metatype,\
-org.eclipse.equinox.cm,\
-org.eclipse.equinox.ds,\
-org.eclipse.rap.rwt.osgi
-
-argeo.osgi.start.3.node=\
-org.argeo.cms
-
-argeo.osgi.start.4.apps=\
-org.eclipse.gemini.blueprint.extender
-
-argeo.osgi.start.4.workbench=\
-org.eclipse.equinox.http.registry,\
-
-argeo.osgi.start.5.slc=\
-org.argeo.slc.agent,\
-org.argeo.slc.agent.jcr,\
-org.argeo.slc.server.repo,\
-
-argeo.node.repo.type=localfs
-
-org.osgi.framework.security=osgi
-java.security.policy=file:../../all.policy
-
-org.osgi.service.http.port=7070
-org.eclipse.equinox.http.jetty.log.stderr.threshold=info
-
-log4j.configuration=file:../../log4j.properties
-org.eclipse.rap.workbenchAutostart=false
-
-slc.executionModules=org.argeo.slc.demo.ant,\
-org.argeo.slc.demo.basic,\
-org.argeo.slc.demo.minimal,\
-
-org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.dist.distributionPerspective
-
-#argeo.node.useradmin.uris="ipa:/// dc=example,dc=com.ldif"
-
-# override ports to run the demo as a server
-argeo.server.port.http=7070
-#argeo.server.port.https=9073
-
-# DON'T CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
-eclipse.ignoreApp=true
-osgi.noShutdown=true
-org.eclipse.equinox.http.jetty.autostart=false
-org.eclipse.rap.workbenchAutostart=false
-
-# Avoid errors logs (see https://issues.apache.org/jira/browse/JCR-2226)
-org.apache.jackrabbit.core.statementcache=false
-
-org.osgi.framework.bootdelegation=com.sun.jndi.ldap,\
-com.sun.jndi.ldap.sasl,\
-com.sun.security.jgss,\
-com.sun.jndi.dns,\
-com.sun.nio.file,\
-com.sun.nio.sctp,\
-com.sun.crypto.provider
\ No newline at end of file
+++ /dev/null
-# SLC SERVICES
-#argeo.osgi.start.1.slc=\
-#org.argeo.server.ads.server,\
-
-argeo.osgi.start.2.slc=\
-org.argeo.slc.node.jackrabbit,\
-org.argeo.slc.support.maven,\
-org.argeo.slc.server.repo,\
-org.argeo.slc.agent,\
-org.argeo.slc.agent.jcr,\
-
-argeo.osgi.start.3.slc=\
-org.argeo.slc.server.repo.webapp,\
-
-# NODE SERVICES
-argeo.osgi.start.1.node=\
-org.springframework.osgi.extender,\
-
-argeo.osgi.start.2.node=\
-org.argeo.node.repo.jackrabbit,\
-org.argeo.security.dao.ldap,\
-
-argeo.osgi.start.3.node=\
-org.argeo.jackrabbit.webapp,\
-org.argeo.server.rap.webapp,\
-org.argeo.server.catalina.start,\
-org.eclipse.equinox.http.registry,\
-org.springframework.osgi.web.extender,\
-
-slc.repo.jcr.dbuser=argeo
-slc.repo.jcr.dbpassword=argeo
-slc.repo.jcr.configuration.java=osgibundle:repository-pg-java.xml
-
-org.argeo.security.ui.initialPerspective=org.argeo.security.ui.userHomePerspective
-
-# LDAP
-argeo.ldap.manager.userdn=uid=admin,ou=system
-argeo.ldap.manager.password=demodemo
-argeo.ldap.port=389
-
-log4j.configuration=file:../../log4j.properties
-
-# DON'T CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
-eclipse.ignoreApp=true
-osgi.noShutdown=true
-
-# Avoid errors logs (see https://issues.apache.org/jira/browse/JCR-2226)
-org.apache.jackrabbit.core.statementcache=false
\ No newline at end of file
+++ /dev/null
-argeo.osgi.start=\
-org.eclipse.equinox.http.servlet,\
-org.eclipse.equinox.http.jetty,\
-org.eclipse.equinox.metatype,\
-org.eclipse.equinox.cm,\
-
-argeo.osgi.start.3.node=\
-org.argeo.cms
-
-argeo.osgi.start.4.apps=\
-org.eclipse.gemini.blueprint.extender
-
-argeo.osgi.start.5.slc=\
-org.argeo.slc.agent,\
-org.argeo.slc.agent.jcr,\
-
-argeo.node.repo.type=localfs
-
-slc.executionModules=org.argeo.slc.demo.ant,\
-org.argeo.slc.demo.basic,\
-org.argeo.slc.demo.minimal,\
-
-#Branding
-eclipse.application=org.argeo.slc.client.rcp.application
-org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.slcExecutionPerspective
-
-log4j.configuration=file:../../log4j.properties
-
-#argeo.server.tomcat.config=conf/default-server-ssl.xml
-
-sun.security.jgss.native=false
-org.osgi.framework.security=osgi
-java.security.policy=file:../../all.policy
-
-# DON'T CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
-org.eclipse.equinox.http.jetty.autostart=false
+++ /dev/null
-argeo.osgi.start=\
-org.springframework.osgi.extender,\
-org.argeo.security.dao.jackrabbit,\
-org.argeo.slc.node.jackrabbit,\
-org.argeo.slc.agent,\
-org.argeo.slc.agent.jcr,\
-org.argeo.slc.support.maven,\
-
-slc.executionModules=org.argeo.slc.demo.ant,\
-org.argeo.slc.demo.basic,\
-org.argeo.slc.demo.minimal,\
-
-eclipse.application=org.argeo.slc.client.rcp.application
-org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.slcExecutionPerspective
-
-log4j.configuration=file:../../log4j.properties
-
-argeo.node.repo.uri=http://localhost:7070/data/jcr/node
+++ /dev/null
------BEGIN CERTIFICATE-----
-MIIF3zCCA8egAwIBAgIJALKBUni09meLMA0GCSqGSIb3DQEBBQUAMIGFMQswCQYD
-VQQGEwJERTEPMA0GA1UECAwGQmVybGluMQ8wDQYDVQQHDAZCZXJsaW4xFTATBgNV
-BAoMDEV4YW1wbGUgR21iSDEMMAoGA1UECwwDUiZEMRAwDgYDVQQDDAdEZW1vIENB
-MR0wGwYJKoZIhvcNAQkBFg5jYUBleGFtcGxlLm9yZzAeFw0xMzA1MjgxMTI0MTNa
-Fw0yMzA1MjYxMTI0MTNaMIGFMQswCQYDVQQGEwJERTEPMA0GA1UECAwGQmVybGlu
-MQ8wDQYDVQQHDAZCZXJsaW4xFTATBgNVBAoMDEV4YW1wbGUgR21iSDEMMAoGA1UE
-CwwDUiZEMRAwDgYDVQQDDAdEZW1vIENBMR0wGwYJKoZIhvcNAQkBFg5jYUBleGFt
-cGxlLm9yZzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKwB6jOoHk+e
-LjI8AqqR9VHG53KgQFwjVkTlMJ5QHgUgFFzZB7af9B0AtzbLPSjJH3rY/8itYQnB
-jL1D9Ijc0EAJOrDgtQjYV1jpL49mFI9mgZkCXJv8rehxm8IDIuyPgceW4/ZrogOB
-MJwmWAK8DfDQzuomw/mKhPvssFFq7zW9l1ae2kSniZ+m7pTqESuZ8gB+qvEi/bMC
-nWD4jp+Sr3e1FGlXJu7Ltc1Z+OWmFRa4VlxBF5wgsNVcL4JRx1Wwhu0I5qWxrpZ3
-KdqBiPivM0N8Aaszf2APsatE6BDYdYJsM4KGJ8aInZYjN8hnzmDSui7taI2/vjrx
-0nE2lhxpykyaUxKhXOnfPHxUOCc6XlfZkKA/fg9ZYz3ybqIjL8SU7DOHEjIT7xdc
-WA9ccSCrr8B6Lfk7P5ZM/zdLir59dyogAMJtHiot4Tn44lXe+2RXBDytGTbWNNlM
-Llxv7O0f5b3QUWQ1lybNDRNJBwTIBoJMW6v09S3zf65XyQ3/hrAnXxQ5T4/fqEBP
-15C4g6n6ANg5jCXqYPdnMzR//vDxJZzKQc01BVdKLsSb02yIb2LizOy0ezx9dEZa
-PexiztKD5dwnrzVxHu4DilBcJBTFOkgbMfDau7fLVuF0XXFTc/FSdsaJDDWI5N7N
-8vzHZGZZfm5qasrZryop2DwzSWfCDYTrAgMBAAGjUDBOMB0GA1UdDgQWBBRsDHcK
-aom/nG0ov6N0soe7SHn1kDAfBgNVHSMEGDAWgBRsDHcKaom/nG0ov6N0soe7SHn1
-kDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4ICAQAw1gp89iBwBSMEnwcc
-OQ6jJ4BEnrvwY31VJmbA/2EOhLoUyGr4hTYo3RYGQB0OeMfu7B/YkurVVkEcuR9q
-uwV3eRpPUTcGSsisEwvUbu9Iur9ygA7S9+IKZJ4KCS6ZDKpdHO2lOcLwtguky6W2
-PJEJLrKOmXqLQ2epjeHqGe9FXHyk3AY4YtXpZ6Mu/sYTiG+LZscXYFkvIM/MwBC8
-THX8J3dE/v1gPgFHaavW5vhsEI1izPj9KN7wyT7ljJgvnWA5Vbs+w1qW6fCtmTxl
-nY/DvhsVoOj+Zg2iMGByZusm6oP+vVVK6ZCst2RBpoZ059RRY71woRYjXa88LxLM
-rOuzcBxLC+X4o4PJwIVTVKnga2TpxyREjFqJehf8+N9aSuvEM+sY9l1ELQ99zk5v
-juX5kykKI+j28TNtwyDsJNWmzK7OFQAhKMBZZYVLj6Wm6roU7TZ93tLQC1uLRZ82
-DIRDebUbKhGHlqmcQFblUztDzqmCHYvEE0t2mjQNoLDwMzi1d5oSYL0NH5gtuosH
-wDCK0GbR0elYFBcxtX6kceyFnQqOGE5b52rB75OHxJ7iQtCn6Lt3ms9h9ODJjS2e
-Kafzg+RuwOpmIwUOGW140WxNO89e9DCwhR3Q4waRTwzmdLLNEhHhi5GNRHlT7Cem
-gZlju4Nu4PKD2RWyBihI4YF1AA==
------END CERTIFICATE-----
+++ /dev/null
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,1E365E4A0FD2EC89
-
-7MkG03lkphw7WxvG8mc86m6oBdxVibv06X9AbUAZ4CWavS3mO13NYU5K1d4bY4JM
-RKoN3QRJSBaBFy6kCGOEpKnpvKN4fSf/AVYZ7PFbe/oEsi9GruY3sjz2LNc3NgvI
-pPsC1uSWq8vODABzBlh6SKBdznJx403PRPzhR2qXZ6P3893J7qlfgHa7SY7hvY9G
-U4cYyas0Tu67Ta0kxGx87oompsfb/L49iEfEZuuNQnT8rNloiTa3kQRSDiUsVek9
-gq0atye+qgeYRWj054FCV9BC8+cxwYam+f7Fa4Au89Ir8fwFbgihbtzWXoowghwW
-9QTCNqeFu5jb0PYJ9NNY/nWa3lWEve45WZSWgJyDSiYZs/Ei497meXaLiPqtubrv
-aCR1OFDRu++8zElUZsxWdAKohBCfqbkQYe5HfFeenAfX9QZoo+mf8q9Ebj8ojfWl
-wIY+8CyMxla0reG4afsCe4IHfQ7I7TJOBlBMFbMUVBYToWPAK10wIOu5S5v7/gGT
-LauiVPbXVSjZB1wiURBGYqxIcqLktPtAV36XSIGu5geRvb4rT73G+D573jO8QVHA
-Fqw5PKLFA0gPaYjO/D9toPQECut61eHpRw5y4av+H2f/guZAE3UMNcQceYphmhFy
-YxxVBsfoQIVHcE51loEPeWdRvxZWBPvaAP+CFuLDkxzSJ3l1Rjl1kxsc4LOLrKJA
-+qzEGMb30T5sS78xo+WTQVXhQOkM+aVVuvZpBZQg2XacTS51Pl/5rpd8m+puTSFO
-Zky4lzpkJwofEwaQeiQxoHnIvniW4Xa0q+ufRPQA6QX8Od1uabS0nuyNS88ezt9d
-yo7kfI6uDxYw1dyqHHsKD/71r3w8oqdtJHzvewK4GMQJqbn7o+i0vVEZ5qL+ZaKl
-/eIFsjxQcqvd5/wGJOyU2jTIotFCHc6AqIlq9sXgRN7F0DpvJCMpdaPpixD46BF8
-3zfRanM6Hx4Mdx9V4zPjujLdNuHMSRR0OzhZsFXkpxUIGE0EnsjrTjzJW8A6dv0P
-LTt3XSe2m8Wkrs7bFCdm4ynZ1wf2ivcB1Np52jP3HUPq9Jeu/VcTY2KnJm0GRsui
-arblNpSqqqi0YSH9KL0VyFFfon2R9u55ZdetPtBUm4PBv3sGqgXwg+a3VqK0CENx
-u//0lI29tIJGzPCMiO5cb9pwsqNbdngeXx7EMfw+bFHb9VVEjctk2Cr4QFKH2+Uf
-c0OvDRdwQdly9zW8Zr8CzSwTLwrIjRoIbNwqhsoTwPN4EXZsicG5hv19sQ1aXs/5
-2IPm968iyqF/ZHAYBNNARK4Pqs+ifMIiCEMpv0ZIovUaHX4/iJZW+UMrq4BqwtPk
-rkI1ZxxbupGFqJEABW8OsZFE8tC5x4lvCntt4tPzQDZuvR3PGcmY+4M9yXkFeYZg
-ol/o6rybVoNRVB/qLjKRWkZNYZUdTp/4zsnBorLaMlIWpyCgTGPQs25Y/7OJI1g5
-l4sZitaW1ucWgsUquWIpqZZCFLZbDGPqKRCZh8k49a7DqEUNf9w+bN6pktRdQ1YR
-uCokQEwUbSZqr4lsBGyJCSfxdZ+A4RdiH5iot6mltUiuKxqYmLfctm002y8daWXh
-Scl9Gv8QtaGu31St67p8FDF6WAZcNXwaP93pC5I2owA17kEbSC65IbNrnU23xqHU
-lEY1hnQuTeiQEXuYIcHURFBLKisKBL4Z1DiSubCK8w3Y9n3LGdMm6lPprLxur7jj
-zvJvWK4ksV+bBzYfhaQ15YVB8R+0DTyGY6LbKtdJ72ZIJsR4zoB5Mtli9xYrdpuA
-SZeE2CSUDRRzaMjdf43gfAM8yAlhQSE2LaQwpGTVrIYLtTJSEVdAk9JYZ+Z8d9DQ
-YeHSm5XROyrqyfnCc50d9Tasaf+ZEzMsmCFnSKalG9g3B4i57TofB6jUyBO8Qob1
-6dDILeXHX4oQ++2HxYeJIMcakiiX/V3rBFJrb0O7swA41cyxu++1x9KYkozHlnkO
-XSspOx3JPadTkcl6BiXpemcqgyd5Xqzx7lit/Y/3lz5mlJr/EIv/qpYpUcFKp2gT
-aijMtflayKignnE8c+1ENq4E8qt8WEuvs8gZG+qu4G8lhaS4dLQNj57W9BeZyAYi
-LvzfFYEVLwUt7mv1zqHLXAGBdvLCZl/DjloXu9RvhF9zOgIR/uNEMFUSyF8v+xZE
-lAwiii2BARCqO+XLo2KkRPsL3fFIItxwEVbpqfTngbe+o/SF/HCXsW+S09y8LNDp
-3Bx2cNIp9+HrDwtRfnN4okjLURxTvki3l19m3rDnvtUgM9AhsA2nNKpEEWAaC5bB
-nPEetLDK7KVniccPro3oI08OwlMGZLM38NgDK66AhgSjkgKri20Wxq5LgG8qLyAE
-kA+g7jjvpaALgbU6PL8k0eLRBldl8NNbdLywZmFOeA27sWNBfblaAeo6MveIGoLY
-Openi1D6uYfLaP/xI0D1Yldmvjgex/P9SDAcRoaj9x5Jaty9oMdGSeSQ+TXA3hrf
-sBsgpn+WN1LR7qBtq+/NdRyu7EXzlgGwpGM3aDUnsFt7iKThwHxEBpyRKXvjL2KO
-jiRaDO9NRpZqj/M0czpGeSXoHNRI/qrqquTDysvYG84rNgxQpWYgYo9R455HPrlQ
-BLlJzr0Nr8H3dp4TDFV0Awpld02FA4XfQ3PUoAnr6ku7CA79GS4PMd2nr4p48GC0
-owtVpm/Bqkp2H1FsnYuBw9FCGEcCe/DTw880V5NiLonUB1L+MVeUhWr/ucJ8txJx
-iBUlg/mxSgfXY715NUgy08UEsTvPw7Ky080RxmEOCIWjxFEvAHE7dCJokHbL8jSO
-8tNlyVPQt9ccEzJbPdag8eMKkIsGIMh1F7HwyLNOrIuM2Cuz9ALTIKwEZ0CE+XBE
-oL5AOn1Cqlvh0fAWUQNP1/RAsT8XqdBXkui/+kvqeVNbZoGJg+wVrNm0sP1nDRqZ
-6oMdcE7tC20YyFl8rkcv2JG+5pJrNQKMosdtQmA2pJ/hS4yZss9vBizJhQHRI4l9
-I7nCHOrxCQvBoxyJb8qKO1cpynN5tttZ0s/njhYXVNtQDpoB2iWFm0/biP63jh4j
-DcqOsuOqMGFtsWPfHM+oMBQ2YT63g4hilMzzilQqUsJ8mBGiYFIcP9CRPUFRI2tQ
------END RSA PRIVATE KEY-----
+++ /dev/null
------BEGIN CERTIFICATE-----
-MIIFfzCCA2cCAQQwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYTAkRFMQ8wDQYD
-VQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBH
-bWJIMQwwCgYDVQQLDANSJkQxEDAOBgNVBAMMB0RlbW8gQ0ExHTAbBgkqhkiG9w0B
-CQEWDmNhQGV4YW1wbGUub3JnMB4XDTEzMDUyODExMzAwNFoXDTIzMDUyNjExMzAw
-NFowgYQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJl
-cmxpbjEVMBMGA1UECgwMRXhhbXBsZSBHbWJIMQwwCgYDVQQLDANSJkQxDTALBgNV
-BAMMBGRlbW8xHzAdBgkqhkiG9w0BCQEWEGRlbW9AZXhhbXBsZS5vcmcwggIiMA0G
-CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDBuEqxINyrCP2IauWReizNWl6J+WgV
-pqTAViqlEtbSbGCzvHE4eF07uCazWmAwWRmXxwf2h4M3siC8Q382n7ri/eS4mijk
-kw7FxoQh1W/jLDFcZ2orY4bz+DoexL+ClVAf8AKBQ68NNbf1aZnUctnDx5Ymrzq/
-KHvgUAIsRmcRzhE5mjWxem33iAVibrQ6LhY5tNDw+VfXZ0IzvTl/ZHfKyOGq4NTl
-21C0iWqksj6sJtvYv88wSHmnzokOXb5rJo5q07HN5b5eHuoAM74SS36ScXpQixDS
-Z4tCjxzo/QwRqQdlWJBv9PSPEq4HNHlCu/zbWZNCbRVKmRf0qYq9dxjxunyj+HjT
-Dj4OfvpmOhTrX78x9ZDOfWmYV/PpoyQ+5PKDhXfFYRGAY97CN1UlQhccdnJCgM3o
-bYkQ+fDXXvgNQLazbOVmeRd5is4TXdcNJIN3LcXXdEOa+O6X8fVTwxzXMD8Uy7fo
-CRvhCrF6gqZZyt+pIJMucLzydiCJHqqDK0xjJ4wtfJNGEyIDJ82hUDEae9X4ao6m
-ti146PH1zbKWS2EYaoEFeXgIqDiU8dKIZNrTd+nflIGd/TLf3LgY43qGEwd/oWtd
-I1hICu173WGdPNnZWbvJtqb4nHag2ldd+jnYHFFF0jnH+neRq4lqW+CAFjWz7c8J
-NtCr+RBVS6bYjwIDAQABMA0GCSqGSIb3DQEBBQUAA4ICAQAO6FbFXoYrM1OvUHdF
-mul7cP7jVys3dRNfIdTcKF9tYf5sWS7/2PbFeQ+bjLGxQJcZhQ8BvK2J00/+kExo
-JMEFqQ5BZRorwdnrQxJNJcHrvrQ6ZTaiBhuyktbWGblCAWkuhqw6NLYxhcE1Wq6s
-6w978F/qHCvqGSi1QkVX+9WjVx48K2JqBRKR04THWlgf+llOJsuMv4Rk75iH385L
-FNsQAXIquQHqgBDqKjcSAR0VAQSXV0gnMadaUrHv7H+QqsYo0zp19cX/WF0HNti6
-GHk+mCnDeZh6Z2z7xii+9fQGIMgQ8YhAJwzOhbk72y8WMqfHtFqcY1KnZq52c7wz
-3+kMx+XJ6t6YiJnWAWs4M/mk7RVPOvNqOAh8y+pnd6tZEzdRcvuDiv+U/HwNS6TS
-nEsUHK0rwWD3Sjfwe9LO9TMxdSZkWePlY2v5oAL4YxJnJGfbeBo/OynUkIa0fRXf
-FtKdAENfpijpuNiN3O92q8FwXpLjr38aTHy0o5n2Zrlly7ydGwRXJ8P7FdbGRXj5
-UPaN6b808kysE9zS6BA0XMslLPqQrFgqZFK2fnv/QW87jyXQkTAAgTVrHODJXVsr
-YLIpWTmykOxyNFGYiT9BCxHXTO7LvlGdK3OqRwbzTcD+CHKZsUxALg/q7FbSBS6i
-OZrgJYlxzdsI061+rLsaW02FOA==
------END CERTIFICATE-----
+++ /dev/null
------BEGIN CERTIFICATE REQUEST-----
-MIIEyjCCArICAQAwgYQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzAN
-BgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBHbWJIMQwwCgYDVQQLDANS
-JkQxDTALBgNVBAMMBGRlbW8xHzAdBgkqhkiG9w0BCQEWEGRlbW9AZXhhbXBsZS5v
-cmcwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDBuEqxINyrCP2IauWR
-eizNWl6J+WgVpqTAViqlEtbSbGCzvHE4eF07uCazWmAwWRmXxwf2h4M3siC8Q382
-n7ri/eS4mijkkw7FxoQh1W/jLDFcZ2orY4bz+DoexL+ClVAf8AKBQ68NNbf1aZnU
-ctnDx5Ymrzq/KHvgUAIsRmcRzhE5mjWxem33iAVibrQ6LhY5tNDw+VfXZ0IzvTl/
-ZHfKyOGq4NTl21C0iWqksj6sJtvYv88wSHmnzokOXb5rJo5q07HN5b5eHuoAM74S
-S36ScXpQixDSZ4tCjxzo/QwRqQdlWJBv9PSPEq4HNHlCu/zbWZNCbRVKmRf0qYq9
-dxjxunyj+HjTDj4OfvpmOhTrX78x9ZDOfWmYV/PpoyQ+5PKDhXfFYRGAY97CN1Ul
-QhccdnJCgM3obYkQ+fDXXvgNQLazbOVmeRd5is4TXdcNJIN3LcXXdEOa+O6X8fVT
-wxzXMD8Uy7foCRvhCrF6gqZZyt+pIJMucLzydiCJHqqDK0xjJ4wtfJNGEyIDJ82h
-UDEae9X4ao6mti146PH1zbKWS2EYaoEFeXgIqDiU8dKIZNrTd+nflIGd/TLf3LgY
-43qGEwd/oWtdI1hICu173WGdPNnZWbvJtqb4nHag2ldd+jnYHFFF0jnH+neRq4lq
-W+CAFjWz7c8JNtCr+RBVS6bYjwIDAQABoAAwDQYJKoZIhvcNAQEFBQADggIBAKYk
-c1LiB2iNqjJMPEjzJ0wpKizHoqv7Tt55Slz4Q9bTgTYmevt8SIpQCKK+ZtMxCPIy
-9tfqjsdYqBxahfXnhXUDQQOYEAKcffEZd/c3LX16kOupximycFOj0iqJDe5VZ/NJ
-7fRXlJqqkufoQQ3OqPYzS/G5mP61gadvReAkTh78StlWMNxwg6wYgQ3p4ZD1GKNI
-M7A1Z99HyJeRZcT+yx1wuyvX2MJY15Kg6m9xaM1N+q4BJ82+u76pNX+pTw6A12mB
-XhmIKqRh+KN7YGSVMtU4dBwHMlZD3CRiGUE9RFg/5aqJeXZgCVnLgzTzJUFQqRqZ
-OehYdizkI6TgTLl3xIJWHFqYc5GhY9NwghYn0BjiC/8xpOmj+soAG4hDkydejtf1
-8lFeTxW8Ga560zjvaUOqntQTLHiAnZai7lVFxE+o3/b284OYu5wWyAFh9j+eE7qP
-pnObCpeFanlsuTnQIXZD4KcojI33dmBXIVhCfe0cvtDEPLl2MYJNguO40tJwPCzL
-JBpdwqh+rBKQjX+pn56js3BgB4qrcQnWGEHWOb/Z+ooRkaIIliRLBTS5DbbnsQWp
-jyVKVhTVLNdp4L2oy94hGi9wJSCujXyBFXH4+e3HpYrZwGSJKrpnRPChm9XW520A
-EFgLzv2Oh0zXJiBJ+EtVwWfkDCImakD1u5QAHW7h
------END CERTIFICATE REQUEST-----
+++ /dev/null
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,955EFD4E985DC326
-
-TXxk9gZOkjLsP4MZmg0HWADP97beNLBrHBLwNvWVzFGmNcuLrAb1r6+OlwIVR/Hl
-BAFwygYvwvo2IL68I2hM+pW9wLY6WAit2CvdWs5J+q0MMc6kXilF33PvmW6G0raB
-XurT0Q0w7TcIXmjMo2k6CCnHGCUxIsYjXIKF7LdC7ERR2wCRUgtuns33/Xf7kfIg
-AEpYC5+iJFT9/ZvXm8Ezod0qG3LZ0TmRMRkWjbBOpHqWVCgTwddHZ2hCF4kNubxC
-DYL0UlDru9JgrW9ezAAloyG0GaiqPyCCkUQGw652e99OllYsfCsGQaoRNPwk2ytA
-fss7GyjymlxtjEdwWnVxngUGr+u+cp9QDD7dkSDm0uMBCVjtSg4MGvk3betn+JIt
-MYbEst4Qr0llFV7jMWt5e/EBllErrPipthfpd2o6JUxv5PNCDEbeKRSU+TZ2KuT5
-4uj8MSA8nbixQf063Q8Nz5sd9Aq4Vc+J9Juyu4fbUAI/PAL71fR3HC0hou6plxev
-EXIk6cAZLhzRKBnmwW0Srh/fp7dAlK/btQHoHVtx4E+uT2Ct+5xm63wMJLE5Z+Gw
-6xr0L9CCrnCicekEUoVdED03+U0r+lfP7nOmk/CgfIYpTP+RqsBXTVcwe1tvZqMN
-RLbL7iDCxPrRFwRs51sM2MS5v/3S4r1yTJ/ijgErhrf4shtR+AO9cqkZkLwLtTmW
-wKgWbRVnt8ITRRqqyBRjwBpmOWNC2YfkJrlDcm3rzn1fWWGOOQHlYjDYjpgVJfte
-v/HEC9Z+J82QQ73tyMUrNyJqeiyKdjUHY9T4oS13goGe3T+UUJ7ReYojmwFKCSu9
-GYNC/+7B2kPTbXVwKG9fZ85W7GdjGzy7ci7IsT95znKbPD7gmrr/5L+iYPqLv+R5
-WD9zNsyPpMZvatJRxjH2EdhhWoqvhY+M/k53AdHiM45iG6MVzKxPOlMlEsD2aiMb
-3zGUINsOm4Js77klemGqfd0uEBynypqhIQOoYnTTHnpqguandGkeyAZ689CncP3o
-pg3u3bZVoH5PubxWAFzxqpmrkk71oPaflbT6AbXGGpm9sjSPVKGm67B1yVMRtJph
-GjXuwiDRqX1HwDIMqQZrJKZv0XcEUObruKODryHuxbAA5IWTfZQoGfVei1acn5/7
-Q7MNqzDN2Rzgk4hOWuTSj3IFWzy432qfA2KQFcU37E5cBKnKq/rZp1L9O2wHY095
-4bXLugJML3pQPGg+VSw5RMhmN0RHh71W0aSQVAbOAu/fhCbrOAA/jHf8RN6gH+v2
-pZp1FZU0Bw5So/E9B2ubaTmBEfsAAnPd56jTAsHsqL8x4omXza96WGOlzqQf7W9x
-I481If4hwNl6KEeRb0guiOp0PFq9cfnjvhkbRVAiD5PodjpttAd1ZTvnJA5BDvdx
-v4JaNgKJ286I/2R65njiWtfDREwiStQzX+RjkFQGAQno3FYQiVajYg+URl8yul32
-Sn1ovaVGoT4AzM4UM6xGiAr5mQgZp75/BIYoFk3eit6025mKNfVOsljFnFhS0Bw7
-oRtfKE32TuEMmIfEMP02Ppofk3vBoLQtsgBpYLCYNy3wzzteAsXEFaAOaIFtHDXv
-TI8aHif0hgEXr6gTpQ7uqk5Kmo/9AAM8/5bbDd83Fk0m6Woi1EA0Ac2nv2TSpTeV
-MHy4vk+QJEmaDcKYCn8BlpgJe5b3CJONdt5yXGpfZISxhRQaWpv1dCSFxfARPGSy
-TPZ9jHU5fS+iegOIcb25dr0bncYy5+UKCoaW05L/z1a8Fn3AmjS5YkZBYqmsI4AX
-tkfcRKlVRGuOe3A1borQvC4pB41wlv93GKxF9xltJ7D0G/kNz9BRLvIoF7xYhzBe
-Jyp8SXUwLkAW3H1zIAf8A1rQNyP60txHXcR7HC3GGx6Y/c11L3XBzniD3VhBVZLc
-Z5ndKINz6wrmi3z87GFsBEe0aRhvXanxgBN1vOD2jhWAwOtsXAP0Pz8VZq/rCnIQ
-BKff0VVwRPqpCasgknY4hs6PmteMvOSynTS3v85a2++LrL4vE0MRMHUusY9jIUJn
-plSF9VOsjMS9eeLbch2FNnmEhnn+Sq06uZEZxgweocapm5TvU9S3b5zXWht+4ECy
-Fbe+hKcsls7B9p/sI564ylWtfy/JOsJ4GfsLaLwytbo8tUU9Z4t6bjiBXRUYBS7D
-bVep0ukngR1xeiML/887MGqN0G4RHgBhbdGvBKX0RYArMl2PTNebysuaabdYy8VB
-mrlodPL+OPrly23IHws6/48EiIugUgqTn0JtzZlAiRhK85b9dUHbnqxP9q6DOum0
-GYBnVivo+LZm+rVOPTB9SMEkZezoZZbV9US495vNQF27c85ERAXMi+qnwEmJZeff
-HqN7KzeK21coUNKrxx/n80lk0mCDX8M0BL1qQEH2iiE0wA0JZYm4cOujpmRtBJs7
-g+0Gd4qU9oQWVjbsr28wdFCBzeKvVdwi5+PVEtliSyB95ZLEFNQbOsomU986VllM
-AVYHDPmLfXVl+eUXFfdVNjnw+pXYGKhpicgJQYOunXOukdjmwu6byB7mR3e9IU/9
-BbrgWopv1ZKq/s/xvRsWih05nvXHKSeITVXUAHE4Z78Ia0ZRAj4qicJ/8XvhnJX9
-17G2nOPtPJFrOE+y+KXanBR+ZPNV8kve8hGxSzxcfvz9divRg77DCB81Jyi4LTXa
-l+p0xoM0UUS4per09zHHg9g8lHfjtaq/rge4KgV2uQENNCFjskCc8BjB9U7TYWun
-K9BNQC49p1lDESvStTDrvnX3Ckw3wsvoR4d7fGMakuZcoNF9VAH2YOi7VFBwaySF
-HB+NosmrfrK7izewfNuE751mIWPBek/5mkMwjdMl2Uch+HchGLFPMTrZSGjl8tlJ
-wzbtVP026Iutm+CDXglZq9OV0pk5NR3zF7444m9xxuzHQypRvklDd2OGwdwMoMCJ
-k370YS4dvIlXtwlW39WPyYwWyGmqpfYO2Fj5Su4Pzwz4c/LD8mUVD1scNXeE7dgD
-n1leMfMX5O1elhs9/FgNFH2ntrU0gRGORbwyD+yjryYxv3KOHic7uVY+JsAlY/JA
-ciqvTgSc49XYari0dMCE/rBAwTpKnEKDKB4pI/o6A+ARPGdSj6UThGRS4538d7cB
------END RSA PRIVATE KEY-----
+++ /dev/null
------BEGIN CERTIFICATE-----
-MIIFfzCCA2cCAQMwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYTAkRFMQ8wDQYD
-VQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBH
-bWJIMQwwCgYDVQQLDANSJkQxEDAOBgNVBAMMB0RlbW8gQ0ExHTAbBgkqhkiG9w0B
-CQEWDmNhQGV4YW1wbGUub3JnMB4XDTEzMDUyODExMjgyNVoXDTIzMDUyNjExMjgy
-NVowgYQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJl
-cmxpbjEVMBMGA1UECgwMRXhhbXBsZSBHbWJIMQwwCgYDVQQLDANSJkQxDTALBgNV
-BAMMBHJvb3QxHzAdBgkqhkiG9w0BCQEWEHJvb3RAZXhhbXBsZS5vcmcwggIiMA0G
-CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDjfJpz+c2ompElZtBWC5HUJ6NevhMm
-I7VCAZjMEa8l64cCXlULOyKYbEZ2oQupg5iqHVbEK1d4UJ7b2EWTFc8bZT+cQODL
-7x3hPJ2856PNSg2Rcsna40Vy/1jieRE1gpLVZBi/myFuCBU5uQkhja+VikgIltfX
-uvYilMEkcEVSQniFJCB91xaNPWPJwuyy5JEMoRXprCjHmChaE+MGnWOXyU5+nSp7
-FuLAOZDXbNi+I8J01q2W+iWVlqvIKAa5ogq5TYayo9foVX6ftnNlkoG14gJUGn8C
-CNSAx8ZGNR16952H1UGQycDXM7T3T1MMYT8gB9qDK90ko1EgvITy2UPyWGhTxh9U
-dKkwpenVgn+hDER5ObTlDmSucCooVKZCAITimb4TjJm1pRfupaJlZfKboFmnmx2Y
-4JvZdbM7sTcCmFRv6P0UEJ3MSptzl/GBqSYFyTKmsVWq1NaRzytUKkTQP3TDpf9c
-vtJKu/CPUWKVtamf2d4U+34MLKIQ2zDRkUWDmEypjHitW9y4PlBYVtZ2ks1rdLCl
-ei7cDgwG6uwLZ9FSjHQgy0BF0lVHKnefrR+c1HZ8/vg12pDtmLvP9tL3rxWQ+fGj
-PluaIgPh/moMEKAWDHH+EeAlJ5mmutIU6HS8cL9G/doV7wfqx7TNGhbCbRIawF+x
-jBYCwiRDmNocGwIDAQABMA0GCSqGSIb3DQEBBQUAA4ICAQCm+WvHykMS7opbbfDu
-reOEt+2i/jyWuPPJB51HheyCQtV5MXyuCRflZpJJdI8iWb3DtayKCI18oK7SakcN
-hVGY+3GJyr5yYVsoeRbyFUgz4apBLb2CeEC7rHbbC39hYVc+FxIUbGiP70dm1TJW
-dZEWeyINScR/YVLitx99g6AVByRjaTDpSDr+Rbw0HWZiuJ2Sb7DqCdwaH5nJqLqN
-N8Vx4+vCCDyOD7kH7cqF3eJ6qepBIYPHib8IAqyLFDcd1OXLMQHv3rrYcQ0WM34P
-NkF7wTO1I8gzpcFyrtOBLOyx/wkoxWhqVcWzYXQrgLbgwp8Z/bJz9MyBnqX2NWq0
-qrGoRBqyLkT4W6acJ2SkgCqMLXhMXfne6wziG+nFiYexeKL+cLEB/CkarxRMEta7
-Hyb/zfWLrXATznjeeXanbgBC9f32Xo2IttLw7hPTAkOqulm7/k/U72/n21g9dLdR
-EtmfzYuDZEOH2QdBqPkrwuqY20t4qvqJITomE8GDFqguJFF5T0h0BS04oSA24J/m
-pwuaccHKuo2j7wapWhqQWZj+3CwYqZDKxIsmWCXAsreUj0GmZEKCgdOI3zzNpAI3
-F6puzfejkHze2rE9Obu71c4q0ibmo8MPx7ovoD9yIZPAvHK8HLiQaRNYP9xvv3FL
-g2zA6bTCQMYERNb1YTBv5xeuOQ==
------END CERTIFICATE-----
+++ /dev/null
------BEGIN CERTIFICATE REQUEST-----
-MIIEyjCCArICAQAwgYQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzAN
-BgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBHbWJIMQwwCgYDVQQLDANS
-JkQxDTALBgNVBAMMBHJvb3QxHzAdBgkqhkiG9w0BCQEWEHJvb3RAZXhhbXBsZS5v
-cmcwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDjfJpz+c2ompElZtBW
-C5HUJ6NevhMmI7VCAZjMEa8l64cCXlULOyKYbEZ2oQupg5iqHVbEK1d4UJ7b2EWT
-Fc8bZT+cQODL7x3hPJ2856PNSg2Rcsna40Vy/1jieRE1gpLVZBi/myFuCBU5uQkh
-ja+VikgIltfXuvYilMEkcEVSQniFJCB91xaNPWPJwuyy5JEMoRXprCjHmChaE+MG
-nWOXyU5+nSp7FuLAOZDXbNi+I8J01q2W+iWVlqvIKAa5ogq5TYayo9foVX6ftnNl
-koG14gJUGn8CCNSAx8ZGNR16952H1UGQycDXM7T3T1MMYT8gB9qDK90ko1EgvITy
-2UPyWGhTxh9UdKkwpenVgn+hDER5ObTlDmSucCooVKZCAITimb4TjJm1pRfupaJl
-ZfKboFmnmx2Y4JvZdbM7sTcCmFRv6P0UEJ3MSptzl/GBqSYFyTKmsVWq1NaRzytU
-KkTQP3TDpf9cvtJKu/CPUWKVtamf2d4U+34MLKIQ2zDRkUWDmEypjHitW9y4PlBY
-VtZ2ks1rdLClei7cDgwG6uwLZ9FSjHQgy0BF0lVHKnefrR+c1HZ8/vg12pDtmLvP
-9tL3rxWQ+fGjPluaIgPh/moMEKAWDHH+EeAlJ5mmutIU6HS8cL9G/doV7wfqx7TN
-GhbCbRIawF+xjBYCwiRDmNocGwIDAQABoAAwDQYJKoZIhvcNAQEFBQADggIBALIn
-S0EvEuPFs6Ap7Pvi4ahwlzNFyRYryeAn2qkqwUyMqM2tHywxPd03jlnCTbMbSANj
-YPXIviamosY3LScyL4BrZTsayuvs0I5VKIZq612cPrpn0+hw3gK/tmiHqjEv/XhZ
-JzSAiJMQqurANhbdwEpBICnY5LjjoKcvdG+Pcto9JmXadmSfLpM25t5ldQ/azPjs
-IctBeXkHExRvT0UV5iCAxLu+kr0jxUFX9fTzewWli/TV50uCJtn7zKvQ/9WbdpZW
-mDKQSFLd2j9bDxhfmDD4A1f9/2qC/ymw9jZAdLgbs9Aan436fzZG0/pYEBxNrl5g
-LJZT+E5oXmLxlJLdPNAHSUccNzpajAaKvrwwksppE2Fqw7x0WNzNiXrsfI5xAORG
-0HIACy2K/+2wmS4Jz/FuA0llunWRhoOV9BpYlvrRL7b0IAbD0iirtakAJ/LOY1RV
-6skID/icIuP68TOy97P154Q58sXp2ic9UegjTAD04+M8+iysfA2p9/z2yWFHqEed
-tOKSe9ZfGhxaDZPmKMWTmQbReP72HLsPp/LRakN0EmxkAaRF3GscurVF90a9fbmm
-R1hKg+F8KOELcp9sgMNNhN/DA6Qwjsg6SOCf7B6nvEGBW0MSTdttZtmuQw686+gU
-2ZFgKlcmTP7epZ38lPhwiSOcObqxLwVrvbvfoxhR
------END CERTIFICATE REQUEST-----
+++ /dev/null
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,4A5FB12597A1CBF1
-
-U3bL1J33MP2KEW9+AWj3YZyjpfAuhYr2c/5Zukdy/kAYRnnK436xUsKJtF9OD6H4
-QTawsgtOFL6gEKvKirbQ8q/xpWBX1xwWUSCf10QogNeRb3pk4h0G0BxM2t2Svh/b
-1iW06CDAl4E/7VAQ2Izsm9Th7Gn7uJEhMJHedDyz6vivxOPFhMA6i4OW3vWdlENZ
-cerjsUe8hE3YkQQZuF9060z4+doV8GUt0chtRorRhkH288BAppXJgqxWFG0mDHve
-EhSTDjQMbxlpS/Amnw2LgRNpBWJtOINKovXy4KzxjZPXnYIzkLF3wFRcq0/R40ND
-Wqs/L+Cc62+XXyY6ZwSYjjoTjaGWnAKfT5oDUIONb6eOOiAxAP4CbGU9m1X7Ctgy
-v4n9ElkRBvzMCnXuneB82tBL6zsEv3IvG4yf7jnPP4HL9+Dp3DtrmW4KYUT1iriE
-iC2Eq+J8TXe+F9Cj8lr95Ou/bqJQcze+5TFAPaZY5UTUqPSbxQczW3yP+Zs6mFia
-JQyUIKkQJAb0FQZYSzgs7nH76Wx0aVzpqTSnv2zZ8zULp4o+8ED2ox2eSKDPbcUa
-y0MNXMj73VGNh22WhJ/ter731TEjXSuysgBIwNZf/8CzZJCN6vSihieED1dIwa75
-a3gi9412v/EWjBJPQjcnUP7H9GyBnqJXyJaqtKuP1eGudl1n/Ri+xTx1BLRmZ0xN
-1wZN2LZaphPBd0tIOOsKfVfMfkyyFP4ymUmi9l2i/350ZPyfhldWKksaN1oGMzXC
-uQwK2NAAGMgbZRHwUEgAiVe/gZN0UyF2JRakcDK4n6woSDSvvD1mRZftb3b5saol
-9krcveZL0PJgZpO1jbw4XiiNj+1SNvfDy0nMsB8LmCtmsFAoANUWlsGZyh0xD3ko
-NE8Red5oz3Ydbw1RZglO5F0qdrZsH+p4nPOrCDttD+E8apsWXY0L4b2TkSGho2Q9
-04FZE/heKywZw+wVP8XMHvF87FP5kvpOKQEh39V9iVyCYOALMYp+Zk+lmZV+1WtW
-W5DnAhOfdXC/kDRQQLWT0SGhHOOtGLrU+KhmKlNDGe1YwjKUeKRL82+eebFIsDWe
-TRg7D3K9U+G8RwRCtsaNXptRLeG/gGb5hnP31KlIVz8QfQ9yOVtuGiGhMVlpzRYO
-prn2emRblIKASQNdYqiEg1OTZ3Hg88NLcXWUkoby6jDmA2hwWIRgVfhPrY8F2JGV
-jy5U7mmcnouVYjzBhkwSj4hMDK6Z4r5eppbEKWulEaxNI+0j+TvSBZmDEPhbtlF2
-ZO9VuHUROtBSK8EhxHgb/s8sR8jBGRGlTYHtk/djDJPmxmEvaMmoTTrZ+IqOwoMg
-CRewUi3cWFt08tvXKbprWpwGEKY9mMysYD4EijLEQGx6+HFSZ6WRMOzHAgb3kjhA
-q86YaI1y8zN6aAnRaq/UYqO/GxJMaj3svQjUwQLYoUAOp+8efs9eUVcZq4QVmAJX
-BDSh+E9GH6pCRMZcT5sETIqXfWHuoWuZTeE4qRBLIT6qCIfIr871cXclQuPRS+sI
-HFxiw0gPT+iSyIGM7pzn8kMMgbiGoSdzN90oJXUJ3OH49Liox58iyOk55LUp842N
-TnKsGgyS10qZ31MnkOw1zNnHtb458FsIXg+FjgT54Nlyf8SA0A6+tpqhPhYNfus0
-U1mjrxt1bL/q7QcjSe7FKUNenQfKHltIAAKUBrlnh3UG9a93D0V7GC8k/u+hFdWN
-kL7o8uva3NCZAXENk/ofiOpXV+wyzrf7O14T2dwQjJC6jmzK07AFL3/8k8rAUFPt
-imZk12TiB2m0mlg8RXVwsxe2PaP6rObl32wqFohOkkINfbSnTso5665LHgMtcB8j
-O7xV4sO/JZaPTe57/fyoOdqNv5MvpZaqhe4EH2mBAp04NqmcrELaux0msnrYdQnF
-7GN3PrVzpvE4jn2tZ8XSPnvawJ+cc6IYXSZrlamRKboq85V3uqhdayNEKWLDXQJ5
-NJLXxDe/9HEuOoMCxNKxScPhulXAkKN4bBAgytIcwi/9DAqDFxH8czGDzoR6aYD2
-3BIAdRkzxygy5uKBkqDSe8wugtTQI1kxvTgz06kBtN619k4dZFukQxWiAkzEZbZQ
-j3ulktFe+1oMjjQhI7S3LByWGuSrYw5kIvZrjwcwkqauk9ThTHsLrNwhKW7Dh1Op
-vCmDzi1WwMZyj6MpTEArA4YOz4UrJZohpK+8n5bPEQfy3jOJpHTilr0dpVpbEnFa
-bkj57y4ltYu1AfSgjRHtVfcXGRgj5/xrmLicDRXLH32O1al9f8bYyNFV8hLTLHUP
-q4D5dFAmVVdoRBbGroaK9fMxjpNzNqM+rHH2qLk9nE33I5LoJrqTamfCOj6a3iBh
-hGxxxmI9yNrPv2duCthEnn52haclWfbx3EJf97iIkEMjmpKnqc0KASqlRYk1pGzn
-6YhtsC+h5I1tLf/ukWgB3smsjeAWYt8bFzvcMHm8MVv6KxEthxdOh0zY3hP7peRK
-+NS6HV6L6b2ci6kUkQLRhFra0SkRkMOkydHEx6d6XuKHNLt8y6yRf+O3xAOEAEIi
-QTcCSsXuLLNJCI7ouLi/IxLD4NBFJkXv5nSWZLP4woOwCF8XAUeMGRjr8iZ97VwL
-Iv1bbKwR3Ad0qQJKo5pGsWgPNceYcVuT+Lrkk0385O8e3yWen4GPsticf43NVN81
-EkQphsCOUOcJlAr2xTm6PWtVGbKQiOVVv/Ny0ixfjk4JLPzNGIaWGbQk/ywqF1VI
-RvPIIVlbGGh1FzxTHaxcvSsuPm/r3yMt0tAb5bBIb/RVuU+3MqFZWfciNurUxu/L
-YfwIc3GYrroJC08n5rBXN3fZIjr0HyAgL3c8ZSa10lqHALcoeOBSoAe4y6wmEsS8
-W1c8qsospdKERHMX6yB4qzQoqssQYtHRaPvli6Cq36yNdqRvcwjOxvzINf3SLY8N
-Lbgp7RvWbSPtmUXeubYi5V9qk3ay6YK7hXeQ2jXrRZpX2D2PB5OgUWkHXcmpx5xA
-QB/nFrx1Mz9dNCCpnBNqIhPwlJLkFYqhIwVXfoJNQtRAjaXBxKNgi+9kgQmqAaOb
-l9OUXiwv7gyepT3T3oM9Nr98b1uhom5LsJ40K2QabRJCcewJCsNCGWkziBaJOtHf
------END RSA PRIVATE KEY-----
+++ /dev/null
-# Password for all users and teh CA is 'demo'
-# Password for all key- and truststores is 'changeit'
-
-# Clean
-# rm server.*
-
-# Create CA
-openssl genrsa -des3 -out ca.key 4096
-openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
-
-# Create Keystore and Truststore and add CA to them
-keytool -import -keystore server.ts -file ca.crt -alias ArgeoDemoCA
-keytool -import -keystore server.ks -file ca.crt -alias ArgeoDemoCA
-
-# Tomcat Server
-# (we must use keytool)
-keytool -genkey -alias tomcat -keyalg RSA -keysize 4096 -keystore server.ks
-keytool -certreq -alias tomcat -keystore server.ks -file tomcat.csr
-openssl x509 -req -set_serial 02 -days 3650 -in tomcat.csr -CA ca.crt -CAkey ca.key -out tomcat.crt
-keytool -importcert -alias tomcat -keystore server.ks -file tomcat.crt
-
-# Root User
-openssl genrsa -des3 -out root@demo.key 4096
-openssl req -new -key root@demo.key -out root@demo.csr
-openssl x509 -req -set_serial 03 -days 3650 -in root@demo.csr -CA ca.crt -CAkey ca.key -out root@demo.crt
-openssl pkcs12 -export -out root@demo.p12 -inkey root@demo.key -in root@demo.crt -certfile ca.crt
-
-# Demo User
-openssl genrsa -des3 -out demo@demo.key 4096
-openssl req -new -key demo@demo.key -out demo@demo.csr
-openssl x509 -req -set_serial 04 -days 3650 -in demo@demo.csr -CA ca.crt -CAkey ca.key -out demo@demo.crt
-openssl pkcs12 -export -out demo@demo.p12 -inkey demo@demo.key -in demo@demo.crt -certfile ca.crt
+++ /dev/null
------BEGIN CERTIFICATE-----
-MIIFYjCCA0oCAQIwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYTAkRFMQ8wDQYD
-VQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBH
-bWJIMQwwCgYDVQQLDANSJkQxEDAOBgNVBAMMB0RlbW8gQ0ExHTAbBgkqhkiG9w0B
-CQEWDmNhQGV4YW1wbGUub3JnMB4XDTEzMDUyODExMjYwM1oXDTIzMDUyNjExMjYw
-M1owaDELMAkGA1UEBhMCREUxDzANBgNVBAgTBkJlcmxpbjEPMA0GA1UEBxMGQmVy
-bGluMRUwEwYDVQQKEwxFeGFtcGxlIEdtYkgxDDAKBgNVBAsMA1ImRDESMBAGA1UE
-AxMJbG9jYWxob3N0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAj0X1
-BD4zndTvh5i+ZI+/PJWNhRQYVh+JMFSc85z/APrqZNbwsOEg2mjyLk+bTUcxSZtA
-JLOBGUp7cwQTLD7VTtW7SEtbrcPdikRFQaTL4MNSZNysCPFTOnaPmkHTqnfrNDq2
-yMoaIDp/73dkefT2hoafy6Of1ZC+Sp8QvVORAsnyauRrSnrQSeQlRLm7i2H8FfXK
-zJm33v7LBoX+xJrpKE0fPvJgTsrUaMH76ytMVvDn+PYrW42lmjnAuWZmPJsCjRX7
-XwPggQ6Sdmzj7Z0XeEX3W2ZAMFP2qhbVVSzS4lOUir7/VwfSHmkfhjR8ElzOw6t+
-wG116OXX+yk0INsP/0pLoo8N7yagyrajYcIO5Il7hxVvG5ToHzwgGEn+rMDr1KrF
-f/4XX55Hx2uw7mzkmpyyUVHCyhkNQUwnEmAXKaRM6TH2k84t3TJD/TapiugOGy+a
-o4cKfqfrRDWg09dk4+l4t+BZdlQ2qs/3Umt1aUGar0CLgRhmQJUvFfYCbTFJH4N8
-TVUE1C1C+anIXlapSZCfe9Nfbj1l8yWZwhhMMKaAjsdcBw1upi+cvPuvNTgu1CUz
-uNuPrYTMVkUxbAvZXE0OClZK8uFhlKD+wPzQOOinH7+xXGpAWoAbs5SckuqD7vIz
-mFA9DcllDRT7eQO5xEdfT1jg/PawS1mY8yp1GysCAwEAATANBgkqhkiG9w0BAQUF
-AAOCAgEAQQJm0wDgnsU4caIYt6LGIvPZtuIUfeCy3ZkM0LJsv3JYj8ppb4ULVknM
-8LNPk3W3BAbnuIZR5E9dkByfu2PF/fNpqJRLpCR5zSN3oQsQjHrf9XAr5VeZ0E/w
-YR/udjTJoXQVm2YhtOhDGJ52TW1TZtNGXrn5kmnkWgqm6WSXIZSQ1viW6a6nklZC
-8Tt0o0l+KiiMapgvC9eNonx3CpM+EzSAASmqUz+uPUG0SIQQfuP0Fs5oYaI/I2F3
-j5WxLBdqjTaatwkrhBV22ZoXigWpTNTHcpc469djr23ie+iHlIO/YkL41DDOI5r9
-EsIKxQBKzO9addeys5gReAiEMhDTYGwflliWhdFMAM1mLB4YJjN1iSJEkWkDGg4G
-N+i/Ydx5fgExAws6tE2nUxTBt/F/6Qe+oWCURLE2YDID+t5z7/JQEFJgnboLsUoe
-epKbITPtzNCnnWRwsqsanlx/RbgtI6Flb6/CWGmzlg1y6XhQDO0D6/4amvjeeqVV
-a3vSVpL06K7/PxDFK8vnJmVcC8SqN5RBwsngMnMpPOjD6TNdXo6R45m7UMjQiFO+
-XLi7SSvngmNsaVOlX3adb77ql6DS4dNLZ0UNi6/fr3ADkdkk6yewNJBgVpFoyNPn
-yZdafIUvaRcrH6QXhRyrDLRhF6j9AJNIqUwDBQ1IhexYz/23r6o=
------END CERTIFICATE-----
+++ /dev/null
------BEGIN NEW CERTIFICATE REQUEST-----
-MIIErTCCApUCAQAwaDELMAkGA1UEBhMCREUxDzANBgNVBAgTBkJlcmxpbjEPMA0GA1UEBxMGQmVy
-bGluMRUwEwYDVQQKEwxFeGFtcGxlIEdtYkgxDDAKBgNVBAsMA1ImRDESMBAGA1UEAxMJbG9jYWxo
-b3N0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAj0X1BD4zndTvh5i+ZI+/PJWNhRQY
-Vh+JMFSc85z/APrqZNbwsOEg2mjyLk+bTUcxSZtAJLOBGUp7cwQTLD7VTtW7SEtbrcPdikRFQaTL
-4MNSZNysCPFTOnaPmkHTqnfrNDq2yMoaIDp/73dkefT2hoafy6Of1ZC+Sp8QvVORAsnyauRrSnrQ
-SeQlRLm7i2H8FfXKzJm33v7LBoX+xJrpKE0fPvJgTsrUaMH76ytMVvDn+PYrW42lmjnAuWZmPJsC
-jRX7XwPggQ6Sdmzj7Z0XeEX3W2ZAMFP2qhbVVSzS4lOUir7/VwfSHmkfhjR8ElzOw6t+wG116OXX
-+yk0INsP/0pLoo8N7yagyrajYcIO5Il7hxVvG5ToHzwgGEn+rMDr1KrFf/4XX55Hx2uw7mzkmpyy
-UVHCyhkNQUwnEmAXKaRM6TH2k84t3TJD/TapiugOGy+ao4cKfqfrRDWg09dk4+l4t+BZdlQ2qs/3
-Umt1aUGar0CLgRhmQJUvFfYCbTFJH4N8TVUE1C1C+anIXlapSZCfe9Nfbj1l8yWZwhhMMKaAjsdc
-Bw1upi+cvPuvNTgu1CUzuNuPrYTMVkUxbAvZXE0OClZK8uFhlKD+wPzQOOinH7+xXGpAWoAbs5Sc
-kuqD7vIzmFA9DcllDRT7eQO5xEdfT1jg/PawS1mY8yp1GysCAwEAAaAAMA0GCSqGSIb3DQEBBQUA
-A4ICAQCORSPE6s/ogDnCwX4KDkk8srvdkuERiC3Hb6vTP0bVkLRwHdj77xGNwkXI7UasE52ykOze
-khMuk94onH8yyeDg57EXO4267AsqowV6Od94AGKTndx4Zosx2N+JOGGA0ZwCHvmoX1Wwe1KJ6QoI
-uMdpO+i9uo4ZYth76VV+Yn3mtyJAH0sdHeFkgevKLDURtC+m70XF77NKl+L7VuoNKxXaVCab3d/x
-aksTJpwLGt8QECR1Wq5FPNG/EQiFqQCd3WyzgsebGLDHYQgPEKkKKhMU3G/kIofutz/hNvxp8MRK
-EEEnyfZWiSpYxxmEPmelyinOkoOH5tqbkHzcPawSPFWDBR4pWAg9efdl7zdVAxzNkS5PqWtXrWvm
-jfMAPkTJoeQ6YWZZjHxpYrbBZfIgCr9VehGdzvhDVGbe8NeTDzwk/AItr5shIbFZpA0vIHB4+wEA
-QVl7d1ZM/0qEKGLeHG8TvF4TUIBE1C6RVpnP5jMB9pLQ4FEbgHaadGxQfGxh18GfyxlWmQy8RgDW
-BDJRPClofXm57665hD+py7Jw5F4ZgD5IKwU96kDe7mZRLkF66ZinoubZeyXZBX4N0p7lrWzd/mJj
-r3Yf69L/Ptct7Cr3c4z7Y1xqrBb88bKhVRCfJVtlvE9mSvMh6UUY1QlAGQaDmSQEB+eCO+8diaTa
-gEOeNw==
------END NEW CERTIFICATE REQUEST-----
+++ /dev/null
--include: ../../cnf/maven.bnd
\ No newline at end of file
+++ /dev/null
-/target/
-*.target
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<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.slc</groupId>
- <artifactId>dep</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.dep.e4.rap</artifactId>
- <name>SLC E4 RAP</name>
- <dependencies>
- <!-- Parent dependencies -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.dep.cms.e4.rap</artifactId>
- <version>${version.argeo-commons}</version>
- <type>pom</type>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.dep.minimal</artifactId>
- <version>2.1-SNAPSHOT</version>
- <type>pom</type>
- </dependency>
-
-
- <!-- OSGi Boot for platform generation only, as it could be used by regular
- Java applications to launch an OSGi runtime. -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.osgi.boot</artifactId>
- <version>${version.argeo-commons}</version>
- <scope>test</scope>
- </dependency>
-
- <!-- ALM Third Parties -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.apache.ant</groupId> -->
- <!-- <artifactId>org.apache.ant</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.apache.ant</groupId> -->
- <!-- <artifactId>org.apache.ant.launch</artifactId> -->
- <!-- </dependency> -->
-
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.sdk</groupId> -->
- <!-- <artifactId>biz.aQute.bndlib</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.sdk</groupId> -->
- <!-- <artifactId>org.junit</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.sdk</groupId> -->
- <!-- <artifactId>org.redline-rpm</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.misc</groupId> -->
- <!-- <artifactId>com.googlecode.javaewah.JavaEWAH</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.misc</groupId> -->
- <!-- <artifactId>org.eclipse.jgit</artifactId> -->
- <!-- </dependency> -->
- </dependencies>
- <profiles>
- <profile>
- <id>rpmbuild</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-source</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>a2-source</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rpm-argeo</id>
- <phase>package</phase>
- <goals>
- <goal>rpm</goal>
- </goals>
- <configuration>
- <name>argeo-slc-e4-rap${argeo.rpm.suffix}</name>
- <mappings>
- <mapping>
- <directory>/usr/share/osgi</directory>
- <username>root</username>
- <groupname>root</groupname>
- <filemode>644</filemode>
- <directoryIncluded>true</directoryIncluded>
- <sources>
- <source>
- <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
- <includes>
- <include>**/*.jar</include>
- </includes>
- </source>
- </sources>
- </mapping>
- </mappings>
- <requires>
- <require>argeo-cms-e4-rap${argeo.rpm.suffix}</require>
- <require>argeo-cms-sdk-tp${argeo.rpm.suffix}</require>
- <require>argeo-slc${argeo.rpm.suffix}</require>
- </requires>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-/target/
-/org.argeo.slc.dep.minimal-maven.target
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<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.slc</groupId>
- <artifactId>dep</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.dep.minimal</artifactId>
- <name>SLC Agent</name>
- <dependencies>
- <!-- Parent dependencies -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.dep.cms.node</artifactId>
- <version>${version.argeo-commons}</version>
- <type>pom</type>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.dep.cms.ext</artifactId>
- <version>${version.argeo-commons}</version>
- <type>pom</type>
- </dependency>
-
- <!-- SLC Runtime -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.api</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.runtime</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.jcr</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- SLC Repo -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.repo</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.factory</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- CMS extensions -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.cms.integration</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.ext.equinox.jetty</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- CLI Agent -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.slc</groupId> -->
- <!-- <artifactId>org.argeo.slc.launcher</artifactId> -->
- <!-- <version>1.1.12-SNAPSHOT</version> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.slc</groupId> -->
- <!-- <artifactId>org.argeo.slc.agent.cli</artifactId> -->
- <!-- <version>2.1.1-SNAPSHOT</version> -->
- <!-- </dependency> -->
-
- <!-- SDK Third Parties -->
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>biz.aQute.bndlib</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>org.junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>org.hamcrest</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>org.redline-rpm</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>com.googlecode.javaewah.JavaEWAH</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>org.eclipse.jgit</artifactId>
- </dependency>
-
- <!-- Misc -->
- <dependency>
- <groupId>org.argeo.tp.apache.commons</groupId>
- <artifactId>org.apache.commons.vfs</artifactId>
- </dependency>
-
- <!-- HTTP2 -->
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.alpn.api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.alpn.client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.alpn.server</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.http2.common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.http2.client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.http2.client.http</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.http2.server</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.http2.hpack</artifactId>
- </dependency>
-
- <!-- Async -->
- <dependency>
- <groupId>org.argeo.tp.javax</groupId>
- <artifactId>javax.websocket</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.websocket.api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.websocket.common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.websocket.client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.websocket.server</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.websocket.servlet</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.websocket.javax.websocket</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.jetty</groupId>
- <artifactId>org.eclipse.jetty.websocket.javax.websocket.server</artifactId>
- </dependency>
-
- <!-- SSH -->
- <dependency>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.mina.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.tomcat.jni</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.sshd.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.sshd.common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.sshd.sftp</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.sshd.scp</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.sshd.cli</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.sshd.putty</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>net.i2p.crypto.eddsa</artifactId>
- </dependency>
-
-
-
-
- </dependencies>
- <profiles>
- <profile>
- <id>rpmbuild</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-source</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>a2-source</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rpm-argeo</id>
- <phase>package</phase>
- <goals>
- <goal>rpm</goal>
- </goals>
- <configuration>
- <name>argeo-slc${argeo.rpm.suffix}</name>
- <mappings>
- <mapping>
- <directory>/usr/share/osgi</directory>
- <username>root</username>
- <groupname>root</groupname>
- <filemode>644</filemode>
- <directoryIncluded>true</directoryIncluded>
- <sources>
- <source>
- <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
- <includes>
- <include>**/*.jar</include>
- </includes>
- </source>
- </sources>
- </mapping>
- </mappings>
- <requires>
- <require>argeo-cms-node${argeo.rpm.suffix}</require>
- <require>argeo-slc-tp${argeo.rpm.suffix}</require>
- </requires>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>rpmbuild-tp</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-source-tp</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>a2-source-tp</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rpm-tp</id>
- <phase>package</phase>
- <goals>
- <goal>rpm</goal>
- </goals>
- <configuration>
- <name>argeo-slc-tp${argeo.rpm.suffix}</name>
- <projversion>${version.argeo-tp}</projversion>
- <release>${argeo.rpm.release.tp}</release>
- <mappings>
- <mapping>
- <directory>/usr/share/osgi</directory>
- <username>root</username>
- <groupname>root</groupname>
- <filemode>644</filemode>
- <directoryIncluded>false</directoryIncluded>
- <sources>
- <source>
- <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source-tp</location>
- <includes>
- <include>**/*.jar</include>
- </includes>
- </source>
- </sources>
- </mapping>
- </mappings>
- <requires>
- <require>argeo-cms-ext-tp${argeo.rpm.suffix}</require>
- </requires>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>dep</artifactId>
- <name>SLC Dependencies</name>
- <packaging>pom</packaging>
- <modules>
- <module>org.argeo.slc.dep.minimal</module>
- <module>org.argeo.slc.dep.e4.rap</module>
- </modules>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <SLC-ModularDistribution>default</SLC-ModularDistribution>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>properties-maven-plugin</artifactId>
- <configuration>
- <quiet>true</quiet>
- <files>
- <file>../../cnf/${version.context}.bnd</file>
- </files>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.argeo.maven.plugins</groupId>
- <artifactId>argeo-osgi-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-descriptors</id>
- <goals>
- <goal>descriptors</goal>
- </goals>
- <phase>generate-resources</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <attach>false</attach>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.argeo.tp.equinox</groupId>
- <artifactId>org.eclipse.osgi</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>org.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>org.hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>check-osgi</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.argeo.maven.plugins</groupId>
- <artifactId>argeo-osgi-plugin</artifactId>
- <executions>
- <execution>
- <id>check-osgi</id>
- <phase>test</phase>
- <goals>
- <goal>equinox</goal>
- </goals>
- <configuration>
- <onlyCheck>true</onlyCheck>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.osgi.boot</artifactId>
- <version>${version.argeo-commons}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1.3-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <groupId>org.argeo.slc</groupId>
- <artifactId>dist</artifactId>
- <packaging>pom</packaging>
- <name>SLC Distribution</name>
- <modules>
- <module>slc</module>
- </modules>
-</project>
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>dist</artifactId>
- <version>2.1.3-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>slc</artifactId>
- <packaging>pom</packaging>
- <name>SLC Legacy Distribution</name>
- <properties>
- <argeo.rpm.stagingRepository>/srv/rpmfactory/legacy/argeo-osgi-2/argeo</argeo.rpm.stagingRepository>
- </properties>
- <profiles>
- <profile>
- <id>dist</id>
- <build>
- <plugins>
- <!-- <plugin> -->
- <!-- <groupId>org.apache.maven.plugins</groupId> -->
- <!-- <artifactId>maven-dependency-plugin</artifactId> -->
- <!-- <executions> -->
- <!-- <execution> -->
- <!-- <id>copy-dependencies-dist</id> -->
- <!-- <phase>package</phase> -->
- <!-- <goals> -->
- <!-- <goal>copy-dependencies</goal> -->
- <!-- </goals> -->
- <!-- <configuration> -->
- <!-- <includeTypes>jar</includeTypes> -->
- <!-- <useRepositoryLayout>true</useRepositoryLayout> -->
- <!-- <outputDirectory>${project.build.directory}/modulest</outputDirectory> -->
- <!-- </configuration> -->
- <!-- </execution> -->
- <!-- </executions> -->
- <!-- </plugin> -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <finalName>argeo-slc-${project.version}</finalName>
- <appendAssemblyId>false</appendAssemblyId>
- <descriptors>
- <descriptor>src/assembly/dist.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>assembly-base</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <!-- Backend -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.dep.backend</artifactId>
- <version>2.1.3-SNAPSHOT</version>
- <type>pom</type>
- </dependency>
-
- <!-- SLC Libs -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.lib.jcr</artifactId>
- <version>2.1.3-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.lib.repo</artifactId>
- <version>2.1.3-SNAPSHOT</version>
- </dependency>
-
- <!-- Launcher -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.launcher</artifactId>
- <version>2.1.3-SNAPSHOT</version>
- <!-- <type>tar.gz</type> -->
- <!-- <classifier>base</classifier> -->
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>rpmbuild</id>
- <build>
- <plugins>
-<!-- <plugin> -->
-<!-- <groupId>org.apache.maven.plugins</groupId> -->
-<!-- <artifactId>maven-dependency-plugin</artifactId> -->
-<!-- <executions> -->
-<!-- <execution> -->
-<!-- <id>copy-dependencies-rpm</id> -->
-<!-- <phase>package</phase> -->
-<!-- <goals> -->
-<!-- <goal>copy</goal> -->
-<!-- </goals> -->
-<!-- <configuration> -->
-<!-- <includeTypes>jar</includeTypes> -->
-<!-- <stripVersion>true</stripVersion> -->
-<!-- <outputDirectory>${project.build.directory}/boot</outputDirectory> -->
-<!-- <artifactItems> -->
-<!-- <artifactItem> -->
-<!-- <groupId>org.argeo.slc</groupId> -->
-<!-- <artifactId>org.argeo.slc.launcher</artifactId> -->
-<!-- <version>${project.version}</version> -->
-<!-- </artifactItem> -->
-<!-- </artifactItems> -->
-<!-- </configuration> -->
-<!-- </execution> -->
-<!-- </executions> -->
-<!-- </plugin> -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rpm</id>
- <phase>package</phase>
- <goals>
- <goal>rpm</goal>
- </goals>
- <configuration>
- <name>slc-legacy</name>
- <mappings>
- <mapping>
- <directory>/etc/argeo/conf.d</directory>
- <username>root</username>
- <groupname>argeo</groupname>
- <filemode>640</filemode>
- <configuration>noreplace</configuration>
- <directoryIncluded>false</directoryIncluded>
- <sources>
- <source>
- <location>rpm/etc/argeo/conf.d</location>
- <includes>
- <include>*.ini</include>
- <include>*.txt</include>
- </includes>
- </source>
- </sources>
- </mapping>
- </mappings>
- <requires>
- <require>argeo-node</require>
- <require>slc-platform</require>
- </requires>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-argeo.osgi.start.5.slc=\
-org.argeo.slc.agent,\
-org.argeo.slc.agent.jcr,\
-org.argeo.slc.server.repo,\
-
-org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.dist.distributionPerspective
+++ /dev/null
-#!/bin/bash
-#
-# slc Argeo SLC
-#
-# chkconfig: 3 92 92
-# description: Argeo SLC (http://www.argeo.org)
-
-# Source function library.
-. /etc/osgiboot/osgi-service-init-functions.sh
-
-# Application id (must be in line with header)
-APP=slc
-
-# main
-case "$1" in
- start)
- osgi_service_start $APP
- ;;
- stop)
- osgi_service_stop $APP
- ;;
- restart)
- osgi_service_stop $APP
- osgi_service_start $APP
- RETVAL=$?
- ;;
- status)
- osgi_service_status $APP
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|status}"
- exit 1
-esac
-
-exit $RETVAL
+++ /dev/null
-argeo.osgi.start=\
-org.eclipse.equinox.cm,\
-org.argeo.cms,\
-org.eclipse.gemini.blueprint.extender,\
-org.argeo.slc.agent,\
-org.argeo.slc.agent.jcr,\
-
-argeo.node.repo.type=localfs
-
-# DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
-
-argeo.osgi.bundles=\
-${user.home}/.slc/modules;in=**;ex=**/.git/**;ex=**/.svn/**,\
-/etc/slc-cl/modules;in=**;ex=**/.git/**;ex=**/.svn/**,\
-/usr/local/share/osgi;in=**/*.jar,\
-/usr/share/osgi;in=**/*.jar
+++ /dev/null
-#log4j.rootLogger=WARN, file
-log4j.rootLogger=WARN, console
-
-## Levels
-log4j.logger.org.argeo=INFO
-
-## Appenders
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} [%15.15t] %m - %c%n - %t
-
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=/var/log/slc/slc.log
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern= %-5p %d{ISO8601} [%15.15t] %m - %c%n
+++ /dev/null
-argeo.osgi.start.2.http=\
-org.eclipse.equinox.http.servlet,\
-org.eclipse.equinox.http.jetty,\
-org.eclipse.equinox.cm,\
-org.eclipse.rap.rwt.osgi
-
-argeo.osgi.start.3.node=\
-org.argeo.cms
-
-argeo.osgi.start.4.apps=\
-org.eclipse.gemini.blueprint.extender
-
-argeo.osgi.start.4.workbench=\
-org.eclipse.equinox.http.registry,\
-
-argeo.osgi.start.5.slc=\
-org.argeo.slc.node.jackrabbit,\
-org.argeo.slc.agent,\
-org.argeo.slc.agent.jcr,\
-org.argeo.slc.server.repo,\
-
-argeo.node.repo.type=localfs
-
-org.osgi.service.http.port=8080
-org.eclipse.equinox.http.jetty.log.stderr.threshold=info
-
-slc.executionModules=org.argeo.slc.demo.ant,\
-org.argeo.slc.demo.basic,\
-org.argeo.slc.demo.minimal,\
-
-org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.dist.distributionPerspective
-
-# OSGi MANAGEMENT
-osgi.console=2323
-
-# DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
-osgi.bundles=org.argeo.osgi.boot.jar@start
-argeo.osgi.baseUrl=file:///usr/share/osgi/
-argeo.osgi.distributionUrl=org/argeo/slc/org.argeo.slc.dep.backend/2.1.*/org.argeo.slc.dep.backend-2.1.*.jar
-argeo.osgi.bundles=\
-/etc/slc/modules;in=*,\
-/usr/local/share/osgi;in=**/*.jar
-#/usr/share/osgi;in=**/*.jar,\
-
-org.osgi.framework.bootdelegation=com.sun.jndi.ldap,\
-com.sun.jndi.ldap.sasl,\
-com.sun.security.jgss,\
-com.sun.jndi.dns,\
-com.sun.nio.file,\
-com.sun.nio.sctp
-
-eclipse.ignoreApp=true
-osgi.noShutdown=true
-org.eclipse.equinox.http.jetty.autostart=false
-org.eclipse.rap.workbenchAutostart=false
+++ /dev/null
-log4j.rootLogger=WARN, file
-#log4j.rootLogger=WARN, console
-
-## Levels
-log4j.logger.org.argeo=INFO
-log4j.logger.org.argeo.jackrabbit.remote.ExtendedDispatcherServlet=ERROR
-log4j.logger.org.springframework.web.servlet.PageNotFound=ERROR
-log4j.logger.org.argeo.server.webextender.TomcatDeployer=WARN
-
-log4j.logger.org.apache.coyote=INFO
-log4j.logger.org.apache.catalina.core.ContainerBase=INFO
-log4j.logger.org.apache.directory.server=ERROR
-log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR
-log4j.logger.org.apache.jackrabbit.core.config.ConfigurationErrorHandler=ERROR
-log4j.logger.org.apache.jackrabbit.core.util.db.DbUtility=FATAL
-
-## Appenders
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} [%15.15t] %m - %c%n - %t
-
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=/var/log/slc/slc.log
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern= %-5p %d{ISO8601} [%15.15t] %m - %c%n
+++ /dev/null
-if [ $1 = "1" ];then
- APP=%{name}
- /sbin/chkconfig --add $APP
- /sbin/chkconfig --level 3 $APP on
-fi
-
-# Workaround until we find a way to do it in the spec file
-chown -f slc.slc /var/lib/slc/.m2
+++ /dev/null
-if [ $1 = "1" ];then
- APP=%{name}
-
- # check if user exists
- /bin/id $APP 2>/dev/null
- if [ $? -ne 0 ];then
- # create application user (EL6)
- echo Create user $APP...
- useradd --system --home-dir /var/lib/$APP --shell /sbin/nologin --user-group --create-home $APP
- fi
-
- # give read access to group on home
- chmod g+r /var/lib/$APP
- mkdir -p /var/lib/$APP/{conf,data}
- chown $APP.$APP /var/lib/$APP/{conf,data}
-fi
\ No newline at end of file
+++ /dev/null
-if [ $1 = "0" ];then
- #APP=%{name} => doesn't work
- APP=slc
- /sbin/chkconfig --del $APP
-
- # Maven
- rm -rf /var/lib/$APP/.m2/repository
-
- #userdel $APP
-fi
+++ /dev/null
-#!/bin/sh
-
-JAVA_CMD=java
-JAVA_OPTS="-client -Xmx128m"
-
-SLC_HOME_DIR=${HOME}/.local/share/slc/
-if [ -f $SLC_HOME_DIR/settings.sh ];then
- . $SLC_HOME_DIR/settings.sh
-fi
-
-OSGI_INSTALL_AREA=/usr/share/osgi/boot
-
-ARGEO_OSGI_BUNDLES="$SLC_HOME_DIR/modules;in=**;ex=**/.git/**;ex=**/.svn/**,/etc/slc-cl/modules;in=**;ex=**/.git/**;ex=**/.svn/**,/usr/share/osgi;in=**/*.jar"
-
-for i in "${OSGI_INSTALL_AREA}"/*.jar
- do
- CLASSPATH="$CLASSPATH:$i"
- done
-
-$JAVA_CMD $JAVA_OPTS \
- "-Dargeo.osgi.bundles=$ARGEO_OSGI_BUNDLES" \
- -Djava.security.manager= \
- -Djava.security.policy="file:/etc/osgiboot/all.policy" \
- -cp "$CLASSPATH" \
- org.argeo.slc.cli.SlcMain "$@"
-
\ No newline at end of file
+++ /dev/null
-[Unit]
-Description=Argeo SLC daemon
-After=network.target
-
-[Service]
-ExecStart=/usr/sbin/slcd start
-ExecStop=/usr/sbin/slcd stop
-Type=forking
-PIDFile=/var/run/slcd.pid
-
-[Install]
-WantedBy=default.target
\ No newline at end of file
+++ /dev/null
-#!/bin/bash
-
-. /etc/osgiboot/osgi-service-init-functions.sh
-
-APP=slc
-
-case "$1" in
- start)
- osgi_service_start $APP
- ;;
- stop)
- osgi_service_stop $APP
- ;;
- restart)
- osgi_service_stop $APP
- osgi_service_start $APP
- RETVAL=$?
- ;;
- status)
- osgi_service_status $APP
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|status}"
- exit 1
-esac
-
-exit $RETVAL
+++ /dev/null
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>devel</id>
- <baseDirectory>argeo-slc-${project.version}</baseDirectory>
- <formats>
- <format>zip</format>
- </formats>
- <fileSets>
- <fileSet>
- <directory>target/libsrc</directory>
- <outputDirectory>libsrc</outputDirectory>
- <includes>
- <include>*</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>
\ No newline at end of file
+++ /dev/null
-<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License,
- Version 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the License. -->
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>dist</id>
- <baseDirectory>argeo-slc-${project.version}</baseDirectory>
- <formats>
- <format>tar.gz</format>
- </formats>
- <fileSets>
- <fileSet>
- <directory>src/main/base/bin</directory>
- <outputDirectory>bin</outputDirectory>
- <fileMode>0755</fileMode>
- <includes>
- <include>slc</include>
- </includes>
- </fileSet>
- </fileSets>
- <dependencySets>
- <dependencySet>
- <unpack>false</unpack>
- <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
- <outputDirectory>modules</outputDirectory>
- <includes>
- <include>*:jar</include>
- </includes>
- <excludes>
- <exclude>org.argeo.tp:org.eclipse.osgi</exclude>
- <exclude>org.argeo.commons.base:org.argeo.osgi.boot</exclude>
- <exclude>org.argeo.slc:org.argeo.slc.launcher</exclude>
- </excludes>
- </dependencySet>
- <dependencySet>
- <unpack>false</unpack>
- <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
- <outputDirectory>boot</outputDirectory>
- <includes>
- <include>org.argeo.tp:org.eclipse.osgi</include>
- <include>org.argeo.commons.base:org.argeo.osgi.boot</include>
- <include>org.argeo.slc:org.argeo.slc.launcher</include>
- </includes>
- </dependencySet>
- <!-- <dependencySet> -->
- <!-- <unpack>true</unpack> -->
- <!-- <includes> -->
- <!-- <include>org.argeo.slc.runtime:org.argeo.slc.launcher:tar.gz:base -->
- <!-- </include> -->
- <!-- </includes> -->
- <!-- </dependencySet> -->
- </dependencySets>
-</assembly>
\ No newline at end of file
+++ /dev/null
-#!/bin/sh
-
-JAVA_CMD=java
-JAVA_OPTS="-client -Xmx128m"
-
-SLC_HOME_DIR=${HOME}/.slc/
-if [ -f $SLC_HOME_DIR/settings.sh ];then
- . $SLC_HOME_DIR/settings.sh
-fi
-
-# Find home
-if [ -z "$ARGEO_SLC_HOME" -o ! -d "$ARGEO_SLC_HOME" ] ; then
- ## resolve links - $0 may be a link to home
- PRG="$0"
- progname=`basename "$0"`
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
- done
-
- ARGEO_SLC_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- ARGEO_SLC_HOME=`cd "$ARGEO_SLC_HOME" && pwd`
-fi
-
-for i in "${ARGEO_SLC_HOME}"/boot/*.jar
- do
- CLASSPATH="$CLASSPATH:$i"
- done
-
-ARGEO_OSGI_BUNDLES="$SLC_HOME_DIR/modules;in=**;ex=**/.git/**;ex=**/.svn/**,$ARGEO_SLC_HOME/modules;in=**;ex=**/.git/**;ex=**/.svn/**"
-
-$JAVA_CMD $JAVA_OPTS \
- "-Dargeo.osgi.bundles=$ARGEO_OSGI_BUNDLES" \
- -cp "$CLASSPATH" \
- org.argeo.slc.cli.SlcMain "$@"
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+/bin/
+/target/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.ext.equinox.jetty</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/MANIFEST.MF
--- /dev/null
+Fragment-Host: org.eclipse.equinox.http.jetty
+
+Import-Package: org.eclipse.jetty.websocket.jsr356,\
+org.eclipse.jetty.websocket.api,\
+org.eclipse.jetty.websocket.common,\
+org.osgi.service.http,\
+*
\ No newline at end of file
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
--- /dev/null
+package org.argeo.equinox.jetty;
+
+import java.util.Dictionary;
+
+import javax.servlet.ServletContext;
+import javax.websocket.DeploymentException;
+
+import org.eclipse.equinox.http.jetty.JettyCustomizer;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
+import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
+import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.Configurator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+
+/** Customises the Jetty HTTP server. */
+public class CmsJettyCustomizer extends JettyCustomizer {
+ private BundleContext bc = FrameworkUtil.getBundle(CmsJettyCustomizer.class).getBundleContext();
+
+ public final static String WEBSOCKET_ENABLED = "websocket.enabled";
+
+ @Override
+ public Object customizeContext(Object context, Dictionary<String, ?> settings) {
+ // WebSocket
+ Object webSocketEnabled = settings.get(WEBSOCKET_ENABLED);
+ if (webSocketEnabled != null && webSocketEnabled.toString().equals("true")) {
+ ServletContextHandler servletContextHandler = (ServletContextHandler) context;
+ WebSocketServerContainerInitializer.configure(servletContextHandler, new Configurator() {
+
+ @Override
+ public void accept(ServletContext servletContext, ServerContainer serverContainer)
+ throws DeploymentException {
+ bc.registerService(javax.websocket.server.ServerContainer.class, serverContainer, null);
+ }
+ });
+ }
+ return super.customizeContext(context, settings);
+
+ }
+}
--- /dev/null
+/** Equinox Jetty extensions. */
+package org.argeo.equinox.jetty;
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.ext.slf4j</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+Export-Package: org.slf4j.impl
+
+Import-Package: *
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
--- /dev/null
+package org.slf4j.impl;
+
+import org.slf4j.helpers.MarkerIgnoringBase;
+
+class ArgeoLogger extends MarkerIgnoringBase {
+ private static final long serialVersionUID = -7719157836932627307L;
+ private final SystemLoggingAdapter log;
+
+ protected ArgeoLogger(String name, SystemLoggingAdapter log) {
+ this.name = name;
+ this.log = log;
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return log.isDebugEnabled();
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return log.isDebugEnabled();
+ }
+
+ @Override
+ public void trace(String msg) {
+ log.trace(msg);
+
+ }
+
+ @Override
+ public void trace(String format, Object... arguments) {
+ log.trace(format, arguments);
+
+ }
+
+ @Override
+ public void trace(String msg, Throwable t) {
+ log.trace(msg, t);
+
+ }
+
+ @Override
+ public void debug(String msg) {
+ log.debug(msg);
+
+ }
+
+ @Override
+ public void debug(String format, Object... arguments) {
+ log.debug(format, arguments);
+
+ }
+
+ @Override
+ public void debug(String msg, Throwable t) {
+ log.debug(msg, t);
+
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return log.isInfoEnabled();
+ }
+
+ @Override
+ public void info(String msg) {
+ log.info(msg);
+
+ }
+
+ @Override
+ public void info(String format, Object... arguments) {
+ log.info(format, arguments);
+ }
+
+ @Override
+ public void info(String msg, Throwable t) {
+ log.info(msg, t);
+
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return log.isWarnEnabled();
+ }
+
+ @Override
+ public void warn(String msg) {
+ log.warn(msg);
+
+ }
+
+ @Override
+ public void warn(String format, Object... arguments) {
+ log.warn(format, arguments);
+
+ }
+
+ @Override
+ public void warn(String msg, Throwable t) {
+ log.warn(msg, t);
+
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+
+ return log.isErrorEnabled();
+ }
+
+ @Override
+ public void error(String msg) {
+ log.error(msg);
+
+ }
+
+ @Override
+ public void error(String format, Object... arguments) {
+ log.error(format, arguments);
+
+ }
+
+ @Override
+ public void error(String msg, Throwable t) {
+ log.error(msg, t);
+
+ }
+
+ @Override
+ public void trace(String format, Object arg) {
+ trace(format, new Object[] { arg });
+
+ }
+
+ @Override
+ public void trace(String format, Object arg1, Object arg2) {
+ trace(format, new Object[] { arg1, arg2 });
+ }
+
+ @Override
+ public void debug(String format, Object arg) {
+ debug(format, new Object[] { arg });
+ }
+
+ @Override
+ public void debug(String format, Object arg1, Object arg2) {
+ debug(format, new Object[] { arg1, arg2 });
+ }
+
+ @Override
+ public void info(String format, Object arg) {
+ info(format, new Object[] { arg });
+ }
+
+ @Override
+ public void info(String format, Object arg1, Object arg2) {
+ info(format, new Object[] { arg1, arg2 });
+ }
+
+ @Override
+ public void warn(String format, Object arg) {
+ warn(format, new Object[] { arg });
+ }
+
+ @Override
+ public void warn(String format, Object arg1, Object arg2) {
+ warn(format, new Object[] { arg1, arg2 });
+ }
+
+ @Override
+ public void error(String format, Object arg) {
+ error(format, new Object[] { arg });
+ }
+
+ @Override
+ public void error(String format, Object arg1, Object arg2) {
+ error(format, new Object[] { arg1, arg2 });
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.spi.LoggerFactoryBinder;
+
+public class StaticLoggerBinder implements LoggerFactoryBinder {
+ public static final String REQUESTED_API_VERSION = "1.7";
+
+ private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
+
+ private final ILoggerFactory loggerFactory;
+
+ protected StaticLoggerBinder() {
+ loggerFactory = new SystemLoggerFactory();
+ }
+
+ @Override
+ public ILoggerFactory getLoggerFactory() {
+ return loggerFactory;
+ }
+
+ @Override
+ public String getLoggerFactoryClassStr() {
+ return SystemLoggerFactory.class.getName();
+ }
+
+ public static final StaticLoggerBinder getSingleton() {
+ return SINGLETON;
+ }
+
+ static class SystemLoggerFactory implements ILoggerFactory {
+
+ @Override
+ public org.slf4j.Logger getLogger(String name) {
+ SystemLoggingAdapter logger = SystemLoggingAdapter.getLog(name);
+ return new ArgeoLogger(name, logger);
+ }
+
+ }
+
+}
--- /dev/null
+package org.slf4j.impl;
+
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
+import java.util.Objects;
+import java.util.function.Supplier;
+
+/**
+ * A Commons Logging / SLF4J style logging utilities wrapping a standard Java
+ * platform {@link Logger}.
+ */
+public interface SystemLoggingAdapter {
+ Logger getLogger();
+
+ default boolean isDebugEnabled() {
+ return getLogger().isLoggable(Level.DEBUG);
+ }
+
+ default boolean isErrorEnabled() {
+ return getLogger().isLoggable(Level.ERROR);
+ }
+
+ default boolean isInfoEnabled() {
+ return getLogger().isLoggable(Level.INFO);
+ }
+
+ default boolean isTraceEnabled() {
+ return getLogger().isLoggable(Level.TRACE);
+ }
+
+ default boolean isWarnEnabled() {
+ return getLogger().isLoggable(Level.WARNING);
+ }
+
+ /*
+ * TRACE
+ */
+
+ default void trace(String message) {
+ getLogger().log(Level.TRACE, message);
+ }
+
+ default void trace(Supplier<String> message) {
+ getLogger().log(Level.TRACE, message);
+ }
+
+ default void trace(Object message) {
+ getLogger().log(Level.TRACE, Objects.requireNonNull(message));
+ }
+
+ default void trace(String message, Throwable t) {
+ getLogger().log(Level.TRACE, message, t);
+ }
+
+ default void trace(Object message, Throwable t) {
+ trace(Objects.requireNonNull(message).toString(), t);
+ }
+
+ default void trace(String format, Object... arguments) {
+ getLogger().log(Level.TRACE, format, arguments);
+ }
+
+ /*
+ * DEBUG
+ */
+
+ default void debug(String message) {
+ getLogger().log(Level.DEBUG, message);
+ }
+
+ default void debug(Supplier<String> message) {
+ getLogger().log(Level.DEBUG, message);
+ }
+
+ default void debug(Object message) {
+ getLogger().log(Level.DEBUG, message);
+ }
+
+ default void debug(String message, Throwable t) {
+ getLogger().log(Level.DEBUG, message, t);
+ }
+
+ default void debug(Object message, Throwable t) {
+ debug(Objects.requireNonNull(message).toString(), t);
+ }
+
+ default void debug(String format, Object... arguments) {
+ getLogger().log(Level.DEBUG, format, arguments);
+ }
+
+ /*
+ * INFO
+ */
+
+ default void info(String message) {
+ getLogger().log(Level.INFO, message);
+ }
+
+ default void info(Supplier<String> message) {
+ getLogger().log(Level.INFO, message);
+ }
+
+ default void info(Object message) {
+ getLogger().log(Level.INFO, message);
+ }
+
+ default void info(String message, Throwable t) {
+ getLogger().log(Level.INFO, message, t);
+ }
+
+ default void info(Object message, Throwable t) {
+ info(Objects.requireNonNull(message).toString(), t);
+ }
+
+ default void info(String format, Object... arguments) {
+ getLogger().log(Level.INFO, format, arguments);
+ }
+
+ /*
+ * WARN
+ */
+
+ default void warn(String message) {
+ getLogger().log(Level.WARNING, message);
+ }
+
+ default void warn(Supplier<String> message) {
+ getLogger().log(Level.WARNING, message);
+ }
+
+ default void warn(Object message) {
+ getLogger().log(Level.WARNING, message);
+ }
+
+ default void warn(String message, Throwable t) {
+ getLogger().log(Level.WARNING, message, t);
+ }
+
+ default void warn(Object message, Throwable t) {
+ warn(Objects.requireNonNull(message).toString(), t);
+ }
+
+ default void warn(String format, Object... arguments) {
+ getLogger().log(Level.WARNING, format, arguments);
+ }
+
+ /*
+ * ERROR
+ */
+
+ default void error(String message) {
+ getLogger().log(Level.ERROR, message);
+ }
+
+ default void error(Supplier<String> message) {
+ getLogger().log(Level.ERROR, message);
+ }
+
+ default void error(Object message) {
+ getLogger().log(Level.ERROR, message);
+ }
+
+ default void error(String message, Throwable t) {
+ getLogger().log(Level.ERROR, message, t);
+ }
+
+ default void error(Object message, Throwable t) {
+ error(Objects.requireNonNull(message).toString(), t);
+ }
+
+ default void error(String format, Object... arguments) {
+ getLogger().log(Level.ERROR, format, arguments);
+ }
+
+ /*
+ * STATIC UTILITIES
+ */
+
+ static SystemLoggingAdapter getLog(Class<?> clss) {
+ return getLog(Objects.requireNonNull(clss).getName());
+ }
+
+ static SystemLoggingAdapter getLog(String name) {
+ Logger logger = System.getLogger(Objects.requireNonNull(name));
+ return new LoggerWrapper(logger);
+ }
+
+ /** A trivial implementation wrapping a platform logger. */
+ static class LoggerWrapper implements SystemLoggingAdapter {
+ private final Logger logger;
+
+ LoggerWrapper(Logger logger) {
+ this.logger = logger;
+ }
+
+ @Override
+ public Logger getLogger() {
+ return logger;
+ }
+
+ }
+
+}
+++ /dev/null
-/target/
-*.target
-/feature.xml
-/modularDistribution.csv
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.ide.node</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-Manifest-Version: 1.0\r
-Automatic-Module-Name: org.argeo.slc.ide.node\r
-Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt\r
-Bundle-ManifestVersion: 2\r
-Bundle-Name: IDE CMS Node\r
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8\r
-Bundle-SymbolicName: org.argeo.slc.ide.node\r
-Bundle-Version: 2.1.16.SNAPSHOT-r201906291110\r
-Include-Resource: modularDistribution.csv=modularDistribution.csv,featur\r
- e.xml=feature.xml\r
-Private-Package: !*\r
-SLC-Category: org.argeo.slc.ide\r
+++ /dev/null
-<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.slc.ide</groupId>
- <artifactId>features</artifactId>
- <version>2.1.16-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.ide.node</artifactId>
- <packaging>jar</packaging>
- <name>IDE CMS Node</name>
- <build>
- <plugins>
- <plugin>
- <groupId>org.argeo.maven.plugins</groupId>
- <artifactId>argeo-osgi-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-descriptors</id>
- <goals>
- <goal>descriptors</goal>
- </goals>
- <phase>generate-resources</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <!-- Parent dependencies -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.dep.cms.node</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.ide.osgi</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-bin.includes = feature.xml
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.argeo.slc.ide.osgi"
- label="Argeo IDE OSGi"
- version="2.1.0.qualifier"
- provider-name="Argeo GmbH">
-
- <description url="http://www.example.com/description">
- [Enter Feature Description here.]
- </description>
-
- <copyright url="http://www.example.com/copyright">
- [Enter Copyright Description here.]
- </copyright>
-
- <license url="http://www.example.com/license">
- [Enter License Description here.]
- </license>
-
- <requires>
- <import feature="org.eclipse.pde" version="3.14.0.v20190605-1800" match="greaterOrEqual"/>
- <import feature="org.eclipse.jdt" version="3.18.0.v20190605-1800" match="greaterOrEqual"/>
- </requires>
-
- <plugin
- id="org.argeo.slc.ide.osgi.ui"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.studio</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-bin.includes = feature.xml,\
- icons/,\
- category.xml,\
- p2.inf
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.argeo.slc.studio"
- label="Argeo IDE"
- version="2.1.0.qualifier"
- provider-name="Argeo GmbH"
- plugin="org.argeo.slc.studio.ui"
- image="icons/argeo-icon-100104-256.png">
-
- <description url="http://projects.argeo.org/slc/">
- Argeo SLC IDE
- </description>
-
- <copyright url="http://www.argeo.org">
- Copyright 2012 Argeo GmbH
- </copyright>
-
- <license url="http://www.apache.org/licenses/LICENSE-2.0.txt">
- Argeo Integrated Development Environment
-Copyright 2012 Argeo GmbH
-Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-http://www.apache.org/licenses/LICENSE-2.0
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an &quot;AS IS&quot;
-BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
-or implied.
-See the License for the specific language governing permissions
-and limitations under the License.
- </license>
-
- <url>
- <update label="Argeo SLC IDE (Devpt)" url="http://projects.argeo.org/projects/slc/update/ide-dev"/>
- <discovery label="Argeo.org" url="http://www.argeo.org"/>
- </url>
-
- <includes
- id="org.argeo.slc.ide.osgi"
- version="0.0.0"/>
-
- <requires>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.debug.core"/>
- <import plugin="org.eclipse.jdt.launching"/>
- <import plugin="org.eclipse.debug.ui"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.ui.console"/>
- <import plugin="org.eclipse.jdt.debug.ui"/>
- <import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.core.variables"/>
- <import plugin="org.eclipse.pde.ui" version="3.4.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.jdt.ui" version="3.4.2" match="greaterOrEqual"/>
- </requires>
-
- <plugin
- id="org.argeo.slc.studio.ui"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.junit"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
-</feature>
+++ /dev/null
-properties.1.name=org.eclipse.equinox.p2.type.category
-properties.1.value=true
\ No newline at end of file
+++ /dev/null
-<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.slc.ide</groupId>
- <artifactId>argeo-ide</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>features</artifactId>
- <packaging>pom</packaging>
- <name>IDE Features</name>
- <modules>
-<!-- <module>org.argeo.slc.ide.node</module> -->
- </modules>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+++ /dev/null
-/bin/
-/target/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<projectDescription>\r
- <name>org.argeo.slc.ide.osgi.ui</name>\r
- <comment></comment>\r
- <projects>\r
- </projects>\r
- <buildSpec>\r
- <buildCommand>\r
- <name>org.eclipse.jdt.core.javabuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- <buildCommand>\r
- <name>org.eclipse.pde.ManifestBuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- <buildCommand>\r
- <name>org.eclipse.pde.SchemaBuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- </buildSpec>\r
- <natures>\r
- <nature>org.eclipse.pde.PluginNature</nature>\r
- <nature>org.eclipse.jdt.core.javanature</nature>\r
- </natures>\r
-</projectDescription>\r
+++ /dev/null
-Manifest-Version: 1.0\r
-Bundle-ActivationPolicy: lazy\r
-Bundle-Activator: org.argeo.slc.ide.ui.SlcIdeUiPlugin\r
-Bundle-ManifestVersion: 2\r
-Bundle-Name: IDE UI\r
-Bundle-RequiredExecutionEnvironment: JavaSE-11\r
-Bundle-SymbolicName: org.argeo.slc.ide.osgi.ui;singleton:=true\r
-Bundle-Version: 2.1.0.qualifier\r
-Require-Bundle: org.eclipse.core.runtime,\r
- org.eclipse.core.commands,\r
- org.eclipse.ui.workbench,\r
- org.eclipse.debug.core;bundle-version="3.13.300",\r
- org.eclipse.debug.ui;bundle-version="3.14.100",\r
- org.eclipse.jface;bundle-version="3.16.0",\r
- org.eclipse.pde.core;bundle-version="3.13.0",\r
- org.eclipse.pde.ui;bundle-version="3.11.0",\r
- org.eclipse.jdt.launching;bundle-version="3.14.0",\r
- org.eclipse.core.variables;bundle-version="3.4.500"\r
-Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"\r
-Export-Package: org.argeo.slc.ide.ui,\r
- org.argeo.slc.ide.ui.launch.osgi\r
-Automatic-Module-Name: org.argeo.slc.ide.osgi.ui\r
+++ /dev/null
-source.. = src/\r
-bin.includes = META-INF/,\\r
- .,\\r
- plugin.xml,\\r
- icons/\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<?eclipse version="3.2"?>\r
-<plugin>\r
-<!--\r
-<extension \r
- point="org.eclipse.ui.preferencePages"> \r
- <page \r
- id="org.argeo.slc.ide.ui.mainPreferencePage" \r
- name="SLC" \r
- class="org.argeo.slc.ide.ui.SlcMainPreferencePage"> \r
- </page> \r
-</extension> \r
-<extension\r
- point="org.eclipse.ui.perspectives">\r
- <perspective\r
- class="org.argeo.slc.ide.ui.SlcPerspectiveFactory"\r
- icon="icons/argeo-icon-100104-256.png"\r
- id="org.argeo.slc.ide.ui.slcPerspective"\r
- name="SLC">\r
- </perspective>\r
-</extension>\r
--->\r
-<extension\r
- point="org.eclipse.debug.ui.launchShortcuts">\r
- <shortcut\r
- class="org.argeo.slc.ide.ui.launch.osgi.OsgiBootLaunchShortcut"\r
- icon="icons/slc-launch.gif"\r
- id="org.argeo.slc.ide.ui.osgiBootLaunchShortcut"\r
- label="OSGi Boot (Equinox, RAP)"\r
- modes="run,debug">\r
- <contextualLaunch>\r
- <enablement>\r
- <with variable="selection">\r
- <count value="1"/>\r
- <iterate>\r
- <or>\r
- <test property="org.eclipse.debug.ui.matchesPattern" value="*.properties"/>\r
- <test property="org.eclipse.debug.ui.matchesPattern" value="config.ini"/>\r
- </or>\r
- </iterate>\r
- </with>\r
- </enablement>\r
- </contextualLaunch> \r
- </shortcut>\r
- <shortcut\r
- class="org.argeo.slc.ide.ui.launch.osgi.EclipseBootLaunchShortcut"\r
- icon="icons/eclipse-launch.gif"\r
- id="org.argeo.slc.ide.ui.eclipseBootLaunchShortcut"\r
- label="Eclipse Boot (RCP)"\r
- modes="run,debug">\r
- <contextualLaunch>\r
- <enablement>\r
- <with variable="selection">\r
- <count value="1"/>\r
- <iterate>\r
- <or>\r
- <test property="org.eclipse.debug.ui.matchesPattern" value="*.properties"/>\r
- <test property="org.eclipse.debug.ui.matchesPattern" value="config.ini"/>\r
- </or>\r
- </iterate>\r
- </with>\r
- </enablement>\r
- </contextualLaunch> \r
- </shortcut>\r
-</extension>\r
- <extension\r
- point="org.eclipse.debug.core.launchConfigurationTypes">\r
- <launchConfigurationType\r
- id="org.argeo.slc.ide.ui.OsgiBootEquinoxLauncher"\r
- name="OSGi Boot Equinox"\r
- delegate="org.argeo.slc.ide.ui.launch.osgi.OsgiBootEquinoxLaunchConfiguration"\r
- modes="run, debug"\r
- sourceLocatorId="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"\r
- sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"/>\r
- <launchConfigurationType\r
- id="org.argeo.slc.ide.ui.EclipseBootLauncher"\r
- name="Eclipse Boot"\r
- delegate="org.argeo.slc.ide.ui.launch.osgi.EclipseBootLaunchConfiguration"\r
- modes="run, debug"\r
- sourceLocatorId="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"\r
- sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"/>\r
- </extension>\r
- <extension\r
- point="org.eclipse.debug.ui.launchConfigurationTabGroups">\r
- <launchConfigurationTabGroup\r
- type="org.argeo.slc.ide.ui.OsgiBootEquinoxLauncher"\r
- class="org.argeo.slc.ide.ui.launch.osgi.OsgiBootLauncherTabGroup"\r
- id="org.argeo.slc.ide.ui.OsgiBootLauncherTabGroup">\r
- </launchConfigurationTabGroup>\r
- <launchConfigurationTabGroup\r
- type="org.argeo.slc.ide.ui.EclipseBootLauncher"\r
- class="org.argeo.slc.ide.ui.launch.osgi.EclipseBootLauncherTabGroup"\r
- id="org.argeo.slc.ide.ui.EclipseBootLauncherTabGroup">\r
- </launchConfigurationTabGroup>\r
- </extension>\r
- <extension\r
- point="org.eclipse.debug.ui.launchConfigurationTypeImages">\r
- <launchConfigurationTypeImage\r
- icon="icons/slc-launch.gif"\r
- configTypeID="org.argeo.slc.ide.ui.OsgiBootEquinoxLauncher"\r
- id="org.argeo.slc.ide.ui.OsgiBootEquinoxLauncherImage">\r
- </launchConfigurationTypeImage>\r
- <launchConfigurationTypeImage\r
- icon="icons/eclipse-launch.gif"\r
- configTypeID="org.argeo.slc.ide.ui.EclipseBootLauncher"\r
- id="org.argeo.slc.ide.ui.EclipseBootLauncherImage">\r
- </launchConfigurationTypeImage>\r
- </extension>\r
-<!-- \r
- <extension point = "org.eclipse.pde.core.targets">\r
- <target \r
- id="org.eclipse.pde.core.rcpTarget"\r
- name="Managed"\r
- definition="targets/managedTarget.target"/>\r
- </extension>\r
- -->\r
-</plugin>\r
+++ /dev/null
-package org.argeo.slc.ide.ui;\r
-\r
-import java.net.URL;\r
-\r
-import org.eclipse.core.resources.IResource;\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.debug.core.DebugEvent;\r
-import org.eclipse.debug.core.DebugPlugin;\r
-import org.eclipse.debug.core.IDebugEventSetListener;\r
-import org.eclipse.debug.core.ILaunch;\r
-import org.eclipse.debug.core.model.IProcess;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.eclipse.jface.resource.ImageRegistry;\r
-import org.eclipse.pde.core.plugin.TargetPlatform;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.ui.plugin.AbstractUIPlugin;\r
-import org.osgi.framework.BundleContext;\r
-\r
-/**\r
- * The activator class controls the plug-in life cycle\r
- */\r
-public class SlcIdeUiPlugin extends AbstractUIPlugin {\r
-\r
- // The plug-in ID\r
- public static final String ID = "org.argeo.slc.ide.ui";\r
-\r
- // The shared instance\r
- private static SlcIdeUiPlugin plugin;\r
-\r
- /**\r
- * The constructor\r
- */\r
- public SlcIdeUiPlugin() {\r
- }\r
-\r
- @Override\r
- public void start(BundleContext context) throws Exception {\r
- super.start(context);\r
- plugin = this;\r
- DebugPlugin.getDefault()\r
- .addDebugEventListener(new DebugEventListener());\r
-\r
- String location = TargetPlatform.getLocation();\r
- System.out.println(location);\r
- }\r
-\r
- @Override\r
- public void stop(BundleContext context) throws Exception {\r
- plugin = null;\r
- super.stop(context);\r
- }\r
-\r
- /**\r
- * Returns the shared instance\r
- * \r
- * @return the shared instance\r
- */\r
- public static SlcIdeUiPlugin getDefault() {\r
- return plugin;\r
- }\r
-\r
- public Image getImage(String relativeURL) {\r
- ImageRegistry imageRegistry = getImageRegistry();\r
- Image image = imageRegistry.get(relativeURL);\r
- if (image == null) {\r
- URL imageURL = getBundle().getEntry(relativeURL);\r
- ImageDescriptor descriptor = ImageDescriptor\r
- .createFromURL(imageURL);\r
- image = descriptor.createImage();\r
- imageRegistry.put(relativeURL, image);\r
- }\r
- return image;\r
- }\r
-\r
- protected static class DebugEventListener implements IDebugEventSetListener {\r
- public void handleDebugEvents(DebugEvent[] events) {\r
- if (events == null)\r
- return;\r
-\r
- for (int i = 0; i < events.length; i++) {\r
- DebugEvent event = events[i];\r
- if (event == null)\r
- continue;\r
- Object source = event.getSource();\r
- if (source instanceof IProcess\r
- && event.getKind() == DebugEvent.TERMINATE) {\r
- IProcess process = (IProcess) source;\r
-// if (process == null)\r
-// continue;\r
- ILaunch launch = process.getLaunch();\r
- if (launch != null)\r
- refreshOsgiBootLaunch(launch);\r
- }\r
- }\r
- }\r
-\r
- protected void refreshOsgiBootLaunch(ILaunch launch) {\r
- try {\r
- if (launch == null)\r
- return;\r
- IResource[] resources = launch.getLaunchConfiguration()\r
- .getMappedResources();\r
- if (resources == null)\r
- return;\r
- if (resources.length > 0) {\r
- IResource propertiesFile = resources[0];\r
- if (propertiesFile.getParent() == null)\r
- return;\r
- propertiesFile.getParent().refreshLocal(\r
- IResource.DEPTH_INFINITE, null);\r
- // System.out.println("Refreshed "\r
- // + propertiesFile.getParent());\r
- }\r
- } catch (CoreException e) {\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ide.ui;\r
-\r
-import org.eclipse.jface.preference.FieldEditorPreferencePage;\r
-import org.eclipse.ui.IWorkbench;\r
-import org.eclipse.ui.IWorkbenchPreferencePage;\r
-\r
-public class SlcMainPreferencePage extends FieldEditorPreferencePage implements\r
- IWorkbenchPreferencePage {\r
- public SlcMainPreferencePage() {\r
-// IPreferenceStore store = SlcIdePlugin.getDefault().getPreferenceStore();\r
-// setPreferenceStore(store);\r
- setDescription("Argeo SLC Preferences");\r
- }\r
-\r
- @Override\r
- protected void createFieldEditors() {\r
-// addField(new DirectoryFieldEditor(PREF_SLC_RUNTIME_LOCATION,\r
-// "SLC Runtime", getFieldEditorParent()));\r
-// addField(new DirectoryFieldEditor(PREF_EMBEDDED_JAVA_LIBRARY_PATH,\r
-// "Embedded Java Library Path", getFieldEditorParent()));\r
- }\r
-\r
- public void init(IWorkbench workbench) {\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ide.ui;\r
-\r
-import org.eclipse.ui.IFolderLayout;\r
-import org.eclipse.ui.IPageLayout;\r
-import org.eclipse.ui.IPerspectiveFactory;\r
-\r
-public class SlcPerspectiveFactory implements IPerspectiveFactory {\r
-\r
- public void createInitialLayout(IPageLayout layout) {\r
- // Get the editor area.\r
- String editorArea = layout.getEditorArea();\r
-\r
- IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.25f,\r
- editorArea);\r
-// topLeft.addView(JavaUI.ID_PACKAGES);\r
-\r
- IFolderLayout bottom = layout.createFolder("bottom", IPageLayout.BOTTOM, 0.66f,\r
- editorArea);\r
-// bottom.addView(IConsoleConstants.ID_CONSOLE_VIEW);\r
- bottom.addView(IPageLayout.ID_TASK_LIST);\r
- \r
- layout.addActionSet("org.eclipse.debug.ui.launchActionSet");\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ide.ui.launch.osgi;
-
-import org.argeo.slc.ide.ui.SlcIdeUiPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.pde.launching.EclipseApplicationLaunchConfiguration;
-
-/** OSGiBoot launch configuration. */
-public class EclipseBootLaunchConfiguration extends
- EclipseApplicationLaunchConfiguration {
- public final static String ID = SlcIdeUiPlugin.ID + ".EclipseBootLauncher";
-
- @Override
- public void launch(ILaunchConfiguration configuration, String mode,
- ILaunch launch, IProgressMonitor monitor) throws CoreException {
- super.launch(configuration, mode, launch, monitor);
- // Refresh resources before launching
- final IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
- propertiesFile.getParent().refreshLocal(IResource.DEPTH_INFINITE,
- monitor);
- }
-
- @Override
- protected void preLaunchCheck(ILaunchConfiguration configuration,
- ILaunch launch, IProgressMonitor monitor) throws CoreException {
- ILaunchConfigurationWorkingCopy wc = configuration.getWorkingCopy();
- OsgiLaunchHelper.updateLaunchConfiguration(wc, true);
- wc.doSave();
-
- super.preLaunchCheck(configuration, launch, monitor);
-
- // Note that if a Java project contains a build.properties it has to
- // declare the sources otherwise it will be skipped in the generation of
- // the dev.properties file!
- }
-
-}
+++ /dev/null
-package org.argeo.slc.ide.ui.launch.osgi;
-
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.pde.ui.launcher.EclipseLaunchShortcut;
-
-/**
- * Launch shortcut simplifying the launch of an Eclipse application (typically
- * an RCP).
- */
-public class EclipseBootLaunchShortcut extends EclipseLaunchShortcut implements
- OsgiLauncherConstants {
- private StringBuffer name = null;
- private IFile propertiesFile = null;
-
- @Override
- protected String getLaunchConfigurationTypeName() {
- return EclipseBootLaunchConfiguration.ID;
- }
-
- @Override
- public void launch(ISelection selection, String mode) {
- // we assume that only one file is selected
- IStructuredSelection sSelection = (IStructuredSelection) selection;
- Iterator<?> it = sSelection.iterator();
- propertiesFile = (IFile) it.next();
-
- name = new StringBuffer(OsgiLaunchHelper.extractName(propertiesFile));
-
- super.launch(selection, mode);
- }
-
- @Override
- protected void initializeConfiguration(ILaunchConfigurationWorkingCopy wc) {
- IResource[] resources = { propertiesFile };
- wc.setMappedResources(resources);
- super.initializeConfiguration(wc);
-
- OsgiLaunchHelper.setDefaults(wc, true);
- wc.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
- OsgiLaunchHelper.findWorkingDirectory(propertiesFile));
-
- OsgiLaunchHelper.updateLaunchConfiguration(wc, true);
- }
-
- protected String getName(ILaunchConfigurationType type) {
- if (name != null && !name.toString().trim().equals(""))
- return DebugPlugin.getDefault().getLaunchManager()
- .generateLaunchConfigurationName(name.toString());
- else
- return DebugPlugin.getDefault().getLaunchManager()
- .generateLaunchConfigurationName("SLC");
- }
-
- @Override
- protected boolean isGoodMatch(ILaunchConfiguration configuration) {
- if (name != null) {
- return name.toString().equals(configuration.getName());
- }
- return super.isGoodMatch(configuration);
- }
-}
+++ /dev/null
-package org.argeo.slc.ide.ui.launch.osgi;
-
-import org.eclipse.debug.ui.CommonTab;
-import org.eclipse.debug.ui.EnvironmentTab;
-import org.eclipse.debug.ui.ILaunchConfigurationDialog;
-import org.eclipse.debug.ui.ILaunchConfigurationTab;
-import org.eclipse.pde.ui.launcher.EclipseLauncherTabGroup;
-import org.eclipse.pde.ui.launcher.MainTab;
-import org.eclipse.pde.ui.launcher.OSGiSettingsTab;
-import org.eclipse.pde.ui.launcher.PluginsTab;
-import org.eclipse.pde.ui.launcher.TracingTab;
-
-/** Definition of the set of tabs used in Eclipse Boot launch configuration UI. */
-public class EclipseBootLauncherTabGroup extends EclipseLauncherTabGroup {
-
- @Override
- public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
- new OsgiBootMainTab(true),
- new MainTab(),
- new PluginsTab(),
- // new PluginsTab() {
- // private boolean activating = false;
- //
- // @Override
- // public void performApply(
- // ILaunchConfigurationWorkingCopy config) {
- // super.performApply(config);
- // if (activating) {
- // try {
- // config.doSave();
- // } catch (CoreException e) {
- // e.printStackTrace();
- // }
- // activating = false;
- // }
- // }
- //
- // @Override
- // public void activated(
- // ILaunchConfigurationWorkingCopy workingCopy) {
- // activating = true;
- // }
- // },
- new OSGiSettingsTab(), new EnvironmentTab(), new TracingTab(),
- new CommonTab() };
- setTabs(tabs);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.ide.ui.launch.osgi;
-
-import org.argeo.slc.ide.ui.SlcIdeUiPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.pde.launching.EquinoxLaunchConfiguration;
-
-/** OSGiBoot launch configuration. */
-public class OsgiBootEquinoxLaunchConfiguration extends
- EquinoxLaunchConfiguration {
- public final static String ID = SlcIdeUiPlugin.ID
- + ".OsgiBootEquinoxLauncher";
-
- @Override
- public void launch(ILaunchConfiguration configuration, String mode,
- ILaunch launch, IProgressMonitor monitor) throws CoreException {
- super.launch(configuration, mode, launch, monitor);
-
-// System.out.println("targetBundles="
-// + configuration.getAttribute(
-// IPDELauncherConstants.TARGET_BUNDLES, ""));
-// System.out.println("workspaceBundles="
-// + configuration.getAttribute(
-// IPDELauncherConstants.WORKSPACE_BUNDLES, ""));
-
- // Refresh resources before launching
- final IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
- propertiesFile.getParent().refreshLocal(IResource.DEPTH_INFINITE,
- monitor);
- }
-
- @Override
- protected void preLaunchCheck(ILaunchConfiguration configuration,
- ILaunch launch, IProgressMonitor monitor) throws CoreException {
- // System.out.println("Launching... " + launch);
- ILaunchConfigurationWorkingCopy wc = configuration.getWorkingCopy();
- OsgiLaunchHelper.updateLaunchConfiguration(wc, false);
- wc.doSave();
- super.preLaunchCheck(configuration, launch, monitor);
-
- // Note that if a Java project contains a build.properties it has to
- // declare the sources otherwise it will be skipped in the generation of
- // the dev.properties file!
-
- // for(Object bundleId:fAllBundles.keySet()){
- // System.out.println(bundleId+"="+fAllBundles.get(bundleId));
- // }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.ide.ui.launch.osgi;
-
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.pde.ui.launcher.OSGiLaunchShortcut;
-
-/** Launch shortcut simplifying the launch of a pure OSGi runtime */
-public class OsgiBootLaunchShortcut extends OSGiLaunchShortcut implements
- OsgiLauncherConstants {
- private StringBuffer name = null;
- private IFile propertiesFile = null;
-
- @Override
- protected String getLaunchConfigurationTypeName() {
- return OsgiBootEquinoxLaunchConfiguration.ID;
- }
-
- @Override
- public void launch(ISelection selection, String mode) {
- // we assume that only one file is selected
- IStructuredSelection sSelection = (IStructuredSelection) selection;
- Iterator<?> it = sSelection.iterator();
- propertiesFile = (IFile) it.next();
-
- name = new StringBuffer(OsgiLaunchHelper.extractName(propertiesFile));
-
- super.launch(selection, mode);
- }
-
- @Override
- protected void initializeConfiguration(ILaunchConfigurationWorkingCopy wc) {
- IResource[] resources = { propertiesFile };
- wc.setMappedResources(resources);
- super.initializeConfiguration(wc);
-
- OsgiLaunchHelper.setDefaults(wc, true);
-
- wc.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
- OsgiLaunchHelper.findWorkingDirectory(propertiesFile));
-
- OsgiLaunchHelper.updateLaunchConfiguration(wc, false);
- }
-
- protected String getName(ILaunchConfigurationType type) {
- if (name != null && !name.toString().trim().equals(""))
- return DebugPlugin.getDefault().getLaunchManager()
- .generateLaunchConfigurationName(name.toString());
- else
- return DebugPlugin.getDefault().getLaunchManager()
- .generateLaunchConfigurationName("SLC");
- }
-
- @Override
- protected boolean isGoodMatch(ILaunchConfiguration configuration) {
- if (name != null) {
- return name.toString().equals(configuration.getName());
- }
- return super.isGoodMatch(configuration);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.ide.ui.launch.osgi;
-
-import org.eclipse.debug.ui.CommonTab;
-import org.eclipse.debug.ui.EnvironmentTab;
-import org.eclipse.debug.ui.ILaunchConfigurationDialog;
-import org.eclipse.debug.ui.ILaunchConfigurationTab;
-import org.eclipse.pde.ui.launcher.BundlesTab;
-import org.eclipse.pde.ui.launcher.OSGiLauncherTabGroup;
-import org.eclipse.pde.ui.launcher.OSGiSettingsTab;
-import org.eclipse.pde.ui.launcher.TracingTab;
-
-/** Definition of the set of tabs used in OSGi Boot launch configuration UI. */
-public class OsgiBootLauncherTabGroup extends OSGiLauncherTabGroup {
-
- @Override
- public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
- new OsgiBootMainTab(false),
- new BundlesTab() {
-// private boolean activating = false;
-//
-// @Override
-// public void performApply(
-// ILaunchConfigurationWorkingCopy config) {
-// super.performApply(config);
-// if (activating) {
-// try {
-// config.doSave();
-// } catch (CoreException e) {
-// e.printStackTrace();
-// }
-// activating = false;
-// }
-// }
-//
-// @Override
-// public void activated(
-// ILaunchConfigurationWorkingCopy workingCopy) {
-// activating = true;
-// }
- }, new OSGiSettingsTab(), new EnvironmentTab(),
- new TracingTab(), new CommonTab() };
- setTabs(tabs);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.ide.ui.launch.osgi;
-
-import org.argeo.slc.ide.ui.SlcIdeUiPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/** Main tab of OSGiBoot launch configuration UI. */
-public class OsgiBootMainTab extends AbstractLaunchConfigurationTab implements
- OsgiLauncherConstants {
- private Listener listener = new Listener();
-
- private Button syncBundles;
- private Button clearDataDirectory;
-
- private Button addJvmPaths;
- private Text additionalVmArgs;
-
- private Text additionalProgramArgs;
-
- // private final Boolean isEclipse;
-
- public OsgiBootMainTab(Boolean isEclipse) {
- super();
- // this.isEclipse = isEclipse;
- }
-
- public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NONE);
- container.setLayout(new GridLayout());
- container.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createAdditionalProgramArgs(container);
- createAdditionalVmArgumentBlock(container);
- createAdvanced(container);
- Dialog.applyDialogFont(container);
- setControl(container);
- }
-
- /** Init UI for programs arguments */
- protected void createAdditionalProgramArgs(Composite parent) {
- Group container = new Group(parent, SWT.NONE);
- container.setText("Additional Program Arguments");
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- container.setLayout(layout);
- container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- additionalProgramArgs = new Text(container, SWT.MULTI | SWT.WRAP
- | SWT.BORDER | SWT.V_SCROLL);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 60;
- gd.widthHint = 100;
- gd.horizontalSpan = 2;
- additionalProgramArgs.setLayoutData(gd);
- additionalProgramArgs.addModifyListener(listener);
- }
-
- /** Init UI for VM arguments */
- protected void createAdditionalVmArgumentBlock(Composite parent) {
- Group container = new Group(parent, SWT.NONE);
- container.setText("Additional VM Arguments");
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- container.setLayout(layout);
- container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- additionalVmArgs = new Text(container, SWT.MULTI | SWT.WRAP
- | SWT.BORDER | SWT.V_SCROLL);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 60;
- gd.widthHint = 100;
- gd.horizontalSpan = 2;
- additionalVmArgs.setLayoutData(gd);
- additionalVmArgs.addModifyListener(listener);
-
- }
-
- /** Init UI for Advanced section */
- protected void createAdvanced(Composite parent) {
- Group container = new Group(parent, SWT.NONE);
- container.setText("Advanced");
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- container.setLayout(layout);
- container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- syncBundles = new Button(container, SWT.CHECK);
- syncBundles.addSelectionListener(listener);
- new Label(container, SWT.NONE)
- .setText("Keep bundles in line with target platform and workspace (recommended)");
- clearDataDirectory = new Button(container, SWT.CHECK);
- clearDataDirectory.addSelectionListener(listener);
- new Label(container, SWT.NONE)
- .setText("Clear data directory before launch");
-
- addJvmPaths = new Button(container, SWT.CHECK);
- addJvmPaths.addSelectionListener(listener);
- new Label(container, SWT.NONE)
- .setText("Add workspace JVM paths as non-standard system properties");
-
- }
-
- public String getName() {
- return "OSGi Boot";
- }
-
- @Override
- public Image getImage() {
- return SlcIdeUiPlugin.getDefault().getImage("icons/slc-launch.gif");
- }
-
- public void initializeFrom(ILaunchConfiguration configuration) {
- // System.out.println("initializeFrom");
- try {
- syncBundles.setSelection(configuration.getAttribute(
- ATTR_SYNC_BUNDLES, true));
- clearDataDirectory.setSelection(configuration.getAttribute(
- ATTR_CLEAR_DATA_DIRECTORY, false));
-
- additionalProgramArgs.setText(configuration.getAttribute(
- ATTR_ADDITIONAL_PROGRAM_ARGS, ""));
- addJvmPaths.setSelection(configuration.getAttribute(
- ATTR_ADD_JVM_PATHS, false));
- additionalVmArgs.setText(configuration.getAttribute(
- ATTR_ADDITIONAL_VM_ARGS, ""));
- // readProperties(configuration);
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {
- // System.out.println("performApply");
- configuration.setAttribute(ATTR_SYNC_BUNDLES,
- syncBundles.getSelection());
- configuration.setAttribute(ATTR_CLEAR_DATA_DIRECTORY,
- clearDataDirectory.getSelection());
-
- configuration.setAttribute(ATTR_ADDITIONAL_PROGRAM_ARGS,
- additionalProgramArgs.getText());
- configuration.setAttribute(ATTR_ADDITIONAL_VM_ARGS,
- additionalVmArgs.getText());
- configuration.setAttribute(ATTR_ADD_JVM_PATHS,
- addJvmPaths.getSelection());
- // writeProperties(configuration);
-
- // OsgiLaunchHelper.updateLaunchConfiguration(configuration, isEclipse);
- }
-
- public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- // System.out.println("setDefaults");
- configuration.setAttribute(ATTR_SYNC_BUNDLES, true);
- configuration.setAttribute(ATTR_CLEAR_DATA_DIRECTORY, false);
- configuration.setAttribute(ATTR_ADD_JVM_PATHS, false);
- configuration.setAttribute(ATTR_ADDITIONAL_VM_ARGS, "-Xmx128m");
- configuration.setAttribute(ATTR_ADDITIONAL_PROGRAM_ARGS, "-console");
- }
-
- @Override
- public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
- initializeFrom(workingCopy);
- try {
- workingCopy.doSave();
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
- // do nothing
- }
-
- class Listener extends SelectionAdapter implements ModifyListener {
- public void widgetSelected(SelectionEvent e) {
- // Object source = e.getSource();
- // setDirty(true);
- updateLaunchConfigurationDialog();
- }
-
- public void modifyText(ModifyEvent e) {
- // System.out.println("modifyText : " + e);
- // setDirty(true);
- updateLaunchConfigurationDialog();
- }
- }
-
- // private void readProperties(ILaunchConfiguration configuration) {
- // BufferedReader reader = null;
- // try {
- // IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
- // propertiesFile.refreshLocal(IResource.DEPTH_ONE, null);
- // reader = new BufferedReader(new InputStreamReader(propertiesFile
- // .getContents()));
- // String line = null;
- // StringBuffer buf = new StringBuffer("");
- // while ((line = reader.readLine()) != null) {
- // buf.append(line);
- // buf.append("\n");
- // }
- // propertiesText.setText(buf.toString());
- // } catch (CoreException e) {
- // ErrorDialog.openError(Display.getCurrent().getActiveShell(),
- // "Error", "Cannot read properties", e.getStatus());
- // return;
- // } catch (Exception e) {
- // ErrorDialog.openError(Display.getCurrent().getActiveShell(),
- // "Error", "Cannot read properties",
- // new Status(IStatus.ERROR, SlcIdeUiPlugin.ID,
- // e.getMessage(), e));
- // return;
- // } finally {
- // if (reader != null)
- // try {
- // reader.close();
- // } catch (IOException e) {
- // // silent
- // }
- // }
- //
- // }
- //
- // private void writeProperties(ILaunchConfiguration configuration) {
- // InputStream in = null;
- // IFile propertiesFile = null;
- // try {
- // propertiesFile = (IFile) configuration.getMappedResources()[0];
- // in = new ByteArrayInputStream(propertiesText.getText().getBytes());
- // propertiesFile.setContents(in, true, true, null);
- // propertiesFile.refreshLocal(IResource.DEPTH_ONE, null);
- // } catch (CoreException e) {
- // ErrorDialog.openError(Display.getCurrent().getActiveShell(),
- // "Error", "Cannot write properties", e.getStatus());
- // return;
- // } catch (Exception e) {
- // ErrorDialog.openError(Display.getCurrent().getActiveShell(),
- // "Error", "Cannot write properties",
- // new Status(IStatus.ERROR, SlcIdeUiPlugin.ID,
- // e.getMessage(), e));
- // return;
- // } finally {
- // if (in != null)
- // try {
- // in.close();
- // } catch (IOException e) {
- // // silent
- // }
- // }
- //
- // }
-
-}
+++ /dev/null
-package org.argeo.slc.ide.ui.launch.osgi;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.argeo.slc.ide.ui.SlcIdeUiPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.variables.IStringVariableManager;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.IVMInstall2;
-import org.eclipse.jdt.launching.IVMInstallType;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.core.plugin.PluginRegistry;
-import org.eclipse.pde.launching.IPDELauncherConstants;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Most of the actual logic is concentrated in this class which manipulates
- * {@link ILaunchConfigurationWorkingCopy}. Static method are used since the
- * shortcut and launch configuration classes are already extending PDE classes.
- */
-@SuppressWarnings("restriction")
-public class OsgiLaunchHelper implements OsgiLauncherConstants {
- private static Boolean debug = true;
-
- private final static String DEFAULT_DATA_DIR = "data";
- private final static String DEFAULT_EXEC_DIR = "exec";
- private final static String DEFAULT_VMARGS = "-Xmx256m";
- private final static String DEFAULT_PROGRAM_ARGS = "-console";
-
- /** Sets default values on this configuration. */
- public static void setDefaults(ILaunchConfigurationWorkingCopy wc,
- Boolean isEclipse) {
- try {
- if (isEclipse) {
- wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, false);
- wc.setAttribute(IPDELauncherConstants.USE_PRODUCT, false);
- }
-
- wc.setAttribute(ATTR_ADD_JVM_PATHS, false);
- wc.setAttribute(ATTR_ADDITIONAL_VM_ARGS, DEFAULT_VMARGS);
- wc.setAttribute(ATTR_ADDITIONAL_PROGRAM_ARGS, DEFAULT_PROGRAM_ARGS);
-
- // Defaults
- String originalVmArgs = wc.getAttribute(
- IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "");
- wc.setAttribute(ATTR_DEFAULT_VM_ARGS, originalVmArgs);
-
- // clear config area by default
- wc.setAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, true);
- } catch (CoreException e) {
- Shell shell = Display.getCurrent().getActiveShell();
- ErrorDialog.openError(shell, "Error",
- "Cannot execute initalize configuration", e.getStatus());
- }
- }
-
- /** Find the working directory based on this properties file. */
- public static String findWorkingDirectory(IFile propertiesFile) {
- try {
- IProject project = propertiesFile.getProject();
- IPath parent = propertiesFile.getProjectRelativePath()
- .removeLastSegments(1);
- IFolder execFolder = project.getFolder(parent
- .append(DEFAULT_EXEC_DIR));
- if (!execFolder.exists())
- execFolder.create(true, true, null);
- IFolder launchFolder = project.getFolder(execFolder
- .getProjectRelativePath().append(
- extractName(propertiesFile)));
- if (!launchFolder.exists())
- launchFolder.create(true, true, null);
- return "${workspace_loc:"
- + launchFolder.getFullPath().toString().substring(1) + "}";
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Cannot create working directory", e);
- }
- }
-
- /** Extract the launch configuration name from the properties file. */
- public static String extractName(IFile propertiesFile) {
- IPath path = propertiesFile.getFullPath();
- IPath pathNoExt = path.removeFileExtension();
- return pathNoExt.segment(pathNoExt.segmentCount() - 1);
-
- }
-
- /** Expects properties file to be set as mapped resources */
- @SuppressWarnings("unchecked")
- public static void updateLaunchConfiguration(
- ILaunchConfigurationWorkingCopy wc, Boolean isEclipse) {
- try {
- if (debug)
- debug("##\n## Launch " + wc.getName() + " - " + new Date()
- + "\n##");
-
- // Finds the properties file and load it
- IFile propertiesFile = (IFile) wc.getMappedResources()[0];
- propertiesFile.refreshLocal(IResource.DEPTH_ONE, null);
- Properties properties = readProperties(propertiesFile);
-
- // Extract information from the properties file
- Map<String, Integer> bundlesToStart = new TreeMap<String, Integer>();
- Map<String, String> systemPropertiesToAppend = new HashMap<String, String>();
- String applicationId = interpretProperties(properties,
- bundlesToStart, systemPropertiesToAppend);
-
- if (applicationId != null)
- wc.setAttribute(IPDELauncherConstants.APPLICATION,
- applicationId);
- else {
- if (isEclipse)
- throw new Exception("No application defined,"
- + " please set the 'eclipse.application' property"
- + " in the properties file");
- }
-
- // Define directories
- File workingDir = getWorkingDirectory(wc);
- File dataDir = new File(workingDir, DEFAULT_DATA_DIR);
-
- // Update the launch configuration accordingly
- updateLaunchConfiguration(wc, bundlesToStart,
- systemPropertiesToAppend, dataDir.getAbsolutePath(),
- isEclipse);
-
- if (debug) {
- Map<String, ?> attrs = new TreeMap<String, Object>(
- wc.getAttributes());
- for (String key : attrs.keySet())
- OsgiLaunchHelper.debug(key + "=" + attrs.get(key));
- }
- } catch (Exception e) {
- e.printStackTrace();
- Shell shell = SlcIdeUiPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getShell();
- // Shell shell= Display.getCurrent().getActiveShell();
- ErrorDialog.openError(shell, "Error",
- "Cannot prepare launch configuration",
- new Status(IStatus.ERROR, SlcIdeUiPlugin.ID,
- e.getMessage(), e));
- return;
- }
- }
-
- /**
- * Actually modifies the launch configuration in order to reflect the
- * current state read from the properties file and the launch configuration
- * UI.
- */
- protected static void updateLaunchConfiguration(
- ILaunchConfigurationWorkingCopy wc,
- Map<String, Integer> bundlesToStart,
- Map<String, String> systemPropertiesToAppend, String dataDir,
- Boolean isEclipse) throws CoreException {
- // Convert bundle lists
- final String targetBundles;
- final String wkSpaceBundles;
- if (wc.getAttribute(ATTR_SYNC_BUNDLES, true)) {
- StringBuffer tBuf = new StringBuffer();
- for (IPluginModelBase model : PluginRegistry.getExternalModels()) {
- tBuf.append(model.getBundleDescription().getSymbolicName());
- tBuf.append(',');
- }
- targetBundles = tBuf.toString();
- StringBuffer wBuf = new StringBuffer();
- models: for (IPluginModelBase model : PluginRegistry
- .getWorkspaceModels()) {
- if (model.getBundleDescription() == null) {
- System.err.println("No bundle description for " + model);
- continue models;
- }
- wBuf.append(model.getBundleDescription().getSymbolicName());
- wBuf.append(',');
- }
- wkSpaceBundles = wBuf.toString();
- } else {
- targetBundles = wc.getAttribute(targetBundlesAttr(isEclipse), "");
- wkSpaceBundles = wc.getAttribute(workspaceBundlesAttr(isEclipse),
- "");
- }
- wc.setAttribute(targetBundlesAttr(isEclipse),
- convertBundleList(bundlesToStart, targetBundles));
-
- wc.setAttribute(workspaceBundlesAttr(isEclipse),
- convertBundleList(bundlesToStart, wkSpaceBundles));
-
- // Update other default information
- wc.setAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, false);
-
- wc.setAttribute(IPDELauncherConstants.USE_CUSTOM_FEATURES, false);
- if (!isEclipse)
- wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, true);
-
- // VM arguments (system properties)
- String defaultVmArgs = wc.getAttribute(
- OsgiLauncherConstants.ATTR_DEFAULT_VM_ARGS, "");
- StringBuffer vmArgs = new StringBuffer(defaultVmArgs);
-
- // Data dir system property
- if (dataDir != null) {
- addSysProperty(vmArgs, OsgiLauncherConstants.ARGEO_OSGI_DATA_DIR,
- dataDir);
- if (isEclipse) {
- wc.setAttribute(IPDELauncherConstants.LOCATION, dataDir);
- }
- }
-
- // Add locations of JVMs
- if (wc.getAttribute(ATTR_ADD_JVM_PATHS, false))
- addVms(vmArgs);
-
- // Add other system properties
- for (String key : systemPropertiesToAppend.keySet())
- addSysProperty(vmArgs, key, systemPropertiesToAppend.get(key));
-
- vmArgs.append(" ").append(wc.getAttribute(ATTR_ADDITIONAL_VM_ARGS, ""));
-
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- vmArgs.toString());
-
- // Program arguments
- StringBuffer progArgs = new StringBuffer("");
- if (dataDir != null) {
- progArgs.append("-data ");
- progArgs.append(surroundSpaces(dataDir));
-
- if (wc.getAttribute(ATTR_CLEAR_DATA_DIRECTORY, false)) {
- File dataDirFile = new File(dataDir);
- deleteDir(dataDirFile);
- dataDirFile.mkdirs();
- }
- }
- String additionalProgramArgs = wc.getAttribute(
- OsgiLauncherConstants.ATTR_ADDITIONAL_PROGRAM_ARGS, "");
- progArgs.append(' ').append(additionalProgramArgs);
- wc.setAttribute(
- IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
- progArgs.toString());
- }
-
- /** The launch configuration attribute to use for target bundles */
- protected static String targetBundlesAttr(Boolean isEclipse) {
- return isEclipse ? IPDELauncherConstants.SELECTED_TARGET_PLUGINS
- : IPDELauncherConstants.TARGET_BUNDLES;
- }
-
- /** The launch configuration attribute to use for workspace bundles */
- protected static String workspaceBundlesAttr(Boolean isEclipse) {
- return isEclipse ? IPDELauncherConstants.SELECTED_WORKSPACE_PLUGINS
- : IPDELauncherConstants.WORKSPACE_BUNDLES;
- }
-
- /**
- * Interprets special properties and register the others as system
- * properties to append.
- *
- * @return the application id defined by
- * {@link OsgiLauncherConstants#ECLIPSE_APPLICATION}, or null if not
- * found
- */
- protected static String interpretProperties(Properties properties,
- Map<String, Integer> bundlesToStart,
- Map<String, String> systemPropertiesToAppend) {
- computeBundlesToStart(bundlesToStart, properties, null);
-
- String applicationId = null;
- propKeys: for (Object keyObj : properties.keySet()) {
- String key = keyObj.toString();
- if (OsgiLauncherConstants.ARGEO_OSGI_START.equals(key))
- continue propKeys;
- if (key.startsWith(OsgiLauncherConstants.ARGEO_OSGI_START + "."))
- continue propKeys;
- else if (OsgiLauncherConstants.ARGEO_OSGI_BUNDLES.equals(key))
- continue propKeys;
- else if (OsgiLauncherConstants.ARGEO_OSGI_LOCATIONS.equals(key))
- continue propKeys;
- else if (OsgiLauncherConstants.OSGI_BUNDLES.equals(key))
- continue propKeys;
- else if (OsgiLauncherConstants.ECLIPSE_APPLICATION.equals(key))
- applicationId = properties.getProperty(key);
- else
- systemPropertiesToAppend.put(key, properties.getProperty(key));
- }
- return applicationId;
- }
-
- /** Adds a regular system property. */
- protected static void addSysProperty(StringBuffer vmArgs, String key,
- String value) {
- surroundSpaces(value);
- String str = "-D" + key + "=" + value;
- vmArgs.append(' ').append(str);
- }
-
- /** Adds JVMS registered in the workspace as special system properties. */
- protected static void addVms(StringBuffer vmArgs) {
- addVmSysProperty(vmArgs, "default", JavaRuntime.getDefaultVMInstall());
- IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
- for (IVMInstallType vmType : vmTypes) {
- for (IVMInstall vmInstall : vmType.getVMInstalls()) {
- // properties based on name
- addVmSysProperty(vmArgs, vmInstall.getName(), vmInstall);
- if (vmInstall instanceof IVMInstall2) {
- // properties based on version
- IVMInstall2 vmInstall2 = (IVMInstall2) vmInstall;
- String version = vmInstall2.getJavaVersion();
- addVmSysProperty(vmArgs, version, vmInstall);
-
- List<String> tokens = new ArrayList<String>();
- StringTokenizer st = new StringTokenizer(version, ".");
- while (st.hasMoreTokens())
- tokens.add(st.nextToken());
- if (tokens.size() >= 2)
- addVmSysProperty(vmArgs,
- tokens.get(0) + "." + tokens.get(1), vmInstall);
- }
- }
- }
-
- }
-
- /** Adds a special system property pointing to one of the registered JVMs. */
- protected static void addVmSysProperty(StringBuffer vmArgs, String suffix,
- IVMInstall vmInstall) {
- addSysProperty(vmArgs, OsgiLauncherConstants.VMS_PROPERTY_PREFIX + "."
- + suffix, vmInstall.getInstallLocation().getPath());
- }
-
- /** Surround the string with quotes if it contains spaces. */
- protected static String surroundSpaces(String str) {
- if (str.indexOf(' ') >= 0)
- return '\"' + str + '\"';
- else
- return str;
- }
-
- /**
- * Reformat the bundle list in order to reflect which bundles have to be
- * started.
- */
- protected static String convertBundleList(
- Map<String, Integer> bundlesToStart, String original) {
- StringTokenizer stComa = new StringTokenizer(original, ",");
- // sort by bundle symbolic name
- Set<String> bundleIds = new TreeSet<String>();
- bundles: while (stComa.hasMoreTokens()) {
-
- String bundleId = stComa.nextToken();
- if (bundleId.indexOf('*') >= 0)
- throw new RuntimeException(
- "Bundle id "
- + bundleId
- + " not properly formatted, clean your workspace projects");
-
- int indexAt = bundleId.indexOf('@');
- if (indexAt >= 0) {
- bundleId = bundleId.substring(0, indexAt);
- }
-
- // We can now rely on bundleId value
-
- if (bundleId.endsWith(".source")) {
- // debug("Skip source bundle " + bundleId);
- continue bundles;
- } else if (bundleId
- .equals("org.eclipse.equinox.simpleconfigurator")) {
- // IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR
- // skip simple configurator in order to avoid side-effects
- continue bundles;
- }
- bundleIds.add(bundleId);
- }
-
- StringBuffer bufBundles = new StringBuffer(1024);
- boolean first = true;
- for (String bundleId : bundleIds) {
- if (first)
- first = false;
- else
- bufBundles.append(',');
- boolean modified = false;
- if (bundlesToStart.containsKey(bundleId)) {
- Integer startLevel = bundlesToStart.get(bundleId);
- String startLevelStr = startLevel != null ? startLevel
- .toString() : "default";
- bufBundles.append(bundleId).append('@').append(startLevelStr)
- .append(":true");
- modified = true;
- debug("Will start " + bundleId + " at level " + startLevelStr);
- }
-
- if (!modified)
- bufBundles.append(bundleId);
-
- }
- String output = bufBundles.toString();
- return output;
- }
-
- // UTILITIES
- /** Recursively deletes a directory tree. */
- private static void deleteDir(File dir) {
- File[] files = dir.listFiles();
- for (File file : files) {
- if (file.isDirectory())
- deleteDir(file);
- else
- file.delete();
- }
- dir.delete();
- }
-
- /** Loads a properties file. */
- private static Properties readProperties(IFile file) throws CoreException {
- Properties props = new Properties();
-
- InputStream in = null;
- try {
- in = file.getContents();
- props.load(in);
- } catch (Exception e) {
- throw new CoreException(new Status(IStatus.ERROR,
- SlcIdeUiPlugin.ID, "Cannot read properties file", e));
- } finally {
- if (in != null)
- try {
- in.close();
- } catch (IOException e) {
- // silent
- }
- }
- return props;
- }
-
- /** Determines the start levels for the bundles */
- private static void computeBundlesToStart(
- Map<String, Integer> bundlesToStart, Properties properties,
- Integer defaultStartLevel) {
-
- // default (and previously, only behaviour)
- appendBundlesToStart(bundlesToStart, defaultStartLevel,
- properties.getProperty(OsgiLauncherConstants.ARGEO_OSGI_START,
- ""));
-
- // list argeo.osgi.start.* system properties
- Iterator<Object> keys = properties.keySet().iterator();
- final String prefix = OsgiLauncherConstants.ARGEO_OSGI_START + ".";
- while (keys.hasNext()) {
- String key = (String) keys.next();
- if (key.startsWith(prefix)) {
- Integer startLevel;
- String suffix = key.substring(prefix.length());
- String[] tokens = suffix.split("\\.");
- if (tokens.length > 0 && !tokens[0].trim().equals(""))
- try {
- // first token is start level
- startLevel = new Integer(tokens[0]);
- } catch (NumberFormatException e) {
- startLevel = defaultStartLevel;
- }
- else
- startLevel = defaultStartLevel;
-
- // append bundle names
- String bundleNames = properties.getProperty(key);
- appendBundlesToStart(bundlesToStart, startLevel, bundleNames);
- }
- }
- }
-
- /** Append a comma-separated list of bundles to the start levels. */
- private static void appendBundlesToStart(
- Map<String, Integer> bundlesToStart, Integer startLevel, String str) {
- if (str == null || str.trim().equals(""))
- return;
-
- String[] bundleNames = str.split(",");
- for (int i = 0; i < bundleNames.length; i++) {
- if (bundleNames[i] != null && !bundleNames[i].trim().equals(""))
- bundlesToStart.put(bundleNames[i], startLevel);
- }
- }
-
- /*
- * HACKED UTILITIES
- */
- // Hacked from
- // org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper.getWorkingDirectory(ILaunchConfiguration)
- private static File getWorkingDirectory(ILaunchConfiguration configuration)
- throws CoreException {
- String working;
- try {
- working = configuration.getAttribute(
- IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
- new File(".").getCanonicalPath()); //$NON-NLS-1$
- } catch (IOException e) {
- working = "${workspace_loc}/../"; //$NON-NLS-1$
- }
- File dir;
- try {
- dir = new File(getSubstitutedString(working));
- } catch (Exception e) {
- // the directory was most probably deleted
- IFile propertiesFile = (IFile) configuration.getMappedResources()[0];
- working = findWorkingDirectory(propertiesFile);
- dir = new File(getSubstitutedString(working));
- }
- if (!dir.exists())
- dir.mkdirs();
- return dir;
- }
-
- // Hacked from
- // org.eclipse.pde.internal.ui.launcher.LaunchArgumentsHelper.getSubstitutedString(String)
- private static String getSubstitutedString(String text)
- throws CoreException {
- if (text == null)
- return ""; //$NON-NLS-1$
- IStringVariableManager mgr = VariablesPlugin.getDefault()
- .getStringVariableManager();
- return mgr.performStringSubstitution(text);
- }
-
- /**
- * Not used anymore, but kept because this routine may be useful in the
- * future.
- */
- protected void addSelectedProjects(StringBuffer name, ISelection selection,
- List<String> bundlesToStart) {
- Assert.isNotNull(selection);
-
- Map<String, IPluginModelBase> bundleProjects = new HashMap<String, IPluginModelBase>();
- for (IPluginModelBase modelBase : PluginRegistry.getWorkspaceModels()) {
- IProject bundleProject = modelBase.getUnderlyingResource()
- .getProject();
- bundleProjects.put(bundleProject.getName(), modelBase);
- }
-
- IStructuredSelection sSelection = (IStructuredSelection) selection;
- for (Iterator<?> it = sSelection.iterator(); it.hasNext();) {
- Object obj = it.next();
- if (obj instanceof IProject) {
- IProject project = (IProject) obj;
- if (bundleProjects.containsKey(project.getName())) {
- IPluginModelBase modelBase = bundleProjects.get(project
- .getName());
-
- BundleDescription bundleDescription = null;
- if (modelBase.isFragmentModel()) {
- BundleDescription[] hosts = modelBase
- .getBundleDescription().getHost().getHosts();
- for (BundleDescription bd : hosts) {
- if (debug)
- System.out.println("Host for "
- + modelBase.getBundleDescription()
- .getSymbolicName() + ": "
- + bd.getSymbolicName());
- bundleDescription = bd;
- }
- } else {
- bundleDescription = modelBase.getBundleDescription();
- }
-
- if (bundleDescription != null) {
- String symbolicName = bundleDescription
- .getSymbolicName();
- String bundleName = bundleDescription.getName();
-
- bundlesToStart.add(symbolicName);
-
- if (name.length() > 0)
- name.append(" ");
- if (bundleName != null)
- name.append(bundleName);
- else
- name.append(symbolicName);
- }
- }
- }
- }
- }
-
- static void debug(Object obj) {
- if (debug)
- System.out.println(obj);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.ide.ui.launch.osgi;
-
-import org.argeo.slc.ide.ui.SlcIdeUiPlugin;
-
-/** Constants used by OSGi launch. */
-public interface OsgiLauncherConstants {
-
- public final static String OSGI_BUNDLES = "osgi.bundles";
- public final static String ECLIPSE_APPLICATION = "eclipse.application";
-
- public final static String ARGEO_OSGI_START = "argeo.osgi.start";
- public final static String ARGEO_OSGI_BUNDLES = "argeo.osgi.bundles";
- public final static String ARGEO_OSGI_LOCATIONS = "argeo.osgi.locations";
- public final static String ARGEO_OSGI_DATA_DIR = "argeo.osgi.data.dir";
- public final static String VMS_PROPERTY_PREFIX = "slc.launch.vm";
-
- // Configuration
- public final static String ATTR_SYNC_BUNDLES = SlcIdeUiPlugin.ID
- + ".syncBundles";
- public final static String ATTR_CLEAR_DATA_DIRECTORY = SlcIdeUiPlugin.ID
- + ".clearDataDirectory";
-
- public final static String ATTR_DEFAULT_VM_ARGS = SlcIdeUiPlugin.ID
- + ".defaultVmArgs";
- public final static String ATTR_ADDITIONAL_PROGRAM_ARGS = SlcIdeUiPlugin.ID
- + ".additionalProgramArgs";
- public final static String ATTR_ADDITIONAL_VM_ARGS = SlcIdeUiPlugin.ID
- + ".additionalVmArgs";
- public final static String ATTR_ADD_JVM_PATHS = SlcIdeUiPlugin.ID
- + ".addJvmPaths";
- public final static String ATTR_DATADIR = SlcIdeUiPlugin.ID + ".dataDir";
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.6"?>
-
-<target name="Managed Target">
-<locations>
-<location path="${workspace_loc}/targets/managed" type="Directory"/>
-</locations>
-</target>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.studio.ui</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<https://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<https://www.gnu.org/licenses/why-not-lgpl.html>.
+++ /dev/null
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Argeo IDE
-Bundle-SymbolicName: org.argeo.slc.studio.ui;singleton:=true
-Bundle-Version: 2.1.0.qualifier
-Bundle-Vendor: Argeo.org
-Require-Bundle: org.eclipse.ui,
- org.eclipse.osgi,
- org.eclipse.core.runtime,
- org.eclipse.jdt.ui,
- org.eclipse.ui.console,
- org.eclipse.ui.navigator.resources
-Bundle-RequiredExecutionEnvironment: JavaSE-11
-Automatic-Module-Name: org.argeo.slc.studio.ui
-Export-Package: org.argeo.slc.studio.ui
+++ /dev/null
-bin.includes = META-INF/,\
- plugin_customization.ini,\
- plugin.xml,\
- icons/,\
- splash.bmp,\
- .,\
- LICENSE,\
- helpData.xml,\
- img/
-source.. = src/
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<extensions>
- <tocOrder>
- <toc id="/org.eclipse.platform.doc.user/toc.xml"/>
- <toc id="/org.eclipse.jdt.doc.user/toc.xml"/>
- <toc id="/org.eclipse.platform.doc.isv/toc.xml"/>
- <toc id="/org.eclipse.jdt.doc.isv/toc.xml"/>
- <toc id="/org.eclipse.pde.doc.user/toc.xml"/>
- </tocOrder>
-</extensions>
+++ /dev/null
-/* XPM */
-static char * argeo_icon_100104_256_xpm[] = {
-"256 256 220 2",
-" c None",
-". c #FE8F00",
-"+ c #FD8F01",
-"@ c #FD8E01",
-"# c #FD8F00",
-"$ c #FC8E01",
-"% c #FA8D02",
-"& c #F78C03",
-"* c #F68C04",
-"= c #F58C04",
-"- c #F48B05",
-"; c #EE8907",
-"> c #DC820F",
-", c #C0781B",
-"' c #F98D02",
-") c #EA8809",
-"! c #D47F12",
-"~ c #BC761D",
-"{ c #A16C28",
-"] c #E6860A",
-"^ c #B37321",
-"/ c #ED8908",
-"( c #CD7D15",
-"_ c #C67A18",
-": c #C2781A",
-"< c #BD771C",
-"[ c #B8751E",
-"} c #AD7123",
-"| c #A96F25",
-"1 c #A46D27",
-"2 c #C97B17",
-"3 c #EB8808",
-"4 c #7A5E39",
-"5 c #F88D02",
-"6 c #D68012",
-"7 c #AF7122",
-"8 c #896333",
-"9 c #625544",
-"0 c #4D4D4D",
-"a c #5A5247",
-"b c #7C5F38",
-"c c #9E6B2A",
-"d c #BF771B",
-"e c #E1840D",
-"f c #BE771C",
-"g c #97692D",
-"h c #715A3D",
-"i c #504E4B",
-"j c #55504A",
-"k c #94672E",
-"l c #A26D28",
-"m c #FB8E01",
-"n c #826136",
-"o c #4F4E4C",
-"p c #7D5F38",
-"q c #CA7C17",
-"r c #F88D03",
-"s c #705A3E",
-"t c #E2850C",
-"u c #5D5346",
-"v c #675742",
-"w c #B27321",
-"x c #D17E14",
-"y c #F68C03",
-"z c #BB761D",
-"A c #765C3B",
-"B c #575149",
-"C c #A06C29",
-"D c #95682E",
-"E c #DF830E",
-"F c #92672F",
-"G c #555049",
-"H c #6C5840",
-"I c #ED8907",
-"J c #4E4E4C",
-"K c #524F4B",
-"L c #9A6A2B",
-"M c #A76F26",
-"N c #806037",
-"O c #605445",
-"P c #5C5346",
-"Q c #CB7C16",
-"R c #D27E13",
-"S c #99692C",
-"T c #F28A05",
-"U c #585148",
-"V c #EF8907",
-"W c #846135",
-"X c #8C6532",
-"Y c #A56E27",
-"Z c #D98110",
-"` c #93672F",
-" . c #F48B04",
-".. c #BA761E",
-"+. c #9D6B2A",
-"@. c #AB7024",
-"#. c #FB8E02",
-"$. c #A76E26",
-"%. c #5C5247",
-"&. c #755C3B",
-"*. c #AE7123",
-"=. c #9B6A2B",
-"-. c #5E5345",
-";. c #B47420",
-">. c #DB820F",
-",. c #514F4B",
-"'. c #6A5840",
-"). c #DD830E",
-"!. c #5F5445",
-"~. c #EA8709",
-"{. c #4E4D4D",
-"]. c #6D593F",
-"^. c #795E3A",
-"/. c #7E5F38",
-"(. c #E7860A",
-"_. c #534F4A",
-":. c #896433",
-"<. c #E5860B",
-"[. c #E4850B",
-"}. c #856235",
-"|. c #575148",
-"1. c #D37F13",
-"2. c #816036",
-"3. c #565049",
-"4. c #A86F25",
-"5. c #D88111",
-"6. c #8D6531",
-"7. c #AA7025",
-"8. c #91662F",
-"9. c #D68011",
-"0. c #CF7D15",
-"a. c #7B5E39",
-"b. c #645643",
-"c. c #B47320",
-"d. c #635543",
-"e. c #504E4C",
-"f. c #E8870A",
-"g. c #906630",
-"h. c #836135",
-"i. c #A36D28",
-"j. c #775D3B",
-"k. c #6C593F",
-"l. c #635544",
-"m. c #F18A06",
-"n. c #A66E26",
-"o. c #E98709",
-"p. c #7C5E39",
-"q. c #E0840D",
-"r. c #8E6531",
-"s. c #D58012",
-"t. c #8A6432",
-"u. c #6B5840",
-"v. c #8F6630",
-"w. c #B17222",
-"x. c #615544",
-"y. c #F08A06",
-"z. c #A46E27",
-"A. c #595248",
-"B. c #E88709",
-"C. c #54504A",
-"D. c #B07222",
-"E. c #CE7D15",
-"F. c #C77B18",
-"G. c #755C3C",
-"H. c #695841",
-"I. c #EF8A06",
-"J. c #595148",
-"K. c #8B6432",
-"L. c #CC7C16",
-"M. c #D27F13",
-"N. c #7F6037",
-"O. c #735B3C",
-"P. c #685741",
-"Q. c #C2791A",
-"R. c #96682D",
-"S. c #534F4B",
-"T. c #D07E14",
-"U. c #C47A19",
-"V. c #725B3D",
-"W. c #B9751E",
-"X. c #AC7024",
-"Y. c #94682E",
-"Z. c #886333",
-"`. c #C3791A",
-" + c #B7751F",
-".+ c #665642",
-"++ c #5E5346",
-"@+ c #9F6C29",
-"#+ c #DA8210",
-"$+ c #876234",
-"%+ c #6F5A3E",
-"&+ c #B6741F",
-"*+ c #655642",
-"=+ c #F38B05",
-"-+ c #EC8808",
-";+ c #E3850C",
-">+ c #6E593F",
-",+ c #F28B05",
-"'+ c #9C6B2B",
-")+ c #E2840C",
-"!+ c #D78111",
-"~+ c #785D3A",
-"{+ c #DA8110",
-"]+ c #F78D03",
-"^+ c #FA8E02",
-"/+ c #B8751F",
-"(+ c #C67A19",
-"_+ c #C57A19",
-":+ c #B7741F",
-"<+ c #A86F26",
-"[+ c #CF7E14",
-"}+ c #9A6A2C",
-"|+ c #795D3A",
-"1+ c #C1781B",
-"2+ c #5B5247",
-"3+ c #695741",
-"4+ c #97682D",
-"5+ c #98692C",
-"6+ c #B57420",
-"7+ c #866234",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . & ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . * ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ; ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . > ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . , ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ' ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ) ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ! ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ~ ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ { ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ] ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ^ ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / ( _ : < [ ^ } | 1 | 2 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 4 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 6 7 8 9 0 0 0 0 0 0 0 0 0 0 0 0 0 a b c d e $ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . > ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / f g h i 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 j k e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . l ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m _ n o 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 p q # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . r s ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . t c u 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 v w * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . y z A 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 B C 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E F G 0 0 0 0 0 0 0 0 0 0 0 0 0 H E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 G ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I F J 0 0 0 0 0 0 0 0 0 0 0 K w . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . & M G 0 0 0 0 0 0 0 0 0 0 0 N ; . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ; G ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # < O 0 0 0 0 0 0 0 0 0 P Q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . R s 0 0 0 0 0 0 0 0 0 S m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T U ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V W 0 0 0 0 0 0 0 0 0 X @ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Y ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Z O 0 0 0 0 0 0 0 0 ` # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .a ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..K 0 0 0 0 0 0 +.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #.D 0 0 0 0 0 0 0 $.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . y %. ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / &.0 0 0 0 0 0 *.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . =.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 -.0 0 0 0 0 0 ;.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . >.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Q ,.0 0 0 0 0 0 ~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . '.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ).G 0 0 0 0 0 ).. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 !.0 0 0 0 0 r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ~.{. ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .].0 0 0 0 0 ( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ^.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m /.0 0 0 0 0 (.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F 0 0 0 0 0 .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ._. ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @.0 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . :.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <.i 0 0 0 0 [.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . q 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . }.0 0 0 0 0 V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m |.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.0 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # s 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . } 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . < 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Z 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . r O 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 3.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . _ 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m G 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % |.0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . /.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Q 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m a 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #.j 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . p 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . g 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a.0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ! 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . b.0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . r c.d.0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m e.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T M %.0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . f.0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 =.G 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e g.i 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.h.{.0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i.0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # q j.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m f k.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . & w l.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . h 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m.n.a 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . j.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . o.L j 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . p.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . q.r.e.0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s.n {.0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . }.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # 2 A 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . t.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #.< u.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . y w.x.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . k 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . y.z.A.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . S 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B.S C.0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . c 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E 6.e.0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ! N 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # F.G.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #.z H.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . * D.O 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . G.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I.i.J.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (.g _.0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ).K.o 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M.N.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ~.0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # _ O.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . % ..P.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . k Q.# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = *.O 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V l U 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ] R.S.0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . > :.o 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T./.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ U.V.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ' W.v 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .X.-.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ; C |.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <.Y.K 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . >.Z.J 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.b 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ `.s 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ' +.+0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - @.++0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . / @+B 0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [.` K 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #+$+J 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ( a.0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ : %+0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 &+*+0 0 0 0 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . =+| u 0 0 0 0 0 0 0 0 0 . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -+c 3.0 0 0 0 0 0 0 0 0 . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ;+F ,.0 0 0 0 0 0 0 0 . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Z }.J 0 0 0 0 0 0 0 0 . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . L.^.0 0 0 0 0 0 0 0 0 . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ , >+0 0 0 0 0 0 0 0 0 . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . r ;.b.0 0 0 0 0 0 0 0 0 . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ,+4.%.0 0 0 0 0 0 0 0 0 . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 '+G 0 0 0 0 0 0 0 0 0 . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . )+g.i 0 0 0 0 0 0 0 0 . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . !+W {.0 0 0 0 0 0 0 0 . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Q ~+0 0 0 0 0 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m d ].0 0 0 0 0 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . z d.0 0 0 0 0 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . W.0 0 0 0 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # ^.0 0 0 0 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [.S.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m j. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . & >+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . & h. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X.0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . {+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I.B 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . >. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . R.0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . f. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . e o 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ( 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . y v 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . g.0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . , 0 0 0 0 0 ",
-" @ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (.B 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m O.0 0 0 0 ",
-" ' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . { 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T.J 0 0 0 0 ",
-" ]+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . f.++0 0 0 0 ",
-" % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . y.v 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . & V.0 0 0 0 0 ",
-" & . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m N 0 0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . g.0 0 0 0 0 ",
-" r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . { 0 0 0 0 0 ",
-" T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ^ 0 0 0 0 0 ",
-" ' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ^ {.0 0 0 0 ",
-" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . n.0 0 0 0 0 0 ",
-" ).. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # S 0 0 0 0 0 0 ",
-" -+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m X 0 0 0 0 0 0 ",
-" ^+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . r 2.0 0 0 0 0 0 ",
-" !+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - j.0 0 0 0 0 0 ",
-" e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . o.>+0 0 0 0 0 0 ",
-" ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ( a 0 0 0 0 0 ",
-" V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ n.J 0 0 0 0 0 ",
-" = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m.N.0 0 0 0 0 0 ",
-" g % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Z l.0 0 0 0 0 0 ",
-" c # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . &+K 0 0 0 0 0 0 ",
-" @.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . * r.0 0 0 0 0 0 0 ",
-" /+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x b.0 0 0 0 0 0 ",
-" (+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . * R.{.0 0 0 0 0 0 ",
-" _+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T.d.0 0 0 0 0 0 0 ",
-" :+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . * R.{.0 0 0 0 0 0 ",
-" <+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [+d.0 0 0 0 0 0 0 ",
-" }+# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .D {.0 0 0 0 0 0 ",
-" 6.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ [ P 0 0 0 0 0 0 0 ",
-" n & . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M.>+0 0 0 0 0 0 0 ",
-" |+=+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (.$+0 0 0 0 0 0 0 0 ",
-" P.#+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = C K 0 0 0 0 0 0 0 ",
-" ,.7 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ z ++0 0 0 0 0 0 0 ",
-" 0 N y.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.s 0 0 0 0 0 0 0 0 ",
-" 0 !.x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [+j.0 0 0 0 0 0 0 0 ",
-" J 1 $ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [+j.0 0 0 0 0 0 0 0 ",
-" 0 j.o.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [+j.0 0 0 0 0 0 0 0 ",
-" 0 C.$.r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [+j.0 0 0 0 0 0 0 0 0 ",
-" 0 9 1+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [+j.0 0 0 0 0 0 0 0 0 ",
-" 0 0 A #+. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ' ~ h 0 0 0 0 0 0 0 0 0 ",
-" 0 {.v./ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . o.C 2+0 0 0 0 0 0 0 0 0 ",
-" 0 0 G | = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.W o 0 0 0 0 0 0 0 0 0 ",
-" 0 0 B L <.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = ^ 3+0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 J n 0.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # 9.4+3.0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 '.:+& . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @ ! S O 0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 J.c > . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ T.4+++0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 9 5+0.#.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . m ( ` %.0 0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 0 |.K.: .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . y T.$.p G 0 0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 0 0 ,./.} E.y.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ; U.=.h e.0 0 0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 0 0 0 0 O n 1 _ f.. . . . . . . . . . . . . . . . . . . . . . . . . . . m.Z 1+| r..+0 0 0 0 0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 0 0 0 0 0 0 U ~+t.5+n.c.1+0.).3 5 . # ' .V ~.<.q.>.6 L.6+c 7+>+B 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 i 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ",
-" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
+++ /dev/null
-log4j.rootLogger=WARN, development
-
-log4j.logger.org.argeo=DEBUG
-
-## Appenders
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c - [%t]%n
-
-log4j.appender.development=org.apache.log4j.ConsoleAppender
-log4j.appender.development.layout=org.apache.log4j.PatternLayout
-log4j.appender.development.layout.ConversionPattern=%d{ABSOLUTE} %m (%F:%L) [%t] %p %n
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<?pde version="3.5"?>
-
-<product name="Argeo Studio" uid="org.argeo.slc.studio" id="org.argeo.slc.studio.ui.product" application="org.eclipse.ui.ide.workbench" version="2.1.17.qualifier" useFeatures="true" includeLaunchers="true">
-
- <aboutInfo>
- <image path="/org.argeo.slc.studio.ui/img/argeo-ITSE.png"/>
- <text>
- Argeo Studio - IDE and management tool focused on Argeo-based application development and deployment
- </text>
- </aboutInfo>
-
- <configIni use="default">
- </configIni>
-
- <launcherArgs>
- <vmArgs>-Xms256m -Xmx2048m
- </vmArgs>
- <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
- </vmArgsMac>
- </launcherArgs>
-
- <windowImages i16="/org.argeo.slc.studio.ui/icons/argeo-icon-16.png" i32="/org.argeo.slc.studio.ui/icons/argeo-icon-32.png" i48="/org.argeo.slc.studio.ui/icons/argeo-icon-48.png" i64="/org.argeo.slc.studio.ui/icons/argeo-icon-64.png" i128="/org.argeo.slc.studio.ui/icons/argeo-icon-128.png" i256="/org.argeo.slc.studio.ui/icons/argeo-icon-256.png"/>
-
- <splash
- location="org.argeo.slc.studio.ui"
- startupProgressRect="0,295,600,5"
- startupMessageRect="5,270,600,20"
- startupForegroundColor="00294b" />
- <launcher name="argeo-studio">
- <linux icon="/org.argeo.slc.studio.ui/icons/argeo-icon-256.xpm"/>
- <win useIco="false">
- <bmp/>
- </win>
- </launcher>
-
- <vm>
- <linux include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11</linux>
- <macos include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11</macos>
- <windows include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11</windows>
- </vm>
-
- <license>
- <url>https://www.gnu.org/licenses/gpl-3.0.txt</url>
- <text>
- Argeo Studio - IDE and management tool focused on Argeo-based application development and deployment
-Copyright (C) 2007-2020 Argeo GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <https://www.gnu.org/licenses/>.
- </text>
- </license>
-
- <plugins>
- </plugins>
-
- <features>
- <feature id="org.argeo.slc.studio" installMode="root"/>
- <feature id="org.eclipse.pde" installMode="root"/>
- <feature id="org.eclipse.jdt" installMode="root"/>
- <feature id="org.argeo.slc.ide.osgi" installMode="root"/>
- <feature id="org.eclipse.e4.rcp" installMode="root"/>
- <feature id="org.eclipse.platform" installMode="root"/>
- <feature id="org.eclipse.emf.common" installMode="root"/>
- <feature id="org.eclipse.emf.ecore" installMode="root"/>
- <feature id="org.eclipse.ecf.core.feature" installMode="root"/>
- <feature id="org.eclipse.ecf.filetransfer.feature" installMode="root"/>
- <feature id="org.eclipse.egit" installMode="root"/>
- <feature id="org.eclipse.jgit" installMode="root"/>
- <feature id="org.eclipse.jgit.http.apache" installMode="root"/>
- <feature id="org.eclipse.jgit.ssh.apache" installMode="root"/>
- <feature id="org.eclipse.jgit.ssh.jsch" installMode="root"/>
- <feature id="org.eclipse.equinox.p2.core.feature" installMode="root"/>
- <feature id="org.eclipse.equinox.p2.rcp.feature" installMode="root"/>
- <feature id="org.eclipse.equinox.p2.user.ui" installMode="root"/>
- <feature id="org.eclipse.ecf.core.ssl.feature" installMode="root"/>
- <feature id="org.eclipse.ecf.filetransfer.httpclient45.feature" installMode="root"/>
- <feature id="org.eclipse.ecf.filetransfer.ssl.feature" installMode="root"/>
- </features>
-
- <configurations>
- <plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
- <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
- <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
- <plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
- <plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
- <property name="osgi.requiredJavaVersion" value="11" />
- </configurations>
-
- <preferencesInfo>
- <targetfile overwrite="false"/>
- </preferencesInfo>
-
- <cssInfo>
- </cssInfo>
-
-</product>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
- <extension
- id="product"
- point="org.eclipse.core.runtime.products">
- <product
- application="org.eclipse.ui.ide.workbench"
- name="Argeo Studio">
- <property
- name="windowImages"
- value="icons/argeo-icon-16.png,icons/argeo-icon-32.png,icons/argeo-icon-48.png,icons/argeo-icon-64.png,icons/argeo-icon-128.png,icons/argeo-icon-256.png">
- </property>
- <property
- name="aboutText"
- value="Argeo Studio - IDE and management tool focused on Argeo-based application development and deployment">
- </property>
- <property
- name="aboutImage"
- value="img/argeo-ITSE.png">
- </property>
- <property
- name="appName"
- value="Argeo Studio">
- </property>
- <property
- name="applicationXMI"
- value="org.eclipse.platform/LegacyIDE.e4xmi">
- </property>
- <property
- name="cssTheme"
- value="org.eclipse.e4.ui.css.theme.e4_default">
- </property>
- <property
- name="applicationCSSResources"
- value="platform:/plugin/org.eclipse.ui.themes/images/">
- </property>
- <property
- name="startupProgressRect"
- value="0,295,600,5">
- </property>
- <property
- name="startupForegroundColor"
- value="00294b">
- </property>
- <property
- name="startupMessageRect"
- value="5,270,600,20">
- </property>
- <property
- name="preferenceCustomization"
- value="plugin_customization.ini">
- </property>
- </product>
- </extension>
- <extension
- point="org.eclipse.ui.perspectives">
- <perspective
- class="org.argeo.slc.studio.ui.ArgeoStudioPerspective"
- fixed="false"
- icon="icons/argeo-icon-16.png"
- id="org.argeo.slc.studio.ui.perspective"
- name="Argeo Studio">
- </perspective>
- </extension>
- <extension
- point="org.eclipse.ui.perspectiveExtensions">
- <perspectiveExtension
- targetID="org.argeo.slc.studio.ui.perspective">
- <actionSet
- id="org.eclipse.debug.ui.breakpointActionSet">
- </actionSet>
- <actionSet
- id="org.eclipse.debug.ui.launchActionSet">
- </actionSet>
- <showInPart
- id="org.eclipse.jdt.ui.PackageExplorer">
- </showInPart>
- <showInPart
- id="org.eclipse.ui.navigator.ProjectExplorer">
- </showInPart>
- <showInPart
- id="org.eclipse.team.ui.GenericHistoryView">
- </showInPart>
- <perspectiveShortcut
- id="org.eclipse.ui.resourcePerspective">
- </perspectiveShortcut>
- <perspectiveShortcut
- id="org.eclipse.jdt.ui.JavaPerspective">
- </perspectiveShortcut>
- <perspectiveShortcut
- id="org.eclipse.debug.ui.DebugPerspective">
- </perspectiveShortcut>
- <viewShortcut
- id="org.eclipse.ui.console.ConsoleView">
- </viewShortcut>
- <viewShortcut
- id="org.eclipse.pde.ui.PluginsView">
- </viewShortcut>
- <viewShortcut
- id="org.eclipse.ui.views.ProblemView">
- </viewShortcut>
- <viewShortcut
- id="org.eclipse.ui.views.TaskList">
- </viewShortcut>
- <viewShortcut
- id="org.eclipse.ui.views.ContentOutline">
- </viewShortcut>
- <newWizardShortcut
- id="org.eclipse.pde.ui.NewProductConfigurationWizard">
- </newWizardShortcut>
- <newWizardShortcut
- id="org.eclipse.pde.ui.NewProfileWizard">
- </newWizardShortcut>
- <newWizardShortcut
- id="org.eclipse.jdt.ui.wizards.NewPackageCreationWizard">
- </newWizardShortcut>
- <newWizardShortcut
- id="org.eclipse.jdt.ui.wizards.NewClassCreationWizard">
- </newWizardShortcut>
- <newWizardShortcut
- id="org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard">
- </newWizardShortcut>
- <newWizardShortcut
- id="org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard">
- </newWizardShortcut>
- <newWizardShortcut
- id="org.eclipse.ui.wizards.new.file">
- </newWizardShortcut>
- <newWizardShortcut
- id="org.eclipse.ui.wizards.new.folder">
- </newWizardShortcut>
- <viewShortcut
- id="org.eclipse.pde.ui.ImageBrowserView">
- </viewShortcut>
- <viewShortcut
- id="org.eclipse.pde.ui.DependenciesView">
- </viewShortcut>
- <viewShortcut
- id="org.eclipse.pde.runtime.RegistryBrowser">
- </viewShortcut>
- <viewShortcut
- id="org.eclipse.jdt.ui.PackageExplorer">
- </viewShortcut>
- <viewShortcut
- id="org.eclipse.pde.runtime.LogView">
- </viewShortcut>
- <viewShortcut
- id="org.eclipse.pde.ui.TargetPlatformState">
- </viewShortcut>
- </perspectiveExtension>
- </extension>
-</plugin>
+++ /dev/null
-# plugin_customization.ini
-# sets default values for plug-in-specific preferences
-# keys are qualified by plug-in id
-# e.g., com.example.acmeplugin/myproperty=myvalue
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in plugin_customization.properties
-# This file does not need to be translated.
-
-# Property "org.eclipse.ui/defaultPerspectiveId" controls the
-# perspective that the workbench opens initially
-org.eclipse.ui/defaultPerspectiveId=org.argeo.slc.studio.ui.perspective
-
-# perspective bar: hide the textual description and show icons only
-org.eclipse.ui/SHOW_TEXT_ON_PERSPECTIVE_BAR=false
-
-# new-style tabs by default
-org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false
-
-# put the perspective switcher on the top right
-org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight
-
-# show progress on startup
-org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = true
-
-# show build id in the splash - only for nightly, integration, and milestone builds
-org.eclipse.ui.workbench/SHOW_BUILDID_ON_STARTUP=false
-
-# use the window set by default
-org.eclipse.ui/USE_WINDOW_WORKING_SET_BY_DEFAULT=true
-
-# lightweight auto-refresh on access by default
-org.eclipse.core.resources/refresh.lightweight.enabled=true
-
-# enable line number ruler in all textual editors by default
-org.eclipse.ui.editors/lineNumberRuler=true
-
-# enable UI responsiveness monitoring by default
-org.eclipse.ui.monitoring/monitoring_enabled=true
-
-# log an error if UI is frozen for 1 second or longer
-org.eclipse.ui.monitoring/long_event_error_threshold=1000
-
-# Order help books in table of contents
-org.eclipse.help/HELP_DATA = helpData.xml
-
-#Ensure m2e indexing is off by default
-org.eclipse.m2e.core/eclipse.m2.updateIndexes=false
-org.eclipse.m2e.core/eclipse.m2.downloadSources=true
-
-# check for updates once a week
-# https://bugs.eclipse.org/bugs/show_bug.cgi?id=421779
-# https://bugs.eclipse.org/bugs/show_bug.cgi?id=498116
-org.eclipse.equinox.p2.ui.sdk.scheduler/enabled=true
-org.eclipse.equinox.p2.ui.sdk.scheduler/schedule=on-fuzzy-schedule
-org.eclipse.equinox.p2.ui.sdk.scheduler/fuzzy_recurrence=Once a week
-
-# disable the Oomph preference recorder - bug 470654, bug 470430
-# https://bugs.eclipse.org/bugs/show_bug.cgi?id=470654
-# https://bugs.eclipse.org/bugs/show_bug.cgi?id=470430
-org.eclipse.oomph.setup.ui/enable.preference.recorder=false
+++ /dev/null
-package org.argeo.slc.studio.ui;
-
-import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.navigator.resources.ProjectExplorer;
-
-/**
- * The default perspective when opening ARgeo Studio, loosely based on PDE.
- */
-public class ArgeoStudioPerspective implements IPerspectiveFactory {
- @Override
- public void createInitialLayout(IPageLayout factory) {
- IFolderLayout topLeft = factory.createFolder("topLeft", IPageLayout.LEFT, 0.25f, factory.getEditorArea());
- topLeft.addView(ProjectExplorer.VIEW_ID);
-
- IFolderLayout bottom = factory.createFolder("bottomRight", IPageLayout.BOTTOM, 0.75f, factory.getEditorArea());
- bottom.addView(IPageLayout.ID_PROBLEM_VIEW);
- bottom.addView(IConsoleConstants.ID_CONSOLE_VIEW);
-
- IFolderLayout topRight = factory.createFolder("topRight", IPageLayout.RIGHT, 0.75f, factory.getEditorArea());
- topRight.addView(IPageLayout.ID_OUTLINE);
- topRight.addPlaceholder(JavaUI.ID_TYPE_HIERARCHY);
-
- factory.addNewWizardShortcut("org.eclipse.pde.ui.NewProjectWizard");
- factory.addNewWizardShortcut("org.eclipse.pde.ui.NewFeatureProjectWizard");
- }
-}
+++ /dev/null
-<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.slc.ide</groupId>
- <artifactId>argeo-ide</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>plugins</artifactId>
- <packaging>pom</packaging>
- <name>IDE Plugins</name>
- <modules>
- <!-- <module>org.argeo.slc.ide.ui</module> -->
- </modules>
-</project>
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <groupId>org.argeo.slc.ide</groupId>
- <artifactId>argeo-ide</artifactId>
- <packaging>pom</packaging>
- <name>SLC IDE</name>
- <modules>
- <module>plugins</module>
- <module>features</module>
- </modules>
-</project>
\ No newline at end of file
+++ /dev/null
--include: ../../cnf/maven.bnd
\ No newline at end of file
+++ /dev/null
--include: ../../cnf/maven.bnd
\ No newline at end of file
+++ /dev/null
-/target/
-/feature.xml
-/modularDistribution.csv
-/*-maven.target
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-bin.includes = feature.xml,\
- modularDistribution.csv
+++ /dev/null
-properties.1.name=org.eclipse.equinox.p2.type.category
-properties.1.value=true
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<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.slc.legacy.commons</groupId>
- <artifactId>legacy-dep</artifactId>
- <version>2.1.104</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.dep.cms.platform</artifactId>
- <name>CMS Platform (Legacy)</name>
- <dependencies>
-
- <!-- Parent dependencies -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.dep.cms.node</artifactId>
- <version>${version.argeo-commons}</version>
- <type>pom</type>
- </dependency>
-
- <!-- RWT -->
- <dependency>
- <groupId>org.argeo.tp.rap.e4</groupId>
- <artifactId>org.eclipse.rap.rwt</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.e4</groupId>
- <artifactId>org.eclipse.core.commands</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.e4</groupId>
- <artifactId>org.eclipse.rap.jface</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.e4</groupId>
- <artifactId>org.eclipse.rap.filedialog</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.e4</groupId>
- <artifactId>org.eclipse.rap.fileupload</artifactId>
- </dependency>
-
- <!-- Argeo Commons UI -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.eclipse.ui</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.eclipse.ui.rap</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.cms.ui</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.cms.ui.theme</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <!-- Eclipse 3 specific -->
- <dependency>
- <groupId>org.argeo.slc.legacy.commons</groupId>
- <artifactId>org.argeo.cms.ui.workbench</artifactId>
- <version>2.1.104</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc.legacy.commons</groupId>
- <artifactId>org.argeo.cms.ui.workbench.rap</artifactId>
- <version>2.1.104</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc.legacy.commons</groupId>
- <artifactId>org.argeo.ext.rap.ui.workbench</artifactId>
- <version>2.1.104</version>
- </dependency>
-
- <!-- Misc Third Parties -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.apache</groupId> -->
- <!-- <artifactId>org.apache.tika.parser</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.bouncycastle</groupId> -->
- <!-- <artifactId>bcmail</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.bouncycastle</groupId> -->
- <!-- <artifactId>bcpg</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.misc</groupId> -->
- <!-- <artifactId>org.quartz-scheduler.quartz</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.misc</groupId> -->
- <!-- <artifactId>org.quartz-scheduler.quartz.jobs</artifactId> -->
- <!-- </dependency> -->
-
- <!-- Base Spring dependency -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.beans</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.core</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.javax</groupId> -->
- <!-- <artifactId>javax.el</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.gemini</groupId> -->
- <!-- <artifactId>org.eclipse.gemini.blueprint.core</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.gemini</groupId> -->
- <!-- <artifactId>org.eclipse.gemini.blueprint.extender</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.gemini</groupId> -->
- <!-- <artifactId>org.eclipse.gemini.blueprint.io</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.misc</groupId> -->
- <!-- <artifactId>org.aspectj.weaver</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.misc</groupId> -->
- <!-- <artifactId>org.aopalliance</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.aop</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.context</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.expression</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.instrument</artifactId> -->
- <!-- </dependency> -->
-
- <!-- Spring -->
-
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.aspects</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.context.support</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.jdbc</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.tx</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.web</artifactId> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.tp.spring</groupId> -->
- <!-- <artifactId>org.springframework.web.servlet</artifactId> -->
- <!-- </dependency> -->
-
- <!-- Equinox HTTP registry is required by Eclipse 3 but causes problem
- with Eclipse 4 -->
- <dependency>
- <groupId>org.argeo.tp.equinox</groupId>
- <artifactId>org.eclipse.equinox.http.registry</artifactId>
- </dependency>
-
- <!-- Eclipse Core -->
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.core.databinding</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.core.databinding.beans</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.core.runtime</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.core.databinding.property</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>com.ibm.icu</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.core.contenttype</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.rap.rwt.osgi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.rap.jface.databinding</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.core.jobs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.core.expressions</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.core.databinding.observable</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.help</artifactId>
- </dependency>
-
- <!-- RAP Workbench -->
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.rap.ui</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.rap.ui.forms</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.rap.ui.views</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.rap.platform</groupId>
- <artifactId>org.eclipse.rap.ui.workbench</artifactId>
- </dependency>
- </dependencies>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp-rap-e3</artifactId>
- <version>${version.argeo-tp}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <profiles>
- <profile>
- <id>rpmbuild</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-source</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>a2-source</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rpm-argeo</id>
- <phase>package</phase>
- <goals>
- <goal>rpm</goal>
- </goals>
- <configuration>
- <name>argeo-cms-platform${argeo.rpm.suffix}</name>
- <version>${project.version}</version>
- <mappings>
- <mapping>
- <directory>/usr/share/osgi</directory>
- <username>root</username>
- <groupname>root</groupname>
- <filemode>644</filemode>
- <directoryIncluded>false</directoryIncluded>
- <sources>
- <source>
- <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
- <includes>
- <include>**/*.jar</include>
- </includes>
- </source>
- </sources>
- </mapping>
- </mappings>
- <requires>
- <require>argeo-cms-node${argeo.rpm.suffix}</require>
- <require>argeo-cms-platform-tp${argeo.rpm.suffix}</require>
- </requires>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>rpmbuild-tp</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-source-tp</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>a2-source-tp</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rpm-tp</id>
- <phase>package</phase>
- <goals>
- <goal>rpm</goal>
- </goals>
- <configuration>
- <name>argeo-cms-platform-tp${argeo.rpm.suffix}</name>
- <projversion>${version.argeo-tp}</projversion>
- <release>${argeo.rpm.release.tp}</release>
- <mappings>
- <mapping>
- <directory>/usr/share/osgi</directory>
- <username>root</username>
- <groupname>root</groupname>
- <filemode>644</filemode>
- <directoryIncluded>false</directoryIncluded>
- <sources>
- <source>
- <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source-tp</location>
- <includes>
- <include>**/*.jar</include>
- </includes>
- </source>
- </sources>
- </mapping>
- </mappings>
- <requires>
- <require>argeo-cms-node-tp${argeo.rpm.suffix}</require>
- </requires>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<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.slc.legacy.commons</groupId>
- <artifactId>argeo-commons-legacy</artifactId>
- <version>2.1.104</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>legacy-dep</artifactId>
- <name>Commons Modular Distributions (Legacy)</name>
- <packaging>pom</packaging>
- <modules>
- <module>org.argeo.dep.cms.platform</module>
- </modules>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <SLC-ModularDistribution>default</SLC-ModularDistribution>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>properties-maven-plugin</artifactId>
- <configuration>
- <quiet>true</quiet>
- <files>
- <file>../../../../cnf/${version.context}.bnd</file>
- </files>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.argeo.maven.plugins</groupId>
- <artifactId>argeo-osgi-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-descriptors</id>
- <goals>
- <goal>descriptors</goal>
- </goals>
- <phase>generate-resources</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <attach>false</attach>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.argeo.tp.equinox</groupId>
- <artifactId>org.eclipse.osgi</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>org.junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>check-osgi</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.argeo.maven.plugins</groupId>
- <artifactId>argeo-osgi-plugin</artifactId>
- <executions>
- <execution>
- <id>check-osgi</id>
- <phase>test</phase>
- <goals>
- <goal>equinox</goal>
- </goals>
- <configuration>
- <onlyCheck>true</onlyCheck>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.osgi.boot</artifactId>
- <version>${version.argeo-commons}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src" />
- <classpathentry kind="con"
- path="org.eclipse.pde.core.requiredPlugins" />
- <classpathentry kind="con"
- path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
- <classpathentry kind="output" path="bin" />
-</classpath>
+++ /dev/null
-/bin/
-/target/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.cms.ui.workbench.rap</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="org.argeo.cms.ui.workbench.rap.openChangePasswordDialog"
- class="org.argeo.cms.ui.workbench.commands.OpenChangePasswordDialog"
- scope="prototype">
- <property name="userAdmin" ref="userAdmin" />
- <property name="userTransaction" ref="userTransaction" />
- <property name="keyring" ref="keyring" />
- </bean>
-
- <!-- RAP Specific command and corresponding service to enable open file -->
- <bean id="org.argeo.cms.ui.workbench.openFile" class="org.argeo.eclipse.ui.specific.OpenFile"
- scope="prototype">
- <property name="openFileServiceId"
- value="org.argeo.security.ui.specific.openFileService" />
- </bean>
-</beans>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:osgi="http://www.springframework.org/schema/osgi"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- osgi:default-timeout="30000">\r
-\r
- <reference id="userAdmin" interface="org.osgi.service.useradmin.UserAdmin" />\r
- <reference id="userTransaction" interface="javax.transaction.UserTransaction" />\r
- <reference id="keyring" interface="org.argeo.api.security.CryptoKeyring" />\r
-</beans:beans>\r
+++ /dev/null
-changePassword=Change password
\ No newline at end of file
+++ /dev/null
-changePassword=Passwort ändern
\ No newline at end of file
+++ /dev/null
-changePassword=Changer de mot de passe
\ No newline at end of file
+++ /dev/null
-changePassword=\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043F\u0430\u0440\u043E\u043B\u044C
+++ /dev/null
-Bundle-SymbolicName: org.argeo.cms.ui.workbench.rap;singleton:=true
-Bundle-Activator: org.argeo.cms.ui.workbench.rap.SecureRapActivator
-Bundle-ActivationPolicy: lazy
-
-Require-Bundle: org.eclipse.rap.ui,org.eclipse.core.runtime
-
-Import-Package: org.argeo.cms,\
-org.argeo.cms.auth,\
-org.argeo.cms.ui.workbench,\
-org.argeo.cms.ui.workbench.commands,\
-org.argeo.eclipse.ui.specific,\
-org.argeo.eclipse.spring,\
-org.argeo.api,\
-*
+++ /dev/null
-<html>
-<head></head>
-<body>
-<center>
-<table height="100%">
-<tr>
- <td style="vertical-align:middle">
- <a
- style="font-family:sans-serif;color:#0066CC;text-decoration:none;"
- href="node"
- title="Click to log in"
- >Login...</a>
- </td>
-</tr>
-</table>
-</center>
-</body>
-</html>
\ No newline at end of file
+++ /dev/null
-<html>
-<head></head>
-<body>
-</body>
-</html>
\ No newline at end of file
+++ /dev/null
-<html>
-<head></head>
-<body>
-<center>
-<table height="100%">
-<tr>
- <td style="vertical-align:middle">
- <a
- style="font-family:sans-serif;color:#0066CC;text-decoration:none;"
- href="javascript:location.reload(true);"
- title="Click to log in"
- >Login...</a>
- </td>
-</tr>
-</table>
-</center>
-</body>
-</html>
\ No newline at end of file
+++ /dev/null
-<html>
-<head></head>
-<body>
-<center>
-<table height="100%">
-<tr>
- <td style="vertical-align:middle">
- <a
- style="font-family:sans-serif;color:#0066CC;text-decoration:none;"
- href="javascript:location.reload(true);"
- title="Refresh"
- >Refresh...</a>
- </td>
-</tr>
-</table>
-</center>
-</body>
-</html>
\ No newline at end of file
+++ /dev/null
-source.. = src/
-bin.includes = OSGI-INF/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.rap.ui.entrypoint">
- <entrypoint
- id="org.argeo.cms.ui.workbench.rap.secureEntryPoint"
- class="org.argeo.cms.ui.workbench.rap.RapWorkbenchLogin"
- path="/node"
- brandingId="org.argeo.cms.ui.workbench.rap.defaultBranding">
- </entrypoint>
- <entrypoint
- id="org.argeo.cms.ui.workbench.rap.anonymousEntryPoint"
- class="org.argeo.cms.ui.workbench.rap.AnonymousEntryPoint"
- path="/public"
- brandingId="org.argeo.cms.ui.workbench.rap.defaultBranding">
- </entrypoint>
- <entrypoint
- brandingId="org.argeo.cms.ui.workbench.rap.defaultBranding"
- class="org.argeo.cms.ui.workbench.rap.SpnegoWorkbenchLogin"
- id="org.argeo.cms.ui.workbench.rap.loginEntryPoint"
- path="/login">
- </entrypoint>
-<!-- <entrypoint
- id="org.argeo.cms.ui.workbench.rap.secureEntryPoint"
- class="org.argeo.security.ui.rap.RapWorkbenchLogin"
- path="/login"
- brandingId="org.argeo.cms.ui.workbench.rap.defaultBranding">
- </entrypoint> -->
- </extension>
-
- <!-- COMMANDS -->
- <extension point="org.eclipse.ui.commands">
- <command
- id="org.argeo.cms.ui.workbench.rap.mainMenuCommand"
- defaultHandler="org.argeo.cms.ui.workbench.rap.commands.OpenHome"
- name="Main">
- </command>
- <command
- id="org.argeo.cms.ui.workbench.rap.openChangePasswordDialog"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="%changePassword">
- </command>
- <!-- Enable an "open file" action in a single sourced application -->
- <command
- id="org.argeo.cms.ui.workbench.openFile"
- defaultHandler="org.argeo.eclipse.spring.SpringExtensionFactory"
- name="OpenFile">
- <commandParameter
- id="param.fileName"
- name="The name of the file to open (optional)">
- </commandParameter>
- <commandParameter
- id="param.fileURI"
- name="The URI of this file on the server">
- </commandParameter>
- </command>
- </extension>
-
- <!-- MENUS -->
- <extension point="org.eclipse.ui.menus">
- <!-- Main tool bar menu -->
- <!--
- <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar">
- <toolbar id="org.argeo.cms.ui.workbench.rap.userToolbar">
- <command
- commandId="org.argeo.cms.ui.workbench.rap.mainMenuCommand"
- icon="icons/home.gif"
- id="org.argeo.cms.ui.workbench.rap.mainMenu"
- style="pulldown">
- </command>
- <command commandId="org.eclipse.ui.file.save"/>
- <command commandId="org.eclipse.ui.file.saveAll"/>
- </toolbar>
- </menuContribution>
- -->
- <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar">
- <toolbar id="org.argeo.cms.ui.workbench.userToolbar">
- <command
- commandId="org.argeo.cms.ui.workbench.rap.mainMenuCommand"
- icon="icons/home.png"
- id="org.argeo.cms.ui.workbench.rap.mainMenu"
- style="pulldown">
- </command>
- <command commandId="org.eclipse.ui.file.save" icon="icons/save.png"/>
- <command commandId="org.eclipse.ui.file.saveAll" icon="icons/save-all.png"/>
- </toolbar>
- </menuContribution>
-
- <!-- User drop down default menu -->
- <menuContribution locationURI="menu:org.argeo.cms.ui.workbench.rap.mainMenu">
- <!-- Managed programmatically in the RapActionBarAdvisor to enable
- the display of the current logged-in user id -->
- <command
- commandId="org.argeo.cms.ui.workbench.rap.userMenuCommand"
- icon="icons/person-logged-in.png"
- id="org.argeo.cms.ui.workbench.rap.userMenu">
- </command>
- <!-- Still unused
- <command
- commandId="org.eclipse.ui.window.preferences"
- icon="icons/preferences.png"/> -->
- <command
- commandId="org.argeo.cms.ui.workbench.rap.openChangePasswordDialog"
- icon="icons/security.gif"
- label="%changePassword"/>
- <separator
- name="org.argeo.cms.ui.workbench.rap.beforeFile"
- visible="true">
- </separator>
- <command commandId="org.eclipse.ui.file.closeAll" icon="icons/close-all.png"/>
- <command commandId="org.eclipse.ui.file.save" icon="icons/save.png"/>
- <command commandId="org.eclipse.ui.file.saveAll" icon="icons/save-all.png"/>
-
- <!--<command commandId="org.eclipse.ui.views.showView"/>-->
- <command commandId="org.eclipse.ui.perspectives.showPerspective"/>
- <separator
- name="org.argeo.cms.ui.workbench.rap.beforeExit"
- visible="true">
- </separator>
- <command commandId="org.eclipse.ui.file.exit" icon="icons/exit.png"/>
- </menuContribution>
- </extension>
-
- <!-- SERVICE HANDLERS -->
- <extension point="org.eclipse.rap.ui.serviceHandler">
- <!-- Rap specific service handler to enable file download over the internet-->
- <serviceHandler
- class="org.argeo.eclipse.ui.specific.OpenFileService"
- id="org.argeo.security.ui.specific.openFileService">
- </serviceHandler>
- </extension>
-
- <!-- ACTIVITIES -->
- <extension
- point="org.eclipse.ui.activities">
- <activity
- description="Anonymous"
- id="org.argeo.cms.ui.workbench.rap.anonymousActivity"
- name="Anonymous">
- <enabledWhen>
- <with variable="roles">
- <iterate ifEmpty="false" operator="or">
- <equals value="cn=anonymous,ou=roles,ou=node" />
- </iterate>
- </with>
- </enabledWhen>
- </activity>
- <activity
- description="Not anonymous"
- id="org.argeo.cms.ui.workbench.rap.notAnonymousActivity"
- name="NotAnonymous">
- <enabledWhen>
- <not>
- <with variable="roles">
- <iterate ifEmpty="false" operator="or">
- <equals value="cn=anonymous,ou=roles,ou=node" />
- </iterate>
- </with>
- </not>
- </enabledWhen>
- </activity>
- <activityPatternBinding
- activityId="org.argeo.cms.ui.workbench.rap.notAnonymousActivity"
- pattern="org.argeo.cms.ui.workbench.rap/org.argeo.cms.ui.workbench.rap.userMenuCommand"/>
- <activityPatternBinding
- activityId="org.argeo.cms.ui.workbench.rap.notAnonymousActivity"
- pattern="org.argeo.cms.ui.workbench.rap/org.eclipse.ui.window.preferences"/>
- <activityPatternBinding
- activityId="org.argeo.cms.ui.workbench.rap.notAnonymousActivity"
- pattern="org.argeo.cms.ui.workbench.rap/org.argeo.cms.ui.workbench.rap.openChangePasswordDialog"/>
- </extension>
-
- <!-- BRANDINGS -->
- <extension
- point="org.eclipse.rap.ui.branding">
- <branding
- id="org.argeo.cms.ui.workbench.rap.defaultBranding"
- themeId="org.eclipse.rap.rwt.theme.Default"
- title="Argeo Web UI"
- favicon="branding/favicon.ico">
- </branding>
- <!-- we need a servlet with this name j_spring_security_logout
- for the logout filter -->
- <branding
- id="org.argeo.cms.ui.workbench.rap.logoutBranding"
- title="Argeo Logout"
- favicon="branding/favicon.ico"
- body="branding/empty.html">
- </branding>
- </extension>
-</plugin>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<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.slc.legacy.commons</groupId>
- <artifactId>argeo-commons-legacy</artifactId>
- <version>2.1.104</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.cms.ui.workbench.rap</artifactId>
- <name>CMS Workbench RAP</name>
- <packaging>jar</packaging>
- <dependencies>
- <dependency>
- <groupId>org.argeo.slc.legacy.commons</groupId>
- <artifactId>org.argeo.cms.ui.workbench</artifactId>
- <version>2.1.104</version>
- </dependency>
- <!-- RAP specific -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.eclipse.ui.rap</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp-rap-e3</artifactId>
- <version>${version.argeo-tp}</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.argeo.cms.ui.workbench.rap;
-
-import java.security.PrivilegedAction;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.CmsException;
-import org.eclipse.rap.rwt.RWT;
-import org.eclipse.rap.rwt.application.EntryPoint;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * RAP entry point which authenticates the subject as anonymous, for public
- * unauthenticated access.
- */
-public class AnonymousEntryPoint implements EntryPoint {
- private final static Log log = LogFactory.getLog(AnonymousEntryPoint.class);
-
- /**
- * How many seconds to wait before invalidating the session if the user has
- * not yet logged in.
- */
- private Integer sessionTimeout = 5 * 60;
-
- @Override
- public int createUI() {
- RWT.getRequest().getSession().setMaxInactiveInterval(sessionTimeout);
-
- // if (log.isDebugEnabled())
- // log.debug("Anonymous THREAD=" + Thread.currentThread().getId()
- // + ", sessionStore=" + RWT.getSessionStore().getId());
-
- final Display display = PlatformUI.createDisplay();
- Subject subject = new Subject();
-
- final LoginContext loginContext;
- try {
- loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_ANONYMOUS,
- subject);
- loginContext.login();
- } catch (LoginException e1) {
- throw new CmsException("Cannot initialize login context", e1);
- }
-
- // identify after successful login
- if (log.isDebugEnabled())
- log.debug("Authenticated " + subject);
- final String username = subject.getPrincipals().iterator().next()
- .getName();
-
- // Logout callback when the display is disposed
- display.disposeExec(new Runnable() {
- public void run() {
- log.debug("Display disposed");
- logout(loginContext, username);
- }
- });
-
- //
- // RUN THE WORKBENCH
- //
- Integer returnCode = null;
- try {
- returnCode = Subject.doAs(subject, new PrivilegedAction<Integer>() {
- public Integer run() {
- RapWorkbenchAdvisor workbenchAdvisor = new RapWorkbenchAdvisor(
- null);
- int result = PlatformUI.createAndRunWorkbench(display,
- workbenchAdvisor);
- return new Integer(result);
- }
- });
- logout(loginContext, username);
- if (log.isTraceEnabled())
- log.trace("Return code " + returnCode);
- } finally {
- display.dispose();
- }
- return 1;
- }
-
- private void logout(LoginContext loginContext, String username) {
- try {
- loginContext.logout();
- log.info("Logged out " + (username != null ? username : "")
- + " (THREAD=" + Thread.currentThread().getId() + ")");
- } catch (LoginException e) {
- log.error("Erorr when logging out", e);
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.rap;
-
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.ui.workbench.commands.OpenHomePerspective;
-import org.eclipse.core.commands.Category;
-import org.eclipse.core.commands.Command;
-import org.eclipse.jface.action.ICoolBarManager;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
-import org.eclipse.ui.application.ActionBarAdvisor;
-import org.eclipse.ui.application.IActionBarConfigurer;
-import org.eclipse.ui.commands.ICommandService;
-
-/** Eclipse rap specific action bar advisor */
-public class RapActionBarAdvisor extends ActionBarAdvisor {
- private final static String ID_BASE = SecureRapActivator.ID;
- // private final static Log log = LogFactory
- // .getLog(SecureActionBarAdvisor.class);
-
- /** Null means anonymous */
- private String username = null;
-
- // private IAction logoutAction;
- // private IWorkbenchAction openPerspectiveDialogAction;
- // private IWorkbenchAction showViewMenuAction;
- // private IWorkbenchAction preferences;
- private IWorkbenchAction saveAction;
- private IWorkbenchAction saveAllAction;
-
- // private IWorkbenchAction closeAllAction;
-
- public RapActionBarAdvisor(IActionBarConfigurer configurer, String username) {
- super(configurer);
- this.username = username;
- }
-
- protected void makeActions(IWorkbenchWindow window) {
- // preferences = ActionFactory.PREFERENCES.create(window);
- // register(preferences);
- // openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
- // .create(window);
- // register(openPerspectiveDialogAction);
- // showViewMenuAction = ActionFactory.SHOW_VIEW_MENU.create(window);
- // register(showViewMenuAction);
- //
- // // logout
- // logoutAction = ActionFactory.QUIT.create(window);
- // // logoutAction = createLogoutAction();
- // register(logoutAction);
- //
- // Save semantics
- saveAction = ActionFactory.SAVE.create(window);
- register(saveAction);
- saveAllAction = ActionFactory.SAVE_ALL.create(window);
- register(saveAllAction);
- // closeAllAction = ActionFactory.CLOSE_ALL.create(window);
- // register(closeAllAction);
-
- }
-
- protected void fillMenuBar(IMenuManager menuBar) {
- // MenuManager fileMenu = new MenuManager("&File",
- // IWorkbenchActionConstants.M_FILE);
- // MenuManager editMenu = new MenuManager("&Edit",
- // IWorkbenchActionConstants.M_EDIT);
- // MenuManager windowMenu = new MenuManager("&Window",
- // IWorkbenchActionConstants.M_WINDOW);
- //
- // menuBar.add(fileMenu);
- // menuBar.add(editMenu);
- // menuBar.add(windowMenu);
- // // Add a group marker indicating where action set menus will appear.
- // menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- //
- // // File
- // fileMenu.add(saveAction);
- // fileMenu.add(saveAllAction);
- // fileMenu.add(closeAllAction);
- // fileMenu.add(new
- // GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- // fileMenu.add(new Separator());
- // fileMenu.add(logoutAction);
- //
- // // Edit
- // editMenu.add(preferences);
- //
- // // Window
- // windowMenu.add(openPerspectiveDialogAction);
- // windowMenu.add(showViewMenuAction);
- }
-
- @Override
- protected void fillCoolBar(ICoolBarManager coolBar) {
- // Add a command which label is the display name of the current
- // logged-in user
- if (username != null) {
- ICommandService cmdService = (ICommandService) getActionBarConfigurer()
- .getWindowConfigurer().getWorkbenchConfigurer()
- .getWorkbench().getService(ICommandService.class);
- Category userMenus = cmdService.getCategory(ID_BASE + ".userMenus");
- if (!userMenus.isDefined())
- userMenus.define("User Menus", "User related menus");
- Command userMenu = cmdService.getCommand(ID_BASE
- + ".userMenuCommand");
- if (userMenu.isDefined())
- userMenu.undefine();
- userMenu.define(CurrentUser.getDisplayName(), "User menu actions",
- userMenus);
- // userMenu.define(username, "User menu actions", userMenus);
-
- userMenu.setHandler(new OpenHomePerspective());
-
- // userToolbar.add(new UserMenuAction());
- // coolBar.add(userToolbar);
- } else {// anonymous
- IToolBarManager userToolbar = new ToolBarManager(SWT.FLAT
- | SWT.RIGHT);
- // userToolbar.add(logoutAction);
- coolBar.add(userToolbar);
- }
- // IToolBarManager saveToolbar = new ToolBarManager(SWT.FLAT |
- // SWT.RIGHT);
- // saveToolbar.add(saveAction);
- // saveToolbar.add(saveAllAction);
- // coolBar.add(saveToolbar);
- }
-
- // class UserMenuAction extends Action implements IWorkbenchAction {
- //
- // public UserMenuAction() {
- // super(username, IAction.AS_DROP_DOWN_MENU);
- // // setMenuCreator(new UserMenu());
- // }
- //
- // @Override
- // public String getId() {
- // return "org.argeo.cms.ui.workbench.rap.userMenu";
- // }
- //
- // @Override
- // public void dispose() {
- // }
- //
- // }
-
- // class UserMenu implements IMenuCreator {
- // private Menu menu;
- //
- // public Menu getMenu(Control parent) {
- // Menu menu = new Menu(parent);
- // addActionToMenu(menu, logoutAction);
- // return menu;
- // }
- //
- // private void addActionToMenu(Menu menu, IAction action) {
- // ActionContributionItem item = new ActionContributionItem(action);
- // item.fill(menu, -1);
- // }
- //
- // public void dispose() {
- // if (menu != null) {
- // menu.dispose();
- // }
- // }
- //
- // public Menu getMenu(Menu parent) {
- // // Not use
- // return null;
- // }
- //
- // }
-
- // protected IAction createLogoutAction() {
- // Subject subject = Subject.getSubject(AccessController.getContext());
- // final String username = subject.getPrincipals().iterator().next()
- // .getName();
- //
- // IAction logoutAction = new Action() {
- // public String getId() {
- // return SecureRapActivator.ID + ".logoutAction";
- // }
- //
- // public String getText() {
- // return "Logout " + username;
- // }
- //
- // public void run() {
- // // try {
- // // Subject subject = SecureRapActivator.getLoginContext()
- // // .getSubject();
- // // String subjectStr = subject.toString();
- // // subject.getPrincipals().clear();
- // // SecureRapActivator.getLoginContext().logout();
- // // log.info(subjectStr + " logged out");
- // // } catch (LoginException e) {
- // // log.error("Error when logging out", e);
- // // }
- // // SecureEntryPoint.logout(username);
- // // PlatformUI.getWorkbench().close();
- // // try {
- // // RWT.getRequest().getSession().setMaxInactiveInterval(1);
- // // } catch (Exception e) {
- // // if (log.isTraceEnabled())
- // // log.trace("Error when invalidating session", e);
- // // }
- // }
- //
- // };
- // return logoutAction;
- // }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.rap;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
-import org.eclipse.ui.application.ActionBarAdvisor;
-import org.eclipse.ui.application.IActionBarConfigurer;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.application.WorkbenchWindowAdvisor;
-
-/** Eclipse RAP specific window advisor */
-public class RapWindowAdvisor extends WorkbenchWindowAdvisor {
-
- private String username;
-
- public RapWindowAdvisor(IWorkbenchWindowConfigurer configurer,
- String username) {
- super(configurer);
- this.username = username;
- }
-
- @Override
- public ActionBarAdvisor createActionBarAdvisor(
- IActionBarConfigurer configurer) {
- return new RapActionBarAdvisor(configurer, username);
- }
-
- public void preWindowOpen() {
- IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
- configurer.setShowCoolBar(true);
- configurer.setShowMenuBar(false);
- configurer.setShowStatusLine(false);
- configurer.setShowPerspectiveBar(true);
- configurer.setTitle("Argeo Web UI"); //$NON-NLS-1$
- // Full screen, see
- // http://wiki.eclipse.org/RAP/FAQ#How_to_create_a_fullscreen_application
- configurer.setShellStyle(SWT.NO_TRIM);
- Rectangle bounds = Display.getCurrent().getBounds();
- configurer.setInitialSize(new Point(bounds.width, bounds.height));
-
- // Handle window resize in Rap 2.1+ see
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=417254
- Display.getCurrent().addListener(SWT.Resize, new Listener() {
- private static final long serialVersionUID = 2970912561866704526L;
-
- @Override
- public void handleEvent(Event event) {
- Rectangle bounds = event.display.getBounds();
- IWorkbenchWindow iww = getWindowConfigurer().getWindow()
- .getWorkbench().getActiveWorkbenchWindow();
- iww.getShell().setBounds(bounds);
- }
- });
- }
-
- @Override
- public void postWindowCreate() {
- Shell shell = getWindowConfigurer().getWindow().getShell();
- shell.setMaximized(true);
- }
-
- @Override
- public void postWindowOpen() {
- String defaultPerspective = getWindowConfigurer()
- .getWorkbenchConfigurer().getWorkbench()
- .getPerspectiveRegistry().getDefaultPerspective();
- if (defaultPerspective == null) {
- IWorkbenchWindow window = getWindowConfigurer().getWindow();
- if (window == null)
- return;
-
- IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
- .create(window);
- openPerspectiveDialogAction.run();
- }
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.rap;
-
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.application.IWorkbenchConfigurer;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.application.WorkbenchAdvisor;
-import org.eclipse.ui.application.WorkbenchWindowAdvisor;
-
-/** Eclipse RAP specific workbench advisor */
-public class RapWorkbenchAdvisor extends WorkbenchAdvisor {
- public final static String INITIAL_PERSPECTIVE_PROPERTY = "org.argeo.security.ui.initialPerspective";
- public final static String SAVE_AND_RESTORE_PROPERTY = "org.argeo.security.ui.saveAndRestore";
-
- private String initialPerspective = System.getProperty(
- INITIAL_PERSPECTIVE_PROPERTY, null);
-
- private String username;
-
- public RapWorkbenchAdvisor(String username) {
- this.username = username;
- }
-
- @Override
- public void initialize(IWorkbenchConfigurer configurer) {
- super.initialize(configurer);
- Boolean saveAndRestore = Boolean.parseBoolean(System.getProperty(
- SAVE_AND_RESTORE_PROPERTY, "false"));
- configurer.setSaveAndRestore(saveAndRestore);
- }
-
- public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
- IWorkbenchWindowConfigurer configurer) {
- return new RapWindowAdvisor(configurer, username);
- }
-
- public String getInitialWindowPerspectiveId() {
- if (initialPerspective != null) {
- // check whether this user can see the declared perspective
- // (typically the perspective won't be listed if this user doesn't
- // have the right to see it)
- IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
- .getPerspectiveRegistry()
- .findPerspectiveWithId(initialPerspective);
- if (pd == null)
- return null;
- }
- return initialPerspective;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.rap;
-
-import java.security.PrivilegedAction;
-import java.util.Locale;
-
-import javax.security.auth.Subject;
-import javax.security.auth.x500.X500Principal;
-
-import org.argeo.cms.CmsMsg;
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.ui.util.CmsUiUtils;
-import org.argeo.cms.ui.util.LoginEntryPoint;
-import org.eclipse.rap.rwt.RWT;
-import org.eclipse.rap.rwt.client.service.JavaScriptExecutor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-public class RapWorkbenchLogin extends LoginEntryPoint {
- // private final static Log log =
- // LogFactory.getLog(RapWorkbenchLogin.class);
-
- /** Override to provide an application specific workbench advisor */
- protected RapWorkbenchAdvisor createRapWorkbenchAdvisor(String username) {
- return new RapWorkbenchAdvisor(username);
- }
-
- @Override
- public int createUI() {
- JavaScriptExecutor jsExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
- int returnCode;
- try {
- returnCode = super.createUI();
- } finally {
- // always reload
- // TODO optimise?
- jsExecutor.execute("location.reload()");
- }
- return returnCode;
- }
-
- @Override
- protected int postLogin() {
- Subject subject = getSubject();
- final Display display = Display.getCurrent();
- if (subject.getPrincipals(X500Principal.class).isEmpty()) {
- RWT.getClient().getService(JavaScriptExecutor.class).execute("location.reload()");
- }
- //
- // RUN THE WORKBENCH
- //
- Integer returnCode = null;
- try {
- returnCode = Subject.doAs(subject, new PrivilegedAction<Integer>() {
- public Integer run() {
- int result = createAndRunWorkbench(display, CurrentUser.getUsername(subject));
- return new Integer(result);
- }
- });
- // explicit workbench closing
- logout();
- } finally {
- display.dispose();
- }
- return returnCode;
- }
-
- protected int createAndRunWorkbench(Display display, String username) {
- RapWorkbenchAdvisor workbenchAdvisor = createRapWorkbenchAdvisor(username);
- return PlatformUI.createAndRunWorkbench(display, workbenchAdvisor);
- }
-
- @Override
- protected void extendsCredentialsBlock(Composite credentialsBlock, Locale selectedLocale,
- SelectionListener loginSelectionListener) {
-// Button loginButton = new Button(credentialsBlock, SWT.PUSH);
-// loginButton.setText(CmsMsg.login.lead(selectedLocale));
-// loginButton.setLayoutData(CmsUtils.fillWidth());
-// loginButton.addSelectionListener(loginSelectionListener);
- }
-
- @Override
- protected Display createDisplay() {
- return PlatformUI.createDisplay();
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.rap;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/** Configure Equinox login context from the bundle context. */
-public class SecureRapActivator implements BundleActivator {
- public final static String ID = "org.argeo.cms.ui.workbench.rap";
-
- private static BundleContext bundleContext;
-
- public void start(BundleContext bc) throws Exception {
- bundleContext = bc;
- }
-
- public void stop(BundleContext context) throws Exception {
- bundleContext = null;
- }
-
- public static BundleContext getBundleContext() {
- return bundleContext;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.rap;
-
-import java.security.PrivilegedAction;
-import java.util.Locale;
-
-import javax.security.auth.Subject;
-import javax.security.auth.x500.X500Principal;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.argeo.cms.CmsMsg;
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.ui.util.CmsUiUtils;
-import org.argeo.cms.ui.util.LoginEntryPoint;
-import org.eclipse.rap.rwt.RWT;
-import org.eclipse.rap.rwt.client.service.JavaScriptExecutor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-public class SpnegoWorkbenchLogin extends LoginEntryPoint {
- // private final static Log log =
- // LogFactory.getLog(RapWorkbenchLogin.class);
-
- /** Override to provide an application specific workbench advisor */
- protected RapWorkbenchAdvisor createRapWorkbenchAdvisor(String username) {
- return new RapWorkbenchAdvisor(username);
- }
-
- @Override
- public int createUI() {
- HttpServletRequest request = RWT.getRequest();
- String authorization = request.getHeader(HEADER_AUTHORIZATION);
- if (authorization == null || !authorization.startsWith("Negotiate")) {
- HttpServletResponse response = RWT.getResponse();
- response.setStatus(401);
- response.setHeader(HEADER_WWW_AUTHENTICATE, "Negotiate");
- response.setDateHeader("Date", System.currentTimeMillis());
- response.setDateHeader("Expires", System.currentTimeMillis() + (24 * 60 * 60 * 1000));
- response.setHeader("Accept-Ranges", "bytes");
- response.setHeader("Connection", "Keep-Alive");
- response.setHeader("Keep-Alive", "timeout=5, max=97");
- // response.setContentType("text/html; charset=UTF-8");
- }
-
- int returnCode;
- returnCode = super.createUI();
- return returnCode;
- }
-
- @Override
- protected int postLogin() {
- Subject subject = getSubject();
- final Display display = Display.getCurrent();
- if (subject.getPrincipals(X500Principal.class).isEmpty()) {
- RWT.getClient().getService(JavaScriptExecutor.class).execute("location.reload()");
- }
- //
- // RUN THE WORKBENCH
- //
- Integer returnCode = null;
- try {
- returnCode = Subject.doAs(subject, new PrivilegedAction<Integer>() {
- public Integer run() {
- int result = createAndRunWorkbench(display, CurrentUser.getUsername(subject));
- return new Integer(result);
- }
- });
- // explicit workbench closing
- logout();
- } finally {
- display.dispose();
- }
- return returnCode;
- }
-
- protected int createAndRunWorkbench(Display display, String username) {
- RapWorkbenchAdvisor workbenchAdvisor = createRapWorkbenchAdvisor(username);
- return PlatformUI.createAndRunWorkbench(display, workbenchAdvisor);
- }
-
- @Override
- protected void extendsCredentialsBlock(Composite credentialsBlock, Locale selectedLocale,
- SelectionListener loginSelectionListener) {
-// Button loginButton = new Button(credentialsBlock, SWT.PUSH);
-// loginButton.setText(CmsMsg.login.lead(selectedLocale));
-// loginButton.setLayoutData(CmsUtils.fillWidth());
-// loginButton.addSelectionListener(loginSelectionListener);
- }
-
- @Override
- protected Display createDisplay() {
- return PlatformUI.createDisplay();
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.rap.commands;
-
-import org.argeo.cms.ui.workbench.UserHomePerspective;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Default action of the user menu */
-public class OpenHome extends AbstractHandler {
- private final static String PROP_OPEN_HOME_CMD_ID = "org.argeo.ui.openHomeCommandId";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- String defaultCmdId = System.getProperty(PROP_OPEN_HOME_CMD_ID, "");
- if (!"".equals(defaultCmdId.trim()))
- CommandUtils.callCommand(defaultCmdId);
- else {
- try {
- String defaultPerspective = HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench()
- .getPerspectiveRegistry().getDefaultPerspective();
- HandlerUtil.getActiveSite(event).getWorkbenchWindow()
- .openPage(defaultPerspective != null ? defaultPerspective : UserHomePerspective.ID, null);
- } catch (WorkbenchException e) {
- ErrorFeedback.show("Cannot open home perspective", e);
- }
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.rap.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Default action of the user menu */
-public class UserMenu extends AbstractHandler {
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- return null;
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src" />
- <classpathentry kind="con"
- path="org.eclipse.pde.core.requiredPlugins" />
- <classpathentry kind="con"
- path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
- <classpathentry kind="output" path="bin" />
-</classpath>
+++ /dev/null
-/bin/
-/target/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.cms.ui.workbench</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <!-- USERS CRUDS -->
- <bean id="newUser" class="org.argeo.cms.ui.workbench.internal.useradmin.commands.NewUser"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- </bean>
- <bean id="deleteUsers"
- class="org.argeo.cms.ui.workbench.internal.useradmin.commands.DeleteUsers"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- </bean>
- <bean id="userBatchUpdate"
- class="org.argeo.cms.ui.workbench.internal.useradmin.commands.UserBatchUpdate"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- </bean>
- <!-- GROUPS CRUDS -->
- <bean id="newGroup" class="org.argeo.cms.ui.workbench.internal.useradmin.commands.NewGroup"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- </bean>
- <bean id="deleteGroups"
- class="org.argeo.cms.ui.workbench.internal.useradmin.commands.DeleteGroups"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- </bean>
-
- <!-- TRANSACTIONS -->
- <bean id="userTransactionHandler"
- class="org.argeo.cms.ui.workbench.internal.useradmin.commands.UserTransactionHandler"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- </bean>
-
- <!-- DATA EXPLORER -->
- <bean id="addRemoteRepository"
- class="org.argeo.cms.ui.workbench.internal.jcr.commands.AddRemoteRepository">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="nodeRepository" ref="nodeRepository" />
- <property name="keyring" ref="keyring" />
- </bean>
-
- <bean id="addPrivileges" class="org.argeo.cms.ui.workbench.internal.jcr.commands.AddPrivileges">
- <property name="userAdmin" ref="userAdmin" />
- </bean>
- <bean id="removePrivileges"
- class="org.argeo.cms.ui.workbench.internal.jcr.commands.RemovePrivileges">
- <!-- <property name="userAdmin" ref="userAdmin" /> -->
- </bean>
-</beans>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <bean id="userTransactionProvider"\r
- class="org.argeo.cms.ui.workbench.internal.useradmin.providers.UserTransactionProvider"\r
- scope="singleton" lazy-init="false">\r
- <property name="userTransaction" ref="userTransaction" />\r
- </bean>\r
-\r
- <bean id="userAdminWrapper"\r
- class="org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper"\r
- scope="singleton" lazy-init="false">\r
- <property name="userTransaction" ref="userTransaction" />\r
- <property name="userAdmin" ref="userAdmin" />\r
- <property name="userAdminServiceReference" ref="userAdmin" />\r
- </bean>\r
-\r
- <bean id="repositoryRegister" class="org.argeo.cms.ui.jcr.DefaultRepositoryRegister" />\r
-\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:osgi="http://www.springframework.org/schema/osgi"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- osgi:default-timeout="30000">\r
-\r
- <!-- JCR -->\r
- <reference id="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
- <reference id="keyring" interface="org.argeo.api.security.CryptoKeyring" />\r
- <list id="repositories" interface="javax.jcr.Repository"\r
- cardinality="0..N">\r
- <listener ref="repositoryRegister" bind-method="register"\r
- unbind-method="unregister" />\r
- </list>\r
-\r
- <reference id="nodeRepository" interface="javax.jcr.Repository"\r
- filter="(cn=ego)" />\r
- \r
- <reference id="nodeInstance" interface="org.argeo.api.NodeInstance" />\r
-\r
- <reference id="nodeFileSystemProvider" interface="java.nio.file.spi.FileSystemProvider"\r
- filter="(service.pid=org.argeo.api.fsProvider)" />\r
-\r
- <!-- UserAdmin -->\r
- <reference id="userAdmin" interface="org.osgi.service.useradmin.UserAdmin" />\r
- <reference id="userTransaction" interface="javax.transaction.UserTransaction" />\r
-\r
-\r
- <reference id="secureLogger" interface="org.argeo.api.ArgeoLogger"\r
- cardinality="0..1" />\r
- <reference id="defaultCallbackHandler" interface="javax.security.auth.callback.CallbackHandler" />\r
-\r
-</beans:beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <!-- SECURITY -->
- <!-- Editors -->
- <bean id="userEditor"
- class="org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditor"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- </bean>
-
- <bean id="groupEditor"
- class="org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditor"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- <property name="repository" ref="nodeRepository" />
- <property name="nodeInstance" ref="nodeInstance" />
- </bean>
-
- <!-- Views -->
- <bean id="usersView"
- class="org.argeo.cms.ui.workbench.internal.useradmin.parts.UsersView"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- </bean>
- <bean id="groupsView"
- class="org.argeo.cms.ui.workbench.internal.useradmin.parts.GroupsView"
- scope="prototype">
- <property name="userAdminWrapper" ref="userAdminWrapper" />
- </bean>
-
-
- <!-- DATA EXPLORER -->
- <!-- Editors -->
- <bean id="genericJcrQueryEditor" class="org.argeo.cms.ui.workbench.jcr.GenericJcrQueryEditor"
- scope="prototype">
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
- <bean id="defaultNodeEditor" class="org.argeo.cms.ui.workbench.jcr.DefaultNodeEditor"
- scope="prototype">
- </bean>
- <!-- Views -->
- <bean id="jcrBrowserView" class="org.argeo.cms.ui.workbench.jcr.JcrBrowserView"
- scope="prototype">
- <property name="repositoryRegister" ref="repositoryRegister" />
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="nodeRepository" ref="nodeRepository" />
- <property name="keyring" ref="keyring" />
- </bean>
- <bean id="nodeFsBrowserView" class="org.argeo.cms.ui.workbench.jcr.NodeFsBrowserView"
- scope="prototype">
- <property name="nodeFileSystemProvider" ref="nodeFileSystemProvider" />
- <!-- <property name="keyring" ref="keyring" /> -->
- </bean>
-
- <!-- LOGGERS -->
- <bean id="logView" class="org.argeo.cms.ui.workbench.useradmin.LogView"
- scope="prototype">
- <property name="argeoLogger" ref="secureLogger" />
- </bean>
- <bean id="adminLogView" class="org.argeo.cms.ui.workbench.useradmin.AdminLogView"
- scope="prototype">
- <property name="argeoLogger" ref="secureLogger" />
- </bean>
-</beans>
+++ /dev/null
-search=Finden
\ No newline at end of file
+++ /dev/null
-search=Search
\ No newline at end of file
+++ /dev/null
-Bundle-SymbolicName: org.argeo.cms.ui.workbench;singleton:=true
-Bundle-Activator: org.argeo.cms.ui.workbench.WorkbenchUiPlugin
-Bundle-ActivationPolicy: lazy
-
-Require-Bundle: org.eclipse.core.runtime,\
-org.eclipse.core.commands
-
-Import-Package: org.argeo.cms.auth,\
-org.argeo.cms,\
-org.argeo.cms.ui,\
-org.argeo.eclipse.spring,\
-org.argeo.eclipse.ui.util,\
-org.eclipse.core.runtime.jobs,\
-org.eclipse.jface.window,\
-org.eclipse.swt,\
-org.eclipse.swt.widgets,\
-org.eclipse.ui.services,\
-org.osgi.*;version=0.0.0,\
-org.springframework.core,\
-org.springframework.beans.factory,\
-org.springframework.core.io.support,\
-!org.eclipse.core.runtime,\
-*
-
-
-# org.argeo.eclipse.ui.workbench;resolution:=optional,\
+++ /dev/null
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- icons/,\
- plugin.xml
-additional.bundles = org.apache.commons.httpclient
+++ /dev/null
-argeo.keyring.secreteKeyLength=256
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.ui.perspectives">
- <perspective
- id="org.argeo.cms.ui.workbench.adminSecurityPerspective"
- class="org.argeo.cms.ui.workbench.SecurityAdminPerspective"
- icon="platform:/plugin/org.argeo.cms.ui.theme/platform:/plugin/org.argeo.cms.ui.theme/icons/group.png"
- name="Security">
- </perspective>
- <perspective
- id="org.argeo.cms.ui.workbench.userHomePerspective"
- class="org.argeo.cms.ui.workbench.UserHomePerspective"
- icon="platform:/plugin/org.argeo.cms.ui.theme/platform:/plugin/org.argeo.cms.ui.theme/icons/home.png"
- name="Home">
- </perspective>
- <perspective
- id="org.argeo.cms.ui.workbench.adminMaintenancePerspective"
- class="org.argeo.cms.ui.workbench.MaintenancePerspective"
- icon="platform:/plugin/org.argeo.cms.ui.theme/platform:/plugin/org.argeo.cms.ui.theme/icons/maintenance.gif"
- name="Maintenance">
- </perspective>
- <perspective
- id="org.argeo.cms.ui.workbench.osgiPerspective"
- class="org.argeo.cms.ui.workbench.OsgiExplorerPerspective"
- name="Monitoring"
- icon="platform:/plugin/org.argeo.cms.ui.theme/platform:/plugin/org.argeo.cms.ui.theme/icons/osgi_explorer.gif">
- </perspective>
- <perspective
- id="org.argeo.cms.ui.workbench.jcrBrowserPerspective"
- class="org.argeo.cms.ui.workbench.JcrBrowserPerspective"
- name="Data Explorer"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/nodes.gif">
- </perspective>
- </extension>
-
- <!-- Definition of the OSGI perspective -->
- <extension point="org.eclipse.ui.perspectiveExtensions">
- <perspectiveExtension targetID="org.argeo.cms.ui.workbench.osgiPerspective">
- <view
- id="org.argeo.cms.ui.workbench.cmsSessionsView"
- minimized="false"
- ratio="0.5"
- relationship="left"
- relative="org.eclipse.ui.editorss"/>
- <view
- id="org.argeo.cms.ui.workbench.modulesView"
- minimized="false"
- relationship="stack"
- relative="org.argeo.cms.ui.workbench.cmsSessionsView"/>
- <view
- id="org.argeo.cms.ui.workbench.bundlesView"
- minimized="false"
- relationship="stack"
- relative="org.argeo.cms.ui.workbench.modulesView"/>
- <view
- id="org.argeo.cms.ui.workbench.multiplePackagesView"
- minimized="false"
- relationship="stack"
- relative="org.argeo.cms.ui.workbench.bundlesView"/>
- </perspectiveExtension>
- </extension>
-
-
- <!-- VIEWS -->
- <extension
- point="org.eclipse.ui.views">
- <!-- Security -->
- <view
- id="org.argeo.cms.ui.workbench.usersView"
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/person.png"
- name="Users"
- restorable="true">
- </view>
- <view
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/group.png"
- id="org.argeo.cms.ui.workbench.groupsView"
- name="Groups"
- restorable="false">
- </view>
- <!-- Home -->
- <view
- id="org.argeo.cms.ui.workbench.userProfile"
- class="org.argeo.cms.ui.workbench.useradmin.UserProfile"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/person-logged-in.png"
- name="Profile"
- restorable="true">
- </view>
- <!-- Maintenance -->
- <view
- id="org.argeo.cms.ui.workbench.logView"
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- name="Log"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/log.gif"
- restorable="true">
- </view>
- <view
- id="org.argeo.cms.ui.workbench.adminLogView"
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- name="Admin Log"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/adminLog.gif"
- restorable="true">
- </view>
- <!-- OSGi Monitor -->
- <view
- name="Modules"
- id="org.argeo.cms.ui.workbench.modulesView"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/service_published.gif"
- class="org.argeo.cms.ui.workbench.osgi.ModulesView">
- </view>
- <view
- name="CMS Session"
- id="org.argeo.cms.ui.workbench.cmsSessionsView"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/service_published.gif"
- class="org.argeo.cms.ui.workbench.osgi.CmsSessionsView">
- </view>
- <view
- name="Bundles"
- id="org.argeo.cms.ui.workbench.bundlesView"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/bundles.gif"
- class="org.argeo.cms.ui.workbench.osgi.BundlesView">
- </view>
- <view
- name="Multiple Packages"
- id="org.argeo.cms.ui.workbench.multiplePackagesView"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/node.gif"
- class="org.argeo.cms.ui.workbench.osgi.MultiplePackagesView">
- </view>
- <!-- Data Explorer -->
- <view
- name="JCR"
- id="org.argeo.cms.ui.workbench.jcrBrowserView"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/browser.gif"
- class="org.argeo.eclipse.spring.SpringExtensionFactory">
- </view>
- <view
- name="Files"
- id="org.argeo.cms.ui.workbench.nodeFsBrowserView"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/browser.gif"
- class="org.argeo.eclipse.spring.SpringExtensionFactory">
- </view>
- </extension>
-
- <!-- EDITORS -->
- <extension
- point="org.eclipse.ui.editors">
- <!-- Security -->
- <editor
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.cms.ui.workbench.userEditor"
- name="User"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/person.png"
- default="false">
- </editor>
- <editor
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.cms.ui.workbench.groupEditor"
- name="User"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/group.png"
- default="false">
- </editor>
- <!-- Data Explorer -->
- <editor
- name="JCR Query"
- id="org.argeo.cms.ui.workbench.genericJcrQueryEditor"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/query.png"
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- default="false">
- </editor>
- <editor
- name="Node Editor"
- id="org.argeo.cms.ui.workbench.defaultNodeEditor"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/query.png"
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- default="false">
- </editor>
- </extension>
-
- <extension
- point="org.eclipse.ui.commands">
- <!-- User CRUD -->
- <command
- id="org.argeo.cms.ui.workbench.newUser"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="New User">
- </command>
- <command
- id="org.argeo.cms.ui.workbench.deleteUsers"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Delete User">
- </command>
- <command
- id="org.argeo.cms.ui.workbench.userBatchUpdate"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="User batch update">
- </command>
- <!-- Group CRUD -->
- <command
- id="org.argeo.cms.ui.workbench.newGroup"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="New Group">
- </command>
- <command
- id="org.argeo.cms.ui.workbench.deleteGroups"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Delete Group">
- </command>
- <!-- Transaction -->
- <command
- id="org.argeo.cms.ui.workbench.userTransactionHandler"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Manage a user transaction">
- <commandParameter
- id="param.commandId"
- name="begin, commit or rollback">
- </commandParameter>
- </command>
- <!-- Force the refresh when the various listener are not enough -->
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.useradmin.commands.ForceRefresh"
- id="org.argeo.cms.ui.workbench.forceRefresh"
- name="Force Refresh">
- </command>
- <!-- Data Explorer -->
- <command
- defaultHandler="org.argeo.cms.ui.workbench.commands.OpenEditor"
- id="org.argeo.cms.ui.workbench.openEditor"
- name="Open an editor given its ID">
- <commandParameter
- id="param.jcrNodePath"
- name="Node path">
- </commandParameter>
- <!-- The path to the corresponding node if needed. -->
- <commandParameter
- id="param.jcrNodePath"
- name="Node path">
- </commandParameter>
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.GetNodeSize"
- id="org.argeo.cms.ui.workbench.getNodeSize"
- name="Get node size">
- </command>
- <command
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- id="org.argeo.cms.ui.workbench.addRemoteRepository"
- name="Add remote JCR repository">
- <!-- <commandParameter
- id="param.repositoryUri"
- name="Repository URI">
- </commandParameter> -->
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.RemoveRemoteRepository"
- id="org.argeo.cms.ui.workbench.removeRemoteRepository"
- name="Remove remote JCR repository">
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.AddFolderNode"
- id="org.argeo.cms.ui.workbench.addFolderNode"
- name="Create a new folder">
- </command>
- <command
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- id="org.argeo.cms.ui.workbench.addPrivileges"
- name="Add Privileges">
- </command>
- <command
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- id="org.argeo.cms.ui.workbench.removePrivileges"
- name="Remove Privileges">
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.CreateWorkspace"
- id="org.argeo.cms.ui.workbench.createWorkspace"
- name="Create a new workspace">
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.Refresh"
- id="org.argeo.cms.ui.workbench.refresh"
- name="Refresh">
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.DeleteNodes"
- id="org.argeo.cms.ui.workbench.deleteNodes"
- name="Delete nodes">
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.UploadFiles"
- id="org.argeo.cms.ui.workbench.uploadFiles"
- name="Upload files">
- </command>
- <!-- <command
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- id="org.argeo.cms.ui.workbench.openFile"
- name="Open current file">
- </command> -->
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.DumpNode"
- id="org.argeo.cms.ui.workbench.dumpNode"
- name="Dump Current Selected Node">
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.RenameNode"
- id="org.argeo.cms.ui.workbench.renameNode"
- name="Rename Current Selected Node">
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.ConfigurableNodeDump"
- id="org.argeo.cms.ui.workbench.nodeConfigurableDump"
- name="Configurable dump of the selected Node">
- </command>
- <command
- defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.SortChildNodes"
- id="org.argeo.cms.ui.workbench.sortChildNodes"
- name="Sort node tree">
- <!-- FIXME: default value does not work -->
- <state
- id="org.argeo.cms.ui.workbench.sortChildNodes.toggleState"
- class="org.eclipse.ui.handlers.RegistryToggleState:true" >
- <!-- <class class="org.eclipse.jface.commands.ToggleState">
- <parameter
- name="default"
- value="true" />
- </class> -->
- </state>
- </command>
- <!-- Utility to provide sub menues when we don't want to define a default command for this menu -->
- <command
- id="org.argeo.cms.ui.workbench.doNothing"
- defaultHandler="org.argeo.cms.ui.workbench.commands.DoNothing"
- name="Open menu">
- </command>
- </extension>
-
- <!-- MENU CONTRIBUTIONS -->
- <extension
- point="org.eclipse.ui.menus">
- <!-- Main tool bar menu
- <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar">
- <toolbar id="org.argeo.cms.ui.workbench.userToolbar">
- <command
- commandId="org.argeo.cms.ui.workbench.rap.mainMenuCommand"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/home.png"
- id="org.argeo.cms.ui.workbench.rap.mainMenu"
- style="pulldown">
- </command>
- <command commandId="org.eclipse.ui.file.save" icon="platform:/plugin/org.argeo.cms.ui.theme/icons/save.png"/>
- <command commandId="org.eclipse.ui.file.saveAll" icon="platform:/plugin/org.argeo.cms.ui.theme/icons/save-all.png"/>
- </toolbar>
- </menuContribution>
- -->
- <menuContribution
- locationURI="toolbar:org.argeo.cms.ui.workbench.userToolbar?after=org.eclipse.ui.file.saveAll">
- <!-- Transaction management -->
- <command
- commandId="org.argeo.cms.ui.workbench.userTransactionHandler"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/commit.gif"
- label="Commit Transaction"
- style="push"
- tooltip="Commit a user transaction">
- <parameter name="param.commandId" value="transaction.commit" />
- <visibleWhen>
- <with variable="org.argeo.cms.ui.workbench.userTransactionState">
- <equals value="status.active" />
- </with>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.userTransactionHandler"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/rollback.gif"
- label="Rollback Transaction"
- style="push"
- tooltip="Abandon current changes and rollback to the latest commited version">
- <parameter name="param.commandId" value="transaction.rollback" />
- <visibleWhen>
- <with variable="org.argeo.cms.ui.workbench.userTransactionState">
- <equals value="status.active" />
- </with>
- </visibleWhen>
- </command>
- </menuContribution>
-
- <!-- UsersView specific toolbar menu -->
- <menuContribution
- locationURI="toolbar:org.argeo.cms.ui.workbench.usersView">
- <command
- commandId="org.argeo.cms.ui.workbench.deleteUsers"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/delete.png"
- label="Delete"
- tooltip="Delete selected users">
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.forceRefresh"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/refresh.png"
- label="Refresh"
- tooltip="Force the full refresh of the user list">
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.newUser"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/add.png"
- label="Add"
- tooltip="Create a new user">
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.userBatchUpdate"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/batch.gif"
- label="Update users"
- tooltip="Perform maintenance activities on a list of chosen users">
- </command>
- </menuContribution>
-
- <!-- GroupsView specific toolbar menu -->
- <menuContribution
- locationURI="toolbar:org.argeo.cms.ui.workbench.groupsView">
- <command
- commandId="org.argeo.cms.ui.workbench.deleteGroups"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/delete.png"
- label="Delete Group"
- tooltip="Delete selected groups">
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.forceRefresh"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/refresh.png"
- label="Refresh list"
- tooltip="Force the full refresh of the group list">
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.newGroup"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/add.png"
- label="Add Group"
- tooltip="Create a new group">
- </command>
- </menuContribution>
-
- <!-- Browser view specific menu -->
- <menuContribution
- locationURI="menu:org.argeo.cms.ui.workbench.jcrBrowserView">
- <!-- See bug 149 -->
- <!-- <command
- commandId="org.argeo.cms.ui.workbench.openGenericJcrQueryEditor"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/query.png"
- style="push">
- </command> -->
- <command
- commandId="org.argeo.cms.ui.workbench.addRemoteRepository"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/addRepo.gif"
- style="push">
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.sortChildNodes"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/sort.gif"
- style="toggle"
- label="Sort child nodes"
- tooltip="NOTE: displaying unsorted nodes will enhance overall performances">
- </command>
- </menuContribution>
- <!-- Browser view popup context menu -->
- <menuContribution
- locationURI="popup:org.argeo.cms.ui.workbench.jcrBrowserView">
- <command
- commandId="org.argeo.cms.ui.workbench.refresh"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/refresh.png"
- style="push">
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.addFolderNode"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/addFolder.gif"
- label="Add Folder..."
- style="push">
- <visibleWhen>
- <iterate>
- <and>
- <or>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.SingleJcrNodeElem">
- </instanceof>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.WorkspaceElem">
- </instanceof>
- </or>
- <with variable="activeMenuSelection"><count value="1"/></with>
- </and>
- </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.addPrivileges"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/addPrivileges.gif"
- label="Add Privileges..."
- style="push">
- <visibleWhen>
- <iterate>
- <and>
- <or>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.SingleJcrNodeElem">
- </instanceof>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.WorkspaceElem">
- </instanceof>
- </or>
- <with variable="activeMenuSelection"><count value="1"/></with>
- </and>
- </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.removePrivileges"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/removePrivileges.gif"
- label="Remove Privileges..."
- style="push">
- <visibleWhen>
- <iterate>
- <and>
- <or>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.SingleJcrNodeElem">
- </instanceof>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.WorkspaceElem">
- </instanceof>
- </or>
- <with variable="activeMenuSelection"><count value="1"/></with>
- </and>
- </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.createWorkspace"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/addWorkspace.png"
- label="Create Workspace..."
- style="push">
- <visibleWhen>
- <iterate>
- <and>
- <or>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.RepositoryElem">
- </instanceof>
- </or>
- <with variable="activeMenuSelection"><count value="1"/></with>
- </and>
- </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.deleteNodes"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/remove.gif"
- label="Delete Nodes"
- style="push">
- <visibleWhen>
- <iterate>
- <or>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.SingleJcrNodeElem" />
- <instanceof
- value="org.argeo.cms.ui.jcr.model.WorkspaceElem" />
- </or>
- </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.uploadFiles"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/import_fs.png"
- style="push"
- tooltip="Upload files from the local file sytem">
- <visibleWhen>
- <iterate>
- <and>
- <or>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.SingleJcrNodeElem" />
- <instanceof
- value="org.argeo.cms.ui.jcr.model.WorkspaceElem" />
- </or>
- <with variable="activeMenuSelection"><count value="1"/></with>
- </and>
- </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.addRemoteRepository"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/addRepo.gif"
- style="push">
- <visibleWhen>
- <iterate>
- <or>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.RepositoriesElem" />
- <instanceof
- value="org.argeo.cms.ui.jcr.model.RepositoryElem" />
- </or>
- </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.removeRemoteRepository"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/remove.gif"
- style="push">
- <visibleWhen>
- <iterate>
- <or>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.RemoteRepositoryElem" />
- </or>
- </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.getNodeSize"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/getSize.gif"
- style="push">
- <visibleWhen>
- <iterate>
- <or>
- <instanceof
- value="org.argeo.cms.ui.jcr.model.SingleJcrNodeElem" />
- <instanceof
- value="org.argeo.cms.ui.jcr.model.WorkspaceElem" />
- </or>
- </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.dumpNode"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/dumpNode.gif"
- label="Dump Node"
- style="push">
- <visibleWhen>
- <iterate> <and>
- <instanceof value="org.argeo.cms.ui.jcr.model.SingleJcrNodeElem"></instanceof>
- <with variable="activeMenuSelection"><count value="1"/></with>
- </and> </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.renameNode"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/rename.gif"
- label="Rename..."
- style="push">
- <visibleWhen>
- <iterate> <and>
- <instanceof value="org.argeo.cms.ui.jcr.model.SingleJcrNodeElem"></instanceof>
- <with variable="activeMenuSelection"><count value="1"/></with>
- </and> </iterate>
- </visibleWhen>
- </command>
- <command
- commandId="org.argeo.cms.ui.workbench.nodeConfigurableDump"
- icon="platform:/plugin/org.argeo.cms.ui.theme/icons/dumpNode.gif"
- label="Configurable dump..."
- style="push">
- <visibleWhen>
- <iterate>
- <and>
- <instanceof value="org.argeo.cms.ui.jcr.model.SingleJcrNodeElem"></instanceof>
- <with variable="activeMenuSelection"><count value="1"/></with>
- </and>
- </iterate>
- </visibleWhen>
- </command>
- </menuContribution>
-
- </extension>
-
- <!-- SERVICES -->
- <extension
- point="org.eclipse.ui.services">
- <sourceProvider
- id="org.argeo.cms.ui.workbench.userTransactionProvider"
- provider="org.argeo.eclipse.spring.SpringExtensionFactory" >
- <variable
- name="org.argeo.cms.ui.workbench.userTransactionState"
- priorityLevel="workbench">
- </variable>
- </sourceProvider>
- <sourceProvider
- provider="org.argeo.cms.ui.workbench.util.RolesSourceProvider">
- <variable
- name="org.argeo.cms.ui.workbench.rolesVariable"
- priorityLevel="workbench">
- </variable>
- </sourceProvider>
- </extension>
-
- <!-- ACTIVITIES -->
- <extension
- point="org.eclipse.ui.activities">
-
- <!-- Admin -->
- <activityPatternBinding
- pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.osgiPerspective"
- isEqualityPattern="true"
- activityId="org.argeo.cms.ui.workbench.adminActivity">
- </activityPatternBinding>
- <activityPatternBinding
- pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.jcrBrowserPerspective"
- isEqualityPattern="true"
- activityId="org.argeo.cms.ui.workbench.adminActivity">
- </activityPatternBinding>
- <activityPatternBinding
- pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.adminMaintenancePerspective"
- isEqualityPattern="true"
- activityId="org.argeo.cms.ui.workbench.adminActivity">
- </activityPatternBinding>
- <activityPatternBinding
- pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.adminLogView"
- isEqualityPattern="true"
- activityId="org.argeo.cms.ui.workbench.adminActivity">
- </activityPatternBinding>
-
- <!-- UserAdmin -->
- <activityPatternBinding
- pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.adminSecurityPerspective"
- activityId="org.argeo.cms.ui.workbench.userAdminActivity"
- isEqualityPattern="true">
- </activityPatternBinding>
-
- <!-- Users -->
- <activityPatternBinding
- pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.userHomePerspective"
- isEqualityPattern="true"
- activityId="org.argeo.cms.ui.workbench.userActivity">
- </activityPatternBinding>
- <activityPatternBinding
- pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.userProfile"
- isEqualityPattern="true"
- activityId="org.argeo.cms.ui.workbench.userActivity">
- </activityPatternBinding>
-
-
- <!-- Activity declaration -->
- <activity
- description="Authenticated users"
- id="org.argeo.cms.ui.workbench.userActivity"
- name="User">
- <enabledWhen>
- <with variable="roles">
- <iterate ifEmpty="false" operator="or">
- <equals value="cn=user,ou=roles,ou=node" />
- </iterate>
- </with>
- </enabledWhen>
- </activity>
- <activity
- description="Admins"
- id="org.argeo.cms.ui.workbench.adminActivity"
- name="Admin">
- <enabledWhen>
- <with variable="roles">
- <iterate ifEmpty="false" operator="or">
- <equals value="cn=admin,ou=roles,ou=node" />
- </iterate>
- </with>
- </enabledWhen>
- </activity>
- <activity
- description="User Admins"
- id="org.argeo.cms.ui.workbench.userAdminActivity"
- name="User Admin">
- <enabledWhen>
- <with variable="roles">
- <iterate ifEmpty="false" operator="or">
- <equals value="cn=userAdmin,ou=roles,ou=node" />
- </iterate>
- </with>
- </enabledWhen>
- </activity>
- <activity
- description="Non admins"
- id="org.argeo.cms.ui.workbench.notAdminActivity"
- name="Not Admin">
- <enabledWhen>
- <not>
- <with variable="roles">
- <iterate ifEmpty="false" operator="or">
- <equals value="cn=admin,ou=roles,ou=node" />
- </iterate>
- </with>
- </not>
- </enabledWhen>
- </activity>
- <activity
- description="Non remote"
- id="org.argeo.cms.ui.workbench.notRemoteActivity"
- name="NonRemote">
- <enabledWhen>
- <not>
- <with variable="roles">
- <iterate ifEmpty="false" operator="or">
- <equals value="ROLE_REMOTE" />
- </iterate>
- </with>
- </not>
- </enabledWhen>
- </activity>
- </extension>
-
- <!-- STARTUP -->
- <extension point="org.eclipse.ui.startup">
- <startup class="org.argeo.cms.ui.workbench.internal.useradmin.PartStateChanged"/>
- </extension>
-</plugin>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<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.slc.legacy.commons</groupId>
- <artifactId>argeo-commons-legacy</artifactId>
- <version>2.1.104</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.cms.ui.workbench</artifactId>
- <name>CMS Workbench</name>
- <packaging>jar</packaging>
- <dependencies>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.cms.ui</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.eclipse.ui.rap</artifactId>
- <version>${version.argeo-commons}</version>
- <scope>provided</scope>
- </dependency>
-
- <!-- Spring -->
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.beans</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.context</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.gemini</groupId>
- <artifactId>org.eclipse.gemini.blueprint.core</artifactId>
- </dependency>
-
- <!-- Eclipse 3 -->
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp-rap-e3</artifactId>
- <version>${version.argeo-tp}</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.argeo.cms.spring;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.CmsException;
-
-/** Provides base method for executing code with system authorization. */
-abstract class AbstractSystemExecution {
- private final static Log log = LogFactory.getLog(AbstractSystemExecution.class);
- private final Subject subject = new Subject();
-
- /** Authenticate the calling thread */
- protected void authenticateAsSystem() {
- ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- try {
- LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
- lc.login();
- } catch (LoginException e) {
- throw new CmsException("Cannot login as system", e);
- } finally {
- Thread.currentThread().setContextClassLoader(origClassLoader);
- }
- if (log.isTraceEnabled())
- log.trace("System authenticated");
- }
-
- protected void deauthenticateAsSystem() {
- ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- try {
- LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
- lc.logout();
- } catch (LoginException e) {
- throw new CmsException("Cannot logout as system", e);
- } finally {
- Thread.currentThread().setContextClassLoader(origClassLoader);
- }
- }
-
- protected Subject getSubject() {
- return subject;
- }
-}
+++ /dev/null
-package org.argeo.cms.spring;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-
-import org.eclipse.gemini.blueprint.context.DependencyInitializationAwareBeanPostProcessor;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.support.AbstractBeanFactory;
-import org.springframework.beans.factory.support.SecurityContextProvider;
-import org.springframework.beans.factory.support.SimpleSecurityContextProvider;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Executes with a system authentication the instantiation and initialization
- * methods of the application context where it has been defined.
- */
-public class AuthenticatedApplicationContextInitialization extends
- AbstractSystemExecution implements
- DependencyInitializationAwareBeanPostProcessor, ApplicationContextAware {
- /** If non empty, restricts to these beans */
- private List<String> beanNames = new ArrayList<String>();
-
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
- if (beanNames.size() == 0 || beanNames.contains(beanName))
- authenticateAsSystem();
- return bean;
- }
-
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
- if (beanNames.size() == 0 || beanNames.contains(beanName))
- deauthenticateAsSystem();
- return bean;
- }
-
- public void setBeanNames(List<String> beanNames) {
- this.beanNames = beanNames;
- }
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext)
- throws BeansException {
- if (applicationContext.getAutowireCapableBeanFactory() instanceof AbstractBeanFactory) {
- final AbstractBeanFactory beanFactory = ((AbstractBeanFactory) applicationContext
- .getAutowireCapableBeanFactory());
- // retrieve subject's access control context
- // and set it as the bean factory security context
- Subject.doAs(getSubject(), new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- SecurityContextProvider scp = new SimpleSecurityContextProvider(
- AccessController.getContext());
- beanFactory.setSecurityContextProvider(scp);
- return null;
- }
- });
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.spring;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-import javax.transaction.UserTransaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.CmsException;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.UserAdmin;
-
-/**
- * Register one or many roles via a user admin service. Does nothing if the role
- * is already registered.
- */
-public class SimpleRoleRegistration implements Runnable {
- private final static Log log = LogFactory
- .getLog(SimpleRoleRegistration.class);
-
- private String role;
- private List<String> roles = new ArrayList<String>();
- private UserAdmin userAdmin;
- private UserTransaction userTransaction;
-
- @Override
- public void run() {
- try {
- userTransaction.begin();
- if (role != null && !roleExists(role))
- newRole(toDn(role));
-
- for (String r : roles)
- if (!roleExists(r))
- newRole(toDn(r));
- userTransaction.commit();
- } catch (Exception e) {
- try {
- userTransaction.rollback();
- } catch (Exception e1) {
- log.error("Cannot rollback", e1);
- }
- throw new CmsException("Cannot add roles", e);
- }
- }
-
- private boolean roleExists(String role) {
- return userAdmin.getRole(toDn(role).toString()) != null;
- }
-
- protected void newRole(LdapName r) {
- userAdmin.createRole(r.toString(), Role.GROUP);
- log.info("Added role " + r + " required by application.");
- }
-
- public void register(UserAdmin userAdminService, Map<?, ?> properties) {
- this.userAdmin = userAdminService;
- run();
- }
-
- protected LdapName toDn(String name) {
- try {
- return new LdapName("cn=" + name + ",ou=roles,ou=node");
- } catch (InvalidNameException e) {
- throw new CmsException("Badly formatted role name " + name, e);
- }
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- public void setRoles(List<String> roles) {
- this.roles = roles;
- }
-
- public void setUserAdmin(UserAdmin userAdminService) {
- this.userAdmin = userAdminService;
- }
-
- public void setUserTransaction(UserTransaction userTransaction) {
- this.userTransaction = userTransaction;
- }
-
-}
+++ /dev/null
-package org.argeo.cms.spring.osgi;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-
-/**
- * Logs the name and version of an OSGi bundle based on its
- * {@link BundleContext}.
- */
-public class OsgiModuleLabel {
- private final static Log log = LogFactory.getLog(OsgiModuleLabel.class);
-
- private Bundle bundle;
-
- public OsgiModuleLabel() {
- }
-
- /** Sets without logging. */
- public OsgiModuleLabel(Bundle bundle) {
- this.bundle = bundle;
- }
-
- /**
- * Retrieved bundle from a bundle context and logs it. Typically to be set
- * as a Spring bean.
- */
- public void setBundleContext(BundleContext bundleContext) {
- this.bundle = bundleContext.getBundle();
- log.info(msg());
- }
-
- public String msg() {
- String name = bundle.getHeaders().get(Constants.BUNDLE_NAME).toString();
- String symbolicName = bundle.getSymbolicName();
- String version = bundle.getVersion().toString();
- return name + " v" + version + " (" + symbolicName + ")";
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench;
-
-/** Centralize the declaration of Workbench specific CSS Styles */
-public interface CmsWorkbenchStyles {
-
- // Specific People layouting
- String WORKBENCH_FORM_TEXT = "workbench_form_text";
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench;
-
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.argeo.cms.ui.workbench.jcr.NodeFsBrowserView;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Base perspective for the Jcr browser */
-public class JcrBrowserPerspective implements IPerspectiveFactory {
-
- public void createInitialLayout(IPageLayout layout) {
- layout.setEditorAreaVisible(true);
- IFolderLayout upperLeft = layout.createFolder(WorkbenchUiPlugin.PLUGIN_ID + ".upperLeft", IPageLayout.LEFT,
- 0.4f, layout.getEditorArea());
- upperLeft.addView(JcrBrowserView.ID);
- upperLeft.addView(NodeFsBrowserView.ID);
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench;
-
-import org.argeo.cms.ui.workbench.useradmin.AdminLogView;
-import org.argeo.cms.ui.workbench.useradmin.UserProfile;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** First draft of a maintenance perspective. Not yet used */
-public class MaintenancePerspective implements IPerspectiveFactory {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".adminMaintenancePerspective";
-
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
- layout.setEditorAreaVisible(true);
- layout.setFixed(false);
-
- IFolderLayout bottom = layout.createFolder("bottom",
- IPageLayout.BOTTOM, 0.50f, editorArea);
- bottom.addView(AdminLogView.ID);
-
- IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
- 0.30f, editorArea);
- left.addView(UserProfile.ID);
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench;
-
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** OSGi explorer perspective (to be enriched declaratively) */
-public class OsgiExplorerPerspective implements IPerspectiveFactory {
-
- public void createInitialLayout(IPageLayout layout) {
- layout.setEditorAreaVisible(true);
- layout.setFixed(false);
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench;
-
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.GroupsView;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UsersView;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Default perspective to manage users and groups */
-public class SecurityAdminPerspective implements IPerspectiveFactory {
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
- layout.setEditorAreaVisible(true);
- layout.setFixed(false);
-
- IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.3f, editorArea);
- IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, 0.5f, editorArea);
- left.addView(UsersView.ID);
- right.addView(GroupsView.ID);
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench;
-
-import org.argeo.cms.ui.workbench.jcr.NodeFsBrowserView;
-import org.argeo.cms.ui.workbench.useradmin.UserProfile;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Home perspective for the current user */
-public class UserHomePerspective implements IPerspectiveFactory {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".userHomePerspective";
-
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
- layout.setEditorAreaVisible(true);
- layout.setFixed(false);
-
- IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.40f, editorArea);
- left.addView(NodeFsBrowserView.ID);
- left.addView(UserProfile.ID);
- // left.addView(LogView.ID);
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench;
-
-import java.io.IOException;
-import java.util.ResourceBundle;
-
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.widgets.auth.DefaultLoginDialog;
-import org.eclipse.core.runtime.ILogListener;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/** The activator class controls the plug-in life cycle */
-public class WorkbenchUiPlugin extends AbstractUIPlugin implements ILogListener {
- private final static Log log = LogFactory.getLog(WorkbenchUiPlugin.class);
-
- // The plug-in ID
- public final static String PLUGIN_ID = "org.argeo.cms.ui.workbench"; //$NON-NLS-1$
- public final static String THEME_PLUGIN_ID = "org.argeo.cms.ui.theme"; //$NON-NLS-1$
-
- private ResourceBundle messages;
- private static BundleContext bundleContext;
-
- public static InheritableThreadLocal<Display> display = new InheritableThreadLocal<Display>() {
-
- @Override
- protected Display initialValue() {
- return Display.getCurrent();
- }
- };
-
- final static String CONTEXT_KEYRING = "KEYRING";
-
- private CallbackHandler defaultCallbackHandler;
- private ServiceRegistration<CallbackHandler> defaultCallbackHandlerReg;
-
- // The shared instance
- private static WorkbenchUiPlugin plugin;
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- bundleContext = context;
- defaultCallbackHandler = new DefaultCallbackHandler();
- defaultCallbackHandlerReg = context.registerService(CallbackHandler.class, defaultCallbackHandler, null);
-
- plugin = this;
- messages = ResourceBundle.getBundle(PLUGIN_ID + ".messages");
- Platform.addLogListener(this);
- if (log.isTraceEnabled())
- log.trace("Eclipse logging now directed to standard logging");
- }
-
- public void stop(BundleContext context) throws Exception {
- bundleContext = null;
- defaultCallbackHandlerReg.unregister();
- }
-
- public static BundleContext getBundleContext() {
- return bundleContext;
- }
-
- /*
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static WorkbenchUiPlugin getDefault() {
- return plugin;
- }
-
- protected class DefaultCallbackHandler implements CallbackHandler {
- public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
-
- // if (display != null) // RCP
- Display displayToUse = display.get();
- if (displayToUse == null)// RCP
- displayToUse = Display.getDefault();
- displayToUse.syncExec(new Runnable() {
- public void run() {
- DefaultLoginDialog dialog = new DefaultLoginDialog(display.get().getActiveShell());
- try {
- dialog.handle(callbacks);
- } catch (IOException e) {
- throw new CmsException("Cannot open dialog", e);
- }
- }
- });
- // else {// RAP
- // DefaultLoginDialog dialog = new DefaultLoginDialog();
- // dialog.handle(callbacks);
- // }
- }
-
- }
-
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(THEME_PLUGIN_ID, path);
- }
-
- /** Returns the internationalized label for the given key */
- public static String getMessage(String key) {
- try {
- return getDefault().messages.getString(key);
- } catch (NullPointerException npe) {
- log.warn(key + " not found.");
- return key;
- }
- }
-
- /**
- * Gives access to the internationalization message bundle. Returns null in case
- * this UiPlugin is not started (for JUnit tests, by instance)
- */
- public static ResourceBundle getMessagesBundle() {
- if (getDefault() != null)
- // To avoid NPE
- return getDefault().messages;
- else
- return null;
- }
-
- public void logging(IStatus status, String plugin) {
- Log pluginLog = LogFactory.getLog(plugin);
- Integer severity = status.getSeverity();
- if (severity == IStatus.ERROR)
- pluginLog.error(status.getMessage(), status.getException());
- else if (severity == IStatus.WARNING)
- pluginLog.warn(status.getMessage(), status.getException());
- else if (severity == IStatus.INFO)
- pluginLog.info(status.getMessage(), status.getException());
- else if (severity == IStatus.CANCEL)
- if (pluginLog.isDebugEnabled())
- pluginLog.debug(status.getMessage(), status.getException());
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.commands;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Utilitary command to enable sub menus in various toolbars. Does nothing */
-public class DoNothing extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".doNothing";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.commands;
-
-import static org.argeo.cms.CmsMsg.changePassword;
-import static org.argeo.cms.CmsMsg.currentPassword;
-import static org.argeo.cms.CmsMsg.newPassword;
-import static org.argeo.cms.CmsMsg.passwordChanged;
-import static org.argeo.cms.CmsMsg.repeatNewPassword;
-import static org.eclipse.jface.dialogs.IMessageProvider.INFORMATION;
-
-import java.security.AccessController;
-import java.util.Arrays;
-
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-import javax.security.auth.Subject;
-import javax.security.auth.x500.X500Principal;
-import javax.transaction.UserTransaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.CryptoKeyring;
-import org.argeo.cms.CmsException;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdmin;
-
-/** Open the change password dialog */
-public class OpenChangePasswordDialog extends AbstractHandler {
- private final static Log log = LogFactory.getLog(OpenChangePasswordDialog.class);
- private UserAdmin userAdmin;
- private UserTransaction userTransaction;
- private CryptoKeyring keyring = null;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ChangePasswordDialog dialog = new ChangePasswordDialog(HandlerUtil.getActiveShell(event), userAdmin);
- if (dialog.open() == Dialog.OK) {
- MessageDialog.openInformation(HandlerUtil.getActiveShell(event), passwordChanged.lead(),
- passwordChanged.lead());
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- protected void changePassword(char[] oldPassword, char[] newPassword) {
- Subject subject = Subject.getSubject(AccessController.getContext());
- String name = subject.getPrincipals(X500Principal.class).iterator().next().toString();
- LdapName dn;
- try {
- dn = new LdapName(name);
- } catch (InvalidNameException e) {
- throw new CmsException("Invalid user dn " + name, e);
- }
- User user = (User) userAdmin.getRole(dn.toString());
- if (!user.hasCredential(null, oldPassword))
- throw new CmsException("Invalid password");
- if (Arrays.equals(newPassword, new char[0]))
- throw new CmsException("New password empty");
- try {
- userTransaction.begin();
- user.getCredentials().put(null, newPassword);
- if (keyring != null) {
- keyring.changePassword(oldPassword, newPassword);
- // TODO change secret keys in the CMS session
- }
- userTransaction.commit();
- } catch (Exception e) {
- try {
- userTransaction.rollback();
- } catch (Exception e1) {
- log.error("Could not roll back", e1);
- }
- if (e instanceof RuntimeException)
- throw (RuntimeException) e;
- else
- throw new CmsException("Cannot change password", e);
- }
- }
-
- class ChangePasswordDialog extends TitleAreaDialog {
- private static final long serialVersionUID = -6963970583882720962L;
- private Text oldPassword, newPassword1, newPassword2;
-
- public ChangePasswordDialog(Shell parentShell, UserAdmin securityService) {
- super(parentShell);
- }
-
- protected Point getInitialSize() {
- return new Point(400, 450);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogarea = (Composite) super.createDialogArea(parent);
- dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Composite composite = new Composite(dialogarea, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- oldPassword = createLP(composite, currentPassword.lead());
- newPassword1 = createLP(composite, newPassword.lead());
- newPassword2 = createLP(composite, repeatNewPassword.lead());
-
- setMessage(changePassword.lead(), INFORMATION);
- parent.pack();
- oldPassword.setFocus();
- return composite;
- }
-
- @Override
- protected void okPressed() {
- try {
- if (!newPassword1.getText().equals(newPassword2.getText()))
- throw new CmsException("New passwords are different");
- changePassword(oldPassword.getTextChars(), newPassword1.getTextChars());
- close();
- } catch (Exception e) {
- ErrorFeedback.show("Cannot change password", e);
- }
- }
-
- /** Creates label and password. */
- protected Text createLP(Composite parent, String label) {
- new Label(parent, SWT.NONE).setText(label);
- Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.PASSWORD | SWT.BORDER);
- text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- return text;
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(changePassword.lead());
- }
- }
-
- public void setUserAdmin(UserAdmin userAdmin) {
- this.userAdmin = userAdmin;
- }
-
- public void setUserTransaction(UserTransaction userTransaction) {
- this.userTransaction = userTransaction;
- }
-
- public void setKeyring(CryptoKeyring keyring) {
- this.keyring = keyring;
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.commands;
-
-import javax.jcr.Node;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.JcrQueryEditorInput;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.NodeEditorInput;
-import org.argeo.cms.ui.workbench.jcr.DefaultNodeEditor;
-import org.argeo.cms.ui.workbench.jcr.GenericJcrQueryEditor;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Open a {@link Node} editor of a specific type given the node path */
-public class OpenEditor extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".openEditor";
-
- public final static String PARAM_PATH = "param.jcrNodePath";
- public final static String PARAM_EDITOR_ID = "param.editorId";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String editorId = event.getParameter(PARAM_EDITOR_ID);
- try {
- IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(
- event).getActivePage();
- if (DefaultNodeEditor.ID.equals(editorId)) {
- String path = event.getParameter(PARAM_PATH);
- NodeEditorInput nei = new NodeEditorInput(path);
- activePage.openEditor(nei, DefaultNodeEditor.ID);
- } else if (GenericJcrQueryEditor.ID.equals(editorId)) {
- JcrQueryEditorInput editorInput = new JcrQueryEditorInput(
- GenericJcrQueryEditor.ID, null);
- activePage.openEditor(editorInput, editorId);
- }
- } catch (PartInitException e) {
- throw new EclipseUiException(
- "Cannot open editor of ID " + editorId, e);
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.commands;
-
-import org.argeo.cms.ui.workbench.UserHomePerspective;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Default action of the user menu */
-public class OpenHomePerspective extends AbstractHandler {
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- try {
- HandlerUtil.getActiveSite(event).getWorkbenchWindow()
- .openPage(UserHomePerspective.ID, null);
- } catch (WorkbenchException e) {
- ErrorFeedback.show("Cannot open home perspective", e);
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal;
-
-/** Constants used across the application. */
-@Deprecated
-public interface WorkbenchConstants {
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.jcr.model.WorkspaceElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.eclipse.ui.dialogs.SingleValue;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Adds a node of type nt:folder, only on {@link SingleJcrNodeElem} and
- * {@link WorkspaceElem} TreeObject types.
- *
- * This handler assumes that a selection provider is available and picks only
- * first selected item. It is UI's job to enable the command only when the
- * selection contains one and only one element. Thus no parameter is passed
- * through the command.
- */
-public class AddFolderNode extends AbstractHandler {
-
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".addFolderNode";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
- .getActivePage().getSelection();
-
- JcrBrowserView view = (JcrBrowserView) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage()
- .findView(HandlerUtil.getActivePartId(event));
-
- if (selection != null && !selection.isEmpty()
- && selection instanceof IStructuredSelection) {
- Object obj = ((IStructuredSelection) selection).getFirstElement();
- TreeParent treeParentNode = null;
- Node jcrParentNode = null;
-
- if (obj instanceof SingleJcrNodeElem) {
- treeParentNode = (TreeParent) obj;
- jcrParentNode = ((SingleJcrNodeElem) treeParentNode).getNode();
- } else if (obj instanceof WorkspaceElem) {
- treeParentNode = (TreeParent) obj;
- jcrParentNode = ((WorkspaceElem) treeParentNode).getRootNode();
- } else
- return null;
-
- String folderName = SingleValue.ask("Folder name",
- "Enter folder name");
- if (folderName != null) {
- try {
- jcrParentNode.addNode(folderName, NodeType.NT_FOLDER);
- jcrParentNode.getSession().save();
- view.nodeAdded(treeParentNode);
- } catch (RepositoryException e) {
- ErrorFeedback.show("Cannot create folder " + folderName
- + " under " + treeParentNode, e);
- }
- }
- } else {
- ErrorFeedback.show(WorkbenchUiPlugin
- .getMessage("errorUnvalidNtFolderNodeType"));
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.jcr.model.WorkspaceElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.AddPrivilegeWizard;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.osgi.service.useradmin.UserAdmin;
-
-/** Open a dialog to add privileges on the selected node to a chosen group */
-public class AddPrivileges extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".addPrivileges";
-
- /* DEPENDENCY INJECTION */
- private UserAdmin userAdmin;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
- .getActivePage().getSelection();
- if (selection != null && !selection.isEmpty()
- && selection instanceof IStructuredSelection) {
- Object obj = ((IStructuredSelection) selection).getFirstElement();
- TreeParent treeParentNode = null;
- Node jcrParentNode = null;
-
- if (obj instanceof SingleJcrNodeElem) {
- treeParentNode = (TreeParent) obj;
- jcrParentNode = ((SingleJcrNodeElem) treeParentNode).getNode();
- } else if (obj instanceof WorkspaceElem) {
- treeParentNode = (TreeParent) obj;
- jcrParentNode = ((WorkspaceElem) treeParentNode).getRootNode();
- } else
- return null;
-
- try {
- String targetPath = jcrParentNode.getPath();
- AddPrivilegeWizard wizard = new AddPrivilegeWizard(
- jcrParentNode.getSession(), targetPath, userAdmin);
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
- dialog.open();
- return null;
- } catch (RepositoryException re) {
- throw new EclipseUiException("Unable to retrieve "
- + "path or JCR session to add privilege on "
- + jcrParentNode, re);
- }
- } else {
- ErrorFeedback.show("Cannot add privileges");
- }
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdmin(UserAdmin userAdmin) {
- this.userAdmin = userAdmin;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.net.URI;
-import java.util.Hashtable;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.cms.ui.workbench.internal.WorkbenchConstants;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Connect to a remote repository and, if successful publish it as an OSGi
- * service.
- */
-public class AddRemoteRepository extends AbstractHandler implements WorkbenchConstants, ArgeoNames {
-
- private RepositoryFactory repositoryFactory;
- private Repository nodeRepository;
- private Keyring keyring;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- RemoteRepositoryLoginDialog dlg = new RemoteRepositoryLoginDialog(Display.getDefault().getActiveShell());
- if (dlg.open() == Dialog.OK) {
- CommandUtils.callCommand(Refresh.ID);
- }
- return null;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-
- class RemoteRepositoryLoginDialog extends TitleAreaDialog {
- private static final long serialVersionUID = 2234006887750103399L;
- private Text name;
- private Text uri;
- private Text username;
- private Text password;
- private Button saveInKeyring;
-
- public RemoteRepositoryLoginDialog(Shell parentShell) {
- super(parentShell);
- }
-
- protected Point getInitialSize() {
- return new Point(600, 400);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogarea = (Composite) super.createDialogArea(parent);
- dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Composite composite = new Composite(dialogarea, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- setMessage("Login to remote repository", IMessageProvider.NONE);
- name = createLT(composite, "Name", "remoteRepository");
- uri = createLT(composite, "URI", "http://localhost:7070/jcr/node");
- username = createLT(composite, "User", "");
- password = createLP(composite, "Password");
-
- saveInKeyring = createLC(composite, "Remember password", false);
- parent.pack();
- return composite;
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- Button test = createButton(parent, 2, "Test", false);
- test.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = -1829962269440419560L;
-
- public void widgetSelected(SelectionEvent arg0) {
- testConnection();
- }
- });
- }
-
- void testConnection() {
- Session session = null;
- try {
- URI checkedUri = new URI(uri.getText());
- String checkedUriStr = checkedUri.toString();
-
- Hashtable<String, String> params = new Hashtable<String, String>();
- params.put(NodeConstants.LABELED_URI, checkedUriStr);
- Repository repository = repositoryFactory.getRepository(params);
- if (username.getText().trim().equals("")) {// anonymous
- // FIXME make it more generic
- session = repository.login("main");
- } else {
- // FIXME use getTextChars() when upgrading to 3.7
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=297412
- char[] pwd = password.getText().toCharArray();
- SimpleCredentials sc = new SimpleCredentials(username.getText(), pwd);
- session = repository.login(sc, "main");
- MessageDialog.openInformation(getParentShell(), "Success",
- "Connection to '" + uri.getText() + "' successful");
- }
- } catch (Exception e) {
- ErrorFeedback.show("Connection test failed for " + uri.getText(), e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- }
-
- @Override
- protected void okPressed() {
- Session nodeSession = null;
- try {
- nodeSession = nodeRepository.login();
- Node home = NodeUtils.getUserHome(nodeSession);
-
- Node remote = home.hasNode(ARGEO_REMOTE) ? home.getNode(ARGEO_REMOTE) : home.addNode(ARGEO_REMOTE);
- if (remote.hasNode(name.getText()))
- throw new EclipseUiException("There is already a remote repository named " + name.getText());
- Node remoteRepository = remote.addNode(name.getText(), ArgeoTypes.ARGEO_REMOTE_REPOSITORY);
- remoteRepository.setProperty(ARGEO_URI, uri.getText());
- remoteRepository.setProperty(ARGEO_USER_ID, username.getText());
- nodeSession.save();
- if (saveInKeyring.getSelection()) {
- String pwdPath = remoteRepository.getPath() + '/' + ARGEO_PASSWORD;
- keyring.set(pwdPath, password.getText().toCharArray());
- }
- nodeSession.save();
- MessageDialog.openInformation(getParentShell(), "Repository Added",
- "Remote repository '" + username.getText() + "@" + uri.getText() + "' added");
-
- super.okPressed();
- } catch (Exception e) {
- ErrorFeedback.show("Cannot add remote repository", e);
- } finally {
- JcrUtils.logoutQuietly(nodeSession);
- }
- }
-
- /** Creates label and text. */
- protected Text createLT(Composite parent, String label, String initial) {
- new Label(parent, SWT.NONE).setText(label);
- Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
- text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- text.setText(initial);
- return text;
- }
-
- /** Creates label and check. */
- protected Button createLC(Composite parent, String label, Boolean initial) {
- new Label(parent, SWT.NONE).setText(label);
- Button check = new Button(parent, SWT.CHECK);
- check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- check.setSelection(initial);
- return check;
- }
-
- protected Text createLP(Composite parent, String label) {
- new Label(parent, SWT.NONE).setText(label);
- Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER | SWT.PASSWORD);
- text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- return text;
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * First draft of a wizard that enable configurable recursive dump of the
- * current selected Node (Only one at a time). Enable among other to export
- * children Nodes and to choose to export binaries or not. It is useful to
- * retrieve business data from live systems to prepare migration or test locally
- */
-public class ConfigurableNodeDump extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".nodeConfigurableDump";
-
- private final static DateFormat df = new SimpleDateFormat(
- "yyyy-MM-dd_HH-mm");
-
- public final static int EXPORT_NODE = 0;
- public final static int EXPORT_CHILDREN = 1;
- public final static int EXPORT_GRAND_CHILDREN = 2;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
- .getActivePage().getSelection();
- if (selection == null || !(selection instanceof IStructuredSelection))
- return null;
-
- Iterator<?> lst = ((IStructuredSelection) selection).iterator();
- if (lst.hasNext()) {
- Object element = lst.next();
- if (element instanceof SingleJcrNodeElem) {
- SingleJcrNodeElem sjn = (SingleJcrNodeElem) element;
- Node node = sjn.getNode();
-
- ConfigureDumpWizard wizard = new ConfigureDumpWizard(
- HandlerUtil.getActiveShell(event),
- "Import Resource CSV");
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
- int result = dialog.open();
-
- if (result == Window.OK) {
-
- String dateVal = df.format(new GregorianCalendar()
- .getTime());
- try {
-
- Path tmpDirPath = Files.createTempDirectory(dateVal
- + "-NodeDump-");
- List<Node> toExport = retrieveToExportNodes(node,
- wizard.currExportType);
-
- for (Node currNode : toExport) {
- FileOutputStream fos;
- String fileName = wizard.prefix
- + JcrUtils.replaceInvalidChars(currNode
- .getName()) + "_" + dateVal
- + ".xml";
- File currFile = new File(tmpDirPath.toString()
- + "/" + fileName);
- currFile.createNewFile();
- fos = new FileOutputStream(currFile);
- node.getSession().exportSystemView(
- currNode.getPath(), fos,
- !wizard.includeBinaries, false);
- fos.flush();
- fos.close();
- }
- } catch (RepositoryException e) {
- throw new EclipseUiException(
- "Unable to perform SystemExport on " + node, e);
- } catch (IOException e) {
- throw new EclipseUiException("Unable to SystemExport "
- + node, e);
- }
- }
- }
- }
- return null;
- }
-
- private List<Node> retrieveToExportNodes(Node node, int currExportType)
- throws RepositoryException {
- List<Node> nodes = new ArrayList<Node>();
- switch (currExportType) {
- case EXPORT_NODE:
- nodes.add(node);
- return nodes;
- case EXPORT_CHILDREN:
- return JcrUtils.nodeIteratorToList(node.getNodes());
- case EXPORT_GRAND_CHILDREN:
- NodeIterator nit = node.getNodes();
- while (nit.hasNext())
- nodes.addAll(JcrUtils.nodeIteratorToList(nit.nextNode()
- .getNodes()));
- return nodes;
-
- default:
- return nodes;
- }
- }
-
- // private synchronized void openGeneratedFile(String path, String fileName)
- // {
- // Map<String, String> params = new HashMap<String, String>();
- // params.put(OpenFile.PARAM_FILE_NAME, fileName);
- // params.put(OpenFile.PARAM_FILE_URI, "file://" + path);
- // CommandUtils.callCommand("org.argeo.security.ui.specific.openFile",
- // params);
- // }
-
- private class ConfigureDumpWizard extends Wizard {
-
- // parameters
- protected String prefix;
- protected int currExportType = EXPORT_NODE;
- protected boolean includeBinaries = false;
-
- // UI Objects
- private BasicPage page;
- private Text prefixTxt;
- private Button includeBinaryBtn;
- private Button b1, b2, b3;
-
- public ConfigureDumpWizard(Shell parentShell, String title) {
- setWindowTitle(title);
- }
-
- @Override
- public void addPages() {
- try {
- page = new BasicPage("Main page");
- addPage(page);
- } catch (Exception e) {
- throw new EclipseUiException("Cannot add page to wizard", e);
- }
- }
-
- @Override
- public boolean performFinish() {
- prefix = prefixTxt.getText();
- if (b1.getSelection())
- currExportType = EXPORT_NODE;
- else if (b2.getSelection())
- currExportType = EXPORT_CHILDREN;
- else if (b3.getSelection())
- currExportType = EXPORT_GRAND_CHILDREN;
- includeBinaries = includeBinaryBtn.getSelection();
- return true;
- }
-
- @Override
- public boolean performCancel() {
- return true;
- }
-
- @Override
- public boolean canFinish() {
- String errorMsg = "No prefix defined.";
- if ("".equals(prefixTxt.getText().trim())) {
- page.setErrorMessage(errorMsg);
- return false;
- } else {
- page.setErrorMessage(null);
- return true;
- }
- }
-
- protected class BasicPage extends WizardPage {
- private static final long serialVersionUID = 1L;
-
- public BasicPage(String pageName) {
- super(pageName);
- setTitle("Configure dump before launching");
- setMessage("Define the parameters of the dump to launch");
- }
-
- public void createControl(Composite parent) {
- parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
- // Main Layout
- Composite mainCmp = new Composite(parent, SWT.NONE);
- mainCmp.setLayout(new GridLayout(2, false));
- mainCmp.setLayoutData(EclipseUiUtils.fillAll());
-
- // The path
- createBoldLabel(mainCmp, "Prefix");
- prefixTxt = new Text(mainCmp, SWT.SINGLE | SWT.BORDER);
- prefixTxt.setLayoutData(EclipseUiUtils.fillAll());
- prefixTxt.addModifyListener(new ModifyListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void modifyText(ModifyEvent event) {
- if (prefixTxt.getText() != null)
- getWizard().getContainer().updateButtons();
- }
- });
-
- new Label(mainCmp, SWT.SEPARATOR | SWT.HORIZONTAL)
- .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- false, 2, 1));
-
- // Which node to export
- Label typeLbl = new Label(mainCmp, SWT.RIGHT);
- typeLbl.setText(" Type");
- typeLbl.setFont(EclipseUiUtils.getBoldFont(mainCmp));
- typeLbl.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false,
- false, 1, 3));
-
- b1 = new Button(mainCmp, SWT.RADIO);
- b1.setText("Export this node");
- b1.setSelection(true);
- b2 = new Button(mainCmp, SWT.RADIO);
- b2.setText("Export children nodes");
- b3 = new Button(mainCmp, SWT.RADIO);
- b3.setText("Export grand-children nodes");
-
- new Label(mainCmp, SWT.SEPARATOR | SWT.HORIZONTAL)
- .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- false, 2, 1));
-
- createBoldLabel(mainCmp, "Files and images");
- includeBinaryBtn = new Button(mainCmp, SWT.CHECK);
- includeBinaryBtn.setText("Include binaries");
-
- prefixTxt.setFocus();
- setControl(mainCmp);
- }
- }
- }
-
- private Label createBoldLabel(Composite parent, String value) {
- Label label = new Label(parent, SWT.RIGHT);
- label.setText(" " + value);
- label.setFont(EclipseUiUtils.getBoldFont(parent));
- label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
- return label;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.util.Arrays;
-
-import org.argeo.cms.ui.jcr.model.RepositoryElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.eclipse.ui.dialogs.SingleValue;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Create a new JCR workspace */
-public class CreateWorkspace extends AbstractHandler {
-
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".addFolderNode";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
- .getActivePage().getSelection();
-
- JcrBrowserView view = (JcrBrowserView) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage()
- .findView(HandlerUtil.getActivePartId(event));
-
- if (selection != null && !selection.isEmpty()
- && selection instanceof IStructuredSelection) {
- Object obj = ((IStructuredSelection) selection).getFirstElement();
- if (!(obj instanceof RepositoryElem))
- return null;
-
- RepositoryElem repositoryNode = (RepositoryElem) obj;
- String workspaceName = SingleValue.ask("Workspace name",
- "Enter workspace name");
- if (workspaceName != null) {
- if (Arrays.asList(repositoryNode.getAccessibleWorkspaceNames())
- .contains(workspaceName)) {
- ErrorFeedback.show("Workspace " + workspaceName
- + " already exists.");
- } else {
- repositoryNode.createWorkspace(workspaceName);
- view.nodeAdded(repositoryNode);
- }
- }
- } else {
- ErrorFeedback.show("Cannot create workspace");
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.util.Iterator;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.jcr.model.WorkspaceElem;
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Delete the selected nodes: both in the JCR repository and in the UI view.
- * Warning no check is done, except implementation dependent native checks,
- * handle with care.
- *
- * This handler is still 'hard linked' to a GenericJcrBrowser view to enable
- * correct tree refresh when a node is added. This must be corrected in future
- * versions.
- */
-public class DeleteNodes extends AbstractHandler {
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
- .getActivePage().getSelection();
- if (selection == null || !(selection instanceof IStructuredSelection))
- return null;
-
- JcrBrowserView view = (JcrBrowserView) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage()
- .findView(HandlerUtil.getActivePartId(event));
-
- // confirmation
- StringBuffer buf = new StringBuffer("");
- Iterator<?> lst = ((IStructuredSelection) selection).iterator();
- while (lst.hasNext()) {
- SingleJcrNodeElem sjn = ((SingleJcrNodeElem) lst.next());
- buf.append(sjn.getName()).append(' ');
- }
- Boolean doRemove = MessageDialog.openConfirm(
- HandlerUtil.getActiveShell(event), "Confirm deletion",
- "Do you want to delete " + buf + "?");
-
- // operation
- if (doRemove) {
- Iterator<?> it = ((IStructuredSelection) selection).iterator();
- Object obj = null;
- SingleJcrNodeElem ancestor = null;
- WorkspaceElem rootAncestor = null;
- try {
- while (it.hasNext()) {
- obj = it.next();
- if (obj instanceof SingleJcrNodeElem) {
- // Cache objects
- SingleJcrNodeElem sjn = (SingleJcrNodeElem) obj;
- TreeParent tp = (TreeParent) sjn.getParent();
- Node node = sjn.getNode();
-
- // Jcr Remove
- node.remove();
- node.getSession().save();
- // UI remove
- tp.removeChild(sjn);
-
- // Check if the parent is the root node
- if (tp instanceof WorkspaceElem)
- rootAncestor = (WorkspaceElem) tp;
- else
- ancestor = getOlder(ancestor, (SingleJcrNodeElem) tp);
- }
- }
- if (rootAncestor != null)
- view.nodeRemoved(rootAncestor);
- else if (ancestor != null)
- view.nodeRemoved(ancestor);
- } catch (Exception e) {
- ErrorFeedback.show("Cannot delete selected node ", e);
- }
- }
- return null;
- }
-
- private SingleJcrNodeElem getOlder(SingleJcrNodeElem A, SingleJcrNodeElem B) {
- try {
- if (A == null)
- return B == null ? null : B;
- // Todo enhanced this method
- else
- return A.getNode().getDepth() <= B.getNode().getDepth() ? A : B;
- } catch (RepositoryException re) {
- throw new EclipseUiException("Cannot find ancestor", re);
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import static org.argeo.eclipse.ui.util.SingleSourcingConstants.FILE_SCHEME;
-import static org.argeo.eclipse.ui.util.SingleSourcingConstants.SCHEME_HOST_SEPARATOR;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.specific.OpenFile;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Canonically call JCR Session#exportSystemView() on the first element returned
- * by HandlerUtil#getActiveWorkbenchWindow()
- * (...getActivePage().getSelection()), if it is a {@link SingleJcrNodeElem},
- * with both skipBinary and noRecurse boolean flags set to false.
- *
- * Resulting stream is saved in a tmp file and opened via the {@link OpenFile}
- * single-sourced command.
- */
-public class DumpNode extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".dumpNode";
-
- private final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
- if (selection == null || !(selection instanceof IStructuredSelection))
- return null;
-
- Iterator<?> lst = ((IStructuredSelection) selection).iterator();
- if (lst.hasNext()) {
- Object element = lst.next();
- if (element instanceof SingleJcrNodeElem) {
- SingleJcrNodeElem sjn = (SingleJcrNodeElem) element;
- Node node = sjn.getNode();
-
- // TODO add a dialog to configure the export and ask for
- // confirmation
- // Boolean ok = MessageDialog.openConfirm(
- // HandlerUtil.getActiveShell(event), "Confirm dump",
- // "Do you want to dump " + buf + "?");
-
- File tmpFile;
- FileOutputStream fos;
- try {
- tmpFile = File.createTempFile("JcrExport", ".xml");
- tmpFile.deleteOnExit();
- fos = new FileOutputStream(tmpFile);
- String dateVal = df.format(new GregorianCalendar().getTime());
- node.getSession().exportSystemView(node.getPath(), fos, true, false);
- openGeneratedFile(tmpFile.getAbsolutePath(),
- "Dump-" + JcrUtils.replaceInvalidChars(node.getName()) + "-" + dateVal + ".xml");
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unable to perform SystemExport on " + node, e);
- } catch (IOException e) {
- throw new EclipseUiException("Unable to SystemExport " + node, e);
- }
- }
- }
- return null;
- }
-
- private synchronized void openGeneratedFile(String path, String fileName) {
- Map<String, String> params = new HashMap<String, String>();
- params.put(OpenFile.PARAM_FILE_NAME, fileName);
- params.put(OpenFile.PARAM_FILE_URI, FILE_SCHEME + SCHEME_HOST_SEPARATOR + path);
- CommandUtils.callCommand(OpenFile.ID, params);
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Property;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.cms.ui.workbench.internal.jcr.parts.NodeEditorInput;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Generic command to open a Node in an editor. */
-public class EditNode extends AbstractHandler {
- public final static String PARAM_EDITOR_ID = "editor";
-
- private String defaultEditorId;
-
- private Map<String, String> nodeTypeToEditor = new HashMap<String, String>();
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String path = event.getParameter(Property.JCR_PATH);
- String type = event.getParameter(NodeType.NT_NODE_TYPE);
- if (type == null)
- type = NodeType.NT_UNSTRUCTURED;
-
- String editorId = event.getParameter(PARAM_EDITOR_ID);
- if (editorId == null)
- editorId = nodeTypeToEditor.containsKey(type) ? nodeTypeToEditor
- .get(type) : defaultEditorId;
-
- NodeEditorInput nei = new NodeEditorInput(path);
- try {
- HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .openEditor(nei, editorId);
- } catch (PartInitException e) {
- ErrorFeedback.show("Cannot open " + editorId + " with " + path
- + " of type " + type, e);
- }
- return null;
- }
-
- public void setDefaultEditorId(String defaultEditorId) {
- this.defaultEditorId = defaultEditorId;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.jcr.model.WorkspaceElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Compute an approximative size for the selected node(s) */
-public class GetNodeSize extends AbstractHandler {
- // private final static Log log = LogFactory.getLog(GetNodeSize.class);
-
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".getNodeSize";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
- .getActivePage().getSelection();
-
- if (selection != null && !selection.isEmpty()
- && selection instanceof IStructuredSelection) {
-
- long size = 0;
-
- Iterator<?> it = ((IStructuredSelection) selection).iterator();
-
- // TODO enhance this: as the size method is recursive, we keep track
- // of nodes for which we already have computed size so that we don't
- // count them twice. In a first approximation, we assume that the
- // structure selection keep the nodes ordered.
- List<String> importedPathes = new ArrayList<String>();
- try {
- nodesIt: while (it.hasNext()) {
- Object obj = it.next();
- String curPath;
- Node node;
- if (obj instanceof SingleJcrNodeElem) {
- node = ((SingleJcrNodeElem) obj).getNode();
- curPath = node.getSession().getWorkspace().getName();
- curPath += "/" + node.getPath();
- } else if (obj instanceof WorkspaceElem) {
- node = ((WorkspaceElem) obj).getRootNode();
- curPath = node.getSession().getWorkspace().getName();
- } else
- // non valid object type
- continue nodesIt;
-
- Iterator<String> itPath = importedPathes.iterator();
- while (itPath.hasNext()) {
- String refPath = itPath.next();
- if (curPath.startsWith(refPath))
- // Already done : skip node
- continue nodesIt;
- }
- size += JcrUtils.getNodeApproxSize(node);
- importedPathes.add(curPath);
- }
- } catch (Exception e) {
- ErrorFeedback.show("Cannot Get size of selected node ", e);
- }
-
- String[] labels = { "OK" };
- Shell shell = HandlerUtil.getActiveWorkbenchWindow(event)
- .getShell();
- MessageDialog md = new MessageDialog(shell, "Node size", null,
- "Node size is: " + size / 1024 + " KB",
- MessageDialog.INFORMATION, labels, 0);
- md.open();
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.util.Iterator;
-
-import org.argeo.cms.ui.jcr.JcrBrowserUtils;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.argeo.eclipse.ui.TreeParent;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-/**
- * Force the selected objects of the active view to be refreshed doing the
- * following:
- * <ol>
- * <li>The model objects are recomputed</li>
- * <li>the view is refreshed</li>
- * </ol>
- */
-public class Refresh extends AbstractHandler {
-
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".refresh";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- JcrBrowserView view = (JcrBrowserView) WorkbenchUiPlugin.getDefault()
- .getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .getActivePart();//
-
- ISelection selection = WorkbenchUiPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getSelection();
-
- if (selection != null && selection instanceof IStructuredSelection
- && !selection.isEmpty()) {
- Iterator<?> it = ((IStructuredSelection) selection).iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TreeParent) {
- TreeParent tp = (TreeParent) obj;
- JcrBrowserUtils.forceRefreshIfNeeded(tp);
- view.refresh(obj);
- }
- }
- } else if (view instanceof JcrBrowserView)
- ((JcrBrowserView) view).refresh(null); // force full refresh
-
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.security.Principal;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.security.AccessControlEntry;
-import javax.jcr.security.AccessControlList;
-import javax.jcr.security.AccessControlManager;
-import javax.jcr.security.Privilege;
-
-import org.argeo.cms.ui.jcr.JcrImages;
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.jcr.model.WorkspaceElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Open a dialog to remove privileges from the selected node */
-public class RemovePrivileges extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".removePrivileges";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
- .getActivePage().getSelection();
- if (selection != null && !selection.isEmpty()
- && selection instanceof IStructuredSelection) {
- Object obj = ((IStructuredSelection) selection).getFirstElement();
- TreeParent uiNode = null;
- Node jcrNode = null;
-
- if (obj instanceof SingleJcrNodeElem) {
- uiNode = (TreeParent) obj;
- jcrNode = ((SingleJcrNodeElem) uiNode).getNode();
- } else if (obj instanceof WorkspaceElem) {
- uiNode = (TreeParent) obj;
- jcrNode = ((WorkspaceElem) uiNode).getRootNode();
- } else
- return null;
-
- try {
- String targetPath = jcrNode.getPath();
- Dialog dialog = new RemovePrivDialog(
- HandlerUtil.getActiveShell(event),
- jcrNode.getSession(), targetPath);
- dialog.open();
- return null;
- } catch (RepositoryException re) {
- throw new EclipseUiException("Unable to retrieve "
- + "path or JCR session to add privilege on " + jcrNode,
- re);
- }
- } else {
- ErrorFeedback.show("Cannot add privileges");
- }
- return null;
- }
-
- private class RemovePrivDialog extends TitleAreaDialog {
- private static final long serialVersionUID = 280139710002698692L;
-
- private Composite body;
-
- private final String path;
- private final Session session;
-
- public RemovePrivDialog(Shell parentShell, Session session, String path) {
- super(parentShell);
- this.session = session;
- this.path = path;
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText("Remove privileges");
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogarea = (Composite) super.createDialogArea(parent);
- dialogarea.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true,
- true));
- body = new Composite(dialogarea, SWT.NONE);
- body.setLayoutData(EclipseUiUtils.fillAll());
- refreshContent();
- parent.pack();
- return body;
- }
-
- private void refreshContent() {
- EclipseUiUtils.clear(body);
- try {
- AccessControlManager acm = session.getAccessControlManager();
- AccessControlList acl = JcrUtils
- .getAccessControlList(acm, path);
- if (acl == null || acl.getAccessControlEntries().length <= 0)
- setMessage("No privilege are defined on this node",
- IMessageProvider.INFORMATION);
- else {
- body.setLayout(new GridLayout(3, false));
- for (AccessControlEntry ace : acl.getAccessControlEntries()) {
- addOnePrivRow(body, ace);
- }
- setMessage("Remove some of the defined privileges",
- IMessageProvider.INFORMATION);
- }
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unable to list privileges on "
- + path, e);
- }
- body.layout(true, true);
- }
-
- private void addOnePrivRow(Composite parent, AccessControlEntry ace) {
- Principal currentPrincipal = ace.getPrincipal();
- final String currPrincipalName = currentPrincipal.getName();
- new Label(parent, SWT.WRAP).setText(currPrincipalName);
- new Label(parent, SWT.WRAP).setText(privAsString(ace
- .getPrivileges()));
- final Button rmBtn = new Button(parent, SWT.FLAT);
- rmBtn.setImage(JcrImages.REMOVE);
-
- rmBtn.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = 7566938841363890730L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
-
- if (MessageDialog.openConfirm(rmBtn.getShell(),
- "Confirm deletion",
- "Are you sure you want to remove this privilege?")) {
- try {
- session.save();
- JcrUtils.clearAccessControList(session, path,
- currPrincipalName);
- session.save();
- refreshContent();
- } catch (RepositoryException re) {
- throw new EclipseUiException("Unable to "
- + "remove privilege for "
- + currPrincipalName + " on " + path, re);
- }
- }
-
- super.widgetSelected(e);
- }
- });
-
- }
-
- private String privAsString(Privilege[] currentPrivileges) {
-
- StringBuilder builder = new StringBuilder();
- builder.append("[ ");
- for (Privilege priv : currentPrivileges) {
- builder.append(priv.getName()).append(", ");
- }
- if (builder.length() > 3)
- return builder.substring(0, builder.length() - 2) + " ]";
- else
- return "[]";
-
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import org.argeo.cms.ui.jcr.model.RemoteRepositoryElem;
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Remove a registered remote repository */
-public class RemoveRemoteRepository extends AbstractHandler {
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
- .getActivePage().getSelection();
-
- JcrBrowserView view = (JcrBrowserView) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage()
- .findView(HandlerUtil.getActivePartId(event));
-
- if (selection != null && !selection.isEmpty()
- && selection instanceof IStructuredSelection) {
- Object obj = ((IStructuredSelection) selection).getFirstElement();
-
- if (obj instanceof RemoteRepositoryElem) {
- ((RemoteRepositoryElem) obj).remove();
- view.refresh(null);
- }
- }
- return null;
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.util.Iterator;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.dialogs.SingleValue;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Canonically call JCR Session#move(String, String) on the first element
- * returned by HandlerUtil#getActiveWorkbenchWindow()
- * (...getActivePage().getSelection()), if it is a {@link SingleJcrNodeElem}.
- * The user must then fill a new name in and confirm
- */
-public class RenameNode extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".renameNode";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchPage iwp = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-
- ISelection selection = iwp.getSelection();
- if (selection == null || !(selection instanceof IStructuredSelection))
- return null;
-
- Iterator<?> lst = ((IStructuredSelection) selection).iterator();
- if (lst.hasNext()) {
- Object element = lst.next();
- if (element instanceof SingleJcrNodeElem) {
- SingleJcrNodeElem sjn = (SingleJcrNodeElem) element;
- Node node = sjn.getNode();
- Session session = null;
- String newName = null;
- String oldPath = null;
- try {
- newName = SingleValue.ask("New node name",
- "Please provide a new name for [" + node.getName() + "]");
- // TODO sanity check and user feedback
- newName = JcrUtils.replaceInvalidChars(newName);
- oldPath = node.getPath();
- session = node.getSession();
- session.move(oldPath, JcrUtils.parentPath(oldPath) + "/" + newName);
- session.save();
-
- // Manually refresh the browser view. Must be enhanced
- if (iwp.getActivePart() instanceof JcrBrowserView)
- ((JcrBrowserView) iwp.getActivePart()).refresh(sjn);
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unable to rename " + node + " to " + newName, e);
- }
- }
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.State;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Change isSorted state of the DataExplorer Browser */
-public class SortChildNodes extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".sortChildNodes";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- JcrBrowserView view = (JcrBrowserView) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage()
- .findView(JcrBrowserView.ID);
-
- ICommandService service = (ICommandService) PlatformUI.getWorkbench()
- .getService(ICommandService.class);
- Command command = service.getCommand(ID);
- State state = command.getState(ID + ".toggleState");
-
- boolean wasSorted = (Boolean) state.getValue();
- view.setSortChildNodes(!wasSorted);
- state.setValue(!wasSorted);
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.commands;
-
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.jcr.model.WorkspaceElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Upload local file(s) under the currently selected node */
-public class UploadFiles extends AbstractHandler {
- // private final static Log log = LogFactory.getLog(ImportFileSystem.class);
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
- JcrBrowserView view = (JcrBrowserView) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .findView(HandlerUtil.getActivePartId(event));
- if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
- Object obj = ((IStructuredSelection) selection).getFirstElement();
- try {
- Node folder = null;
- if (obj instanceof SingleJcrNodeElem) {
- folder = ((SingleJcrNodeElem) obj).getNode();
- } else if (obj instanceof WorkspaceElem) {
- folder = ((WorkspaceElem) obj).getRootNode();
- } else {
- ErrorFeedback.show(WorkbenchUiPlugin.getMessage("warningInvalidNodeToImport"));
- }
- if (folder != null) {
- FileDialog dialog = new FileDialog(HandlerUtil.getActiveShell(event), SWT.MULTI);
- dialog.setText("Choose one or more files to upload");
-
- if (EclipseUiUtils.notEmpty(dialog.open())) {
- String[] names = dialog.getFileNames();
- // Workaround small differences between RAP and RCP
- // 1. returned names are absolute path on RAP and
- // relative in RCP
- // 2. in RCP we must use getFilterPath that does not
- // exists on RAP
- Method filterMethod = null;
- Path parPath = null;
-
- try {
- filterMethod = dialog.getClass().getDeclaredMethod("getFilterPath");
- String filterPath = (String) filterMethod.invoke(dialog);
- parPath = Paths.get(filterPath);
- } catch (NoSuchMethodException nsme) { // RAP
- }
- if (names.length == 0)
- return null;
- else {
- loop: for (String name : names) {
- Path path = Paths.get(name);
- if (parPath != null)
- path = parPath.resolve(path);
- if (Files.exists(path)) {
- URI uri = path.toUri();
- String uriStr = uri.toString();
- System.out.println(uriStr);
-
- if (Files.isDirectory(path)) {
- MessageDialog.openError(HandlerUtil.getActiveShell(event),
- "Unimplemented directory import",
- "Upload of directories in the system is not yet implemented");
- continue loop;
- }
- Node fileNode = folder.addNode(path.getFileName().toString(), NodeType.NT_FILE);
- Node resNode = fileNode.addNode(Property.JCR_CONTENT, NodeType.NT_RESOURCE);
- Binary binary = null;
- try (InputStream is = Files.newInputStream(path)) {
- binary = folder.getSession().getValueFactory().createBinary(is);
- resNode.setProperty(Property.JCR_DATA, binary);
- }
- folder.getSession().save();
- } else {
- String msg = "Cannot upload file at " + path.toString();
- if (parPath != null)
- msg += "\nPlease remember that file upload fails when choosing files from the \"Recently Used\" bookmarks on some OS";
- MessageDialog.openError(HandlerUtil.getActiveShell(event), "Missing file", msg);
- continue loop;
- }
- }
- view.nodeAdded((TreeParent) obj);
- return true;
- }
- }
- }
- } catch (Exception e) {
- ErrorFeedback.show("Cannot import files to " + obj, e);
- }
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.Row;
-import javax.jcr.query.RowIterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.GenericTableComparator;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.EditorPart;
-
-/** Executes any JCR query. */
-public abstract class AbstractJcrQueryEditor extends EditorPart {
- private final static Log log = LogFactory.getLog(AbstractJcrQueryEditor.class);
-
- protected String initialQuery;
- protected String initialQueryType;
-
- /* DEPENDENCY INJECTION */
- private Session session;
-
- // Widgets
- private TableViewer viewer;
- private List<TableViewerColumn> tableViewerColumns = new ArrayList<TableViewerColumn>();
- private GenericTableComparator comparator;
-
- /** Override to layout a form enabling the end user to build his query */
- protected abstract void createQueryForm(Composite parent);
-
- @Override
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- JcrQueryEditorInput editorInput = (JcrQueryEditorInput) input;
- initialQuery = editorInput.getQuery();
- initialQueryType = editorInput.getQueryType();
- setSite(site);
- setInput(editorInput);
- }
-
- @Override
- public final void createPartControl(final Composite parent) {
- parent.setLayout(new FillLayout());
-
- SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
- sashForm.setSashWidth(4);
- sashForm.setLayout(new FillLayout());
-
- Composite top = new Composite(sashForm, SWT.NONE);
- GridLayout gl = new GridLayout(1, false);
- top.setLayout(gl);
-
- createQueryForm(top);
-
- Composite bottom = new Composite(sashForm, SWT.NONE);
- bottom.setLayout(new GridLayout(1, false));
- sashForm.setWeights(getWeights());
-
- viewer = new TableViewer(bottom);
- viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- viewer.getTable().setHeaderVisible(true);
- viewer.setContentProvider(getQueryResultContentProvider());
- viewer.setInput(getEditorSite());
-
- if (getComparator() != null) {
- comparator = getComparator();
- viewer.setComparator(comparator);
- }
- if (getTableDoubleClickListener() != null)
- viewer.addDoubleClickListener(getTableDoubleClickListener());
-
- }
-
- protected void executeQuery(String statement) {
- try {
- if (log.isDebugEnabled())
- log.debug("Query : " + statement);
-
- QueryResult qr = session.getWorkspace().getQueryManager().createQuery(statement, initialQueryType)
- .execute();
-
- // remove previous columns
- for (TableViewerColumn tvc : tableViewerColumns)
- tvc.getColumn().dispose();
-
- int i = 0;
- for (final String columnName : qr.getColumnNames()) {
- TableViewerColumn tvc = new TableViewerColumn(viewer, SWT.NONE);
- configureColumn(columnName, tvc, i);
- tvc.setLabelProvider(getLabelProvider(columnName));
- tableViewerColumns.add(tvc);
- i++;
- }
-
- // Must create a local list: QueryResults can only be read once.
- try {
- List<Row> rows = new ArrayList<Row>();
- RowIterator rit = qr.getRows();
- while (rit.hasNext()) {
- rows.add(rit.nextRow());
- }
- viewer.setInput(rows);
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot read query result", e);
- }
-
- } catch (RepositoryException e) {
- ErrorDialog.openError(null, "Error", "Cannot execute JCR query: " + statement,
- new Status(IStatus.ERROR, "org.argeo.eclipse.ui.jcr", e.getMessage()));
- }
- }
-
- /**
- * To be overidden to adapt size of form and result frames.
- *
- * @return
- */
- protected int[] getWeights() {
- return new int[] { 30, 70 };
- }
-
- /**
- * To be overidden to implement a doubleclick Listener on one of the rows of
- * the table.
- *
- * @return
- */
- protected IDoubleClickListener getTableDoubleClickListener() {
- return null;
- }
-
- /**
- * To be overiden in order to implement a specific
- * QueryResultContentProvider
- */
- protected IStructuredContentProvider getQueryResultContentProvider() {
- return new QueryResultContentProvider();
- }
-
- /**
- * Enable specific implementation for columns
- */
- protected List<TableViewerColumn> getTableViewerColumns() {
- return tableViewerColumns;
- }
-
- /**
- * Enable specific implementation for columns
- */
- protected TableViewer getTableViewer() {
- return viewer;
- }
-
- /**
- * To be overridden in order to configure column label providers .
- */
- protected ColumnLabelProvider getLabelProvider(final String columnName) {
- return new ColumnLabelProvider() {
- private static final long serialVersionUID = -3539689333250152606L;
-
- public String getText(Object element) {
- Row row = (Row) element;
- try {
- return row.getValue(columnName).getString();
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot display row " + row, e);
- }
- }
-
- public Image getImage(Object element) {
- return null;
- }
- };
- }
-
- /**
- * To be overridden in order to configure the columns.
- *
- * @deprecated use
- * {@link AbstractJcrQueryEditor#configureColumn(String, TableViewerColumn , int )}
- * instead
- */
- protected void configureColumn(String jcrColumnName, TableViewerColumn column) {
- column.getColumn().setWidth(50);
- column.getColumn().setText(jcrColumnName);
- }
-
- /** To be overridden in order to configure the columns. */
- protected void configureColumn(String jcrColumnName, TableViewerColumn column, int columnIndex) {
- column.getColumn().setWidth(50);
- column.getColumn().setText(jcrColumnName);
- }
-
- private class QueryResultContentProvider implements IStructuredContentProvider {
- private static final long serialVersionUID = -5421095459600554741L;
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public Object[] getElements(Object inputElement) {
-
- if (inputElement instanceof List)
- return ((List<?>) inputElement).toArray();
-
- // Never reached might be deleted in future release
- if (!(inputElement instanceof QueryResult))
- return new String[] {};
-
- try {
- QueryResult queryResult = (QueryResult) inputElement;
- List<Row> rows = new ArrayList<Row>();
- RowIterator rit = queryResult.getRows();
- while (rit.hasNext()) {
- rows.add(rit.nextRow());
- }
-
- // List<Node> elems = new ArrayList<Node>();
- // NodeIterator nit = queryResult.getNodes();
- // while (nit.hasNext()) {
- // elems.add(nit.nextNode());
- // }
- return rows.toArray();
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot read query result", e);
- }
- }
-
- }
-
- /**
- * Might be used by children classes to sort columns.
- *
- * @param column
- * @param index
- * @return
- */
- protected SelectionAdapter getSelectionAdapter(final TableColumn column, final int index) {
-
- // A comparator must be define
- if (comparator == null)
- return null;
-
- SelectionAdapter selectionAdapter = new SelectionAdapter() {
- private static final long serialVersionUID = 239829307927778349L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
-
- try {
-
- comparator.setColumn(index);
- int dir = viewer.getTable().getSortDirection();
- if (viewer.getTable().getSortColumn() == column) {
- dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
- } else {
-
- dir = SWT.DOWN;
- }
- viewer.getTable().setSortDirection(dir);
- viewer.getTable().setSortColumn(column);
- viewer.refresh();
- } catch (Exception exc) {
- exc.printStackTrace();
- }
- }
- };
- return selectionAdapter;
- }
-
- /**
- * To be overridden to enable sorting.
- */
- protected GenericTableComparator getComparator() {
- return null;
- }
-
- @Override
- public boolean isDirty() {
- return false;
- }
-
- @Override
- public void doSave(IProgressMonitor monitor) {
- // TODO save the query in JCR?
- }
-
- @Override
- public void doSaveAs() {
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- /** Returns the injected current session */
- protected Session getSession() {
- return session;
- }
-
- /* DEPENDENCY INJECTION */
- public void setSession(Session session) {
- this.session = session;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.argeo.cms.ui.useradmin.PickUpUserDialog;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Text;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdmin;
-
-/** Add JCR privileges to the chosen user group on a given node */
-public class AddPrivilegeWizard extends Wizard {
-
- // Context
- private UserAdmin userAdmin;
- private Session currentSession;
- private String targetPath;
- // Chosen parameters
- private String chosenDn;
- private User chosenUser;
- private String jcrPrivilege;
-
- // UI Object
- private DefinePrivilegePage page;
-
- // TODO enable external definition of possible values and corresponding
- // description
- protected static final Map<String, String> AUTH_TYPE_LABELS;
- static {
- Map<String, String> tmpMap = new HashMap<String, String>();
- tmpMap.put(Privilege.JCR_READ, "jcr:read");
- tmpMap.put(Privilege.JCR_WRITE, "jcr:write");
- tmpMap.put(Privilege.JCR_ALL, "jcr:all");
- AUTH_TYPE_LABELS = Collections.unmodifiableMap(tmpMap);
- }
-
- protected static final Map<String, String> AUTH_TYPE_DESC;
- static {
- Map<String, String> tmpMap = new HashMap<String, String>();
- tmpMap.put(Privilege.JCR_READ, "The privilege to retrieve a node and get its properties and their values.");
- tmpMap.put(Privilege.JCR_WRITE, "An aggregate privilege that "
- + "contains: jcr:modifyProperties, jcr:addChildNodes, " + "jcr:removeNode, jcr:removeChildNodes");
- tmpMap.put(Privilege.JCR_ALL, "An aggregate privilege that " + "contains all JCR predefined privileges, "
- + "plus all implementation-defined privileges. ");
- AUTH_TYPE_DESC = Collections.unmodifiableMap(tmpMap);
- }
-
- public AddPrivilegeWizard(Session currentSession, String path, UserAdmin userAdmin) {
- super();
- this.userAdmin = userAdmin;
- this.currentSession = currentSession;
- this.targetPath = path;
- }
-
- @Override
- public void addPages() {
- try {
- setWindowTitle("Add privilege on " + targetPath);
- page = new DefinePrivilegePage(userAdmin, targetPath);
- addPage(page);
- } catch (Exception e) {
- throw new EclipseUiException("Cannot add page to wizard ", e);
- }
- }
-
- @Override
- public boolean performFinish() {
- if (!canFinish())
- return false;
- try {
- String username = chosenUser.getName();
- if (EclipseUiUtils.notEmpty(chosenDn) && chosenDn.equalsIgnoreCase(username))
- // Enable forcing the username case. TODO clean once this issue
- // has been generally addressed
- username = chosenDn;
- JcrUtils.addPrivilege(currentSession, targetPath, username, jcrPrivilege);
- } catch (RepositoryException re) {
- throw new EclipseUiException(
- "Cannot set " + jcrPrivilege + " for " + chosenUser.getName() + " on " + targetPath, re);
- }
- return true;
- }
-
- private class DefinePrivilegePage extends WizardPage implements ModifyListener {
- private static final long serialVersionUID = 8084431378762283920L;
-
- // Context
- final private UserAdmin userAdmin;
-
- public DefinePrivilegePage(UserAdmin userAdmin, String path) {
- super("Main");
- this.userAdmin = userAdmin;
- setTitle("Define the privilege to apply to " + path);
- setMessage("Please choose a user or a group and relevant JCR Privilege.");
- }
-
- public void createControl(Composite parent) {
- final Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(3, false));
-
- // specify subject
- createBoldLabel(composite, "User or group name");
- final Label userNameLbl = new Label(composite, SWT.LEAD);
- userNameLbl.setLayoutData(EclipseUiUtils.fillWidth());
-
- Link pickUpLk = new Link(composite, SWT.LEFT);
- pickUpLk.setText(" <a>Change</a> ");
-
- createBoldLabel(composite, "User or group DN");
- final Text userNameTxt = new Text(composite, SWT.LEAD | SWT.BORDER);
- userNameTxt.setLayoutData(EclipseUiUtils.fillWidth(2));
-
- pickUpLk.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- PickUpUserDialog dialog = new PickUpUserDialog(getShell(), "Choose a group or a user", userAdmin);
- if (dialog.open() == Window.OK) {
- chosenUser = dialog.getSelected();
- userNameLbl.setText(UserAdminUtils.getCommonName(chosenUser));
- userNameTxt.setText(chosenUser.getName());
- }
- }
- });
-
- userNameTxt.addFocusListener(new FocusListener() {
- private static final long serialVersionUID = 1965498600105667738L;
-
- @Override
- public void focusLost(FocusEvent event) {
- String dn = userNameTxt.getText();
- if (EclipseUiUtils.isEmpty(dn))
- return;
-
- User newChosen = null;
- try {
- newChosen = (User) userAdmin.getRole(dn);
- } catch (Exception e) {
- boolean tryAgain = MessageDialog.openQuestion(getShell(), "Unvalid DN",
- "DN " + dn + " is not valid.\nError message: " + e.getMessage()
- + "\n\t\tDo you want to try again?");
- if (tryAgain)
- userNameTxt.setFocus();
- else
- resetOnFail();
- }
-
- if (userAdmin.getRole(dn) == null) {
- boolean tryAgain = MessageDialog.openQuestion(getShell(), "Unexisting role",
- "User/group " + dn + " does not exist. " + "Do you want to try again?");
- if (tryAgain)
- userNameTxt.setFocus();
- else
- resetOnFail();
- } else {
- chosenUser = newChosen;
- chosenDn = dn;
- userNameLbl.setText(UserAdminUtils.getCommonName(chosenUser));
- }
- }
-
- private void resetOnFail() {
- String oldDn = chosenUser == null ? "" : chosenUser.getName();
- userNameTxt.setText(oldDn);
- }
-
- @Override
- public void focusGained(FocusEvent event) {
- }
- });
-
- // JCR Privileges
- createBoldLabel(composite, "Privilege type");
- Combo authorizationCmb = new Combo(composite, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL);
- authorizationCmb.setItems(AUTH_TYPE_LABELS.values().toArray(new String[0]));
- authorizationCmb.setLayoutData(EclipseUiUtils.fillWidth(2));
- createBoldLabel(composite, ""); // empty cell
- final Label descLbl = new Label(composite, SWT.WRAP);
- descLbl.setLayoutData(EclipseUiUtils.fillWidth(2));
-
- authorizationCmb.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- String chosenPrivStr = ((Combo) e.getSource()).getText();
- if (AUTH_TYPE_LABELS.containsValue(chosenPrivStr)) {
- loop: for (String key : AUTH_TYPE_LABELS.keySet()) {
- if (AUTH_TYPE_LABELS.get(key).equals(chosenPrivStr)) {
- jcrPrivilege = key;
- break loop;
- }
- }
- }
-
- if (jcrPrivilege != null) {
- descLbl.setText(AUTH_TYPE_DESC.get(jcrPrivilege));
- composite.layout(true, true);
- }
- }
- });
-
- // Compulsory
- setControl(composite);
- }
-
- public void modifyText(ModifyEvent event) {
- String message = checkComplete();
- if (message != null)
- setMessage(message, WizardPage.ERROR);
- else {
- setMessage("Complete", WizardPage.INFORMATION);
- setPageComplete(true);
- }
- }
-
- /** @return error message or null if complete */
- protected String checkComplete() {
- if (chosenUser == null)
- return "Please choose a relevant group or user";
- else if (userAdmin.getRole(chosenUser.getName()) == null)
- return "Please choose a relevant group or user";
- else if (jcrPrivilege == null)
- return "Please choose a relevant JCR privilege";
- return null;
- }
- }
-
- private Label createBoldLabel(Composite parent, String value) {
- Label label = new Label(parent, SWT.RIGHT);
- label.setText(" " + value);
- label.setFont(EclipseUiUtils.getBoldFont(parent));
- label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
- return label;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import javax.jcr.Node;
-
-import org.argeo.cms.ui.jcr.JcrTreeContentProvider;
-import org.argeo.cms.ui.jcr.NodeLabelProvider;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.jcr.DefaultNodeEditor;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/** List all children of the current node */
-public class ChildNodesPage extends FormPage {
- // private final static Log log = LogFactory.getLog(ChildNodesPage.class);
-
- private Node currentNode;
-
- private JcrTreeContentProvider nodeContentProvider;
- private TreeViewer nodesViewer;
-
- public ChildNodesPage(FormEditor editor, String title, Node currentNode) {
- super(editor, "ChildNodesPage", title);
- this.currentNode = currentNode;
- }
-
- protected void createFormContent(IManagedForm managedForm) {
- try {
- ScrolledForm form = managedForm.getForm();
- form.setText(WorkbenchUiPlugin.getMessage("childNodesPageTitle"));
- Composite innerBox = form.getBody();
- // Composite innerBox = new Composite(body, SWT.NO_FOCUS);
- GridLayout twt = new GridLayout(1, false);
- twt.marginWidth = twt.marginHeight = 5;
- innerBox.setLayout(twt);
- if (!currentNode.hasNodes()) {
- managedForm.getToolkit().createLabel(innerBox, WorkbenchUiPlugin.getMessage("warningNoChildNode"));
- } else {
- nodeContentProvider = new JcrTreeContentProvider();
- nodesViewer = createNodeViewer(innerBox, nodeContentProvider);
- nodesViewer.setInput(currentNode);
- }
- } catch (Exception e) {
- throw new EclipseUiException("Cannot create children page for " + currentNode, e);
- }
- }
-
- protected TreeViewer createNodeViewer(Composite parent, final ITreeContentProvider nodeContentProvider) {
-
- final TreeViewer tmpNodeViewer = new TreeViewer(parent, SWT.BORDER);
- Tree tree = tmpNodeViewer.getTree();
- tree.setLinesVisible(true);
- tmpNodeViewer.getTree().setLayoutData(EclipseUiUtils.fillAll());
- tmpNodeViewer.setContentProvider(nodeContentProvider);
- tmpNodeViewer.setLabelProvider(new NodeLabelProvider());
- tmpNodeViewer.addDoubleClickListener(new DClickListener());
- return tmpNodeViewer;
- }
-
- public class DClickListener implements IDoubleClickListener {
-
- public void doubleClick(DoubleClickEvent event) {
- if (event.getSelection() == null || event.getSelection().isEmpty())
- return;
- Object obj = ((IStructuredSelection) event.getSelection()).getFirstElement();
- if (obj instanceof Node) {
- Node node = (Node) obj;
- try {
- GenericNodeEditorInput gnei = new GenericNodeEditorInput(node);
- WorkbenchUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .openEditor(gnei, DefaultNodeEditor.ID);
- } catch (PartInitException pie) {
- throw new EclipseUiException("Cannot open editor for " + node, pie);
- }
- }
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/** Ask end user for a name */
-public class ChooseNameDialog extends TitleAreaDialog {
- private static final long serialVersionUID = 280139710002698692L;
- private Text nameTxt;
-
- public ChooseNameDialog(Shell parentShell) {
- super(parentShell);
- setTitle("Choose name");
- }
-
- protected Point getInitialSize() {
- return new Point(300, 250);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogarea = (Composite) super.createDialogArea(parent);
- dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Composite composite = new Composite(dialogarea, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- nameTxt = createLT(composite, "Name");
- setMessage("Choose name", IMessageProvider.INFORMATION);
- parent.pack();
- nameTxt.setFocus();
- return composite;
- }
-
- /** Creates label and text. */
- protected Text createLT(Composite parent, String label) {
- new Label(parent, SWT.NONE).setText(label);
- Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
- text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- return text;
- }
-
- public String getName() {
- return nameTxt.getText();
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/** Editor input for {@link Node} editors */
-public class GenericNodeEditorInput implements IEditorInput {
- private final Node currentNode;
-
- // Caches key properties at creation time to avoid Exception at recovering
- // time when the session has been closed
- private String path;
- private String uid;
- private String name;
-
- public GenericNodeEditorInput(Node currentNode) {
- this.currentNode = currentNode;
- try {
- name = currentNode.getName();
- uid = currentNode.getIdentifier();
- path = currentNode.getPath();
- } catch (RepositoryException re) {
- throw new EclipseUiException("Cannot cache the key properties for " + currentNode, re);
- }
- }
-
- public Node getCurrentNode() {
- return currentNode;
- }
-
- @SuppressWarnings("unchecked")
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public boolean exists() {
- return true;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- return name;
- }
-
- public String getUid() {
- return uid;
- }
-
- public String getToolTipText() {
- return path;
- }
-
- public String getPath() {
- return path;
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- /**
- * Equals method based on UID that is unique within a workspace and path of
- * the node, thus 2 shared node that have same UID as defined in the spec
- * but 2 different paths will open two distinct editors.
- *
- * TODO enhance this method to support multi repository and multi workspace
- * environments
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
-
- GenericNodeEditorInput other = (GenericNodeEditorInput) obj;
- if (!getUid().equals(other.getUid()))
- return false;
- if (!getPath().equals(other.getPath()))
- return false;
- return true;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.ListIterator;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ui.CmsConstants;
-import org.argeo.cms.ui.workbench.internal.WorkbenchConstants;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.AbstractFormPart;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Work-In-Progress Node editor page: provides edition feature on String
- * properties for power users. TODO implement manual modification of all
- * property types.
- */
-
-public class GenericNodePage extends FormPage implements WorkbenchConstants {
- // private final static Log log = LogFactory.getLog(GenericNodePage.class);
-
- // local constants
- private final static String JCR_PROPERTY_NAME = "jcr:name";
-
- // Utils
- protected DateFormat timeFormatter = new SimpleDateFormat(CmsConstants.DATE_TIME_FORMAT);
-
- // Main business Objects
- private Node currentNode;
-
- // This page widgets
- private FormToolkit tk;
- private List<Control> modifyableProperties = new ArrayList<Control>();
-
- public GenericNodePage(FormEditor editor, String title, Node currentNode) {
- super(editor, "id", title);
- this.currentNode = currentNode;
- }
-
- protected void createFormContent(IManagedForm managedForm) {
- tk = managedForm.getToolkit();
- ScrolledForm form = managedForm.getForm();
- Composite innerBox = form.getBody();
- // Composite innerBox = new Composite(form.getBody(), SWT.NO_FOCUS);
- GridLayout twt = new GridLayout(3, false);
- innerBox.setLayout(twt);
- createPropertiesPart(innerBox);
- }
-
- private void createPropertiesPart(Composite parent) {
- try {
- AbstractFormPart part = new AbstractFormPart() {
- public void commit(boolean onSave) {
- try {
- if (onSave) {
- ListIterator<Control> it = modifyableProperties.listIterator();
- while (it.hasNext()) {
- // we only support Text controls
- Text curControl = (Text) it.next();
- String value = curControl.getText();
- currentNode.setProperty((String) curControl.getData(JCR_PROPERTY_NAME), value);
- }
-
- // We only commit when onSave = true,
- // thus it is still possible to save after a tab
- // change.
- if (currentNode.getSession().hasPendingChanges())
- currentNode.getSession().save();
- super.commit(onSave);
- }
- } catch (RepositoryException re) {
- throw new EclipseUiException("Cannot save properties on " + currentNode, re);
- }
- }
- };
-
- PropertyIterator pi = currentNode.getProperties();
- while (pi.hasNext()) {
- Property prop = pi.nextProperty();
- addPropertyLine(parent, part, prop);
- }
- getManagedForm().addPart(part);
- } catch (RepositoryException re) {
- throw new EclipseUiException("Cannot display properties for " + currentNode, re);
- }
- }
-
- private void addPropertyLine(Composite parent, AbstractFormPart part, Property prop) {
- try {
- tk.createLabel(parent, prop.getName());
- tk.createLabel(parent, "[" + JcrUtils.getPropertyDefinitionAsString(prop) + "]");
-
- if (prop.getDefinition().isProtected()) {
- tk.createLabel(parent, formatReadOnlyPropertyValue(prop));
- } else
- addModifyableValueWidget(parent, part, prop);
- } catch (RepositoryException re) {
- throw new EclipseUiException("Cannot display property " + prop, re);
- }
- }
-
- private String formatReadOnlyPropertyValue(Property prop) throws RepositoryException {
- String strValue;
- if (prop.getType() == PropertyType.BINARY)
- strValue = "<binary>";
- else if (prop.isMultiple())
- strValue = Arrays.asList(prop.getValues()).toString();
- else if (prop.getType() == PropertyType.DATE)
- strValue = timeFormatter.format(prop.getValue().getDate().getTime());
- else
- strValue = prop.getValue().getString();
- return strValue;
- }
-
- private Control addModifyableValueWidget(Composite parent, AbstractFormPart part, Property prop)
- throws RepositoryException {
- GridData gd;
- if (prop.getType() == PropertyType.STRING && !prop.isMultiple()) {
- Text txt = tk.createText(parent, prop.getString(), SWT.WRAP | SWT.MULTI);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- txt.setLayoutData(gd);
- txt.addModifyListener(new ModifiedFieldListener(part));
- txt.setData(JCR_PROPERTY_NAME, prop.getName());
- modifyableProperties.add(txt);
- } else {
- // unsupported property type for editing, we create a read only
- // label.
- return tk.createLabel(parent, formatReadOnlyPropertyValue(prop));
- }
- return null;
- }
-
- private class ModifiedFieldListener implements ModifyListener {
- private static final long serialVersionUID = 2117484480773434646L;
- private AbstractFormPart formPart;
-
- public ModifiedFieldListener(AbstractFormPart generalPart) {
- this.formPart = generalPart;
- }
-
- public void modifyText(ModifyEvent e) {
- formPart.markDirty();
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ui.jcr.PropertyLabelProvider;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.WorkbenchConstants;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.eclipse.jface.layout.TreeColumnLayout;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Generic editor property page. Lists all properties of current node as a
- * complex tree. TODO: enable editing
- */
-public class GenericPropertyPage extends FormPage implements WorkbenchConstants {
- // private final static Log log =
- // LogFactory.getLog(GenericPropertyPage.class);
-
- // Main business Objects
- private Node currentNode;
-
- public GenericPropertyPage(FormEditor editor, String title, Node currentNode) {
- super(editor, "id", title);
- this.currentNode = currentNode;
- }
-
- protected void createFormContent(IManagedForm managedForm) {
- ScrolledForm form = managedForm.getForm();
- form.setText(WorkbenchUiPlugin.getMessage("genericNodePageTitle"));
- Composite innerBox = form.getBody();
- //Composite innerBox = new Composite(body, SWT.NO_FOCUS);
- FillLayout layout = new FillLayout();
- layout.marginHeight = 5;
- layout.marginWidth = 5;
- innerBox.setLayout(layout);
- createComplexTree(innerBox);
- // TODO TreeColumnLayout triggers a scroll issue with the form:
- // The inside body is always to big and a scroll bar is shown
- // Composite tableCmp = new Composite(body, SWT.NO_FOCUS);
- // createComplexTree(tableCmp);
- }
-
- private TreeViewer createComplexTree(Composite parent) {
- int style = SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION;
- Tree tree = new Tree(parent, style);
- TreeColumnLayout tableColumnLayout = new TreeColumnLayout();
-
- createColumn(tree, tableColumnLayout, "Property", SWT.LEFT, 200, 30);
- createColumn(tree, tableColumnLayout, "Value(s)", SWT.LEFT, 300, 60);
- createColumn(tree, tableColumnLayout, "Type", SWT.LEFT, 75, 10);
- createColumn(tree, tableColumnLayout, "Attributes", SWT.LEFT, 75, 0);
- // Do not apply the treeColumnLayout it does not work yet
- // parent.setLayout(tableColumnLayout);
-
- tree.setLinesVisible(true);
- tree.setHeaderVisible(true);
-
- TreeViewer treeViewer = new TreeViewer(tree);
- treeViewer.setContentProvider(new TreeContentProvider());
- treeViewer.setLabelProvider(new PropertyLabelProvider());
- treeViewer.setInput(currentNode);
- treeViewer.expandAll();
- return treeViewer;
- }
-
- private static TreeColumn createColumn(Tree parent, TreeColumnLayout tableColumnLayout, String name, int style,
- int width, int weight) {
- TreeColumn column = new TreeColumn(parent, style);
- column.setText(name);
- column.setWidth(width);
- column.setMoveable(true);
- column.setResizable(true);
- tableColumnLayout.setColumnData(column, new ColumnWeightData(weight, width, true));
- return column;
- }
-
- private class TreeContentProvider implements ITreeContentProvider {
- private static final long serialVersionUID = -6162736530019406214L;
-
- public Object[] getElements(Object parent) {
- Object[] props = null;
- try {
-
- if (parent instanceof Node) {
- Node node = (Node) parent;
- PropertyIterator pi;
- pi = node.getProperties();
- List<Property> propList = new ArrayList<Property>();
- while (pi.hasNext()) {
- propList.add(pi.nextProperty());
- }
- props = propList.toArray();
- }
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unexpected exception while listing node properties", e);
- }
- return props;
- }
-
- public Object getParent(Object child) {
- return null;
- }
-
- public Object[] getChildren(Object parent) {
- if (parent instanceof Property) {
- Property prop = (Property) parent;
- try {
- if (prop.isMultiple())
- return prop.getValues();
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot get multi-prop values on " + prop, e);
- }
- }
- return null;
- }
-
- public boolean hasChildren(Object parent) {
- try {
- return (parent instanceof Property && ((Property) parent).isMultiple());
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot check if property is multiple for " + parent, e);
- }
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import javax.jcr.query.Query;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-public class JcrQueryEditorInput implements IEditorInput {
- private final String query;
- private final String queryType;
-
- public JcrQueryEditorInput(String query, String queryType) {
- this.query = query;
- if (queryType == null)
- this.queryType = Query.JCR_SQL2;
- else
- this.queryType = queryType;
- }
-
- @SuppressWarnings("unchecked")
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public boolean exists() {
- return true;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- return query;
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public String getToolTipText() {
- return query;
- }
-
- public String getQuery() {
- return query;
- }
-
- public String getQueryType() {
- return queryType;
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/**
- * A canonical editor input based on a path to a node. In a multirepository
- * environment, path can be enriched with Repository Alias and workspace
- */
-
-public class NodeEditorInput implements IEditorInput {
- private final String path;
-
- public NodeEditorInput(String path) {
- this.path = path;
- }
-
- @SuppressWarnings("unchecked")
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public boolean exists() {
- return true;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- return path;
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public String getToolTipText() {
- return path;
- }
-
- public String getPath() {
- return path;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Display and edit a given node privilege. For the time being it is completely
- * JackRabbit specific (and hard coded for this) and will display an empty page
- * if using any other implementation
- */
-public class NodePrivilegesPage extends FormPage {
-
- private Node context;
-
- private TableViewer viewer;
-
- public NodePrivilegesPage(FormEditor editor, String title, Node context) {
- super(editor, "NodePrivilegesPage", title);
- this.context = context;
- }
-
- protected void createFormContent(IManagedForm managedForm) {
- ScrolledForm form = managedForm.getForm();
- form.setText(WorkbenchUiPlugin.getMessage("nodeRightsManagementPageTitle"));
- FillLayout layout = new FillLayout();
- layout.marginHeight = 5;
- layout.marginWidth = 5;
- form.getBody().setLayout(layout);
- if (isJackRabbit())
- createRightsPart(form.getBody());
- }
-
- /** Creates the authorization part */
- protected void createRightsPart(Composite parent) {
- Table table = new Table(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
- viewer = new TableViewer(table);
-
- // Group / user name
- TableViewerColumn column = createTableViewerColumn(viewer, "User/Group Name", 280);
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -2290781173498395973L;
-
- public String getText(Object element) {
- Node node = (Node) element;
- try {
- if (node.hasProperty("rep:principalName"))
- return node.getProperty("rep:principalName").getString();
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unable to retrieve " + "principal name on " + node, e);
- }
- return "";
- }
-
- public Image getImage(Object element) {
- return null;
- }
- });
-
- // Privileges
- column = createTableViewerColumn(viewer, "Assigned privileges", 300);
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -2290781173498395973L;
- private String propertyName = "rep:privileges";
-
- public String getText(Object element) {
- Node node = (Node) element;
- try {
- if (node.hasProperty(propertyName)) {
- String separator = ", ";
- Value[] langs = node.getProperty(propertyName).getValues();
- StringBuilder builder = new StringBuilder();
- for (Value val : langs) {
- String currStr = val.getString();
- builder.append(currStr).append(separator);
- }
- if (builder.lastIndexOf(separator) >= 0)
- return builder.substring(0, builder.length() - separator.length());
- else
- return builder.toString();
-
- }
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unable to retrieve " + "privileges on " + node, e);
- }
- return "";
- }
-
- public Image getImage(Object element) {
- return null;
- }
- });
-
- // Relevant node
- column = createTableViewerColumn(viewer, "Relevant node", 300);
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 4245522992038244849L;
-
- public String getText(Object element) {
- Node node = (Node) element;
- try {
- return node.getParent().getParent().getPath();
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unable get path for " + node, e);
- }
- }
-
- public Image getImage(Object element) {
- return null;
- }
- });
-
- viewer.setContentProvider(new RightsContentProvider());
- viewer.setInput(getEditorSite());
- }
-
- protected TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound) {
- TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
- TableColumn column = viewerColumn.getColumn();
- column.setText(title);
- column.setWidth(bound);
- column.setResizable(true);
- column.setMoveable(true);
- return viewerColumn;
- }
-
- private class RightsContentProvider implements IStructuredContentProvider {
- private static final long serialVersionUID = -7631476348552802706L;
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- // TODO JackRabbit specific retrieval of authorization. Clean and
- // generalize
- public Object[] getElements(Object inputElement) {
- try {
- List<Node> privs = new ArrayList<Node>();
-
- Node currNode = context;
- String currPath = currNode.getPath();
-
- loop: while (true) {
- if (currNode.hasNode("rep:policy")) {
- NodeIterator nit = currNode.getNode("rep:policy").getNodes();
- while (nit.hasNext()) {
- Node currPrivNode = nit.nextNode();
- if (currPrivNode.getName().startsWith("allow"))
- privs.add(currPrivNode);
- }
- }
- if ("/".equals(currPath))
- break loop;
- else {
- currNode = currNode.getParent();
- currPath = currNode.getPath();
- }
- }
-
- // AccessControlManager acm = context.getSession()
- // .getAccessControlManager();
- // AccessControlPolicyIterator acpi = acm
- // .getApplicablePolicies(context.getPath());
- //
- // List<AccessControlPolicy> acps = new
- // ArrayList<AccessControlPolicy>();
- // try {
- // while (true) {
- // Object obj = acpi.next();
- // acps.add((AccessControlPolicy) obj);
- // }
- // } catch (Exception e) {
- // // No more elements
- // }
- //
- // AccessControlList acl = ((AccessControlList) acps.get(0));
- // AccessControlEntry[] entries = acl.getAccessControlEntries();
-
- return privs.toArray();
- } catch (Exception e) {
- throw new EclipseUiException("Cannot retrieve authorization for " + context, e);
- }
- }
- }
-
- /**
- * Simply checks if we are using jackrabbit without adding code dependencies
- */
- private boolean isJackRabbit() {
- try {
- String cname = context.getSession().getClass().getName();
- return cname.startsWith("org.apache.jackrabbit");
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot check JCR implementation used on " + context, e);
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.version.Version;
-import javax.jcr.version.VersionHistory;
-import javax.jcr.version.VersionIterator;
-import javax.jcr.version.VersionManager;
-
-import org.argeo.cms.ui.CmsConstants;
-import org.argeo.cms.ui.jcr.FullVersioningTreeContentProvider;
-import org.argeo.cms.ui.jcr.JcrDClickListener;
-import org.argeo.cms.ui.jcr.VersionLabelProvider;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.WorkbenchConstants;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.jcr.PropertyDiff;
-import org.argeo.jcr.VersionDiff;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.AbstractFormPart;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
-/**
- * Offers two main sections : one to display a text area with a summary of all
- * variations between a version and its predecessor and one tree view that
- * enable browsing
- */
-public class NodeVersionHistoryPage extends FormPage implements WorkbenchConstants {
- // private final static Log log = LogFactory
- // .getLog(NodeVersionHistoryPage.class);
-
- // Utils
- protected DateFormat timeFormatter = new SimpleDateFormat(CmsConstants.DATE_TIME_FORMAT);
-
- // business objects
- private Node currentNode;
-
- // this page UI components
- private FullVersioningTreeContentProvider nodeContentProvider;
- private TreeViewer nodesViewer;
- private FormToolkit tk;
-
- public NodeVersionHistoryPage(FormEditor editor, String title, Node currentNode) {
- super(editor, "NodeVersionHistoryPage", title);
- this.currentNode = currentNode;
- }
-
- protected void createFormContent(IManagedForm managedForm) {
- ScrolledForm form = managedForm.getForm();
- form.setText(WorkbenchUiPlugin.getMessage("nodeVersionHistoryPageTitle"));
- tk = managedForm.getToolkit();
- Composite innerBox = form.getBody();
- // Composite innerBox = new Composite(body, SWT.NO_FOCUS);
- GridLayout twt = new GridLayout(1, false);
- twt.marginWidth = twt.marginHeight = 5;
- innerBox.setLayout(twt);
- try {
- if (!currentNode.isNodeType(NodeType.MIX_VERSIONABLE)) {
- tk.createLabel(innerBox, WorkbenchUiPlugin.getMessage("warningUnversionableNode"));
- } else {
- createHistorySection(innerBox);
- createTreeSection(innerBox);
- }
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unable to check if node is versionable", e);
- }
- }
-
- protected void createTreeSection(Composite parent) {
- Section section = tk.createSection(parent, Section.TWISTIE);
- section.setLayoutData(new GridData(GridData.FILL_BOTH));
- section.setText(WorkbenchUiPlugin.getMessage("versionTreeSectionTitle"));
-
- Composite body = tk.createComposite(section, SWT.FILL);
- section.setClient(body);
- section.setExpanded(true);
- body.setLayoutData(new GridData(GridData.FILL_BOTH));
- body.setLayout(new GridLayout());
-
- nodeContentProvider = new FullVersioningTreeContentProvider();
- nodesViewer = createNodeViewer(body, nodeContentProvider);
- nodesViewer.setInput(currentNode);
- }
-
- protected TreeViewer createNodeViewer(Composite parent, final ITreeContentProvider nodeContentProvider) {
-
- final TreeViewer tmpNodeViewer = new TreeViewer(parent, SWT.MULTI);
-
- tmpNodeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- tmpNodeViewer.setContentProvider(nodeContentProvider);
- tmpNodeViewer.setLabelProvider(new VersionLabelProvider());
- tmpNodeViewer.addDoubleClickListener(new JcrDClickListener(tmpNodeViewer));
- return tmpNodeViewer;
- }
-
- protected void createHistorySection(Composite parent) {
-
- // Section Layout
- Section section = tk.createSection(parent, Section.TWISTIE);
- section.setLayoutData(new GridData(TableWrapData.FILL_GRAB));
- TableWrapLayout twt = new TableWrapLayout();
- section.setLayout(twt);
-
- // Set title of the section
- section.setText(WorkbenchUiPlugin.getMessage("versionHistorySectionTitle"));
-
- final Text styledText = tk.createText(section, "",
- SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
- section.setClient(styledText);
- styledText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB));
- refreshHistory(styledText);
- styledText.setEditable(false);
- section.setExpanded(false);
-
- AbstractFormPart part = new AbstractFormPart() {
- public void commit(boolean onSave) {
- }
-
- public void refresh() {
- super.refresh();
- refreshHistory(styledText);
- }
- };
- getManagedForm().addPart(part);
- }
-
- protected void refreshHistory(Text styledText) {
- try {
- List<VersionDiff> lst = listHistoryDiff();
- StringBuffer main = new StringBuffer("");
-
- for (int i = lst.size() - 1; i >= 0; i--) {
- if (i == 0)
- main.append("Creation (");
- else
- main.append("Update " + i + " (");
-
- if (lst.get(i).getUserId() != null)
- main.append("UserId : " + lst.get(i).getUserId());
-
- if (lst.get(i).getUserId() != null && lst.get(i).getUpdateTime() != null)
- main.append(", ");
-
- if (lst.get(i).getUpdateTime() != null)
- main.append("Date : " + timeFormatter.format(lst.get(i).getUpdateTime().getTime()) + ")\n");
-
- StringBuffer buf = new StringBuffer("");
- Map<String, PropertyDiff> diffs = lst.get(i).getDiffs();
- for (String prop : diffs.keySet()) {
- PropertyDiff pd = diffs.get(prop);
- // String propName = pd.getRelPath();
- Value refValue = pd.getReferenceValue();
- Value newValue = pd.getNewValue();
- String refValueStr = "";
- String newValueStr = "";
-
- if (refValue != null) {
- if (refValue.getType() == PropertyType.DATE) {
- refValueStr = timeFormatter.format(refValue.getDate().getTime());
- } else
- refValueStr = refValue.getString();
- }
- if (newValue != null) {
- if (newValue.getType() == PropertyType.DATE) {
- newValueStr = timeFormatter.format(newValue.getDate().getTime());
- } else
- newValueStr = newValue.getString();
- }
-
- if (pd.getType() == PropertyDiff.MODIFIED) {
- buf.append(prop).append(": ");
- buf.append(refValueStr);
- buf.append(" > ");
- buf.append(newValueStr);
- buf.append("\n");
- } else if (pd.getType() == PropertyDiff.ADDED && !"".equals(newValueStr)) {
- // we don't list property that have been added with an
- // empty string as value
- buf.append(prop).append(": ");
- buf.append(" + ");
- buf.append(newValueStr);
- buf.append("\n");
- } else if (pd.getType() == PropertyDiff.REMOVED) {
- buf.append(prop).append(": ");
- buf.append(" - ");
- buf.append(refValueStr);
- buf.append("\n");
- }
- }
- buf.append("\n");
- main.append(buf);
- }
- styledText.setText(main.toString());
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot generate history for node", e);
- }
- }
-
- public List<VersionDiff> listHistoryDiff() {
- try {
- List<VersionDiff> res = new ArrayList<VersionDiff>();
- VersionManager versionManager = currentNode.getSession().getWorkspace().getVersionManager();
- VersionHistory versionHistory = versionManager.getVersionHistory(currentNode.getPath());
-
- VersionIterator vit = versionHistory.getAllLinearVersions();
- while (vit.hasNext()) {
- Version version = vit.nextVersion();
- Node node = version.getFrozenNode();
- Version predecessor = null;
- try {
- predecessor = version.getLinearPredecessor();
- } catch (Exception e) {
- // no predecessor seems to throw an exception even if it
- // shouldn't...
- }
- if (predecessor == null) {// original
- } else {
- Map<String, PropertyDiff> diffs = JcrUtils.diffProperties(predecessor.getFrozenNode(), node);
- if (!diffs.isEmpty()) {
- String lastUserName = null;
- Calendar lastUpdate = null;
- try {
- if (currentNode.isNodeType(NodeType.MIX_LAST_MODIFIED)) {
- lastUserName = node.getProperty(Property.JCR_LAST_MODIFIED_BY).getString();
- lastUpdate = node.getProperty(Property.JCR_LAST_MODIFIED).getDate();
- } else
- lastUpdate = version.getProperty(Property.JCR_CREATED).getDate();
-
- } catch (Exception e) {
- // Silent that info is optional
- }
- VersionDiff vd = new VersionDiff(lastUserName, lastUpdate, diffs);
- res.add(vd);
- }
- }
- }
- return res;
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot generate history for node ");
- }
-
- }
-
- @Override
- public void setActive(boolean active) {
- super.setActive(active);
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.jcr.parts;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/**
- * An editor input based on three strings define a node :
- * <ul>
- * <li>complete path to the node</li>
- * <li>the workspace name</li>
- * <li>the repository alias</li>
- * </ul>
- * In a single workspace and/or repository environment, name and alias can be
- * null.
- *
- * Note : unused for the time being.
- */
-
-public class StringNodeEditorInput implements IEditorInput {
- private final String path;
- private final String repositoryAlias;
- private final String workspaceName;
-
- /**
- * In order to implement a generic explorer that supports remote and multi
- * workspaces repositories, node path can be detailed by these strings.
- *
- * @param repositoryAlias
- * : can be null
- * @param workspaceName
- * : can be null
- * @param path
- */
- public StringNodeEditorInput(String repositoryAlias, String workspaceName,
- String path) {
- this.path = path;
- this.repositoryAlias = repositoryAlias;
- this.workspaceName = workspaceName;
- }
-
- @SuppressWarnings("unchecked")
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public boolean exists() {
- return true;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- return path;
- }
-
- public String getRepositoryAlias() {
- return repositoryAlias;
- }
-
- public String getWorkspaceName() {
- return workspaceName;
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public String getToolTipText() {
- return path;
- }
-
- public String getPath() {
- return path;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
-
- StringNodeEditorInput other = (StringNodeEditorInput) obj;
-
- if (!path.equals(other.getPath()))
- return false;
-
- String own = other.getWorkspaceName();
- if ((workspaceName == null && own != null)
- || (workspaceName != null && (own == null || !workspaceName
- .equals(own))))
- return false;
-
- String ora = other.getRepositoryAlias();
- if ((repositoryAlias == null && ora != null)
- || (repositoryAlias != null && (ora == null || !repositoryAlias
- .equals(ora))))
- return false;
-
- return true;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin;
-
-import org.argeo.cms.CmsException;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IStartup;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-
-/** Manage transaction and part refresh while updating the security model */
-public class PartStateChanged implements IPartListener, IStartup {
- // private final static Log log = LogFactory.getLog(PartStateChanged.class);
- // private IContextActivation contextActivation;
-
- @Override
- public void earlyStartup() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- IWorkbenchPage iwp = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- if (iwp != null)
- iwp.addPartListener(new PartStateChanged());
- } catch (Exception e) {
- throw new CmsException(
- "Error while registering the PartStateChangedListener",
- e);
- }
- }
- });
- }
-
- @Override
- public void partActivated(IWorkbenchPart part) {
- // Nothing to do
- }
-
- @Override
- public void partBroughtToTop(IWorkbenchPart part) {
- // Nothing to do
- }
-
- @Override
- public void partClosed(IWorkbenchPart part) {
- // Nothing to do
- }
-
- @Override
- public void partDeactivated(IWorkbenchPart part) {
- // Nothing to do
- }
-
- @Override
- public void partOpened(IWorkbenchPart part) {
- // Nothing to do
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin;
-
-import static org.argeo.cms.ui.workbench.WorkbenchUiPlugin.getImageDescriptor;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-
-/** Shared icons that must be declared programmatically . */
-public class SecurityAdminImages {
- private final static String PREFIX = "icons/";
-
- public final static ImageDescriptor ICON_REMOVE_DESC = getImageDescriptor(PREFIX + "delete.png");
- public final static ImageDescriptor ICON_USER_DESC = getImageDescriptor(PREFIX + "person.png");
-
- public final static Image ICON_USER = ICON_USER_DESC.createImage();
- public final static Image ICON_GROUP = getImageDescriptor(PREFIX + "group.png").createImage();
- public final static Image ICON_WORKGROUP = getImageDescriptor(PREFIX + "workgroup.png").createImage();
- public final static Image ICON_ROLE = getImageDescriptor(PREFIX + "role.gif").createImage();
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin;
-
-import javax.transaction.UserTransaction;
-
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserTransactionProvider;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.services.ISourceProviderService;
-
-/** First effort to centralize back end methods used by the user admin UI */
-public class UiAdminUtils {
- /*
- * INTERNAL METHODS: Below methods are meant to stay here and are not part
- * of a potential generic backend to manage the useradmin
- */
- /** Easily notify the ActiveWindow that the transaction had a state change */
- public final static void notifyTransactionStateChange(
- UserTransaction userTransaction) {
- try {
- IWorkbenchWindow aww = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- ISourceProviderService sourceProviderService = (ISourceProviderService) aww
- .getService(ISourceProviderService.class);
- UserTransactionProvider esp = (UserTransactionProvider) sourceProviderService
- .getSourceProvider(UserTransactionProvider.TRANSACTION_STATE);
- esp.fireTransactionStateChange();
- } catch (Exception e) {
- throw new CmsException("Unable to begin transaction", e);
- }
- }
-
- /**
- * Email addresses must match this regexp pattern ({@value #EMAIL_PATTERN}.
- * Thanks to <a href=
- * "http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/"
- * >this tip</a>.
- */
- public final static String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin;
-
-import org.eclipse.swt.widgets.Display;
-import org.osgi.service.useradmin.UserAdminEvent;
-import org.osgi.service.useradmin.UserAdminListener;
-
-/** Convenience class to insure the call to refresh is done in the UI thread */
-public abstract class UiUserAdminListener implements UserAdminListener {
-
- private final Display display;
-
- public UiUserAdminListener(Display display) {
- this.display = display;
- }
-
- @Override
- public void roleChanged(final UserAdminEvent event) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- roleChangedToUiThread(event);
- }
- });
- }
-
- public abstract void roleChangedToUiThread(UserAdminEvent event);
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.transaction.Status;
-import javax.transaction.UserTransaction;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.CmsException;
-import org.argeo.osgi.useradmin.UserAdminConf;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.useradmin.UserAdmin;
-import org.osgi.service.useradmin.UserAdminEvent;
-import org.osgi.service.useradmin.UserAdminListener;
-
-/** Centralise interaction with the UserAdmin in this bundle */
-public class UserAdminWrapper {
-
- private UserAdmin userAdmin;
- private ServiceReference<UserAdmin> userAdminServiceReference;
- private UserTransaction userTransaction;
-
- // First effort to simplify UX while managing users and groups
- public final static boolean COMMIT_ON_SAVE = true;
-
- // Registered listeners
- List<UserAdminListener> listeners = new ArrayList<UserAdminListener>();
-
- /**
- * Starts a transaction if necessary. Should always been called together
- * with {@link UserAdminWrapper#commitOrNotifyTransactionStateChange()} once
- * the security model changes have been performed.
- */
- public UserTransaction beginTransactionIfNeeded() {
- try {
- // UserTransaction userTransaction = getUserTransaction();
- if (userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION) {
- userTransaction.begin();
- // UiAdminUtils.notifyTransactionStateChange(userTransaction);
- }
- return userTransaction;
- } catch (Exception e) {
- throw new CmsException("Unable to begin transaction", e);
- }
- }
-
- /**
- * Depending on the current application configuration, it will either commit
- * the current transaction or throw a notification that the transaction
- * state has changed (In the later case, it must be called from the UI
- * thread).
- */
- public void commitOrNotifyTransactionStateChange() {
- try {
- // UserTransaction userTransaction = getUserTransaction();
- if (userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION)
- return;
-
- if (UserAdminWrapper.COMMIT_ON_SAVE)
- userTransaction.commit();
- else
- UiAdminUtils.notifyTransactionStateChange(userTransaction);
- } catch (Exception e) {
- throw new CmsException("Unable to clean transaction", e);
- }
- }
-
- // TODO implement safer mechanism
- public void addListener(UserAdminListener userAdminListener) {
- if (!listeners.contains(userAdminListener))
- listeners.add(userAdminListener);
- }
-
- public void removeListener(UserAdminListener userAdminListener) {
- if (listeners.contains(userAdminListener))
- listeners.remove(userAdminListener);
- }
-
- public void notifyListeners(UserAdminEvent event) {
- for (UserAdminListener listener : listeners)
- listener.roleChanged(event);
- }
-
- public Map<String, String> getKnownBaseDns(boolean onlyWritable) {
- Map<String, String> dns = new HashMap<String, String>();
- for (String uri : userAdminServiceReference.getPropertyKeys()) {
- if (!uri.startsWith("/"))
- continue;
- Dictionary<String, ?> props = UserAdminConf.uriAsProperties(uri);
- String readOnly = UserAdminConf.readOnly.getValue(props);
- String baseDn = UserAdminConf.baseDn.getValue(props);
-
- if (onlyWritable && "true".equals(readOnly))
- continue;
- if (baseDn.equalsIgnoreCase(NodeConstants.ROLES_BASEDN))
- continue;
- dns.put(baseDn, uri);
- }
- return dns;
- }
-
- public UserAdmin getUserAdmin() {
- return userAdmin;
- }
-
- public UserTransaction getUserTransaction() {
- return userTransaction;
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdmin(UserAdmin userAdmin) {
- this.userAdmin = userAdmin;
- }
-
- public void setUserTransaction(UserTransaction userTransaction) {
- this.userTransaction = userTransaction;
- }
-
- public void setUserAdminServiceReference(
- ServiceReference<UserAdmin> userAdminServiceReference) {
- this.userAdminServiceReference = userAdminServiceReference;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.commands;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditorInput;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.osgi.service.useradmin.Group;
-import org.osgi.service.useradmin.UserAdmin;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/** Delete the selected groups */
-public class DeleteGroups extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".deleteGroups";
-
- /* DEPENDENCY INJECTION */
- private UserAdminWrapper userAdminWrapper;
-
- @SuppressWarnings("unchecked")
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection.isEmpty())
- return null;
-
- List<Group> groups = new ArrayList<Group>();
- Iterator<Group> it = ((IStructuredSelection) selection).iterator();
- StringBuilder builder = new StringBuilder();
- while (it.hasNext()) {
- Group currGroup = it.next();
- String groupName = UserAdminUtils.getUserLocalId(currGroup.getName());
- // TODO add checks
- builder.append(groupName).append("; ");
- groups.add(currGroup);
- }
-
- if (!MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Delete Groups", "Are you sure that you "
- + "want to delete these groups?\n" + builder.substring(0, builder.length() - 2)))
- return null;
-
- userAdminWrapper.beginTransactionIfNeeded();
- UserAdmin userAdmin = userAdminWrapper.getUserAdmin();
- IWorkbenchPage iwp = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
- for (Group group : groups) {
- String groupName = group.getName();
- // TODO find a way to close the editor cleanly if opened. Cannot be
- // done through the UserAdminListeners, it causes a
- // java.util.ConcurrentModificationException because disposing the
- // editor unregisters and disposes the listener
- IEditorPart part = iwp.findEditor(new UserEditorInput(groupName));
- if (part != null)
- iwp.closeEditor(part, false);
- userAdmin.removeRole(groupName);
- }
- userAdminWrapper.commitOrNotifyTransactionStateChange();
-
- // Update the view
- for (Group group : groups) {
- userAdminWrapper.notifyListeners(new UserAdminEvent(null, UserAdminEvent.ROLE_REMOVED, group));
- }
-
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdminWrapper(UserAdminWrapper userAdminWrapper) {
- this.userAdminWrapper = userAdminWrapper;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.commands;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditorInput;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdmin;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/** Delete the selected users */
-public class DeleteUsers extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".deleteUsers";
-
- /* DEPENDENCY INJECTION */
- private UserAdminWrapper userAdminWrapper;
-
- @SuppressWarnings("unchecked")
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection.isEmpty())
- return null;
-
- Iterator<User> it = ((IStructuredSelection) selection).iterator();
- List<User> users = new ArrayList<User>();
- StringBuilder builder = new StringBuilder();
-
- while (it.hasNext()) {
- User currUser = it.next();
- String userName = UserAdminUtils.getUserLocalId(currUser.getName());
- if (UserAdminUtils.isCurrentUser(currUser)) {
- MessageDialog.openError(HandlerUtil.getActiveShell(event), "Deletion forbidden",
- "You cannot delete your own user this way.");
- return null;
- }
- builder.append(userName).append("; ");
- users.add(currUser);
- }
-
- if (!MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Delete Users",
- "Are you sure that you want to delete these users?\n" + builder.substring(0, builder.length() - 2)))
- return null;
-
- userAdminWrapper.beginTransactionIfNeeded();
- UserAdmin userAdmin = userAdminWrapper.getUserAdmin();
- IWorkbenchPage iwp = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-
- for (User user : users) {
- String userName = user.getName();
- // TODO find a way to close the editor cleanly if opened. Cannot be
- // done through the UserAdminListeners, it causes a
- // java.util.ConcurrentModificationException because disposing the
- // editor unregisters and disposes the listener
- IEditorPart part = iwp.findEditor(new UserEditorInput(userName));
- if (part != null)
- iwp.closeEditor(part, false);
- userAdmin.removeRole(userName);
- }
- userAdminWrapper.commitOrNotifyTransactionStateChange();
-
- for (User user : users) {
- userAdminWrapper.notifyListeners(new UserAdminEvent(null, UserAdminEvent.ROLE_REMOVED, user));
- }
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdminWrapper(UserAdminWrapper userAdminWrapper) {
- this.userAdminWrapper = userAdminWrapper;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.commands;
-
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.GroupsView;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UsersView;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Retrieve the active view or editor and call forceRefresh method if defined */
-public class ForceRefresh extends AbstractHandler {
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow iww = HandlerUtil.getActiveWorkbenchWindow(event);
- if (iww == null)
- return null;
- IWorkbenchPage activePage = iww.getActivePage();
- IWorkbenchPart part = activePage.getActivePart();
- if (part instanceof UsersView)
- ((UsersView) part).refresh();
- else if (part instanceof GroupsView)
- ((GroupsView) part).refresh();
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.commands;
-
-import java.util.Dictionary;
-import java.util.Map;
-
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.naming.LdapAttrs;
-import org.argeo.osgi.useradmin.UserAdminConf;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.osgi.service.useradmin.Group;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/** Create a new group */
-public class NewGroup extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".newGroup";
-
- /* DEPENDENCY INJECTION */
- private UserAdminWrapper userAdminWrapper;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- NewGroupWizard newGroupWizard = new NewGroupWizard();
- newGroupWizard.setWindowTitle("Group creation");
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), newGroupWizard);
- dialog.open();
- return null;
- }
-
- private class NewGroupWizard extends Wizard {
-
- // Pages
- private MainGroupInfoWizardPage mainGroupInfo;
-
- // UI fields
- private Text dNameTxt, commonNameTxt, descriptionTxt;
- private Combo baseDnCmb;
-
- public NewGroupWizard() {
- }
-
- @Override
- public void addPages() {
- mainGroupInfo = new MainGroupInfoWizardPage();
- addPage(mainGroupInfo);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public boolean performFinish() {
- if (!canFinish())
- return false;
- String commonName = commonNameTxt.getText();
- try {
- userAdminWrapper.beginTransactionIfNeeded();
- String dn = getDn(commonName);
- Group group = (Group) userAdminWrapper.getUserAdmin()
- .createRole(dn, Role.GROUP);
- Dictionary props = group.getProperties();
- String descStr = descriptionTxt.getText();
- if (EclipseUiUtils.notEmpty(descStr))
- props.put(LdapAttrs.description.name(), descStr);
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- userAdminWrapper.notifyListeners(new UserAdminEvent(null,
- UserAdminEvent.ROLE_CREATED, group));
- return true;
- } catch (Exception e) {
- ErrorFeedback.show("Cannot create new group " + commonName, e);
- return false;
- }
- }
-
- private class MainGroupInfoWizardPage extends WizardPage implements
- FocusListener, ArgeoNames {
- private static final long serialVersionUID = -3150193365151601807L;
-
- public MainGroupInfoWizardPage() {
- super("Main");
- setTitle("General information");
- setMessage("Please choose a domain, provide a common name "
- + "and a free description");
- }
-
- @Override
- public void createControl(Composite parent) {
- Composite bodyCmp = new Composite(parent, SWT.NONE);
- setControl(bodyCmp);
- bodyCmp.setLayout(new GridLayout(2, false));
-
- dNameTxt = EclipseUiUtils.createGridLT(bodyCmp,
- "Distinguished name");
- dNameTxt.setEnabled(false);
-
- baseDnCmb = createGridLC(bodyCmp, "Base DN");
- // Initialise before adding the listener to avoid NPE
- initialiseDnCmb(baseDnCmb);
- baseDnCmb.addFocusListener(this);
-
- commonNameTxt = EclipseUiUtils.createGridLT(bodyCmp,
- "Common name");
- commonNameTxt.addFocusListener(this);
-
- Label descLbl = new Label(bodyCmp, SWT.LEAD);
- descLbl.setText("Description");
- descLbl.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false,
- false));
- descriptionTxt = new Text(bodyCmp, SWT.LEAD | SWT.MULTI
- | SWT.WRAP | SWT.BORDER);
- descriptionTxt.setLayoutData(EclipseUiUtils.fillAll());
- descriptionTxt.addFocusListener(this);
-
- // Initialize buttons
- setPageComplete(false);
- getContainer().updateButtons();
- }
-
- @Override
- public void focusLost(FocusEvent event) {
- String name = commonNameTxt.getText();
- if (EclipseUiUtils.isEmpty(name))
- dNameTxt.setText("");
- else
- dNameTxt.setText(getDn(name));
-
- String message = checkComplete();
- if (message != null) {
- setMessage(message, WizardPage.ERROR);
- setPageComplete(false);
- } else {
- setMessage("Complete", WizardPage.INFORMATION);
- setPageComplete(true);
- }
- getContainer().updateButtons();
- }
-
- @Override
- public void focusGained(FocusEvent event) {
- }
-
- /** @return the error message or null if complete */
- protected String checkComplete() {
- String name = commonNameTxt.getText();
-
- if (name.trim().equals(""))
- return "Common name must not be empty";
- Role role = userAdminWrapper.getUserAdmin()
- .getRole(getDn(name));
- if (role != null)
- return "Group " + name + " already exists";
- return null;
- }
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible)
- if (baseDnCmb.getSelectionIndex() == -1)
- baseDnCmb.setFocus();
- else
- commonNameTxt.setFocus();
- }
- }
-
- private Map<String, String> getDns() {
- return userAdminWrapper.getKnownBaseDns(true);
- }
-
- private String getDn(String cn) {
- Map<String, String> dns = getDns();
- String bdn = baseDnCmb.getText();
- if (EclipseUiUtils.notEmpty(bdn)) {
- Dictionary<String, ?> props = UserAdminConf.uriAsProperties(dns
- .get(bdn));
- String dn = LdapAttrs.cn.name() + "=" + cn + ","
- + UserAdminConf.groupBase.getValue(props) + "," + bdn;
- return dn;
- }
- return null;
- }
-
- private void initialiseDnCmb(Combo combo) {
- Map<String, String> dns = userAdminWrapper.getKnownBaseDns(true);
- if (dns.isEmpty())
- throw new CmsException(
- "No writable base dn found. Cannot create group");
- combo.setItems(dns.keySet().toArray(new String[0]));
- if (dns.size() == 1)
- combo.select(0);
- }
- }
-
- private Combo createGridLC(Composite parent, String label) {
- Label lbl = new Label(parent, SWT.LEAD);
- lbl.setText(label);
- lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
- Combo combo = new Combo(parent, SWT.LEAD | SWT.BORDER | SWT.READ_ONLY);
- combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- return combo;
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdminWrapper(UserAdminWrapper userAdminWrapper) {
- this.userAdminWrapper = userAdminWrapper;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.commands;
-
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Map;
-
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-import javax.naming.ldap.Rdn;
-
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.useradmin.UiAdminUtils;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.naming.LdapAttrs;
-import org.argeo.osgi.useradmin.UserAdminConf;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/** Open a wizard that enables creation of a new user. */
-public class NewUser extends AbstractHandler {
- // private final static Log log = LogFactory.getLog(NewUser.class);
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".newUser";
-
- /* DEPENDENCY INJECTION */
- private UserAdminWrapper userAdminWrapper;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- NewUserWizard newUserWizard = new NewUserWizard();
- newUserWizard.setWindowTitle("User creation");
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), newUserWizard);
- dialog.open();
- return null;
- }
-
- private class NewUserWizard extends Wizard {
-
- // pages
- private MainUserInfoWizardPage mainUserInfo;
-
- // End user fields
- private Text dNameTxt, usernameTxt, firstNameTxt, lastNameTxt,
- primaryMailTxt, pwd1Txt, pwd2Txt;
- private Combo baseDnCmb;
-
- public NewUserWizard() {
-
- }
-
- @Override
- public void addPages() {
- mainUserInfo = new MainUserInfoWizardPage();
- addPage(mainUserInfo);
- String message = "Default wizard that also eases user creation tests:\n "
- + "Mail and last name are automatically "
- + "generated form the uid. Password are defauted to 'demo'.";
- mainUserInfo.setMessage(message, WizardPage.WARNING);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public boolean performFinish() {
- if (!canFinish())
- return false;
- String username = mainUserInfo.getUsername();
- userAdminWrapper.beginTransactionIfNeeded();
- try {
- User user = (User) userAdminWrapper.getUserAdmin().createRole(
- getDn(username), Role.USER);
-
- Dictionary props = user.getProperties();
-
- String lastNameStr = lastNameTxt.getText();
- if (EclipseUiUtils.notEmpty(lastNameStr))
- props.put(LdapAttrs.sn.name(), lastNameStr);
-
- String firstNameStr = firstNameTxt.getText();
- if (EclipseUiUtils.notEmpty(firstNameStr))
- props.put(LdapAttrs.givenName.name(), firstNameStr);
-
- String cn = UserAdminUtils.buildDefaultCn(firstNameStr,
- lastNameStr);
- if (EclipseUiUtils.notEmpty(cn))
- props.put(LdapAttrs.cn.name(), cn);
-
- String mailStr = primaryMailTxt.getText();
- if (EclipseUiUtils.notEmpty(mailStr))
- props.put(LdapAttrs.mail.name(), mailStr);
-
- char[] password = mainUserInfo.getPassword();
- user.getCredentials().put(null, password);
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- userAdminWrapper.notifyListeners(new UserAdminEvent(null,
- UserAdminEvent.ROLE_CREATED, user));
- return true;
- } catch (Exception e) {
- ErrorFeedback.show("Cannot create new user " + username, e);
- return false;
- }
- }
-
- private class MainUserInfoWizardPage extends WizardPage implements
- ModifyListener, ArgeoNames {
- private static final long serialVersionUID = -3150193365151601807L;
-
- public MainUserInfoWizardPage() {
- super("Main");
- setTitle("Required Information");
- }
-
- @Override
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- dNameTxt = EclipseUiUtils.createGridLT(composite,
- "Distinguished name", this);
- dNameTxt.setEnabled(false);
-
- baseDnCmb = createGridLC(composite, "Base DN");
- initialiseDnCmb(baseDnCmb);
- baseDnCmb.addModifyListener(this);
- baseDnCmb.addModifyListener(new ModifyListener() {
- private static final long serialVersionUID = -1435351236582736843L;
-
- @Override
- public void modifyText(ModifyEvent event) {
- String name = usernameTxt.getText();
- dNameTxt.setText(getDn(name));
- }
- });
-
- usernameTxt = EclipseUiUtils.createGridLT(composite,
- "Local ID", this);
- usernameTxt.addModifyListener(new ModifyListener() {
- private static final long serialVersionUID = -1435351236582736843L;
-
- @Override
- public void modifyText(ModifyEvent event) {
- String name = usernameTxt.getText();
- if (name.trim().equals("")) {
- dNameTxt.setText("");
- lastNameTxt.setText("");
- primaryMailTxt.setText("");
- pwd1Txt.setText("");
- pwd2Txt.setText("");
- } else {
- dNameTxt.setText(getDn(name));
- lastNameTxt.setText(name.toUpperCase());
- primaryMailTxt.setText(getMail(name));
- pwd1Txt.setText("demo");
- pwd2Txt.setText("demo");
- }
- }
- });
-
- primaryMailTxt = EclipseUiUtils.createGridLT(composite,
- "Email", this);
- firstNameTxt = EclipseUiUtils.createGridLT(composite,
- "First name", this);
- lastNameTxt = EclipseUiUtils.createGridLT(composite,
- "Last name", this);
- pwd1Txt = EclipseUiUtils.createGridLP(composite, "Password",
- this);
- pwd2Txt = EclipseUiUtils.createGridLP(composite,
- "Repeat password", this);
- setControl(composite);
-
- // Initialize buttons
- setPageComplete(false);
- getContainer().updateButtons();
- }
-
- @Override
- public void modifyText(ModifyEvent event) {
- String message = checkComplete();
- if (message != null) {
- setMessage(message, WizardPage.ERROR);
- setPageComplete(false);
- } else {
- setMessage("Complete", WizardPage.INFORMATION);
- setPageComplete(true);
- }
- getContainer().updateButtons();
- }
-
- /** @return error message or null if complete */
- protected String checkComplete() {
- String name = usernameTxt.getText();
-
- if (name.trim().equals(""))
- return "User name must not be empty";
- Role role = userAdminWrapper.getUserAdmin()
- .getRole(getDn(name));
- if (role != null)
- return "User " + name + " already exists";
- if (!primaryMailTxt.getText().matches(UiAdminUtils.EMAIL_PATTERN))
- return "Not a valid email address";
- if (lastNameTxt.getText().trim().equals(""))
- return "Specify a last name";
- if (pwd1Txt.getText().trim().equals(""))
- return "Specify a password";
- if (pwd2Txt.getText().trim().equals(""))
- return "Repeat the password";
- if (!pwd2Txt.getText().equals(pwd1Txt.getText()))
- return "Passwords are different";
- return null;
- }
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible)
- if (baseDnCmb.getSelectionIndex() == -1)
- baseDnCmb.setFocus();
- else
- usernameTxt.setFocus();
- }
-
- public String getUsername() {
- return usernameTxt.getText();
- }
-
- public char[] getPassword() {
- return pwd1Txt.getTextChars();
- }
-
- }
-
- private Map<String, String> getDns() {
- return userAdminWrapper.getKnownBaseDns(true);
- }
-
- private String getDn(String uid) {
- Map<String, String> dns = getDns();
- String bdn = baseDnCmb.getText();
- if (EclipseUiUtils.notEmpty(bdn)) {
- Dictionary<String, ?> props = UserAdminConf.uriAsProperties(dns
- .get(bdn));
- String dn = LdapAttrs.uid.name() + "=" + uid + ","
- + UserAdminConf.userBase.getValue(props) + "," + bdn;
- return dn;
- }
- return null;
- }
-
- private void initialiseDnCmb(Combo combo) {
- Map<String, String> dns = userAdminWrapper.getKnownBaseDns(true);
- if (dns.isEmpty())
- throw new CmsException(
- "No writable base dn found. Cannot create user");
- combo.setItems(dns.keySet().toArray(new String[0]));
- if (dns.size() == 1)
- combo.select(0);
- }
-
- private String getMail(String username) {
- if (baseDnCmb.getSelectionIndex() == -1)
- return null;
- String baseDn = baseDnCmb.getText();
- try {
- LdapName name = new LdapName(baseDn);
- List<Rdn> rdns = name.getRdns();
- return username + "@" + (String) rdns.get(1).getValue() + '.'
- + (String) rdns.get(0).getValue();
- } catch (InvalidNameException e) {
- throw new CmsException("Unable to generate mail for "
- + username + " with base dn " + baseDn, e);
- }
- }
- }
-
- private Combo createGridLC(Composite parent, String label) {
- Label lbl = new Label(parent, SWT.LEAD);
- lbl.setText(label);
- lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
- Combo combo = new Combo(parent, SWT.LEAD | SWT.BORDER | SWT.READ_ONLY);
- combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- return combo;
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdminWrapper(UserAdminWrapper userAdminWrapper) {
- this.userAdminWrapper = userAdminWrapper;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.commands;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Save the currently edited Argeo user. */
-public class SaveArgeoUser extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".saveArgeoUser";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- try {
- IWorkbenchPart iwp = HandlerUtil.getActiveWorkbenchWindow(event)
- .getActivePage().getActivePart();
- if (!(iwp instanceof IEditorPart))
- return null;
- IEditorPart editor = (IEditorPart) iwp;
- editor.doSave(null);
- } catch (Exception e) {
- MessageDialog.openError(Display.getDefault().getActiveShell(),
- "Error", "Cannot save user: " + e.getMessage());
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.commands;
-
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UserBatchUpdateWizard;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Launch a wizard to perform batch process on users */
-public class UserBatchUpdate extends AbstractHandler {
-
- /* DEPENDENCY INJECTION */
- private UserAdminWrapper uaWrapper;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- UserBatchUpdateWizard wizard = new UserBatchUpdateWizard(uaWrapper);
- wizard.setWindowTitle("User batch processing");
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
- dialog.open();
- return null;
- }
-
- public void setUserAdminWrapper(UserAdminWrapper userAdminWrapper) {
- this.uaWrapper = userAdminWrapper;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.commands;
-
-import javax.transaction.Status;
-import javax.transaction.UserTransaction;
-
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.useradmin.UiAdminUtils;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/** Manage the transaction that is bound to the current perspective */
-public class UserTransactionHandler extends AbstractHandler {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".userTransactionHandler";
-
- public final static String PARAM_COMMAND_ID = "param.commandId";
-
- public final static String TRANSACTION_BEGIN = "transaction.begin";
- public final static String TRANSACTION_COMMIT = "transaction.commit";
- public final static String TRANSACTION_ROLLBACK = "transaction.rollback";
-
- /* DEPENDENCY INJECTION */
- private UserAdminWrapper userAdminWrapper;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String commandId = event.getParameter(PARAM_COMMAND_ID);
- final UserTransaction userTransaction = userAdminWrapper
- .getUserTransaction();
- try {
- if (TRANSACTION_BEGIN.equals(commandId)) {
- if (userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION)
- throw new CmsException("A transaction already exists");
- else
- userTransaction.begin();
- } else if (TRANSACTION_COMMIT.equals(commandId)) {
- if (userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION)
- throw new CmsException("No transaction.");
- else
- userTransaction.commit();
- } else if (TRANSACTION_ROLLBACK.equals(commandId)) {
- if (userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION)
- throw new CmsException("No transaction to rollback.");
- else {
- userTransaction.rollback();
- userAdminWrapper.notifyListeners(new UserAdminEvent(null,
- UserAdminEvent.ROLE_CHANGED, null));
- }
- }
-
- UiAdminUtils.notifyTransactionStateChange(userTransaction);
- // Try to remove invalid thread access errors when managing users.
- // HandlerUtil.getActivePart(event).getSite().getShell().getDisplay()
- // .asyncExec(new Runnable() {
- // @Override
- // public void run() {
- // UiAdminUtils
- // .notifyTransactionStateChange(userTransaction);
- // }
- // });
-
- } catch (CmsException e) {
- throw e;
- } catch (Exception e) {
- throw new CmsException("Unable to call " + commandId + " on "
- + userTransaction, e);
- }
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdminWrapper(UserAdminWrapper userAdminWrapper) {
- this.userAdminWrapper = userAdminWrapper;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.parts;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/** Editor input for an Argeo user. */
-public class ArgeoUserEditorInput implements IEditorInput {
- private final String username;
-
- public ArgeoUserEditorInput(String username) {
- this.username = username;
- }
-
- @SuppressWarnings("unchecked")
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public boolean exists() {
- return username != null;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- return username != null ? username : "<new user>";
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public String getToolTipText() {
- return username != null ? username : "<new user>";
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof ArgeoUserEditorInput))
- return false;
- if (((ArgeoUserEditorInput) obj).getUsername() == null)
- return false;
- return ((ArgeoUserEditorInput) obj).getUsername().equals(username);
- }
-
- public String getUsername() {
- return username;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.parts;
-
-import static org.argeo.api.NodeInstance.WORKGROUP;
-import static org.argeo.cms.auth.UserAdminUtils.setProperty;
-import static org.argeo.naming.LdapAttrs.businessCategory;
-import static org.argeo.naming.LdapAttrs.description;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-import javax.transaction.UserTransaction;
-
-import org.argeo.api.NodeInstance;
-import org.argeo.api.NodeUtils;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.workbench.CmsWorkbenchStyles;
-import org.argeo.cms.ui.workbench.internal.useradmin.SecurityAdminImages;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditor.GroupChangeListener;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditor.MainInfoListener;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.CommonNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.MailLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.RoleIconLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserFilter;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserTableDefaultDClickListener;
-import org.argeo.cms.ui.util.CmsUiUtils;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.eclipse.ui.ColumnDefinition;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.parts.LdifUsersTable;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.naming.LdapAttrs;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.ui.forms.AbstractFormPart;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.SectionPart;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-import org.osgi.service.useradmin.Group;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdmin;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/** Display/edit main properties of a given group */
-public class GroupMainPage extends FormPage implements ArgeoNames {
- final static String ID = "GroupEditor.mainPage";
-
- private final UserEditor editor;
- private final NodeInstance nodeInstance;
- private final UserAdminWrapper userAdminWrapper;
- private final Session session;
-
- public GroupMainPage(FormEditor editor, UserAdminWrapper userAdminWrapper, Repository repository,
- NodeInstance nodeInstance) {
- super(editor, ID, "Main");
- try {
- session = repository.login();
- } catch (RepositoryException e) {
- throw new CmsException("Cannot retrieve session of in MainGroupPage constructor", e);
- }
- this.editor = (UserEditor) editor;
- this.userAdminWrapper = userAdminWrapper;
- this.nodeInstance = nodeInstance;
- }
-
- protected void createFormContent(final IManagedForm mf) {
- ScrolledForm form = mf.getForm();
- Composite body = form.getBody();
- GridLayout mainLayout = new GridLayout();
- body.setLayout(mainLayout);
- Group group = (Group) editor.getDisplayedUser();
- appendOverviewPart(body, group);
- appendMembersPart(body, group);
- }
-
- @Override
- public void dispose() {
- JcrUtils.logoutQuietly(session);
- super.dispose();
- }
-
- /** Creates the general section */
- protected void appendOverviewPart(final Composite parent, final Group group) {
- FormToolkit tk = getManagedForm().getToolkit();
- Composite body = addSection(tk, parent);
- // GridLayout layout = new GridLayout(5, false);
- GridLayout layout = new GridLayout(2, false);
- body.setLayout(layout);
-
- String cn = UserAdminUtils.getProperty(group, LdapAttrs.cn.name());
- createReadOnlyLT(body, "Name", cn);
- // Text dnTxt = createReadOnlyLT(body, "DN", group.getName());
- createReadOnlyLT(body, "Domain", UserAdminUtils.getDomainName(group));
-
- // Description
- Label descLbl = new Label(body, SWT.LEAD);
- descLbl.setFont(EclipseUiUtils.getBoldFont(body));
- descLbl.setText("Description");
- descLbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false, 2, 1));
- final Text descTxt = new Text(body, SWT.LEAD | SWT.MULTI | SWT.WRAP | SWT.BORDER);
- GridData gd = EclipseUiUtils.fillAll();
- gd.heightHint = 50;
- gd.horizontalSpan = 2;
- descTxt.setLayoutData(gd);
-
- // Mark as workgroup
- Link markAsWorkgroupLk = new Link(body, SWT.NONE);
- markAsWorkgroupLk.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
-
- // create form part (controller)
- final AbstractFormPart part = new SectionPart((Section) body.getParent()) {
-
- private MainInfoListener listener;
-
- @Override
- public void initialize(IManagedForm form) {
- super.initialize(form);
- listener = editor.new MainInfoListener(parent.getDisplay(), this);
- userAdminWrapper.addListener(listener);
- }
-
- @Override
- public void dispose() {
- userAdminWrapper.removeListener(listener);
- super.dispose();
- }
-
- public void commit(boolean onSave) {
- // group.getProperties().put(LdapAttrs.description.name(), descTxt.getText());
- setProperty(group, description, descTxt.getText());
- super.commit(onSave);
- }
-
- @Override
- public void refresh() {
- // dnTxt.setText(group.getName());
- // cnTxt.setText(UserAdminUtils.getProperty(group, LdapAttrs.cn.name()));
- descTxt.setText(UserAdminUtils.getProperty(group, LdapAttrs.description.name()));
- Node workgroupHome = NodeUtils.getGroupHome(session, cn);
- if (workgroupHome == null)
- markAsWorkgroupLk.setText("<a>Mark as workgroup</a>");
- else
- markAsWorkgroupLk.setText("Configured as workgroup");
- parent.layout(true, true);
- super.refresh();
- }
- };
-
- markAsWorkgroupLk.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = -6439340898096365078L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
-
- boolean confirmed = MessageDialog.openConfirm(parent.getShell(), "Mark as workgroup",
- "Are you sure you want to mark " + cn + " as being a workgroup? ");
- if (confirmed) {
- Node workgroupHome = NodeUtils.getGroupHome(session, cn);
- if (workgroupHome != null)
- return; // already marked as workgroup, do nothing
- else
- try {
- // improve transaction management
- userAdminWrapper.beginTransactionIfNeeded();
- nodeInstance.createWorkgroup(new LdapName(group.getName()));
- setProperty(group, businessCategory, WORKGROUP);
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- userAdminWrapper
- .notifyListeners(new UserAdminEvent(null, UserAdminEvent.ROLE_CHANGED, group));
- part.refresh();
- } catch (InvalidNameException e1) {
- throw new CmsException("Cannot create Workgroup for " + group.toString(), e1);
- }
-
- }
- }
- });
-
- ModifyListener defaultListener = editor.new FormPartML(part);
- descTxt.addModifyListener(defaultListener);
- getManagedForm().addPart(part);
- }
-
- /** Filtered table with members. Has drag and drop ability */
- protected void appendMembersPart(Composite parent, Group group) {
- FormToolkit tk = getManagedForm().getToolkit();
- Section section = tk.createSection(parent, Section.TITLE_BAR);
- section.setText("Members");
- section.setLayoutData(EclipseUiUtils.fillAll());
-
- Composite body = new Composite(section, SWT.NO_FOCUS);
- section.setClient(body);
- body.setLayoutData(EclipseUiUtils.fillAll());
-
- LdifUsersTable userTableViewerCmp = createMemberPart(body, group);
-
- SectionPart part = new GroupMembersPart(section, userTableViewerCmp);
- getManagedForm().addPart(part);
- addRemoveAbitily(part, userTableViewerCmp.getTableViewer(), group);
- }
-
- public LdifUsersTable createMemberPart(Composite parent, Group group) {
- parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
- // Define the displayed columns
- List<ColumnDefinition> columnDefs = new ArrayList<ColumnDefinition>();
- columnDefs.add(new ColumnDefinition(new RoleIconLP(), "", 0, 24));
- columnDefs.add(new ColumnDefinition(new CommonNameLP(), "Name", 150));
- columnDefs.add(new ColumnDefinition(new MailLP(), "Mail", 150));
- // columnDefs.add(new ColumnDefinition(new UserNameLP(), "Distinguished Name",
- // 240));
-
- // Create and configure the table
- LdifUsersTable userViewerCmp = new MyUserTableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL,
- userAdminWrapper.getUserAdmin());
-
- userViewerCmp.setColumnDefinitions(columnDefs);
- userViewerCmp.populate(true, false);
- userViewerCmp.setLayoutData(EclipseUiUtils.fillAll());
-
- // Controllers
- TableViewer userViewer = userViewerCmp.getTableViewer();
- userViewer.addDoubleClickListener(new UserTableDefaultDClickListener());
- int operations = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
- userViewer.addDropSupport(operations, tt,
- new GroupDropListener(userAdminWrapper, userViewerCmp, (Group) editor.getDisplayedUser()));
-
- return userViewerCmp;
- }
-
- // Local viewers
- private class MyUserTableViewer extends LdifUsersTable {
- private static final long serialVersionUID = 8467999509931900367L;
-
- private final UserFilter userFilter;
-
- public MyUserTableViewer(Composite parent, int style, UserAdmin userAdmin) {
- super(parent, style, true);
- userFilter = new UserFilter();
-
- }
-
- @Override
- protected List<User> listFilteredElements(String filter) {
- // reload user and set it in the editor
- Group group = (Group) editor.getDisplayedUser();
- Role[] roles = group.getMembers();
- List<User> users = new ArrayList<User>();
- userFilter.setSearchText(filter);
- // userFilter.setShowSystemRole(true);
- for (Role role : roles)
- // if (role.getType() == Role.GROUP)
- if (userFilter.select(null, null, role))
- users.add((User) role);
- return users;
- }
- }
-
- private void addRemoveAbitily(SectionPart sectionPart, TableViewer userViewer, Group group) {
- Section section = sectionPart.getSection();
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
- ToolBar toolbar = toolBarManager.createControl(section);
- final Cursor handCursor = new Cursor(section.getDisplay(), SWT.CURSOR_HAND);
- toolbar.setCursor(handCursor);
- toolbar.addDisposeListener(new DisposeListener() {
- private static final long serialVersionUID = 3882131405820522925L;
-
- public void widgetDisposed(DisposeEvent e) {
- if ((handCursor != null) && (handCursor.isDisposed() == false)) {
- handCursor.dispose();
- }
- }
- });
-
- Action action = new RemoveMembershipAction(userViewer, group, "Remove selected items from this group",
- SecurityAdminImages.ICON_REMOVE_DESC);
- toolBarManager.add(action);
- toolBarManager.update(true);
- section.setTextClient(toolbar);
- }
-
- private class RemoveMembershipAction extends Action {
- private static final long serialVersionUID = -1337713097184522588L;
-
- private final TableViewer userViewer;
- private final Group group;
-
- RemoveMembershipAction(TableViewer userViewer, Group group, String name, ImageDescriptor img) {
- super(name, img);
- this.userViewer = userViewer;
- this.group = group;
- }
-
- @Override
- public void run() {
- ISelection selection = userViewer.getSelection();
- if (selection.isEmpty())
- return;
-
- @SuppressWarnings("unchecked")
- Iterator<User> it = ((IStructuredSelection) selection).iterator();
- List<User> users = new ArrayList<User>();
- while (it.hasNext()) {
- User currUser = it.next();
- users.add(currUser);
- }
-
- userAdminWrapper.beginTransactionIfNeeded();
- for (User user : users) {
- group.removeMember(user);
- }
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- userAdminWrapper.notifyListeners(new UserAdminEvent(null, UserAdminEvent.ROLE_CHANGED, group));
- }
- }
-
- // LOCAL CONTROLLERS
- private class GroupMembersPart extends SectionPart {
- private final LdifUsersTable userViewer;
- // private final Group group;
-
- private GroupChangeListener listener;
-
- public GroupMembersPart(Section section, LdifUsersTable userViewer) {
- super(section);
- this.userViewer = userViewer;
- // this.group = group;
- }
-
- @Override
- public void initialize(IManagedForm form) {
- super.initialize(form);
- listener = editor.new GroupChangeListener(userViewer.getDisplay(), GroupMembersPart.this);
- userAdminWrapper.addListener(listener);
- }
-
- @Override
- public void dispose() {
- userAdminWrapper.removeListener(listener);
- super.dispose();
- }
-
- @Override
- public void refresh() {
- userViewer.refresh();
- super.refresh();
- }
- }
-
- /**
- * Defines this table as being a potential target to add group membership
- * (roles) to this group
- */
- private class GroupDropListener extends ViewerDropAdapter {
- private static final long serialVersionUID = 2893468717831451621L;
-
- private final UserAdminWrapper userAdminWrapper;
- // private final LdifUsersTable myUserViewerCmp;
- private final Group myGroup;
-
- public GroupDropListener(UserAdminWrapper userAdminWrapper, LdifUsersTable userTableViewerCmp, Group group) {
- super(userTableViewerCmp.getTableViewer());
- this.userAdminWrapper = userAdminWrapper;
- this.myGroup = group;
- // this.myUserViewerCmp = userTableViewerCmp;
- }
-
- @Override
- public boolean validateDrop(Object target, int operation, TransferData transferType) {
- // Target is always OK in a list only view
- // TODO check if not a string
- boolean validDrop = true;
- return validDrop;
- }
-
- @Override
- public void drop(DropTargetEvent event) {
- // TODO Is there an opportunity to perform the check before?
- String newUserName = (String) event.data;
- UserAdmin myUserAdmin = userAdminWrapper.getUserAdmin();
- Role role = myUserAdmin.getRole(newUserName);
- if (role.getType() == Role.GROUP) {
- Group newGroup = (Group) role;
- Shell shell = getViewer().getControl().getShell();
- // Sanity checks
- if (myGroup == newGroup) { // Equality
- MessageDialog.openError(shell, "Forbidden addition ", "A group cannot be a member of itself.");
- return;
- }
-
- // Cycle
- String myName = myGroup.getName();
- List<User> myMemberships = editor.getFlatGroups(myGroup);
- if (myMemberships.contains(newGroup)) {
- MessageDialog.openError(shell, "Forbidden addition: cycle",
- "Cannot add " + newUserName + " to group " + myName + ". This would create a cycle");
- return;
- }
-
- // Already member
- List<User> newGroupMemberships = editor.getFlatGroups(newGroup);
- if (newGroupMemberships.contains(myGroup)) {
- MessageDialog.openError(shell, "Forbidden addition",
- "Cannot add " + newUserName + " to group " + myName + ", this membership already exists");
- return;
- }
- userAdminWrapper.beginTransactionIfNeeded();
- myGroup.addMember(newGroup);
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- userAdminWrapper.notifyListeners(new UserAdminEvent(null, UserAdminEvent.ROLE_CHANGED, myGroup));
- } else if (role.getType() == Role.USER) {
- // TODO check if the group is already member of this group
- UserTransaction transaction = userAdminWrapper.beginTransactionIfNeeded();
- User user = (User) role;
- myGroup.addMember(user);
- if (UserAdminWrapper.COMMIT_ON_SAVE)
- try {
- transaction.commit();
- } catch (Exception e) {
- throw new CmsException("Cannot commit transaction " + "after user group membership update", e);
- }
- userAdminWrapper.notifyListeners(new UserAdminEvent(null, UserAdminEvent.ROLE_CHANGED, myGroup));
- }
- super.drop(event);
- }
-
- @Override
- public boolean performDrop(Object data) {
- // myUserViewerCmp.refresh();
- return true;
- }
- }
-
- // LOCAL HELPERS
- private Composite addSection(FormToolkit tk, Composite parent) {
- Section section = tk.createSection(parent, SWT.NO_FOCUS);
- section.setLayoutData(EclipseUiUtils.fillWidth());
- Composite body = tk.createComposite(section, SWT.WRAP);
- body.setLayoutData(EclipseUiUtils.fillAll());
- section.setClient(body);
- return body;
- }
-
- /** Creates label and text. */
- // private Text createLT(Composite parent, String label, String value) {
- // FormToolkit toolkit = getManagedForm().getToolkit();
- // Label lbl = toolkit.createLabel(parent, label);
- // lbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
- // lbl.setFont(EclipseUiUtils.getBoldFont(parent));
- // Text text = toolkit.createText(parent, value, SWT.BORDER);
- // text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- // CmsUiUtils.style(text, CmsWorkbenchStyles.WORKBENCH_FORM_TEXT);
- // return text;
- // }
- //
- Text createReadOnlyLT(Composite parent, String label, String value) {
- FormToolkit toolkit = getManagedForm().getToolkit();
- Label lbl = toolkit.createLabel(parent, label);
- lbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
- lbl.setFont(EclipseUiUtils.getBoldFont(parent));
- Text text = toolkit.createText(parent, value, SWT.NONE);
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- text.setEditable(false);
- CmsUiUtils.style(text, CmsWorkbenchStyles.WORKBENCH_FORM_TEXT);
- return text;
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.parts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.CmsException;
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.useradmin.UiUserAdminListener;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.CommonNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.DomainNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.RoleIconLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserDragListener;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserTableDefaultDClickListener;
-import org.argeo.eclipse.ui.ColumnDefinition;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.parts.LdifUsersTable;
-import org.argeo.naming.LdapAttrs;
-import org.argeo.naming.LdapObjs;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.part.ViewPart;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdminEvent;
-import org.osgi.service.useradmin.UserAdminListener;
-
-/** List all groups with filter */
-public class GroupsView extends ViewPart implements ArgeoNames {
- private final static Log log = LogFactory.getLog(GroupsView.class);
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".groupsView";
-
- /* DEPENDENCY INJECTION */
- private UserAdminWrapper userAdminWrapper;
-
- // UI Objects
- private LdifUsersTable groupTableViewerCmp;
- private TableViewer userViewer;
- private List<ColumnDefinition> columnDefs = new ArrayList<ColumnDefinition>();
-
- private UserAdminListener listener;
-
- @Override
- public void createPartControl(Composite parent) {
- parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
-// boolean isAdmin = CurrentUser.isInRole(NodeConstants.ROLE_ADMIN);
-
- // Define the displayed columns
- columnDefs.add(new ColumnDefinition(new RoleIconLP(), "", 19));
- columnDefs.add(new ColumnDefinition(new CommonNameLP(), "Name", 150));
- columnDefs.add(new ColumnDefinition(new DomainNameLP(), "Domain", 100));
- // Only show technical DN to admin
- // if (isAdmin)
- // columnDefs.add(new ColumnDefinition(new UserNameLP(),
- // "Distinguished Name", 300));
-
- // Create and configure the table
- groupTableViewerCmp = new MyUserTableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
-
- groupTableViewerCmp.setColumnDefinitions(columnDefs);
-// if (isAdmin)
-// groupTableViewerCmp.populateWithStaticFilters(false, false);
-// else
- groupTableViewerCmp.populate(true, false);
-
- groupTableViewerCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // Links
- userViewer = groupTableViewerCmp.getTableViewer();
- userViewer.addDoubleClickListener(new UserTableDefaultDClickListener());
- getViewSite().setSelectionProvider(userViewer);
-
- // Really?
- groupTableViewerCmp.refresh();
-
- // Drag and drop
- int operations = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
- userViewer.addDragSupport(operations, tt, new UserDragListener(userViewer));
-
- // // Register a useradmin listener
- // listener = new UserAdminListener() {
- // @Override
- // public void roleChanged(UserAdminEvent event) {
- // if (userViewer != null && !userViewer.getTable().isDisposed())
- // refresh();
- // }
- // };
- // userAdminWrapper.addListener(listener);
- // }
-
- // Register a useradmin listener
- listener = new MyUiUAListener(parent.getDisplay());
- userAdminWrapper.addListener(listener);
- }
-
- private class MyUiUAListener extends UiUserAdminListener {
- public MyUiUAListener(Display display) {
- super(display);
- }
-
- @Override
- public void roleChangedToUiThread(UserAdminEvent event) {
- if (userViewer != null && !userViewer.getTable().isDisposed())
- refresh();
- }
- }
-
- private class MyUserTableViewer extends LdifUsersTable {
- private static final long serialVersionUID = 8467999509931900367L;
-
- private boolean showSystemRoles = true;
-
- private final String[] knownProps = { LdapAttrs.uid.name(), LdapAttrs.cn.name(), LdapAttrs.DN };
-
- public MyUserTableViewer(Composite parent, int style) {
- super(parent, style);
- showSystemRoles = CurrentUser.isInRole(NodeConstants.ROLE_ADMIN);
- }
-
- protected void populateStaticFilters(Composite staticFilterCmp) {
- staticFilterCmp.setLayout(new GridLayout());
- final Button showSystemRoleBtn = new Button(staticFilterCmp, SWT.CHECK);
- showSystemRoleBtn.setText("Show system roles");
- showSystemRoles = CurrentUser.isInRole(NodeConstants.ROLE_ADMIN);
- showSystemRoleBtn.setSelection(showSystemRoles);
-
- showSystemRoleBtn.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = -7033424592697691676L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- showSystemRoles = showSystemRoleBtn.getSelection();
- refresh();
- }
-
- });
- }
-
- @Override
- protected List<User> listFilteredElements(String filter) {
- Role[] roles;
- try {
- StringBuilder builder = new StringBuilder();
- StringBuilder tmpBuilder = new StringBuilder();
- if (EclipseUiUtils.notEmpty(filter))
- for (String prop : knownProps) {
- tmpBuilder.append("(");
- tmpBuilder.append(prop);
- tmpBuilder.append("=*");
- tmpBuilder.append(filter);
- tmpBuilder.append("*)");
- }
- if (tmpBuilder.length() > 1) {
- builder.append("(&(").append(LdapAttrs.objectClass.name()).append("=")
- .append(LdapObjs.groupOfNames.name()).append(")");
- if (!showSystemRoles)
- builder.append("(!(").append(LdapAttrs.DN).append("=*").append(NodeConstants.ROLES_BASEDN)
- .append("))");
- builder.append("(|");
- builder.append(tmpBuilder.toString());
- builder.append("))");
- } else {
- if (!showSystemRoles)
- builder.append("(&(").append(LdapAttrs.objectClass.name()).append("=")
- .append(LdapObjs.groupOfNames.name()).append(")(!(").append(LdapAttrs.DN).append("=*")
- .append(NodeConstants.ROLES_BASEDN).append(")))");
- else
- builder.append("(").append(LdapAttrs.objectClass.name()).append("=")
- .append(LdapObjs.groupOfNames.name()).append(")");
-
- }
- roles = userAdminWrapper.getUserAdmin().getRoles(builder.toString());
- } catch (InvalidSyntaxException e) {
- throw new CmsException("Unable to get roles with filter: " + filter, e);
- }
- List<User> users = new ArrayList<User>();
- for (Role role : roles)
- if (!users.contains(role))
- users.add((User) role);
- else
- log.warn("Duplicated role: " + role);
-
- return users;
- }
- }
-
- public void refresh() {
- groupTableViewerCmp.refresh();
- }
-
- // Override generic view methods
- @Override
- public void dispose() {
- userAdminWrapper.removeListener(listener);
- super.dispose();
- }
-
- @Override
- public void setFocus() {
- groupTableViewerCmp.setFocus();
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdminWrapper(UserAdminWrapper userAdminWrapper) {
- this.userAdminWrapper = userAdminWrapper;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.parts;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.transaction.SystemException;
-import javax.transaction.UserTransaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.CmsException;
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.ui.workbench.internal.useradmin.UiAdminUtils;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.CommonNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.DomainNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.MailLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserNameLP;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.eclipse.ui.ColumnDefinition;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.parts.LdifUsersTable;
-import org.argeo.naming.LdapAttrs;
-import org.argeo.naming.LdapObjs;
-import org.eclipse.jface.dialogs.IPageChangeProvider;
-import org.eclipse.jface.dialogs.IPageChangedListener;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.PageChangedEvent;
-import org.eclipse.jface.wizard.IWizardContainer;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/** Wizard to update users */
-public class UserBatchUpdateWizard extends Wizard {
-
- private final static Log log = LogFactory.getLog(UserBatchUpdateWizard.class);
- private UserAdminWrapper userAdminWrapper;
-
- // pages
- private ChooseCommandWizardPage chooseCommandPage;
- private ChooseUsersWizardPage userListPage;
- private ValidateAndLaunchWizardPage validatePage;
-
- // Various implemented commands keys
- private final static String CMD_UPDATE_PASSWORD = "resetPassword";
- private final static String CMD_UPDATE_EMAIL = "resetEmail";
- private final static String CMD_GROUP_MEMBERSHIP = "groupMembership";
-
- private final Map<String, String> commands = new HashMap<String, String>() {
- private static final long serialVersionUID = 1L;
- {
- put("Reset password(s)", CMD_UPDATE_PASSWORD);
- put("Reset email(s)", CMD_UPDATE_EMAIL);
- // TODO implement role / group management
- // put("Add/Remove from group", CMD_GROUP_MEMBERSHIP);
- }
- };
-
- public UserBatchUpdateWizard(UserAdminWrapper userAdminWrapper) {
- this.userAdminWrapper = userAdminWrapper;
- }
-
- @Override
- public void addPages() {
- chooseCommandPage = new ChooseCommandWizardPage();
- addPage(chooseCommandPage);
- userListPage = new ChooseUsersWizardPage();
- addPage(userListPage);
- validatePage = new ValidateAndLaunchWizardPage();
- addPage(validatePage);
- }
-
- @Override
- public boolean performFinish() {
- if (!canFinish())
- return false;
- UserTransaction ut = userAdminWrapper.getUserTransaction();
- try {
- if (ut.getStatus() != javax.transaction.Status.STATUS_NO_TRANSACTION
- && !MessageDialog.openConfirm(getShell(), "Existing Transaction",
- "A user transaction is already existing, " + "are you sure you want to proceed ?"))
- return false;
- } catch (SystemException e) {
- throw new CmsException("Cannot get user transaction state " + "before user batch update", e);
- }
-
- // We cannot use jobs, user modifications are still meant to be done in
- // the UIThread
- // UpdateJob job = null;
- // if (job != null)
- // job.schedule();
-
- if (CMD_UPDATE_PASSWORD.equals(chooseCommandPage.getCommand())) {
- char[] newValue = chooseCommandPage.getPwdValue();
- if (newValue == null)
- throw new CmsException("Password cannot be null or an empty string");
- ResetPassword job = new ResetPassword(userAdminWrapper, userListPage.getSelectedUsers(), newValue);
- job.doUpdate();
- } else if (CMD_UPDATE_EMAIL.equals(chooseCommandPage.getCommand())) {
- String newValue = chooseCommandPage.getEmailValue();
- if (newValue == null)
- throw new CmsException("Password cannot be null or an empty string");
- ResetEmail job = new ResetEmail(userAdminWrapper, userListPage.getSelectedUsers(), newValue);
- job.doUpdate();
- }
- return true;
- }
-
- public boolean canFinish() {
- if (this.getContainer().getCurrentPage() == validatePage)
- return true;
- return false;
- }
-
- private class ResetPassword {
- private char[] newPwd;
- private UserAdminWrapper userAdminWrapper;
- private List<User> usersToUpdate;
-
- public ResetPassword(UserAdminWrapper userAdminWrapper, List<User> usersToUpdate, char[] newPwd) {
- this.newPwd = newPwd;
- this.usersToUpdate = usersToUpdate;
- this.userAdminWrapper = userAdminWrapper;
- }
-
- @SuppressWarnings("unchecked")
- protected void doUpdate() {
- userAdminWrapper.beginTransactionIfNeeded();
- try {
- for (User user : usersToUpdate) {
- // the char array is emptied after being used.
- user.getCredentials().put(null, newPwd.clone());
- }
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- } catch (Exception e) {
- throw new CmsException("Cannot perform batch update on users", e);
- } finally {
- UserTransaction ut = userAdminWrapper.getUserTransaction();
- try {
- if (ut.getStatus() != javax.transaction.Status.STATUS_NO_TRANSACTION)
- ut.rollback();
- } catch (IllegalStateException | SecurityException | SystemException e) {
- log.error("Unable to rollback session in 'finally', " + "the system might be in a dirty state");
- e.printStackTrace();
- }
- }
- }
- }
-
- private class ResetEmail {
- private String newEmail;
- private UserAdminWrapper userAdminWrapper;
- private List<User> usersToUpdate;
-
- public ResetEmail(UserAdminWrapper userAdminWrapper, List<User> usersToUpdate, String newEmail) {
- this.newEmail = newEmail;
- this.usersToUpdate = usersToUpdate;
- this.userAdminWrapper = userAdminWrapper;
- }
-
- @SuppressWarnings("unchecked")
- protected void doUpdate() {
- userAdminWrapper.beginTransactionIfNeeded();
- try {
- for (User user : usersToUpdate) {
- // the char array is emptied after being used.
- user.getProperties().put(LdapAttrs.mail.name(), newEmail);
- }
-
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- if (!usersToUpdate.isEmpty())
- userAdminWrapper.notifyListeners(
- new UserAdminEvent(null, UserAdminEvent.ROLE_CHANGED, usersToUpdate.get(0)));
- } catch (Exception e) {
- throw new CmsException("Cannot perform batch update on users", e);
- } finally {
- UserTransaction ut = userAdminWrapper.getUserTransaction();
- try {
- if (ut.getStatus() != javax.transaction.Status.STATUS_NO_TRANSACTION)
- ut.rollback();
- } catch (IllegalStateException | SecurityException | SystemException e) {
- log.error("Unable to rollback session in finally block, the system might be in a dirty state");
- e.printStackTrace();
- }
- }
- }
- }
-
- // @SuppressWarnings("unused")
- // private class AddToGroup extends UpdateJob {
- // private String groupID;
- // private Session session;
- //
- // public AddToGroup(Session session, List<Node> nodesToUpdate,
- // String groupID) {
- // super(session, nodesToUpdate);
- // this.session = session;
- // this.groupID = groupID;
- // }
- //
- // protected void doUpdate(Node node) {
- // log.info("Add/Remove to group actions are not yet implemented");
- // // TODO implement this
- // // try {
- // // throw new CmsException("Not yet implemented");
- // // } catch (RepositoryException re) {
- // // throw new CmsException(
- // // "Unable to update boolean value for node " + node, re);
- // // }
- // }
- // }
-
- // /**
- // * Base privileged job that will be run asynchronously to perform the
- // batch
- // * update
- // */
- // private abstract class UpdateJob extends PrivilegedJob {
- //
- // private final UserAdminWrapper userAdminWrapper;
- // private final List<User> usersToUpdate;
- //
- // protected abstract void doUpdate(User user);
- //
- // public UpdateJob(UserAdminWrapper userAdminWrapper,
- // List<User> usersToUpdate) {
- // super("Perform update");
- // this.usersToUpdate = usersToUpdate;
- // this.userAdminWrapper = userAdminWrapper;
- // }
- //
- // @Override
- // protected IStatus doRun(IProgressMonitor progressMonitor) {
- // try {
- // JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
- // int total = usersToUpdate.size();
- // monitor.beginTask("Performing change", total);
- // userAdminWrapper.beginTransactionIfNeeded();
- // for (User user : usersToUpdate) {
- // doUpdate(user);
- // monitor.worked(1);
- // }
- // userAdminWrapper.getUserTransaction().commit();
- // } catch (Exception e) {
- // throw new CmsException(
- // "Cannot perform batch update on users", e);
- // } finally {
- // UserTransaction ut = userAdminWrapper.getUserTransaction();
- // try {
- // if (ut.getStatus() != javax.transaction.Status.STATUS_NO_TRANSACTION)
- // ut.rollback();
- // } catch (IllegalStateException | SecurityException
- // | SystemException e) {
- // log.error("Unable to rollback session in 'finally', "
- // + "the system might be in a dirty state");
- // e.printStackTrace();
- // }
- // }
- // return Status.OK_STATUS;
- // }
- // }
-
- // PAGES
- /**
- * Displays a combo box that enables user to choose which action to perform
- */
- private class ChooseCommandWizardPage extends WizardPage {
- private static final long serialVersionUID = -8069434295293996633L;
- private Combo chooseCommandCmb;
- private Button trueChk;
- private Text valueTxt;
- private Text pwdTxt;
- private Text pwd2Txt;
-
- public ChooseCommandWizardPage() {
- super("Choose a command to run.");
- setTitle("Choose a command to run.");
- }
-
- @Override
- public void createControl(Composite parent) {
- GridLayout gl = new GridLayout();
- Composite container = new Composite(parent, SWT.NO_FOCUS);
- container.setLayout(gl);
-
- chooseCommandCmb = new Combo(container, SWT.READ_ONLY);
- chooseCommandCmb.setLayoutData(EclipseUiUtils.fillWidth());
- String[] values = commands.keySet().toArray(new String[0]);
- chooseCommandCmb.setItems(values);
-
- final Composite bottomPart = new Composite(container, SWT.NO_FOCUS);
- bottomPart.setLayoutData(EclipseUiUtils.fillAll());
- bottomPart.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
- chooseCommandCmb.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (getCommand().equals(CMD_UPDATE_PASSWORD))
- populatePasswordCmp(bottomPart);
- else if (getCommand().equals(CMD_UPDATE_EMAIL))
- populateEmailCmp(bottomPart);
- else if (getCommand().equals(CMD_GROUP_MEMBERSHIP))
- populateGroupCmp(bottomPart);
- else
- populateBooleanFlagCmp(bottomPart);
- checkPageComplete();
- bottomPart.layout(true, true);
- }
- });
- setControl(container);
- }
-
- private void populateBooleanFlagCmp(Composite parent) {
- EclipseUiUtils.clear(parent);
- trueChk = new Button(parent, SWT.CHECK);
- trueChk.setText("Do it. (It will to the contrary if unchecked)");
- trueChk.setSelection(true);
- trueChk.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
- }
-
- private void populatePasswordCmp(Composite parent) {
- EclipseUiUtils.clear(parent);
- Composite body = new Composite(parent, SWT.NO_FOCUS);
-
- ModifyListener ml = new ModifyListener() {
- private static final long serialVersionUID = -1558726363536729634L;
-
- @Override
- public void modifyText(ModifyEvent event) {
- checkPageComplete();
- }
- };
-
- body.setLayout(new GridLayout(2, false));
- body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- pwdTxt = EclipseUiUtils.createGridLP(body, "New password", ml);
- pwd2Txt = EclipseUiUtils.createGridLP(body, "Repeat password", ml);
- }
-
- private void populateEmailCmp(Composite parent) {
- EclipseUiUtils.clear(parent);
- Composite body = new Composite(parent, SWT.NO_FOCUS);
-
- ModifyListener ml = new ModifyListener() {
- private static final long serialVersionUID = 2147704227294268317L;
-
- @Override
- public void modifyText(ModifyEvent event) {
- checkPageComplete();
- }
- };
-
- body.setLayout(new GridLayout(2, false));
- body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- valueTxt = EclipseUiUtils.createGridLT(body, "New e-mail", ml);
- }
-
- private void checkPageComplete() {
- String errorMsg = null;
- if (chooseCommandCmb.getSelectionIndex() < 0)
- errorMsg = "Please select an action";
- else if (CMD_UPDATE_EMAIL.equals(getCommand())) {
- if (!valueTxt.getText().matches(UiAdminUtils.EMAIL_PATTERN))
- errorMsg = "Not a valid e-mail address";
- } else if (CMD_UPDATE_PASSWORD.equals(getCommand())) {
- if (EclipseUiUtils.isEmpty(pwdTxt.getText()) || pwdTxt.getText().length() < 4)
- errorMsg = "Please enter a password that is at least 4 character long";
- else if (!pwdTxt.getText().equals(pwd2Txt.getText()))
- errorMsg = "Passwords are different";
- }
- if (EclipseUiUtils.notEmpty(errorMsg)) {
- setMessage(errorMsg, WizardPage.ERROR);
- setPageComplete(false);
- } else {
- setMessage("Page complete, you can proceed to user choice", WizardPage.INFORMATION);
- setPageComplete(true);
- }
-
- getContainer().updateButtons();
- }
-
- private void populateGroupCmp(Composite parent) {
- EclipseUiUtils.clear(parent);
- trueChk = new Button(parent, SWT.CHECK);
- trueChk.setText("Add to group. (It will remove user(s) from the " + "corresponding group if unchecked)");
- trueChk.setSelection(true);
- trueChk.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
- }
-
- protected String getCommand() {
- return commands.get(chooseCommandCmb.getItem(chooseCommandCmb.getSelectionIndex()));
- }
-
- protected String getCommandLbl() {
- return chooseCommandCmb.getItem(chooseCommandCmb.getSelectionIndex());
- }
-
- @SuppressWarnings("unused")
- protected boolean getBoleanValue() {
- // FIXME this is not consistent and will lead to errors.
- if ("argeo:enabled".equals(getCommand()))
- return trueChk.getSelection();
- else
- return !trueChk.getSelection();
- }
-
- @SuppressWarnings("unused")
- protected String getStringValue() {
- String value = null;
- if (valueTxt != null) {
- value = valueTxt.getText();
- if ("".equals(value.trim()))
- value = null;
- }
- return value;
- }
-
- protected char[] getPwdValue() {
- // We do not directly reset the password text fields: There is no
- // need to over secure this process: setting a pwd to multi users
- // at the same time is anyhow a bad practice and should be used only
- // in test environment or for temporary access
- if (pwdTxt == null || pwdTxt.isDisposed())
- return null;
- else
- return pwdTxt.getText().toCharArray();
- }
-
- protected String getEmailValue() {
- // We do not directly reset the password text fields: There is no
- // need to over secure this process: setting a pwd to multi users
- // at the same time is anyhow a bad practice and should be used only
- // in test environment or for temporary access
- if (valueTxt == null || valueTxt.isDisposed())
- return null;
- else
- return valueTxt.getText();
- }
- }
-
- /**
- * Displays a list of users with a check box to be able to choose some of
- * them
- */
- private class ChooseUsersWizardPage extends WizardPage implements IPageChangedListener {
- private static final long serialVersionUID = 7651807402211214274L;
- private ChooseUserTableViewer userTableCmp;
-
- public ChooseUsersWizardPage() {
- super("Choose Users");
- setTitle("Select users who will be impacted");
- }
-
- @Override
- public void createControl(Composite parent) {
- Composite pageCmp = new Composite(parent, SWT.NONE);
- pageCmp.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
- // Define the displayed columns
- List<ColumnDefinition> columnDefs = new ArrayList<ColumnDefinition>();
- columnDefs.add(new ColumnDefinition(new CommonNameLP(), "Common Name", 150));
- columnDefs.add(new ColumnDefinition(new MailLP(), "E-mail", 150));
- columnDefs.add(new ColumnDefinition(new DomainNameLP(), "Domain", 200));
-
- // Only show technical DN to admin
- if (CurrentUser.isInRole(NodeConstants.ROLE_ADMIN))
- columnDefs.add(new ColumnDefinition(new UserNameLP(), "Distinguished Name", 300));
-
- userTableCmp = new ChooseUserTableViewer(pageCmp, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- userTableCmp.setLayoutData(EclipseUiUtils.fillAll());
- userTableCmp.setColumnDefinitions(columnDefs);
- userTableCmp.populate(true, true);
- userTableCmp.refresh();
-
- setControl(pageCmp);
-
- // Add listener to update message when shown
- final IWizardContainer wContainer = this.getContainer();
- if (wContainer instanceof IPageChangeProvider) {
- ((IPageChangeProvider) wContainer).addPageChangedListener(this);
- }
-
- }
-
- @Override
- public void pageChanged(PageChangedEvent event) {
- if (event.getSelectedPage() == this) {
- String msg = "Chosen batch action: " + chooseCommandPage.getCommandLbl();
- ((WizardPage) event.getSelectedPage()).setMessage(msg);
- }
- }
-
- protected List<User> getSelectedUsers() {
- return userTableCmp.getSelectedUsers();
- }
-
- private class ChooseUserTableViewer extends LdifUsersTable {
- private static final long serialVersionUID = 5080437561015853124L;
- private final String[] knownProps = { LdapAttrs.uid.name(), LdapAttrs.DN, LdapAttrs.cn.name(),
- LdapAttrs.givenName.name(), LdapAttrs.sn.name(), LdapAttrs.mail.name() };
-
- public ChooseUserTableViewer(Composite parent, int style) {
- super(parent, style);
- }
-
- @Override
- protected List<User> listFilteredElements(String filter) {
- Role[] roles;
-
- try {
- StringBuilder builder = new StringBuilder();
-
- StringBuilder tmpBuilder = new StringBuilder();
- if (EclipseUiUtils.notEmpty(filter))
- for (String prop : knownProps) {
- tmpBuilder.append("(");
- tmpBuilder.append(prop);
- tmpBuilder.append("=*");
- tmpBuilder.append(filter);
- tmpBuilder.append("*)");
- }
- if (tmpBuilder.length() > 1) {
- builder.append("(&(").append(LdapAttrs.objectClass.name()).append("=")
- .append(LdapObjs.inetOrgPerson.name()).append(")(|");
- builder.append(tmpBuilder.toString());
- builder.append("))");
- } else
- builder.append("(").append(LdapAttrs.objectClass.name()).append("=")
- .append(LdapObjs.inetOrgPerson.name()).append(")");
- roles = userAdminWrapper.getUserAdmin().getRoles(builder.toString());
- } catch (InvalidSyntaxException e) {
- throw new CmsException("Unable to get roles with filter: " + filter, e);
- }
- List<User> users = new ArrayList<User>();
- for (Role role : roles)
- // Prevent current logged in user to perform batch on
- // himself
- if (!UserAdminUtils.isCurrentUser((User) role))
- users.add((User) role);
- return users;
- }
- }
- }
-
- /** Summary of input data before launching the process */
- private class ValidateAndLaunchWizardPage extends WizardPage implements IPageChangedListener {
- private static final long serialVersionUID = 7098918351451743853L;
- private ChosenUsersTableViewer userTableCmp;
-
- public ValidateAndLaunchWizardPage() {
- super("Validate and launch");
- setTitle("Validate and launch");
- }
-
- @Override
- public void createControl(Composite parent) {
- Composite pageCmp = new Composite(parent, SWT.NO_FOCUS);
- pageCmp.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
- List<ColumnDefinition> columnDefs = new ArrayList<ColumnDefinition>();
- columnDefs.add(new ColumnDefinition(new CommonNameLP(), "Common Name", 150));
- columnDefs.add(new ColumnDefinition(new MailLP(), "E-mail", 150));
- columnDefs.add(new ColumnDefinition(new DomainNameLP(), "Domain", 200));
- // Only show technical DN to admin
- if (CurrentUser.isInRole(NodeConstants.ROLE_ADMIN))
- columnDefs.add(new ColumnDefinition(new UserNameLP(), "Distinguished Name", 300));
- userTableCmp = new ChosenUsersTableViewer(pageCmp, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- userTableCmp.setLayoutData(EclipseUiUtils.fillAll());
- userTableCmp.setColumnDefinitions(columnDefs);
- userTableCmp.populate(false, false);
- userTableCmp.refresh();
- setControl(pageCmp);
- // Add listener to update message when shown
- final IWizardContainer wContainer = this.getContainer();
- if (wContainer instanceof IPageChangeProvider) {
- ((IPageChangeProvider) wContainer).addPageChangedListener(this);
- }
- }
-
- @Override
- public void pageChanged(PageChangedEvent event) {
- if (event.getSelectedPage() == this) {
- @SuppressWarnings({ "unchecked", "rawtypes" })
- Object[] values = ((ArrayList) userListPage.getSelectedUsers())
- .toArray(new Object[userListPage.getSelectedUsers().size()]);
- userTableCmp.getTableViewer().setInput(values);
- String msg = "Following batch action: [" + chooseCommandPage.getCommandLbl()
- + "] will be perfomed on the users listed below.\n";
- // + "Are you sure you want to proceed?";
- setMessage(msg);
- }
- }
-
- private class ChosenUsersTableViewer extends LdifUsersTable {
- private static final long serialVersionUID = 7814764735794270541L;
-
- public ChosenUsersTableViewer(Composite parent, int style) {
- super(parent, style);
- }
-
- @Override
- protected List<User> listFilteredElements(String filter) {
- return userListPage.getSelectedUsers();
- }
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.parts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Repository;
-
-import org.argeo.api.NodeInstance;
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.useradmin.UiUserAdminListener;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.naming.LdapAttrs;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.AbstractFormPart;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.osgi.service.useradmin.Authorization;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdmin;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/** Editor for a user, might be a user or a group. */
-public class UserEditor extends FormEditor {
- private static final long serialVersionUID = 8357851520380820241L;
-
- public final static String USER_EDITOR_ID = WorkbenchUiPlugin.PLUGIN_ID + ".userEditor";
- public final static String GROUP_EDITOR_ID = WorkbenchUiPlugin.PLUGIN_ID + ".groupEditor";
-
- /* DEPENDENCY INJECTION */
- private Repository repository;
- private UserAdminWrapper userAdminWrapper;
- private UserAdmin userAdmin;
- private NodeInstance nodeInstance;
-
- // Context
- private User user;
- private String username;
-
- private NameChangeListener listener;
-
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- super.init(site, input);
- this.userAdmin = userAdminWrapper.getUserAdmin();
- username = ((UserEditorInput) getEditorInput()).getUsername();
- user = (User) userAdmin.getRole(username);
-
- listener = new NameChangeListener(site.getShell().getDisplay());
- userAdminWrapper.addListener(listener);
- updateEditorTitle(null);
- }
-
- /**
- * returns the list of all authorization for the given user or of the current
- * displayed user if parameter is null
- */
- protected List<User> getFlatGroups(User aUser) {
- Authorization currAuth;
- if (aUser == null)
- currAuth = userAdmin.getAuthorization(this.user);
- else
- currAuth = userAdmin.getAuthorization(aUser);
-
- String[] roles = currAuth.getRoles();
-
- List<User> groups = new ArrayList<User>();
- for (String roleStr : roles) {
- User currRole = (User) userAdmin.getRole(roleStr);
- if (currRole != null && !groups.contains(currRole))
- groups.add(currRole);
- }
- return groups;
- }
-
- /** Exposes the user (or group) that is displayed by the current editor */
- protected User getDisplayedUser() {
- return user;
- }
-
- private void setDisplayedUser(User user) {
- this.user = user;
- }
-
- void updateEditorTitle(String title) {
- if (title == null) {
- String commonName = UserAdminUtils.getProperty(user, LdapAttrs.cn.name());
- title = "".equals(commonName) ? user.getName() : commonName;
- }
- setPartName(title);
- }
-
- protected void addPages() {
- try {
- if (user.getType() == Role.GROUP)
- addPage(new GroupMainPage(this, userAdminWrapper, repository, nodeInstance));
- else
- addPage(new UserMainPage(this, userAdminWrapper));
- } catch (Exception e) {
- throw new CmsException("Cannot add pages", e);
- }
- }
-
- @Override
- public void doSave(IProgressMonitor monitor) {
- userAdminWrapper.beginTransactionIfNeeded();
- commitPages(true);
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- firePropertyChange(PROP_DIRTY);
- userAdminWrapper.notifyListeners(new UserAdminEvent(null, UserAdminEvent.ROLE_REMOVED, user));
- }
-
- @Override
- public void doSaveAs() {
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- @Override
- public void dispose() {
- userAdminWrapper.removeListener(listener);
- super.dispose();
- }
-
- // CONTROLERS FOR THIS EDITOR AND ITS PAGES
-
- private class NameChangeListener extends UiUserAdminListener {
- public NameChangeListener(Display display) {
- super(display);
- }
-
- @Override
- public void roleChangedToUiThread(UserAdminEvent event) {
- Role changedRole = event.getRole();
- if (changedRole == null || changedRole.equals(user)) {
- updateEditorTitle(null);
- User reloadedUser = (User) userAdminWrapper.getUserAdmin().getRole(user.getName());
- setDisplayedUser(reloadedUser);
- }
- }
- }
-
- class MainInfoListener extends UiUserAdminListener {
- private final AbstractFormPart part;
-
- public MainInfoListener(Display display, AbstractFormPart part) {
- super(display);
- this.part = part;
- }
-
- @Override
- public void roleChangedToUiThread(UserAdminEvent event) {
- // Rollback
- if (event.getRole() == null)
- part.markStale();
- }
- }
-
- class GroupChangeListener extends UiUserAdminListener {
- private final AbstractFormPart part;
-
- public GroupChangeListener(Display display, AbstractFormPart part) {
- super(display);
- this.part = part;
- }
-
- @Override
- public void roleChangedToUiThread(UserAdminEvent event) {
- // always mark as stale
- part.markStale();
- }
- }
-
- /** Registers a listener that will notify this part */
- class FormPartML implements ModifyListener {
- private static final long serialVersionUID = 6299808129505381333L;
- private AbstractFormPart formPart;
-
- public FormPartML(AbstractFormPart generalPart) {
- this.formPart = generalPart;
- }
-
- public void modifyText(ModifyEvent e) {
- // Discard event when the control does not have the focus, typically
- // to avoid all editors being marked as dirty during a Rollback
- if (((Control) e.widget).isFocusControl())
- formPart.markDirty();
- }
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdminWrapper(UserAdminWrapper userAdminWrapper) {
- this.userAdminWrapper = userAdminWrapper;
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-
- public void setNodeInstance(NodeInstance nodeInstance) {
- this.nodeInstance = nodeInstance;
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.parts;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/**
- * Editor input for an user defined by unique name (usually a distinguished
- * name).
- */
-public class UserEditorInput implements IEditorInput {
- private final String username;
-
- public UserEditorInput(String username) {
- this.username = username;
- }
-
- @SuppressWarnings("unchecked")
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public boolean exists() {
- return username != null;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- return username != null ? username : "<new user>";
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public String getToolTipText() {
- return username != null ? username : "<new user>";
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof UserEditorInput))
- return false;
- if (((UserEditorInput) obj).getUsername() == null)
- return false;
- return ((UserEditorInput) obj).getUsername().equals(username);
- }
-
- public String getUsername() {
- return username;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.parts;
-
-import static org.argeo.cms.auth.UserAdminUtils.getProperty;
-import static org.argeo.naming.LdapAttrs.cn;
-import static org.argeo.naming.LdapAttrs.givenName;
-import static org.argeo.naming.LdapAttrs.mail;
-import static org.argeo.naming.LdapAttrs.sn;
-import static org.argeo.naming.LdapAttrs.uid;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.ui.workbench.CmsWorkbenchStyles;
-import org.argeo.cms.ui.workbench.internal.useradmin.SecurityAdminImages;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditor.GroupChangeListener;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditor.MainInfoListener;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.CommonNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.DomainNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.RoleIconLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserFilter;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserTableDefaultDClickListener;
-import org.argeo.cms.ui.util.CmsUiUtils;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.eclipse.ui.ColumnDefinition;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.parts.LdifUsersTable;
-import org.argeo.naming.LdapAttrs;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.TrayDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.ui.forms.AbstractFormPart;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.SectionPart;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-import org.osgi.service.useradmin.Group;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdmin;
-import org.osgi.service.useradmin.UserAdminEvent;
-
-/** Display/edit the properties of a given user */
-public class UserMainPage extends FormPage implements ArgeoNames {
- final static String ID = "UserEditor.mainPage";
-
- private final UserEditor editor;
- private UserAdminWrapper userAdminWrapper;
-
- // Local configuration
- private final int PRE_TITLE_INDENT = 10;
-
- public UserMainPage(FormEditor editor, UserAdminWrapper userAdminWrapper) {
- super(editor, ID, "Main");
- this.editor = (UserEditor) editor;
- this.userAdminWrapper = userAdminWrapper;
- }
-
- protected void createFormContent(final IManagedForm mf) {
- ScrolledForm form = mf.getForm();
- Composite body = form.getBody();
- GridLayout mainLayout = new GridLayout();
- // mainLayout.marginRight = 10;
- body.setLayout(mainLayout);
- User user = editor.getDisplayedUser();
- appendOverviewPart(body, user);
- // Remove to ability to force the password for his own user. The user
- // must then use the change pwd feature
- appendMemberOfPart(body, user);
- }
-
- /** Creates the general section */
- private void appendOverviewPart(final Composite parent, final User user) {
- FormToolkit tk = getManagedForm().getToolkit();
-
- Section section = tk.createSection(parent, SWT.NO_FOCUS);
- GridData gd = EclipseUiUtils.fillWidth();
- // gd.verticalAlignment = PRE_TITLE_INDENT;
- section.setLayoutData(gd);
- Composite body = tk.createComposite(section, SWT.WRAP);
- body.setLayoutData(EclipseUiUtils.fillAll());
- section.setClient(body);
- // body.setLayout(new GridLayout(6, false));
- body.setLayout(new GridLayout(2, false));
-
- Text commonName = createReadOnlyLT(tk, body, "Name", getProperty(user, cn));
- Text distinguishedName = createReadOnlyLT(tk, body, "Login", getProperty(user, uid));
- Text firstName = createLT(tk, body, "First name", getProperty(user, givenName));
- Text lastName = createLT(tk, body, "Last name", getProperty(user, sn));
- Text email = createLT(tk, body, "Email", getProperty(user, mail));
-
- Link resetPwdLk = new Link(body, SWT.NONE);
- if (!UserAdminUtils.isCurrentUser(user)) {
- resetPwdLk.setText("<a>Reset password</a>");
- }
- resetPwdLk.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
-
- // create form part (controller)
- AbstractFormPart part = new SectionPart((Section) body.getParent()) {
- private MainInfoListener listener;
-
- @Override
- public void initialize(IManagedForm form) {
- super.initialize(form);
- listener = editor.new MainInfoListener(parent.getDisplay(), this);
- userAdminWrapper.addListener(listener);
- }
-
- @Override
- public void dispose() {
- userAdminWrapper.removeListener(listener);
- super.dispose();
- }
-
- @SuppressWarnings("unchecked")
- public void commit(boolean onSave) {
- // TODO Sanity checks (mail validity...)
- user.getProperties().put(LdapAttrs.givenName.name(), firstName.getText());
- user.getProperties().put(LdapAttrs.sn.name(), lastName.getText());
- user.getProperties().put(LdapAttrs.cn.name(), commonName.getText());
- user.getProperties().put(LdapAttrs.mail.name(), email.getText());
- super.commit(onSave);
- }
-
- @Override
- public void refresh() {
- distinguishedName.setText(UserAdminUtils.getProperty(user, LdapAttrs.uid.name()));
- commonName.setText(UserAdminUtils.getProperty(user, LdapAttrs.cn.name()));
- firstName.setText(UserAdminUtils.getProperty(user, LdapAttrs.givenName.name()));
- lastName.setText(UserAdminUtils.getProperty(user, LdapAttrs.sn.name()));
- email.setText(UserAdminUtils.getProperty(user, LdapAttrs.mail.name()));
- refreshFormTitle(user);
- super.refresh();
- }
- };
-
- // Improve this: automatically generate CN when first or last name
- // changes
- ModifyListener cnML = new ModifyListener() {
- private static final long serialVersionUID = 4298649222869835486L;
-
- @Override
- public void modifyText(ModifyEvent event) {
- String first = firstName.getText();
- String last = lastName.getText();
- String cn = first.trim() + " " + last.trim() + " ";
- cn = cn.trim();
- commonName.setText(cn);
- // getManagedForm().getForm().setText(cn);
- editor.updateEditorTitle(cn);
- }
- };
- firstName.addModifyListener(cnML);
- lastName.addModifyListener(cnML);
-
- ModifyListener defaultListener = editor.new FormPartML(part);
- firstName.addModifyListener(defaultListener);
- lastName.addModifyListener(defaultListener);
- email.addModifyListener(defaultListener);
-
- if (!UserAdminUtils.isCurrentUser(user))
- resetPwdLk.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = 5881800534589073787L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- new ChangePasswordDialog(tk, user, "Reset password").open();
- }
- });
-
- getManagedForm().addPart(part);
- }
-
- private class ChangePasswordDialog extends TrayDialog {
- private static final long serialVersionUID = 2843538207460082349L;
-
- private User user;
- private Text password1;
- private Text password2;
- private String title;
- private FormToolkit tk;
-
- public ChangePasswordDialog(FormToolkit tk, User user, String title) {
- super(Display.getDefault().getActiveShell());
- this.tk = tk;
- this.user = user;
- this.title = title;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogarea = (Composite) super.createDialogArea(parent);
- dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Composite body = new Composite(dialogarea, SWT.NO_FOCUS);
- body.setLayoutData(EclipseUiUtils.fillAll());
- GridLayout layout = new GridLayout(2, false);
- body.setLayout(layout);
-
- password1 = createLP(tk, body, "New password", "");
- password2 = createLP(tk, body, "Repeat password", "");
- parent.pack();
- return body;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected void okPressed() {
- String msg = null;
-
- if (password1.getText().equals(""))
- msg = "Password cannot be empty";
- else if (password1.getText().equals(password2.getText())) {
- char[] newPassword = password1.getText().toCharArray();
- // userAdminWrapper.beginTransactionIfNeeded();
- userAdminWrapper.beginTransactionIfNeeded();
- user.getCredentials().put(null, newPassword);
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- super.okPressed();
- } else {
- msg = "Passwords are not equals";
- }
-
- if (EclipseUiUtils.notEmpty(msg))
- MessageDialog.openError(getParentShell(), "Cannot reset pasword", msg);
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(title);
- }
- }
-
- private LdifUsersTable appendMemberOfPart(final Composite parent, User user) {
- FormToolkit tk = getManagedForm().getToolkit();
- Section section = addSection(tk, parent, "Roles");
- Composite body = (Composite) section.getClient();
- body.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
- // boolean isAdmin = CurrentUser.isInRole(NodeConstants.ROLE_ADMIN);
-
- // Displayed columns
- List<ColumnDefinition> columnDefs = new ArrayList<ColumnDefinition>();
- columnDefs.add(new ColumnDefinition(new RoleIconLP(), "", 0, 24));
- columnDefs.add(new ColumnDefinition(new CommonNameLP(), "Name", 150));
- columnDefs.add(new ColumnDefinition(new DomainNameLP(), "Domain", 100));
- // Only show technical DN to administrators
- // if (isAdmin)
- // columnDefs.add(new ColumnDefinition(new UserNameLP(), "Distinguished Name",
- // 300));
-
- // Create and configure the table
- final LdifUsersTable userViewerCmp = new MyUserTableViewer(body, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, user);
-
- userViewerCmp.setColumnDefinitions(columnDefs);
- // if (isAdmin)
- // userViewerCmp.populateWithStaticFilters(false, false);
- // else
- userViewerCmp.populate(true, false);
- GridData gd = EclipseUiUtils.fillAll();
- gd.heightHint = 500;
- userViewerCmp.setLayoutData(gd);
-
- // Controllers
- TableViewer userViewer = userViewerCmp.getTableViewer();
- userViewer.addDoubleClickListener(new UserTableDefaultDClickListener());
- int operations = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
- GroupDropListener dropL = new GroupDropListener(userAdminWrapper, userViewer, user);
- userViewer.addDropSupport(operations, tt, dropL);
-
- SectionPart part = new SectionPart((Section) body.getParent()) {
-
- private GroupChangeListener listener;
-
- @Override
- public void initialize(IManagedForm form) {
- super.initialize(form);
- listener = editor.new GroupChangeListener(parent.getDisplay(), this);
- userAdminWrapper.addListener(listener);
- }
-
- public void commit(boolean onSave) {
- super.commit(onSave);
- }
-
- @Override
- public void dispose() {
- userAdminWrapper.removeListener(listener);
- super.dispose();
- }
-
- @Override
- public void refresh() {
- userViewerCmp.refresh();
- super.refresh();
- }
- };
- getManagedForm().addPart(part);
- addRemoveAbitily(part, userViewer, user);
- return userViewerCmp;
- }
-
- private class MyUserTableViewer extends LdifUsersTable {
- private static final long serialVersionUID = 2653790051461237329L;
-
- private Button showSystemRoleBtn;
-
- private final User user;
- private final UserFilter userFilter;
-
- public MyUserTableViewer(Composite parent, int style, User user) {
- super(parent, style, true);
- this.user = user;
- userFilter = new UserFilter();
- }
-
- protected void populateStaticFilters(Composite staticFilterCmp) {
- staticFilterCmp.setLayout(new GridLayout());
- showSystemRoleBtn = new Button(staticFilterCmp, SWT.CHECK);
- showSystemRoleBtn.setText("Show system roles");
- boolean showSysRole = CurrentUser.isInRole(NodeConstants.ROLE_ADMIN);
- showSystemRoleBtn.setSelection(showSysRole);
- userFilter.setShowSystemRole(showSysRole);
- showSystemRoleBtn.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = -7033424592697691676L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- userFilter.setShowSystemRole(showSystemRoleBtn.getSelection());
- refresh();
- }
- });
- }
-
- @Override
- protected List<User> listFilteredElements(String filter) {
- List<User> users = (List<User>) editor.getFlatGroups(null);
- List<User> filteredUsers = new ArrayList<User>();
- if (users.contains(user))
- users.remove(user);
- userFilter.setSearchText(filter);
- for (User user : users)
- if (userFilter.select(null, null, user))
- filteredUsers.add(user);
- return filteredUsers;
- }
- }
-
- private void addRemoveAbitily(SectionPart sectionPart, TableViewer userViewer, User user) {
- Section section = sectionPart.getSection();
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
- ToolBar toolbar = toolBarManager.createControl(section);
- final Cursor handCursor = new Cursor(section.getDisplay(), SWT.CURSOR_HAND);
- toolbar.setCursor(handCursor);
- toolbar.addDisposeListener(new DisposeListener() {
- private static final long serialVersionUID = 3882131405820522925L;
-
- public void widgetDisposed(DisposeEvent e) {
- if ((handCursor != null) && (handCursor.isDisposed() == false)) {
- handCursor.dispose();
- }
- }
- });
-
- String tooltip = "Remove " + UserAdminUtils.getUserLocalId(user.getName()) + " from the below selected groups";
- Action action = new RemoveMembershipAction(userViewer, user, tooltip, SecurityAdminImages.ICON_REMOVE_DESC);
- toolBarManager.add(action);
- toolBarManager.update(true);
- section.setTextClient(toolbar);
- }
-
- private class RemoveMembershipAction extends Action {
- private static final long serialVersionUID = -1337713097184522588L;
-
- private final TableViewer userViewer;
- private final User user;
-
- RemoveMembershipAction(TableViewer userViewer, User user, String name, ImageDescriptor img) {
- super(name, img);
- this.userViewer = userViewer;
- this.user = user;
- }
-
- @Override
- public void run() {
- ISelection selection = userViewer.getSelection();
- if (selection.isEmpty())
- return;
-
- @SuppressWarnings("unchecked")
- Iterator<Group> it = ((IStructuredSelection) selection).iterator();
- List<Group> groups = new ArrayList<Group>();
- while (it.hasNext()) {
- Group currGroup = it.next();
- groups.add(currGroup);
- }
-
- userAdminWrapper.beginTransactionIfNeeded();
- for (Group group : groups) {
- group.removeMember(user);
- }
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- for (Group group : groups) {
- userAdminWrapper.notifyListeners(new UserAdminEvent(null, UserAdminEvent.ROLE_CHANGED, group));
- }
- }
- }
-
- /**
- * Defines the table as being a potential target to add group memberships
- * (roles) to this user
- */
- private class GroupDropListener extends ViewerDropAdapter {
- private static final long serialVersionUID = 2893468717831451621L;
-
- private final UserAdminWrapper myUserAdminWrapper;
- private final User myUser;
-
- public GroupDropListener(UserAdminWrapper userAdminWrapper, Viewer userViewer, User user) {
- super(userViewer);
- this.myUserAdminWrapper = userAdminWrapper;
- this.myUser = user;
- }
-
- @Override
- public boolean validateDrop(Object target, int operation, TransferData transferType) {
- // Target is always OK in a list only view
- // TODO check if not a string
- boolean validDrop = true;
- return validDrop;
- }
-
- @Override
- public void drop(DropTargetEvent event) {
- String name = (String) event.data;
- UserAdmin myUserAdmin = myUserAdminWrapper.getUserAdmin();
- Role role = myUserAdmin.getRole(name);
- // TODO this check should be done before.
- if (role.getType() == Role.GROUP) {
- // TODO check if the user is already member of this group
-
- myUserAdminWrapper.beginTransactionIfNeeded();
- Group group = (Group) role;
- group.addMember(myUser);
- userAdminWrapper.commitOrNotifyTransactionStateChange();
- myUserAdminWrapper.notifyListeners(new UserAdminEvent(null, UserAdminEvent.ROLE_CHANGED, group));
- }
- super.drop(event);
- }
-
- @Override
- public boolean performDrop(Object data) {
- // userTableViewerCmp.refresh();
- return true;
- }
- }
-
- // LOCAL HELPERS
- private void refreshFormTitle(User group) {
- // getManagedForm().getForm().setText(UserAdminUtils.getProperty(group,
- // LdapAttrs.cn.name()));
- }
-
- /** Appends a section with a title */
- private Section addSection(FormToolkit tk, Composite parent, String title) {
- Section section = tk.createSection(parent, Section.TITLE_BAR);
- GridData gd = EclipseUiUtils.fillWidth();
- gd.verticalAlignment = PRE_TITLE_INDENT;
- section.setLayoutData(gd);
- section.setText(title);
- // section.getMenu().setVisible(true);
-
- Composite body = tk.createComposite(section, SWT.WRAP);
- body.setLayoutData(EclipseUiUtils.fillAll());
- section.setClient(body);
-
- return section;
- }
-
- /** Creates label and multiline text. */
- Text createLMT(FormToolkit toolkit, Composite body, String label, String value) {
- Label lbl = toolkit.createLabel(body, label);
- lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
- Text text = toolkit.createText(body, value, SWT.BORDER | SWT.MULTI);
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
- return text;
- }
-
- /** Creates label and password. */
- Text createLP(FormToolkit toolkit, Composite body, String label, String value) {
- Label lbl = toolkit.createLabel(body, label);
- lbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
- Text text = toolkit.createText(body, value, SWT.BORDER | SWT.PASSWORD);
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- return text;
- }
-
- /** Creates label and text. */
- Text createLT(FormToolkit toolkit, Composite parent, String label, String value) {
- Label lbl = toolkit.createLabel(parent, label);
- lbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
- lbl.setFont(EclipseUiUtils.getBoldFont(parent));
- Text text = toolkit.createText(parent, value, SWT.BORDER);
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- CmsUiUtils.style(text, CmsWorkbenchStyles.WORKBENCH_FORM_TEXT);
- return text;
- }
-
- Text createReadOnlyLT(FormToolkit toolkit, Composite parent, String label, String value) {
- Label lbl = toolkit.createLabel(parent, label);
- lbl.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
- lbl.setFont(EclipseUiUtils.getBoldFont(parent));
- Text text = toolkit.createText(parent, value, SWT.NONE);
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- text.setEditable(false);
- CmsUiUtils.style(text, CmsWorkbenchStyles.WORKBENCH_FORM_TEXT);
- return text;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.parts;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.CmsException;
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.useradmin.UiUserAdminListener;
-import org.argeo.cms.ui.workbench.internal.useradmin.UserAdminWrapper;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.CommonNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.DomainNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.MailLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserDragListener;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserNameLP;
-import org.argeo.cms.ui.workbench.internal.useradmin.providers.UserTableDefaultDClickListener;
-import org.argeo.eclipse.ui.ColumnDefinition;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.eclipse.ui.parts.LdifUsersTable;
-import org.argeo.naming.LdapAttrs;
-import org.argeo.naming.LdapObjs;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.part.ViewPart;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdminEvent;
-import org.osgi.service.useradmin.UserAdminListener;
-
-/** List all users with filter - based on Ldif userAdmin */
-public class UsersView extends ViewPart implements ArgeoNames {
- // private final static Log log = LogFactory.getLog(UsersView.class);
-
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".usersView";
-
- /* DEPENDENCY INJECTION */
- private UserAdminWrapper userAdminWrapper;
-
- // UI Objects
- private LdifUsersTable userTableViewerCmp;
- private TableViewer userViewer;
- private List<ColumnDefinition> columnDefs = new ArrayList<ColumnDefinition>();
-
- private UserAdminListener listener;
-
- @Override
- public void createPartControl(Composite parent) {
-
- parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
- // Define the displayed columns
- columnDefs.add(new ColumnDefinition(new CommonNameLP(), "Common Name",
- 150));
- columnDefs.add(new ColumnDefinition(new MailLP(), "E-mail", 150));
- columnDefs.add(new ColumnDefinition(new DomainNameLP(), "Domain", 200));
- // Only show technical DN to admin
- if (CurrentUser.isInRole(NodeConstants.ROLE_ADMIN))
- columnDefs.add(new ColumnDefinition(new UserNameLP(),
- "Distinguished Name", 300));
-
- // Create and configure the table
- userTableViewerCmp = new MyUserTableViewer(parent, SWT.MULTI
- | SWT.H_SCROLL | SWT.V_SCROLL);
- userTableViewerCmp.setLayoutData(EclipseUiUtils.fillAll());
- userTableViewerCmp.setColumnDefinitions(columnDefs);
- userTableViewerCmp.populate(true, false);
-
- // Links
- userViewer = userTableViewerCmp.getTableViewer();
- userViewer.addDoubleClickListener(new UserTableDefaultDClickListener());
- getViewSite().setSelectionProvider(userViewer);
-
- // Really?
- userTableViewerCmp.refresh();
-
- // Drag and drop
- int operations = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
- userViewer.addDragSupport(operations, tt, new UserDragListener(
- userViewer));
-
- // Register a useradmin listener
- listener = new MyUiUAListener(parent.getDisplay());
- userAdminWrapper.addListener(listener);
- }
-
- private class MyUiUAListener extends UiUserAdminListener {
- public MyUiUAListener(Display display) {
- super(display);
- }
-
- @Override
- public void roleChangedToUiThread(UserAdminEvent event) {
- if (userViewer != null && !userViewer.getTable().isDisposed())
- refresh();
- }
- }
-
- private class MyUserTableViewer extends LdifUsersTable {
- private static final long serialVersionUID = 8467999509931900367L;
-
- private final String[] knownProps = { LdapAttrs.DN,
- LdapAttrs.uid.name(), LdapAttrs.cn.name(),
- LdapAttrs.givenName.name(), LdapAttrs.sn.name(),
- LdapAttrs.mail.name() };
-
- public MyUserTableViewer(Composite parent, int style) {
- super(parent, style);
- }
-
- @Override
- protected List<User> listFilteredElements(String filter) {
- Role[] roles;
-
- try {
- StringBuilder builder = new StringBuilder();
-
- StringBuilder tmpBuilder = new StringBuilder();
- if (EclipseUiUtils.notEmpty(filter))
- for (String prop : knownProps) {
- tmpBuilder.append("(");
- tmpBuilder.append(prop);
- tmpBuilder.append("=*");
- tmpBuilder.append(filter);
- tmpBuilder.append("*)");
- }
- if (tmpBuilder.length() > 1) {
- builder.append("(&(").append(LdapAttrs.objectClass.name())
- .append("=").append(LdapObjs.inetOrgPerson.name())
- .append(")(|");
- builder.append(tmpBuilder.toString());
- builder.append("))");
- } else
- builder.append("(").append(LdapAttrs.objectClass.name())
- .append("=").append(LdapObjs.inetOrgPerson.name())
- .append(")");
- roles = userAdminWrapper.getUserAdmin().getRoles(
- builder.toString());
- } catch (InvalidSyntaxException e) {
- throw new CmsException("Unable to get roles with filter: "
- + filter, e);
- }
- List<User> users = new ArrayList<User>();
- for (Role role : roles)
- // if (role.getType() == Role.USER && role.getType() !=
- // Role.GROUP)
- users.add((User) role);
- return users;
- }
- }
-
- public void refresh() {
- userTableViewerCmp.refresh();
- }
-
- // Override generic view methods
- @Override
- public void dispose() {
- userAdminWrapper.removeListener(listener);
- super.dispose();
- }
-
- @Override
- public void setFocus() {
- userTableViewerCmp.setFocus();
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserAdminWrapper(UserAdminWrapper userAdminWrapper) {
- this.userAdminWrapper = userAdminWrapper;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.naming.LdapAttrs;
-import org.osgi.service.useradmin.User;
-
-/** Simply declare a label provider that returns the common name of a user */
-public class CommonNameLP extends UserAdminAbstractLP {
- private static final long serialVersionUID = 5256703081044911941L;
-
- @Override
- public String getText(User user) {
- return UserAdminUtils.getProperty(user, LdapAttrs.cn.name());
- }
-
- @Override
- public String getToolTipText(Object element) {
- return UserAdminUtils.getProperty((User) element, LdapAttrs.DN);
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import org.argeo.cms.auth.UserAdminUtils;
-import org.osgi.service.useradmin.User;
-
-/** The human friendly domain name for the corresponding user. */
-public class DomainNameLP extends UserAdminAbstractLP {
- private static final long serialVersionUID = 5256703081044911941L;
-
- @Override
- public String getText(User user) {
- return UserAdminUtils.getDomainName(user);
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.naming.LdapAttrs;
-import org.osgi.service.useradmin.User;
-
-/** Simply declare a label provider that returns the Primary Mail of a user */
-public class MailLP extends UserAdminAbstractLP {
- private static final long serialVersionUID = 8329764452141982707L;
-
- @Override
- public String getText(User user) {
- return UserAdminUtils.getProperty(user, LdapAttrs.mail.name());
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import org.argeo.cms.ui.workbench.internal.useradmin.SecurityAdminImages;
-import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeInstance;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.naming.LdapAttrs;
-import org.eclipse.swt.graphics.Image;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.User;
-
-/** Provide a bundle specific image depending on the current user type */
-public class RoleIconLP extends UserAdminAbstractLP {
- private static final long serialVersionUID = 6550449442061090388L;
-
- @Override
- public String getText(User user) {
- return "";
- }
-
- @Override
- public Image getImage(Object element) {
- User user = (User) element;
- String dn = user.getName();
- if (dn.endsWith(NodeConstants.ROLES_BASEDN))
- return SecurityAdminImages.ICON_ROLE;
- else if (user.getType() == Role.GROUP) {
- String businessCategory = UserAdminUtils.getProperty(user, LdapAttrs.businessCategory);
- if (businessCategory != null && businessCategory.equals(NodeInstance.WORKGROUP))
- return SecurityAdminImages.ICON_WORKGROUP;
- return SecurityAdminImages.ICON_GROUP;
- } else
- return SecurityAdminImages.ICON_USER;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-
-import org.argeo.cms.CmsException;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.widgets.Display;
-import org.osgi.service.useradmin.User;
-
-/**
- * Utility class that add font modifications to a column label provider
- * depending on the given user properties
- */
-public abstract class UserAdminAbstractLP extends ColumnLabelProvider {
- private static final long serialVersionUID = 137336765024922368L;
-
- // private Font italic;
- private Font bold;
-
- @Override
- public Font getFont(Object element) {
- // Self as bold
- try {
- LdapName selfUserName = UserAdminUtils.getCurrentUserLdapName();
- String userName = ((User) element).getName();
- LdapName userLdapName = new LdapName(userName);
- if (userLdapName.equals(selfUserName)) {
- if (bold == null)
- bold = JFaceResources.getFontRegistry()
- .defaultFontDescriptor().setStyle(SWT.BOLD)
- .createFont(Display.getCurrent());
- return bold;
- }
- } catch (InvalidNameException e) {
- throw new CmsException("cannot parse dn for " + element, e);
- }
-
- // Disabled as Italic
- // Node userProfile = (Node) elem;
- // if (!userProfile.getProperty(ARGEO_ENABLED).getBoolean())
- // return italic;
-
- return null;
- // return super.getFont(element);
- }
-
- @Override
- public String getText(Object element) {
- User user = (User) element;
- return getText(user);
- }
-
- public void setDisplay(Display display) {
- // italic = JFaceResources.getFontRegistry().defaultFontDescriptor()
- // .setStyle(SWT.ITALIC).createFont(display);
- bold = JFaceResources.getFontRegistry().defaultFontDescriptor()
- .setStyle(SWT.BOLD).createFont(Display.getCurrent());
- }
-
- public abstract String getText(User user);
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-import org.osgi.service.useradmin.User;
-
-/** Default drag listener to modify group and users via the UI */
-public class UserDragListener implements DragSourceListener {
- private static final long serialVersionUID = -2074337775033781454L;
- private final Viewer viewer;
-
- public UserDragListener(Viewer viewer) {
- this.viewer = viewer;
- }
-
- public void dragStart(DragSourceEvent event) {
- // TODO implement finer checks
- IStructuredSelection selection = (IStructuredSelection) viewer
- .getSelection();
- if (selection.isEmpty() || selection.size() > 1)
- event.doit = false;
- else
- event.doit = true;
- }
-
- public void dragSetData(DragSourceEvent event) {
- // TODO Support multiple selection
- Object obj = ((IStructuredSelection) viewer.getSelection())
- .getFirstElement();
- if (obj != null) {
- User user = (User) obj;
- event.data = user.getName();
- }
- }
-
- public void dragFinished(DragSourceEvent event) {
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import static org.argeo.eclipse.ui.EclipseUiUtils.notEmpty;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.auth.UserAdminUtils;
-import org.argeo.naming.LdapAttrs;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.osgi.service.useradmin.User;
-
-/**
- * Filter user list using JFace mechanism on the client (yet on the server) side
- * rather than having the UserAdmin to process the search
- */
-public class UserFilter extends ViewerFilter {
- private static final long serialVersionUID = 5082509381672880568L;
-
- private String searchString;
- private boolean showSystemRole = true;
-
- private final String[] knownProps = { LdapAttrs.DN, LdapAttrs.cn.name(), LdapAttrs.givenName.name(),
- LdapAttrs.sn.name(), LdapAttrs.uid.name(), LdapAttrs.description.name(), LdapAttrs.mail.name() };
-
- public void setSearchText(String s) {
- // ensure that the value can be used for matching
- if (notEmpty(s))
- searchString = ".*" + s.toLowerCase() + ".*";
- else
- searchString = ".*";
- }
-
- public void setShowSystemRole(boolean showSystemRole) {
- this.showSystemRole = showSystemRole;
- }
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- User user = (User) element;
- if (!showSystemRole && user.getName().matches(".*(" + NodeConstants.ROLES_BASEDN + ")"))
- // UserAdminUtils.getProperty(user, LdifName.dn.name())
- // .toLowerCase().endsWith(AuthConstants.ROLES_BASEDN))
- return false;
-
- if (searchString == null || searchString.length() == 0)
- return true;
-
- if (user.getName().matches(searchString))
- return true;
-
- for (String key : knownProps) {
- String currVal = UserAdminUtils.getProperty(user, key);
- if (notEmpty(currVal) && currVal.toLowerCase().matches(searchString))
- return true;
- }
- return false;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import org.osgi.service.useradmin.User;
-
-/** Simply declare a label provider that returns the username of a user */
-public class UserNameLP extends UserAdminAbstractLP {
- private static final long serialVersionUID = 6550449442061090388L;
-
- @Override
- public String getText(User user) {
- return user.getName();
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditor;
-import org.argeo.cms.ui.workbench.internal.useradmin.parts.UserEditorInput;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.osgi.service.useradmin.Group;
-import org.osgi.service.useradmin.User;
-
-/**
- * Default double click listener for the various user tables, will open the
- * clicked item in the editor
- */
-public class UserTableDefaultDClickListener implements IDoubleClickListener {
- public void doubleClick(DoubleClickEvent evt) {
- if (evt.getSelection().isEmpty())
- return;
- Object obj = ((IStructuredSelection) evt.getSelection())
- .getFirstElement();
- User user = (User) obj;
- IWorkbenchWindow iww = WorkbenchUiPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow();
- IWorkbenchPage iwp = iww.getActivePage();
- UserEditorInput uei = new UserEditorInput(user.getName());
-
- try {
- // Works around the fact that dynamic setting of the editor icon
- // causes NPE after a login/logout on RAP
- if (user instanceof Group)
- iwp.openEditor(uei, UserEditor.GROUP_EDITOR_ID);
- else
- iwp.openEditor(uei, UserEditor.USER_EDITOR_ID);
- } catch (PartInitException pie) {
- throw new CmsException("Unable to open UserEditor for " + user, pie);
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.internal.useradmin.providers;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.transaction.Status;
-import javax.transaction.UserTransaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.eclipse.ui.AbstractSourceProvider;
-import org.eclipse.ui.ISources;
-
-/** Observe and notify UI on UserTransaction state changes */
-public class UserTransactionProvider extends AbstractSourceProvider {
- private final static Log log = LogFactory
- .getLog(UserTransactionProvider.class);
-
- public final static String TRANSACTION_STATE = WorkbenchUiPlugin.PLUGIN_ID
- + ".userTransactionState";
- public final static String STATUS_ACTIVE = "status.active";
- public final static String STATUS_NO_TRANSACTION = "status.noTransaction";
-
- /* DEPENDENCY INJECTION */
- private UserTransaction userTransaction;
-
- @Override
- public String[] getProvidedSourceNames() {
- return new String[] { TRANSACTION_STATE };
- }
-
- @Override
- public Map<String, String> getCurrentState() {
- Map<String, String> currentState = new HashMap<String, String>(1);
- currentState.put(TRANSACTION_STATE, getInternalCurrentState());
- return currentState;
- }
-
- @Override
- public void dispose() {
- }
-
- private String getInternalCurrentState() {
- try {
- String transactionState;
- if (userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION)
- transactionState = STATUS_NO_TRANSACTION;
- else
- // if (userTransaction.getStatus() == Status.STATUS_ACTIVE)
- transactionState = STATUS_ACTIVE;
- return transactionState;
- } catch (Exception e) {
- throw new CmsException("Unable to begin transaction", e);
- }
- }
-
- /** Publishes the ability to notify a state change */
- public void fireTransactionStateChange() {
- try {
- fireSourceChanged(ISources.WORKBENCH, TRANSACTION_STATE,
- getInternalCurrentState());
- } catch (Exception e) {
- log.warn("Cannot fire transaction state change event. Caught exception: "
- + e.getClass().getCanonicalName() + " - " + e.getMessage());
- }
- }
-
- /* DEPENDENCY INJECTION */
- public void setUserTransaction(UserTransaction userTransaction) {
- this.userTransaction = userTransaction;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.jcr;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.security.AccessControlManager;
-import javax.jcr.security.Privilege;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.ChildNodesPage;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.GenericNodeEditorInput;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.GenericNodePage;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.GenericPropertyPage;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.NodePrivilegesPage;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.NodeVersionHistoryPage;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/** Default form editor for a Jcr {@link Node} */
-public class DefaultNodeEditor extends FormEditor {
- private static final long serialVersionUID = 8322127770921612239L;
-
- // private final static Log log =
- // LogFactory.getLog(GenericNodeEditor.class);
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".defaultNodeEditor";
-
- private Node currentNode;
-
- private GenericNodePage genericNodePage;
- private GenericPropertyPage genericPropertyPage;
- private ChildNodesPage childNodesPage;
- private NodePrivilegesPage nodeRightsManagementPage;
- private NodeVersionHistoryPage nodeVersionHistoryPage;
-
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
- super.init(site, input);
- GenericNodeEditorInput nei = (GenericNodeEditorInput) getEditorInput();
- currentNode = nei.getCurrentNode();
- this.setPartName(JcrUtils.lastPathElement(nei.getPath()));
- }
-
- @Override
- protected void addPages() {
- try {
- genericPropertyPage = new GenericPropertyPage(this,
- WorkbenchUiPlugin.getMessage("genericNodePageTitle"),
- currentNode);
- addPage(genericPropertyPage);
-
- childNodesPage = new ChildNodesPage(this,
- WorkbenchUiPlugin.getMessage("childNodesPageTitle"),
- currentNode);
- addPage(childNodesPage);
-
- AccessControlManager accessControlManager = currentNode
- .getSession().getAccessControlManager();
- List<Privilege> privileges = new ArrayList<Privilege>();
- privileges.add(accessControlManager
- .privilegeFromName(Privilege.JCR_READ_ACCESS_CONTROL));
- if (accessControlManager.hasPrivileges(currentNode.getPath(),
- privileges.toArray(new Privilege[0]))) {
- nodeRightsManagementPage = new NodePrivilegesPage(this,
- WorkbenchUiPlugin
- .getMessage("nodeRightsManagementPageTitle"),
- currentNode);
- addPage(nodeRightsManagementPage);
- }
- if (currentNode.isNodeType(NodeType.MIX_VERSIONABLE)) {
- nodeVersionHistoryPage = new NodeVersionHistoryPage(this,
- WorkbenchUiPlugin
- .getMessage("nodeVersionHistoryPageTitle"),
- currentNode);
- addPage(nodeVersionHistoryPage);
- }
-
- privileges = new ArrayList<Privilege>();
- privileges.add(accessControlManager
- .privilegeFromName(Privilege.JCR_ALL));
- if (accessControlManager.hasPrivileges(currentNode.getPath(),
- privileges.toArray(new Privilege[0]))) {
- genericNodePage = new GenericNodePage(
- this,
- WorkbenchUiPlugin.getMessage("propertyEditorPageTitle"),
- currentNode);
- addPage(genericNodePage);
- }
-
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot get node info for "
- + currentNode, e);
- } catch (PartInitException e) {
- throw new EclipseUiException("Cannot add page "
- + "on node editor for " + currentNode, e);
- }
- }
-
- @Override
- public void doSaveAs() {
- // unused compulsory method
- }
-
- @Override
- public void doSave(IProgressMonitor monitor) {
- try {
- // Automatically commit all pages of the editor
- commitPages(true);
- firePropertyChange(PROP_DIRTY);
- } catch (Exception e) {
- throw new EclipseUiException("Error while saving node", e);
- }
-
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return true;
- }
-
- Node getCurrentNode() {
- return currentNode;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.jcr;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.AbstractJcrQueryEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/** Enables end user to type and execute any JCR query. */
-public class GenericJcrQueryEditor extends AbstractJcrQueryEditor {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
- + ".genericJcrQueryEditor";
-
- private Text queryField;
-
- @Override
- public void createQueryForm(Composite parent) {
- parent.setLayout(new GridLayout(1, false));
-
- queryField = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.WRAP);
- queryField.setText(initialQuery);
- queryField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Button execute = new Button(parent, SWT.PUSH);
- execute.setText("Execute");
-
- Listener executeListener = new Listener() {
- private static final long serialVersionUID = -918256291554301699L;
-
- public void handleEvent(Event event) {
- executeQuery(queryField.getText());
- }
- };
-
- execute.addListener(SWT.Selection, executeListener);
- // queryField.addListener(SWT.DefaultSelection, executeListener);
- }
-
- @Override
- public void setFocus() {
- queryField.setFocus();
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.jcr;
-
-import java.util.List;
-
-import javax.jcr.Property;
-import javax.jcr.PropertyType;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.Value;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ui.jcr.DefaultRepositoryRegister;
-import org.argeo.cms.ui.jcr.JcrBrowserUtils;
-import org.argeo.cms.ui.jcr.JcrDClickListener;
-import org.argeo.cms.ui.jcr.NodeContentProvider;
-import org.argeo.cms.ui.jcr.NodeLabelProvider;
-import org.argeo.cms.ui.jcr.PropertiesContentProvider;
-import org.argeo.cms.ui.jcr.RepositoryRegister;
-import org.argeo.cms.ui.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.eclipse.ui.jcr.util.NodeViewerComparer;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Basic View to display a sash form to browse a JCR compliant multiple
- * repository environment
- */
-public class JcrBrowserView extends ViewPart {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".jcrBrowserView";
- private boolean sortChildNodes = true;
-
- /* DEPENDENCY INJECTION */
- private Keyring keyring;
- private RepositoryRegister repositoryRegister = new DefaultRepositoryRegister();
- private RepositoryFactory repositoryFactory;
- private Repository nodeRepository;
-
- // Current user session on the "Argeo node" default workspace
- private Session userSession;
-
- // This page widgets
- private TreeViewer nodesViewer;
- private NodeContentProvider nodeContentProvider;
- private TableViewer propertiesViewer;
- private EventListener resultsObserver;
-
- @Override
- public void createPartControl(Composite parent) {
- parent.setLayout(new FillLayout());
- SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
- sashForm.setSashWidth(4);
- sashForm.setLayout(new FillLayout());
-
- // Create the tree on top of the view
- Composite top = new Composite(sashForm, SWT.NONE);
- GridLayout gl = new GridLayout(1, false);
- top.setLayout(gl);
-
- try {
- this.userSession = this.nodeRepository.login(NodeConstants.HOME_WORKSPACE);
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot open user session", e);
- }
-
- nodeContentProvider = new NodeContentProvider(userSession, keyring, repositoryRegister, repositoryFactory,
- sortChildNodes);
-
- // nodes viewer
- nodesViewer = createNodeViewer(top, nodeContentProvider);
-
- // context menu : it is completely defined in the plugin.xml file.
- MenuManager menuManager = new MenuManager();
- Menu menu = menuManager.createContextMenu(nodesViewer.getTree());
-
- nodesViewer.getTree().setMenu(menu);
- getSite().registerContextMenu(menuManager, nodesViewer);
- getSite().setSelectionProvider(nodesViewer);
-
- nodesViewer.setInput(getViewSite());
-
- // Create the property viewer on the bottom
- Composite bottom = new Composite(sashForm, SWT.NONE);
- bottom.setLayout(new GridLayout(1, false));
- propertiesViewer = createPropertiesViewer(bottom);
-
- sashForm.setWeights(getWeights());
- nodesViewer.setComparer(new NodeViewerComparer());
- }
-
- public void refresh(Object obj) {
- // Enable full refresh from a command when no element of the tree is
- // selected
- if (obj == null) {
- Object[] elements = nodeContentProvider.getElements(null);
- for (Object el : elements) {
- if (el instanceof TreeParent)
- JcrBrowserUtils.forceRefreshIfNeeded((TreeParent) el);
- getNodeViewer().refresh(el);
- }
- } else
- getNodeViewer().refresh(obj);
- }
-
- /**
- * To be overridden to adapt size of form and result frames.
- */
- protected int[] getWeights() {
- return new int[] { 70, 30 };
- }
-
- protected TreeViewer createNodeViewer(Composite parent, final ITreeContentProvider nodeContentProvider) {
-
- final TreeViewer tmpNodeViewer = new TreeViewer(parent, SWT.MULTI);
-
- tmpNodeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- tmpNodeViewer.setContentProvider(nodeContentProvider);
- tmpNodeViewer.setLabelProvider(new NodeLabelProvider());
- tmpNodeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if (!event.getSelection().isEmpty()) {
- IStructuredSelection sel = (IStructuredSelection) event.getSelection();
- Object firstItem = sel.getFirstElement();
- if (firstItem instanceof SingleJcrNodeElem)
- propertiesViewer.setInput(((SingleJcrNodeElem) firstItem).getNode());
- } else {
- propertiesViewer.setInput(getViewSite());
- }
- }
- });
-
- resultsObserver = new TreeObserver(tmpNodeViewer.getTree().getDisplay());
- if (keyring != null)
- try {
- ObservationManager observationManager = userSession.getWorkspace().getObservationManager();
- observationManager.addEventListener(resultsObserver, Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED, "/",
- true, null, null, false);
- } catch (RepositoryException e) {
- throw new EclipseUiException("Cannot register listeners", e);
- }
-
- tmpNodeViewer.addDoubleClickListener(new JcrDClickListener(tmpNodeViewer));
- return tmpNodeViewer;
- }
-
- protected TableViewer createPropertiesViewer(Composite parent) {
- propertiesViewer = new TableViewer(parent);
- propertiesViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- propertiesViewer.getTable().setHeaderVisible(true);
- propertiesViewer.setContentProvider(new PropertiesContentProvider());
- TableViewerColumn col = new TableViewerColumn(propertiesViewer, SWT.NONE);
- col.getColumn().setText("Name");
- col.getColumn().setWidth(200);
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -6684361063107478595L;
-
- public String getText(Object element) {
- try {
- return ((Property) element).getName();
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unexpected exception in label provider", e);
- }
- }
- });
- col = new TableViewerColumn(propertiesViewer, SWT.NONE);
- col.getColumn().setText("Value");
- col.getColumn().setWidth(400);
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -8201994187693336657L;
-
- public String getText(Object element) {
- try {
- Property property = (Property) element;
- if (property.getType() == PropertyType.BINARY)
- return "<binary>";
- else if (property.isMultiple()) {
- StringBuffer buf = new StringBuffer("[");
- Value[] values = property.getValues();
- for (int i = 0; i < values.length; i++) {
- if (i != 0)
- buf.append(", ");
- buf.append(values[i].getString());
- }
- buf.append(']');
- return buf.toString();
- } else
- return property.getValue().getString();
- } catch (RepositoryException e) {
- throw new EclipseUiException("Unexpected exception in label provider", e);
- }
- }
- });
- col = new TableViewerColumn(propertiesViewer, SWT.NONE);
- col.getColumn().setText("Type");
- col.getColumn().setWidth(200);
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -6009599998150286070L;
-
- public String getText(Object element) {
- return JcrBrowserUtils.getPropertyTypeAsString((Property) element);
- }
- });
- propertiesViewer.setInput(getViewSite());
- return propertiesViewer;
- }
-
- @Override
- public void dispose() {
- super.dispose();
- }
-
- protected TreeViewer getNodeViewer() {
- return nodesViewer;
- }
-
- /**
- * Resets the tree content provider
- *
- * @param sortChildNodes
- * if true the content provider will use a comparer to sort nodes
- * that might slow down the display
- */
- public void setSortChildNodes(boolean sortChildNodes) {
- this.sortChildNodes = sortChildNodes;
- ((NodeContentProvider) nodesViewer.getContentProvider()).setSortChildren(sortChildNodes);
- nodesViewer.setInput(getViewSite());
- }
-
- /** Notifies the current view that a node has been added */
- public void nodeAdded(TreeParent parentNode) {
- // insure that Ui objects have been correctly created:
- JcrBrowserUtils.forceRefreshIfNeeded(parentNode);
- getNodeViewer().refresh(parentNode);
- getNodeViewer().expandToLevel(parentNode, 1);
- }
-
- /** Notifies the current view that a node has been removed */
- public void nodeRemoved(TreeParent parentNode) {
- IStructuredSelection newSel = new StructuredSelection(parentNode);
- getNodeViewer().setSelection(newSel, true);
- // Force refresh
- IStructuredSelection tmpSel = (IStructuredSelection) getNodeViewer().getSelection();
- getNodeViewer().refresh(tmpSel.getFirstElement());
- }
-
- class TreeObserver extends AsyncUiEventListener {
-
- public TreeObserver(Display display) {
- super(display);
- }
-
- @Override
- protected Boolean willProcessInUiThread(List<Event> events) throws RepositoryException {
- for (Event event : events) {
- if (getLog().isTraceEnabled())
- getLog().debug("Received event " + event);
- String path = event.getPath();
- int index = path.lastIndexOf('/');
- String propertyName = path.substring(index + 1);
- if (getLog().isTraceEnabled())
- getLog().debug("Concerned property " + propertyName);
- }
- return false;
- }
-
- protected void onEventInUiThread(List<Event> events) throws RepositoryException {
- if (getLog().isTraceEnabled())
- getLog().trace("Refresh result list");
- nodesViewer.refresh();
- }
-
- }
-
- public boolean getSortChildNodes() {
- return sortChildNodes;
- }
-
- @Override
- public void setFocus() {
- getNodeViewer().getTree().setFocus();
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepositoryRegister(RepositoryRegister repositoryRegister) {
- this.repositoryRegister = repositoryRegister;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.jcr;
-
-import java.net.URI;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.spi.FileSystemProvider;
-
-import org.argeo.cms.CmsException;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.fs.SimpleFsBrowser;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-
-/** Browse the node file system. */
-public class NodeFsBrowserView extends ViewPart {
- public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".nodeFsBrowserView";
-
- private FileSystemProvider nodeFileSystemProvider;
-
- @Override
- public void createPartControl(Composite parent) {
- try {
- URI uri = new URI("node:///");
- FileSystem fileSystem = nodeFileSystemProvider.getFileSystem(uri);
- if (fileSystem == null)
- fileSystem = nodeFileSystemProvider.newFileSystem(uri, null);
- Path nodePath = fileSystem.getPath("~");
- SimpleFsBrowser browser = new SimpleFsBrowser(parent, SWT.NO_FOCUS);
- browser.setInput(nodePath);
- } catch (Exception e) {
- throw new CmsException("Cannot open file system browser", e);
- }
- }
-
- @Override
- public void setFocus() {
- }
-
- public void setNodeFileSystemProvider(FileSystemProvider nodeFileSystemProvider) {
- this.nodeFileSystemProvider = nodeFileSystemProvider;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.jcr;
-
-import static javax.jcr.Node.JCR_CONTENT;
-import static javax.jcr.Property.JCR_DATA;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.cms.ui.jcr.JcrDClickListener;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.GenericNodeEditorInput;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.specific.OpenFile;
-import org.argeo.eclipse.ui.specific.SingleSourcingException;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.jface.viewers.TreeViewer;
-
-public class WorkbenchJcrDClickListener extends JcrDClickListener {
-
- public WorkbenchJcrDClickListener(TreeViewer nodeViewer) {
- super(nodeViewer);
- }
-
- @Override
- protected void openNode(Node node) {
- try {
- if (node.isNodeType(NodeType.NT_FILE)) {
- // Also open it
-
- String name = node.getName();
- Map<String, String> params = new HashMap<String, String>();
- params.put(OpenFile.PARAM_FILE_NAME, name);
-
- // TODO rather directly transmit the path to the node, once
- // we have defined convention to provide an Absolute URI to
- // a node in a multi repo / workspace / user context
- // params.put(OpenFile.PARAM_FILE_URI,
- // OpenFileService.JCR_SCHEME + node.getPath());
-
- // we copy the node to a tmp file to be opened as a dirty
- // workaround
- File tmpFile = null;
- // OutputStream os = null;
- // InputStream is = null;
- int i = name.lastIndexOf('.');
- String prefix, suffix;
- if (i == -1) {
- prefix = name;
- suffix = null;
- } else {
- prefix = name.substring(0, i);
- suffix = name.substring(i);
- }
- Binary binary = null;
- try {
- tmpFile = File.createTempFile(prefix, suffix);
- tmpFile.deleteOnExit();
- } catch (IOException e1) {
- throw new EclipseUiException("Cannot create temp file", e1);
- }
- try (OutputStream os = new FileOutputStream(tmpFile)) {
- binary = node.getNode(JCR_CONTENT).getProperty(JCR_DATA).getBinary();
- try (InputStream is = binary.getStream();) {
- IOUtils.copy(is, os);
- }
- } catch (IOException e) {
- throw new SingleSourcingException("Cannot open file " + prefix + "." + suffix, e);
- } finally {
- // IOUtils.closeQuietly(is);
- // IOUtils.closeQuietly(os);
- JcrUtils.closeQuietly(binary);
- }
- Path path = Paths.get(tmpFile.getAbsolutePath());
- String uri = path.toUri().toString();
- params.put(OpenFile.PARAM_FILE_URI, uri);
- CommandUtils.callCommand(OpenFile.ID, params);
- }
- GenericNodeEditorInput gnei = new GenericNodeEditorInput(node);
- WorkbenchUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(gnei,
- DefaultNodeEditor.ID);
- } catch (RepositoryException re) {
- throw new EclipseUiException("Repository error while getting node info", re);
- } catch (Exception pie) {
- throw new EclipseUiException("Unexpected exception while opening node editor", pie);
- }
- }
-}
+++ /dev/null
-## English labels for Agreo JCR UI application
-
-## Generic labels
-
-## Errors & warnings
-errorUnvalidNtFolderNodeType= Error: folder can only be created on a Jcr Node
-warningInvalidNodeToImport=Can only import to a node
-warningInvalidMultipleSelection=This functionality is implemented only on a single node for the time being.
-warningUnversionableNode= Current node is not versionable.
-warningNoChildNode= Current node has no child.
-
-## Commands
-getNodeSizeCmdLbl= Get approx. size
-addFolderNodeCmdLbl= Add Folder
-
-## GenericNodeEditor
-nodeEditorLbl=Generic node editor
-genericNodePageTitle=Properties
-childNodesPageTitle=Children
-nodeRightsManagementPageTitle=Effective privileges
-nodeVersionHistoryPageTitle=History
-propertyEditorPageTitle=Properties Editor (Experimental)
-
-# History
-versionTreeSectionTitle=Version list
-versionHistorySectionTitle=History
-
-## Dummy ones
-testLbl=Internationalizations of messages seems to work properly.
+++ /dev/null
-package org.argeo.cms.ui.workbench.osgi;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-
-/** A tree element representing a {@link Bundle} */
-class BundleNode extends TreeParent {
- private final Bundle bundle;
-
- public BundleNode(Bundle bundle) {
- this(bundle, false);
- }
-
- @SuppressWarnings("rawtypes")
- public BundleNode(Bundle bundle, boolean hasChildren) {
- super(bundle.getSymbolicName());
- this.bundle = bundle;
-
- if (hasChildren) {
- // REFERENCES
- ServiceReference[] usedServices = bundle.getServicesInUse();
- if (usedServices != null) {
- for (ServiceReference sr : usedServices) {
- if (sr != null)
- addChild(new ServiceReferenceNode(sr, false));
- }
- }
-
- // SERVICES
- ServiceReference[] registeredServices = bundle
- .getRegisteredServices();
- if (registeredServices != null) {
- for (ServiceReference sr : registeredServices) {
- if (sr != null)
- addChild(new ServiceReferenceNode(sr, true));
- }
- }
- }
-
- }
-
- Bundle getBundle() {
- return bundle;
- }
-}
+++ /dev/null
-//package org.argeo.eclipse.ui.workbench.osgi;
-//public class BundlesView {}
-
-package org.argeo.cms.ui.workbench.osgi;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.ColumnViewerComparator;
-import org.argeo.eclipse.ui.specific.EclipseUiSpecificUtils;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * Overview of the bundles as a table. Equivalent to Equinox 'ss' console
- * command.
- */
-public class BundlesView extends ViewPart {
- private TableViewer viewer;
-
- @Override
- public void createPartControl(Composite parent) {
- viewer = new TableViewer(parent);
- viewer.setContentProvider(new BundleContentProvider());
- viewer.getTable().setHeaderVisible(true);
-
- EclipseUiSpecificUtils.enableToolTipSupport(viewer);
-
- // ID
- TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setWidth(30);
- column.getColumn().setText("ID");
- column.getColumn().setAlignment(SWT.RIGHT);
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -3122136344359358605L;
-
- public String getText(Object element) {
- return Long.toString(((Bundle) element).getBundleId());
- }
- });
- new ColumnViewerComparator(column);
-
- // State
- column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setWidth(18);
- column.getColumn().setText("State");
- column.setLabelProvider(new StateLabelProvider());
- new ColumnViewerComparator(column);
-
- // Symbolic name
- column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setWidth(250);
- column.getColumn().setText("Symbolic Name");
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -4280840684440451080L;
-
- public String getText(Object element) {
- return ((Bundle) element).getSymbolicName();
- }
- });
- new ColumnViewerComparator(column);
-
- // Version
- column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setWidth(150);
- column.getColumn().setText("Version");
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 6871926308708629989L;
-
- public String getText(Object element) {
- Bundle bundle = (org.osgi.framework.Bundle) element;
- return bundle.getVersion().toString();
- }
- });
- new ColumnViewerComparator(column);
-
- viewer.setInput(WorkbenchUiPlugin.getDefault().getBundle().getBundleContext());
-
- }
-
- @Override
- public void setFocus() {
- if (viewer != null)
- viewer.getControl().setFocus();
- }
-
- /** Content provider managing the array of bundles */
- private static class BundleContentProvider implements IStructuredContentProvider {
- private static final long serialVersionUID = -8533792785725875977L;
-
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof BundleContext) {
- BundleContext bc = (BundleContext) inputElement;
- return bc.getBundles();
- }
- return null;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-}
+++ /dev/null
-//package org.argeo.eclipse.ui.workbench.osgi;
-//public class BundlesView {}
-
-package org.argeo.cms.ui.workbench.osgi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.naming.ldap.LdapName;
-
-import org.argeo.cms.CmsException;
-import org.argeo.cms.auth.CmsSession;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.ColumnViewerComparator;
-import org.argeo.eclipse.ui.specific.EclipseUiSpecificUtils;
-import org.argeo.util.LangUtils;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Overview of the active CMS sessions.
- */
-public class CmsSessionsView extends ViewPart {
- private TableViewer viewer;
-
- @Override
- public void createPartControl(Composite parent) {
- viewer = new TableViewer(parent);
- viewer.setContentProvider(new CmsSessionContentProvider());
- viewer.getTable().setHeaderVisible(true);
-
- EclipseUiSpecificUtils.enableToolTipSupport(viewer);
-
- int longColWidth = 150;
- int smallColWidth = 100;
-
- // Display name
- TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setWidth(longColWidth);
- column.getColumn().setText("User");
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -5234573509093747505L;
-
- public String getText(Object element) {
- return ((CmsSession) element).getAuthorization().toString();
- }
-
- public String getToolTipText(Object element) {
- return ((CmsSession) element).getUserDn().toString();
- }
- });
- new ColumnViewerComparator(column);
-
- // Creation time
- column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setWidth(smallColWidth);
- column.getColumn().setText("Since");
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -5234573509093747505L;
-
- public String getText(Object element) {
- return LangUtils.since(((CmsSession) element).getCreationTime());
- }
-
- public String getToolTipText(Object element) {
- return ((CmsSession) element).getCreationTime().toString();
- }
- });
- new ColumnViewerComparator(column);
-
- // Username
- column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setWidth(smallColWidth);
- column.getColumn().setText("Username");
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -5234573509093747505L;
-
- public String getText(Object element) {
- LdapName userDn = ((CmsSession) element).getUserDn();
- return userDn.getRdn(userDn.size() - 1).getValue().toString();
- }
-
- public String getToolTipText(Object element) {
- return ((CmsSession) element).getUserDn().toString();
- }
- });
- new ColumnViewerComparator(column);
-
- // UUID
- column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setWidth(smallColWidth);
- column.getColumn().setText("UUID");
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -5234573509093747505L;
-
- public String getText(Object element) {
- return ((CmsSession) element).getUuid().toString();
- }
-
- public String getToolTipText(Object element) {
- return getText(element);
- }
- });
- new ColumnViewerComparator(column);
-
- // Local ID
- column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setWidth(smallColWidth);
- column.getColumn().setText("Local ID");
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -5234573509093747505L;
-
- public String getText(Object element) {
- return ((CmsSession) element).getLocalId();
- }
-
- public String getToolTipText(Object element) {
- return getText(element);
- }
- });
- new ColumnViewerComparator(column);
-
- viewer.setInput(WorkbenchUiPlugin.getDefault().getBundle().getBundleContext());
-
- }
-
- @Override
- public void setFocus() {
- if (viewer != null)
- viewer.getControl().setFocus();
- }
-
- /** Content provider managing the array of bundles */
- private static class CmsSessionContentProvider implements IStructuredContentProvider {
- private static final long serialVersionUID = -8533792785725875977L;
-
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof BundleContext) {
- BundleContext bc = (BundleContext) inputElement;
- Collection<ServiceReference<CmsSession>> srs;
- try {
- srs = bc.getServiceReferences(CmsSession.class, null);
- } catch (InvalidSyntaxException e) {
- throw new CmsException("Cannot retrieve CMS sessions", e);
- }
- List<CmsSession> res = new ArrayList<>();
- for (ServiceReference<CmsSession> sr : srs) {
- res.add(bc.getService(sr));
- }
- return res.toArray();
- }
- return null;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.osgi;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.TreeParent;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/** The OSGi runtime from a module perspective. */
-public class ModulesView extends ViewPart {
- private TreeViewer viewer;
-
- @Override
- public void createPartControl(Composite parent) {
- viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- viewer.setContentProvider(new ModulesContentProvider());
- viewer.setLabelProvider(new ModulesLabelProvider());
- viewer.setInput(WorkbenchUiPlugin.getDefault().getBundle()
- .getBundleContext());
- }
-
- @Override
- public void setFocus() {
- viewer.getTree().setFocus();
- }
-
- private class ModulesContentProvider implements ITreeContentProvider {
- private static final long serialVersionUID = 3819934804640641721L;
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof BundleContext) {
- BundleContext bundleContext = (BundleContext) parentElement;
- Bundle[] bundles = bundleContext.getBundles();
-
- List<BundleNode> modules = new ArrayList<BundleNode>();
- for (Bundle bundle : bundles) {
- if (bundle.getState() == Bundle.ACTIVE)
- modules.add(new BundleNode(bundle, true));
- }
- return modules.toArray();
- } else if (parentElement instanceof TreeParent) {
- return ((TreeParent) parentElement).getChildren();
- } else {
- return null;
- }
- }
-
- public Object getParent(Object element) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof TreeParent) {
- return ((TreeParent) element).hasChildren();
- }
- return false;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- private class ModulesLabelProvider extends StateLabelProvider {
- private static final long serialVersionUID = 5290046145534824722L;
-
- @Override
- public String getText(Object element) {
- if (element instanceof BundleNode)
- return element.toString() + " ["
- + ((BundleNode) element).getBundle().getBundleId()
- + "]";
- return element.toString();
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.osgi;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.TreeParent;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/** <b>Experimental</b> The OSGi runtime from a module perspective. */
-@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" })
-public class MultiplePackagesView extends ViewPart {
- private TreeViewer viewer;
- private PackageAdmin packageAdmin;
- private Comparator<ExportedPackage> epc = new Comparator<ExportedPackage>() {
- public int compare(ExportedPackage o1, ExportedPackage o2) {
- if (!o1.getName().equals(o2.getName()))
- return o1.getName().compareTo(o2.getName());
- else
- return o1.getVersion().compareTo(o2.getVersion());
- }
- };
-
- @Override
- public void createPartControl(Composite parent) {
- viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- viewer.setContentProvider(new ModulesContentProvider());
- viewer.setLabelProvider(new LabelProvider());
- viewer.setInput(WorkbenchUiPlugin.getDefault().getBundle()
- .getBundleContext());
- }
-
- @Override
- public void setFocus() {
- viewer.getTree().setFocus();
- }
-
- private class ModulesContentProvider implements ITreeContentProvider {
- private static final long serialVersionUID = 3819934804640641721L;
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof BundleContext) {
- BundleContext bundleContext = (BundleContext) parentElement;
- Bundle[] bundles = bundleContext.getBundles();
-
- // scan packages
- ServiceReference paSr = bundleContext
- .getServiceReference(PackageAdmin.class.getName());
- // TODO: make a cleaner referencing
- packageAdmin = (PackageAdmin) bundleContext.getService(paSr);
-
- Map<Bundle, Set<ExportedPackage>> imported = new HashMap<Bundle, Set<ExportedPackage>>();
- Map<String, Set<ExportedPackage>> packages = new TreeMap<String, Set<ExportedPackage>>();
- for (Bundle bundle : bundles) {
- processBundle(bundle, imported, packages);
- }
-
- List<MultiplePackagesNode> multiplePackages = new ArrayList<MultiplePackagesNode>();
- for (String packageName : packages.keySet()) {
- Set<ExportedPackage> pkgs = packages.get(packageName);
- if (pkgs.size() > 1) {
- MultiplePackagesNode mpn = new MultiplePackagesNode(
- packageName, pkgs);
- multiplePackages.add(mpn);
- }
- }
-
- return multiplePackages.toArray();
- } else if (parentElement instanceof TreeParent) {
- return ((TreeParent) parentElement).getChildren();
- } else {
- return null;
- }
- }
-
- protected void processBundle(Bundle bundle,
- Map<Bundle, Set<ExportedPackage>> imported,
- Map<String, Set<ExportedPackage>> packages) {
- ExportedPackage[] pkgs = packageAdmin.getExportedPackages(bundle);
- if (pkgs == null)
- return;
- for (ExportedPackage pkg : pkgs) {
- if (!packages.containsKey(pkg.getName()))
- packages.put(pkg.getName(), new TreeSet<ExportedPackage>(
- epc));
- Set<ExportedPackage> expPackages = packages.get(pkg.getName());
- expPackages.add(pkg);
-
- // imported
- for (Bundle b : pkg.getImportingBundles()) {
- if (bundle.getBundleId() != b.getBundleId()) {
- if (!imported.containsKey(b)) {
- imported.put(b, new TreeSet<ExportedPackage>(epc));
- }
- Set<ExportedPackage> impPackages = imported.get(b);
- impPackages.add(pkg);
- }
- }
- }
- }
-
- public Object getParent(Object element) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof TreeParent) {
- return ((TreeParent) element).hasChildren();
- }
- return false;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- private class MultiplePackagesNode extends TreeParent {
- public MultiplePackagesNode(String packageName,
- Set<ExportedPackage> exportedPackages) {
- super(packageName);
- for (ExportedPackage pkg : exportedPackages) {
- addChild(new ExportedPackageNode(pkg));
- }
- }
- }
-
- private class ExportedPackageNode extends TreeParent {
- public ExportedPackageNode(ExportedPackage exportedPackage) {
- super(exportedPackage.getName() + " - "
- + exportedPackage.getVersion() + " ("
- + exportedPackage.getExportingBundle() + ")");
- for (Bundle bundle : exportedPackage.getImportingBundles()) {
- addChild(new BundleNode(bundle, true));
- }
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.osgi;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.eclipse.swt.graphics.Image;
-
-/** Shared icons. */
-public class OsgiExplorerImages {
- public final static Image INSTALLED = WorkbenchUiPlugin.getImageDescriptor(
- "icons/installed.gif").createImage();
- public final static Image RESOLVED = WorkbenchUiPlugin.getImageDescriptor(
- "icons/resolved.gif").createImage();
- public final static Image STARTING = WorkbenchUiPlugin.getImageDescriptor(
- "icons/starting.gif").createImage();
- public final static Image ACTIVE = WorkbenchUiPlugin.getImageDescriptor(
- "icons/active.gif").createImage();
- public final static Image SERVICE_PUBLISHED = WorkbenchUiPlugin
- .getImageDescriptor("icons/service_published.gif").createImage();
- public final static Image SERVICE_REFERENCED = WorkbenchUiPlugin
- .getImageDescriptor("icons/service_referenced.gif").createImage();
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.osgi;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
-
-/** A tree element representing a {@link ServiceReference} */
-@SuppressWarnings({ "rawtypes" })
-class ServiceReferenceNode extends TreeParent {
- private final ServiceReference serviceReference;
- private final boolean published;
-
- public ServiceReferenceNode(ServiceReference serviceReference,
- boolean published) {
- super(serviceReference.toString());
- this.serviceReference = serviceReference;
- this.published = published;
-
- if (isPublished()) {
- Bundle[] usedBundles = serviceReference.getUsingBundles();
- if (usedBundles != null) {
- for (Bundle b : usedBundles) {
- if (b != null)
- addChild(new BundleNode(b));
- }
- }
- } else {
- Bundle provider = serviceReference.getBundle();
- addChild(new BundleNode(provider));
- }
-
- for (String key : serviceReference.getPropertyKeys()) {
- addChild(new TreeParent(key + "="
- + serviceReference.getProperty(key)));
- }
-
- }
-
- public ServiceReference getServiceReference() {
- return serviceReference;
- }
-
- public boolean isPublished() {
- return published;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.osgi;
-
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-
-/** Label provider showing the sate of bundles */
-class StateLabelProvider extends ColumnLabelProvider {
- private static final long serialVersionUID = -7885583135316000733L;
-
- @Override
- public Image getImage(Object element) {
- int state;
- if (element instanceof Bundle)
- state = ((Bundle) element).getState();
- else if (element instanceof BundleNode)
- state = ((BundleNode) element).getBundle().getState();
- else if (element instanceof ServiceReferenceNode)
- if (((ServiceReferenceNode) element).isPublished())
- return OsgiExplorerImages.SERVICE_PUBLISHED;
- else
- return OsgiExplorerImages.SERVICE_REFERENCED;
- else
- return null;
-
- switch (state) {
- case Bundle.UNINSTALLED:
- return OsgiExplorerImages.INSTALLED;
- case Bundle.INSTALLED:
- return OsgiExplorerImages.INSTALLED;
- case Bundle.RESOLVED:
- return OsgiExplorerImages.RESOLVED;
- case Bundle.STARTING:
- return OsgiExplorerImages.STARTING;
- case Bundle.STOPPING:
- return OsgiExplorerImages.STARTING;
- case Bundle.ACTIVE:
- return OsgiExplorerImages.ACTIVE;
- default:
- return null;
- }
- }
-
- @Override
- public String getText(Object element) {
- return null;
- }
-
- @Override
- public String getToolTipText(Object element) {
- Bundle bundle = (Bundle) element;
- Integer state = bundle.getState();
- switch (state) {
- case Bundle.UNINSTALLED:
- return "UNINSTALLED";
- case Bundle.INSTALLED:
- return "INSTALLED";
- case Bundle.RESOLVED:
- return "RESOLVED";
- case Bundle.STARTING:
- String activationPolicy = bundle.getHeaders()
- .get(Constants.BUNDLE_ACTIVATIONPOLICY).toString();
-
- // .get("Bundle-ActivationPolicy").toString();
- // FIXME constant triggers the compilation failure
- if (activationPolicy != null
- && activationPolicy.equals(Constants.ACTIVATION_LAZY))
- // && activationPolicy.equals("lazy"))
- // FIXME constant triggers the compilation failure
- // && activationPolicy.equals(Constants.ACTIVATION_LAZY))
- return "<<LAZY>>";
- return "STARTING";
- case Bundle.STOPPING:
- return "STOPPING";
- case Bundle.ACTIVE:
- return "ACTIVE";
- default:
- return null;
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.useradmin;
-
-import java.util.ArrayList;
-
-import org.argeo.api.ArgeoLogger;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Display log lines for all users with a virtual table.
- */
-public class AdminLogView extends ViewPart {
- public static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".adminLogView";
-
- private TableViewer viewer;
-
- private LogContentProvider logContentProvider;
- private ArgeoLogger argeoLogger;
-
- @Override
- public void createPartControl(Composite parent) {
- // FIXME doesn't return a monospace font in RAP
- Font font = JFaceResources.getTextFont();
- Table table = new Table(parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
- table.setFont(font);
-
- viewer = new TableViewer(table);
- viewer.setLabelProvider(new LabelProvider());
- logContentProvider = new LogContentProvider(viewer) {
- private static final long serialVersionUID = -3401776448301180724L;
-
- @Override
- protected StringBuffer prefix(String username, Long timestamp,
- String level, String category, String thread) {
- return super
- .prefix(username, timestamp, level, category, thread)
- .append(norm(level, 5))
- .append(' ')
- .append(norm(username != null ? username
- : "<anonymous>", 16)).append(' ');
- }
- };
- viewer.setContentProvider(logContentProvider);
- // viewer.setUseHashlookup(true);
- viewer.setInput(new ArrayList<String>());
-
- if (argeoLogger != null)
- argeoLogger.registerForAll(logContentProvider, 1000, true);
- }
-
- @Override
- public void setFocus() {
- viewer.getTable().setFocus();
- }
-
- @Override
- public void dispose() {
- if (argeoLogger != null)
- argeoLogger.unregisterForAll(logContentProvider);
- }
-
- public void setArgeoLogger(ArgeoLogger argeoLogger) {
- this.argeoLogger = argeoLogger;
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.useradmin;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.argeo.api.ArgeoLogListener;
-import org.eclipse.jface.viewers.ILazyContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-/** A content provider maintaining an array of lines */
-class LogContentProvider implements ILazyContentProvider, ArgeoLogListener {
- private static final long serialVersionUID = -2084872367738339721L;
-
- private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
-
- private final Long start;
- /** current - start = line number. first line is number '1' */
- private Long current;
-
- // TODO make it configurable
- private final Integer maxLineBufferSize = 10 * 1000;
-
- private final TableViewer viewer;
- private LinkedList<LogLine> lines;
-
- public LogContentProvider(TableViewer viewer) {
- this.viewer = viewer;
- start = System.currentTimeMillis();
- lines = new LinkedList<LogLine>();
- current = start;
- }
-
- public synchronized void dispose() {
- lines.clear();
- lines = null;
- }
-
- @SuppressWarnings("unchecked")
- public synchronized void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- List<String> lin = (List<String>) newInput;
- if (lin == null)
- return;
- for (String line : lin) {
- addLine(line);
- }
- this.viewer.setItemCount(lines.size());
- }
-
- public void updateElement(int index) {
- viewer.replace(lines.get(index), index);
- }
-
- public synchronized void appendLog(String username, Long timestamp,
- String level, String category, String thread, Object msg,
- String[] exception) {
- // check if valid
- if (lines == null)
- return;
-
- String message = msg.toString();
- int count = 0;
- String prefix = prefix(username, timestamp, level, category, thread)
- .toString();
- // String suffix = suffix(username, timestamp, level, category, thread);
- for (String line : message.split("\n")) {
- addLine(count == 0 ? prefix + line : line);
- count++;
- }
-
- if (exception != null) {
- for (String ste : exception) {
- addLine(ste);
- }
- }
-
- viewer.getTable().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (lines == null)
- return;
- viewer.setItemCount(lines.size());
- // doesn't work with syncExec
- scrollToLastLine();
- }
- });
- }
-
- protected StringBuffer prefix(String username, Long timestamp,
- String level, String category, String thread) {
- StringBuffer buf = new StringBuffer("");
- buf.append(dateFormat.format(new Date(timestamp))).append(" ");
- // buf.append(level).append(" ");
- return buf;
- }
-
- /** Normalize string to the given size */
- protected String norm(String str, Integer size) {
- int length = str.length();
- if (length == size)
- return str;
- else if (length > size)
- return str.substring(0, size);
- else {
- char[] arr = new char[size - length];
- Arrays.fill(arr, ' ');
- return str + new String(arr);
- }
- }
-
- // protected String suffix(String username, Long timestamp, String level,
- // String category, String thread) {
- // return "";
- // }
-
- /** Scroll to the last line */
- protected synchronized void scrollToLastLine() {
- // we try to show last line with two methods
- // viewer.reveal(lines.peekLast());
-
- Table table = viewer.getTable();
- TableItem ti = table.getItem(table.getItemCount() - 1);
- table.showItem(ti);
- }
-
- protected synchronized LogLine addLine(String line) {
- // check for maximal size and purge if necessary
- while (lines.size() >= maxLineBufferSize) {
- for (int i = 0; i < maxLineBufferSize / 10; i++) {
- lines.poll();
- }
- }
-
- current++;
- LogLine logLine = new LogLine(current, line);
- lines.add(logLine);
- return logLine;
- }
-
- private class LogLine {
- private Long linenumber;
- private String message;
-
- public LogLine(Long linenumber, String message) {
- this.linenumber = linenumber;
- this.message = message;
- }
-
- @Override
- public int hashCode() {
- return linenumber.intValue();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof LogLine)
- return ((LogLine) obj).linenumber.equals(linenumber);
- else
- return false;
- }
-
- @Override
- public String toString() {
- return message;
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.useradmin;
-
-import java.util.ArrayList;
-
-import org.argeo.api.ArgeoLogListener;
-import org.argeo.api.ArgeoLogger;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Display log lines with a virtual table. Register and unregisters a
- * {@link ArgeoLogListener} via OSGi services.
- */
-public class LogView extends ViewPart {
- public static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".logView";
-
- private TableViewer viewer;
-
- private LogContentProvider logContentProvider;
- private ArgeoLogger argeoLogger;
-
- @Override
- public void createPartControl(Composite parent) {
- Font font = JFaceResources.getTextFont();
- Table table = new Table(parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
- table.setFont(font);
-
- viewer = new TableViewer(table);
- viewer.setLabelProvider(new LabelProvider());
- logContentProvider = new LogContentProvider(viewer);
- viewer.setContentProvider(logContentProvider);
- // viewer.setUseHashlookup(true);
- viewer.setInput(new ArrayList<String>());
-
- if (argeoLogger != null)
- argeoLogger.register(logContentProvider, 1000);
- }
-
- @Override
- public void setFocus() {
- viewer.getTable().setFocus();
- }
-
- @Override
- public void dispose() {
- if (argeoLogger != null)
- argeoLogger.unregister(logContentProvider);
- }
-
- public void setArgeoLogger(ArgeoLogger argeoLogger) {
- this.argeoLogger = argeoLogger;
- }
-
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.useradmin;
-
-import java.util.TreeSet;
-
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.part.ViewPart;
-
-/** Information about the currently logged in user */
-public class UserProfile extends ViewPart {
- public static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".userProfile";
-
- private TableViewer viewer;
-
- @Override
- public void createPartControl(Composite parent) {
- parent.setLayout(new GridLayout(2, false));
-
- // Authentication authentication = CurrentUser.getAuthentication();
- // EclipseUiUtils.createGridLL(parent, "Name", authentication
- // .getPrincipal().toString());
- EclipseUiUtils.createGridLL(parent, "User ID",
- CurrentUser.getUsername());
-
- // roles table
- Table table = new Table(parent, SWT.V_SCROLL | SWT.BORDER);
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
- table.setLinesVisible(false);
- table.setHeaderVisible(false);
- viewer = new TableViewer(table);
- viewer.setContentProvider(new RolesContentProvider());
- viewer.setLabelProvider(new LabelProvider());
- getViewSite().setSelectionProvider(viewer);
- viewer.setInput(getViewSite());
- }
-
- @Override
- public void setFocus() {
- viewer.getTable();
- }
-
- private class RolesContentProvider implements IStructuredContentProvider {
- private static final long serialVersionUID = -4576917440167866233L;
-
- public Object[] getElements(Object inputElement) {
- return new TreeSet<String>(CurrentUser.roles()).toArray();
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.Parameterization;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.menus.CommandContributionItem;
-import org.eclipse.ui.menus.CommandContributionItemParameter;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * Centralises useful and generic methods when dealing with commands in an
- * Eclipse Workbench context
- */
-public class CommandUtils {
-
- /**
- * Commodities the refresh of a single command with no parameter in a
- * Menu.aboutToShow method to simplify further development
- *
- * Note: that this method should be called with a false show command flag to
- * remove a contribution that have been previously contributed
- */
- public static void refreshCommand(IMenuManager menuManager, IServiceLocator locator, String cmdId, String label,
- ImageDescriptor icon, boolean showCommand) {
- refreshParameterizedCommand(menuManager, locator, cmdId, label, icon, showCommand, null);
- }
-
- /**
- * Commodities the refresh the contribution of a command with a map of
- * parameters in a context menu
- *
- * The command ID is used has contribution item ID
- */
- public static void refreshParameterizedCommand(IMenuManager menuManager, IServiceLocator locator, String cmdId,
- String label, ImageDescriptor icon, boolean showCommand, Map<String, String> params) {
- refreshParameterizedCommand(menuManager, locator, cmdId, cmdId, label, icon, showCommand, params);
- }
-
- /**
- * Commodities the refresh the contribution of a command with a map of
- * parameters in a context menu
- *
- * @param menuManager
- * @param locator
- * @param contributionId
- * @param commandId
- * @param label
- * @param icon
- * @param showCommand
- * @param params
- */
- public static void refreshParameterizedCommand(IMenuManager menuManager, IServiceLocator locator,
- String contributionId, String commandId, String label, ImageDescriptor icon, boolean showCommand,
- Map<String, String> params) {
- IContributionItem ici = menuManager.find(contributionId);
- if (ici != null)
- menuManager.remove(ici);
- if (showCommand) {
- CommandContributionItemParameter contributionItemParameter = new CommandContributionItemParameter(locator,
- null, commandId, SWT.PUSH);
-
- // Set Params
- contributionItemParameter.label = label;
- contributionItemParameter.icon = icon;
-
- if (params != null)
- contributionItemParameter.parameters = params;
-
- CommandContributionItem cci = new CommandContributionItem(contributionItemParameter);
- cci.setId(contributionId);
- menuManager.add(cci);
- }
- }
-
- /** Helper to call a command without parameter easily */
- public static void callCommand(String commandID) {
- callCommand(commandID, null);
- }
-
- /** Helper to call a command with a single parameter easily */
- public static void callCommand(String commandID, String parameterID, String parameterValue) {
- Map<String, String> params = new HashMap<String, String>();
- params.put(parameterID, parameterValue);
- callCommand(commandID, params);
- }
-
- /**
- * Helper to call a command with a map of parameters easily
- *
- * @param paramMap
- * a map that links various command IDs with corresponding String
- * values.
- */
- public static void callCommand(String commandID, Map<String, String> paramMap) {
- try {
- IWorkbench iw = WorkbenchUiPlugin.getDefault().getWorkbench();
- IHandlerService handlerService = (IHandlerService) iw.getService(IHandlerService.class);
- ICommandService cmdService = (ICommandService) iw.getActiveWorkbenchWindow()
- .getService(ICommandService.class);
- Command cmd = cmdService.getCommand(commandID);
-
- ArrayList<Parameterization> parameters = null;
- ParameterizedCommand pc;
-
- if (paramMap != null) {
- // Set parameters of the command to launch :
- parameters = new ArrayList<Parameterization>();
- Parameterization parameterization;
-
- for (String id : paramMap.keySet()) {
- parameterization = new Parameterization(cmd.getParameter(id), paramMap.get(id));
- parameters.add(parameterization);
- }
- pc = new ParameterizedCommand(cmd, parameters.toArray(new Parameterization[parameters.size()]));
- } else
- pc = new ParameterizedCommand(cmd, null);
-
- // execute the command
- handlerService.executeCommand(pc, null);
- } catch (Exception e) {
- throw new EclipseUiException("Unexpected error while" + " calling the command " + commandID, e);
- }
- }
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.util;
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import javax.security.auth.Subject;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.Job;
-
-/**
- * Propagate authentication to an eclipse job. Typically to execute a privileged
- * action outside the UI thread
- */
-public abstract class PrivilegedJob extends Job {
- private final Subject subject;
-
- public PrivilegedJob(String jobName) {
- this(jobName, AccessController.getContext());
- }
-
- public PrivilegedJob(String jobName,
- AccessControlContext accessControlContext) {
- super(jobName);
- subject = Subject.getSubject(accessControlContext);
-
- // Must be called *before* the job is scheduled,
- // it is required for the progress window to appear
- setUser(true);
- }
-
- @Override
- protected IStatus run(final IProgressMonitor progressMonitor) {
- PrivilegedAction<IStatus> privilegedAction = new PrivilegedAction<IStatus>() {
- public IStatus run() {
- return doRun(progressMonitor);
- }
- };
- return Subject.doAs(subject, privilegedAction);
- }
-
- /**
- * Implement here what should be executed with default context
- * authentication
- */
- protected abstract IStatus doRun(IProgressMonitor progressMonitor);
-}
+++ /dev/null
-package org.argeo.cms.ui.workbench.util;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.argeo.cms.auth.CurrentUser;
-import org.eclipse.ui.AbstractSourceProvider;
-
-/**
- * Provides the roles of the current user as a variable to be used for activity
- * binding
- */
-public class RolesSourceProvider extends AbstractSourceProvider {
- public final static String ROLES_VARIABLE = "roles";
- private final static String[] PROVIDED_SOURCE_NAMES = new String[] { ROLES_VARIABLE };
-
- public Map<String, Set<String>> getCurrentState() {
- Map<String, Set<String>> stateMap = new HashMap<String, Set<String>>();
- stateMap.put(ROLES_VARIABLE, CurrentUser.roles());
- return stateMap;
- }
-
- public String[] getProvidedSourceNames() {
- return PROVIDED_SOURCE_NAMES;
- }
-
- public void updateRoles() {
- fireSourceChanged(0, getCurrentState());
- }
-
- public void dispose() {
- }
-}
+++ /dev/null
-package org.argeo.eclipse.spring;\r
-\r
-import static java.text.MessageFormat.format;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.eclipse.core.runtime.Platform;\r
-import org.osgi.framework.Bundle;\r
-import org.osgi.framework.BundleContext;\r
-import org.osgi.framework.BundleException;\r
-import org.osgi.framework.FrameworkUtil;\r
-import org.osgi.framework.InvalidSyntaxException;\r
-import org.osgi.util.tracker.ServiceTracker;\r
-import org.springframework.context.ApplicationContext;\r
-\r
-/** Tracks Spring application context published as services. */\r
-class ApplicationContextTracker {\r
- private final static Log log = LogFactory\r
- .getLog(ApplicationContextTracker.class);\r
-\r
- private static final String FILTER = "(&(objectClass=org.springframework.context.ApplicationContext)" //$NON-NLS-1$\r
- + "(org.springframework.context.service.name={0}))"; //$NON-NLS-1$\r
-\r
- public final static String APPLICATION_CONTEXT_TRACKER_TIMEOUT = "org.argeo.eclipse.spring.applicationContextTrackerTimeout";\r
-\r
- private static Long defaultTimeout = Long.parseLong(System.getProperty(\r
- APPLICATION_CONTEXT_TRACKER_TIMEOUT, "30000"));\r
-\r
- @SuppressWarnings("rawtypes")\r
- private ServiceTracker applicationContextServiceTracker;\r
-\r
- /**\r
- * @param contributorBundle\r
- * OSGi bundle for which the Spring application context is to be\r
- * tracked. Must not be null!\r
- * @param factoryBundleContext\r
- * BundleContext object which can be used to track services\r
- * @throws IllegalArgumentException\r
- * if the given bundle is null.\r
- */\r
- @SuppressWarnings({ "unchecked", "rawtypes" })\r
- public ApplicationContextTracker(final Bundle contributorBundle,\r
- final BundleContext factoryBundleContext) {\r
- final String filter = format(FILTER,\r
- contributorBundle.getSymbolicName());\r
- try {\r
- applicationContextServiceTracker = new ServiceTracker(\r
- factoryBundleContext, FrameworkUtil.createFilter(filter),\r
- null);\r
- // applicationContextServiceTracker.open();\r
- } catch (final InvalidSyntaxException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
-\r
- public void open() {\r
- if (applicationContextServiceTracker != null) {\r
- applicationContextServiceTracker.open();\r
- }\r
- }\r
-\r
- public void close() {\r
- if (applicationContextServiceTracker != null) {\r
- applicationContextServiceTracker.close();\r
- }\r
- }\r
-\r
- public ApplicationContext getApplicationContext() {\r
- ApplicationContext applicationContext = null;\r
- if (applicationContextServiceTracker != null) {\r
- try {\r
- applicationContext = (ApplicationContext) applicationContextServiceTracker\r
- .waitForService(defaultTimeout);\r
- } catch (InterruptedException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
- return applicationContext;\r
- }\r
-\r
- @Override\r
- protected void finalize() throws Throwable {\r
- close();\r
- super.finalize();\r
- }\r
-\r
- static ApplicationContext getApplicationContext(String bundleSymbolicName) {\r
- Bundle contributorBundle = Platform.getBundle(bundleSymbolicName);\r
- return getApplicationContext(contributorBundle);\r
- }\r
-\r
- static ApplicationContext getApplicationContext(\r
- final Bundle contributorBundle) {\r
- if (log.isTraceEnabled())\r
- log.trace("Get application context for bundle " + contributorBundle);\r
-\r
- // Start if not yet started (also if in STARTING state, may be lazy)\r
- if (contributorBundle.getState() != Bundle.ACTIVE) {\r
- if (log.isTraceEnabled())\r
- log.trace("Starting bundle: "\r
- + contributorBundle.getSymbolicName());\r
- // Thread startBundle = new Thread("Start bundle "\r
- // + contributorBundle.getSymbolicName()) {\r
- // public void run() {\r
- try {\r
- contributorBundle.start();\r
- } catch (BundleException e) {\r
- log.error("Cannot start bundle " + contributorBundle, e);\r
- }\r
- // }\r
- // };\r
- // startBundle.start();\r
- // try {\r
- // startBundle.join(10 * 1000l);\r
- // } catch (InterruptedException e) {\r
- // // silent\r
- // }\r
- }\r
-\r
- final ApplicationContextTracker applicationContextTracker = new ApplicationContextTracker(\r
- contributorBundle, contributorBundle.getBundleContext());\r
- ApplicationContext applicationContext = null;\r
- try {\r
- applicationContextTracker.open();\r
- applicationContext = applicationContextTracker\r
- .getApplicationContext();\r
- } finally {\r
- applicationContextTracker.close();\r
- }\r
- return applicationContext;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.eclipse.spring;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.IHandlerListener;
-import org.springframework.context.ApplicationContext;
-
-/** Allows to declare Eclipse commands as Spring beans */
-public class SpringCommandHandler implements IHandler {
- private final static Log log = LogFactory
- .getLog(SpringCommandHandler.class);
-
- public void addHandlerListener(IHandlerListener handlerListener) {
- }
-
- public void dispose() {
- }
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String commandId = event.getCommand().getId();
- String bundleSymbolicName = commandId.substring(0,
- commandId.lastIndexOf('.'));
- try {
- if (log.isTraceEnabled())
- log.trace("Execute " + event + " via spring command handler "
- + this);
- // TODO: make it more flexible and robust
- ApplicationContext applicationContext = ApplicationContextTracker
- .getApplicationContext(bundleSymbolicName);
- if (applicationContext == null)
- throw new EclipseUiException(
- "No application context found for "
- + bundleSymbolicName);
-
- // retrieve the command via its id
- String beanName = event.getCommand().getId();
-
- if (!applicationContext.containsBean(beanName)) {
- if (beanName.startsWith(bundleSymbolicName))
- beanName = beanName
- .substring(bundleSymbolicName.length() + 1);
- }
-
- if (!applicationContext.containsBean(beanName))
- throw new ExecutionException("No bean found with name "
- + beanName + " in bundle " + bundleSymbolicName);
- Object bean = applicationContext.getBean(beanName);
-
- if (!(bean instanceof IHandler))
- throw new ExecutionException("Bean with name " + beanName
- + " and class " + bean.getClass()
- + " does not implement the IHandler interface.");
-
- IHandler handler = (IHandler) bean;
- return handler.execute(event);
- } catch (Exception e) {
- // TODO: use eclipse error management
- // log.error(e);
- throw new ExecutionException("Cannot execute Spring command "
- + commandId + " in bundle " + bundleSymbolicName, e);
- }
- }
-
- public boolean isEnabled() {
- return true;
- }
-
- public boolean isHandled() {
- return true;
- }
-
- public void removeHandlerListener(IHandlerListener handlerListener) {
- }
-}
+++ /dev/null
-package org.argeo.eclipse.spring;\r
-\r
-import org.argeo.eclipse.ui.EclipseUiException;\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.core.runtime.IConfigurationElement;\r
-import org.eclipse.core.runtime.IExecutableExtension;\r
-import org.eclipse.core.runtime.IExecutableExtensionFactory;\r
-import org.eclipse.core.runtime.IExtension;\r
-import org.springframework.context.ApplicationContext;\r
-\r
-/**\r
- * The Spring Extension Factory builds a bridge between the Eclipse Extension\r
- * Registry and the Spring Framework (especially Spring Dynamic Modules).\r
- * \r
- * It allows you to define your extension as a spring bean within the spring\r
- * application context of your bundle. If you would like to use this bean as an\r
- * instance of an extension (an Eclipse RCP view, for example) you define the\r
- * extension with this spring extension factory as the class to be created.\r
- * \r
- * To let the spring extension factory pick the right bean from your application\r
- * context you need to set the bean id to the same value as the id of the view\r
- * within the view definition, for example. This is important if your extension\r
- * definition contains more than one element, where each element has its own id.\r
- * \r
- * If the extension definition elements themselves have no id attribute the\r
- * spring extension factory uses the id of the extension itself to identify the\r
- * bean.\r
- * \r
- * original code from: <a href=\r
- * "http://martinlippert.blogspot.com/2008/10/new-version-of-spring-extension-factory.html"\r
- * >Blog entry</a>\r
- */\r
-public class SpringExtensionFactory implements IExecutableExtensionFactory,\r
- IExecutableExtension {\r
-\r
- private Object bean;\r
-\r
- public Object create() throws CoreException {\r
- if (bean == null)\r
- throw new EclipseUiException("No underlying bean for extension");\r
- return bean;\r
- }\r
-\r
- public void setInitializationData(IConfigurationElement config,\r
- String propertyName, Object data) throws CoreException {\r
- String bundleSymbolicName = config.getContributor().getName();\r
- ApplicationContext applicationContext = ApplicationContextTracker\r
- .getApplicationContext(bundleSymbolicName);\r
- if (applicationContext == null)\r
- throw new EclipseUiException(\r
- "Cannot find application context for bundle "\r
- + bundleSymbolicName);\r
-\r
- String beanName = getBeanName(data, config);\r
- if (beanName == null)\r
- throw new EclipseUiException("Cannot find bean name for extension "\r
- + config);\r
-\r
- if (!applicationContext.containsBean(beanName)) {\r
- if (beanName.startsWith(bundleSymbolicName))\r
- beanName = beanName.substring(bundleSymbolicName.length() + 1);\r
- }\r
-\r
- if (!applicationContext.containsBean(beanName))\r
- throw new EclipseUiException("No bean with name '" + beanName + "'");\r
-\r
- this.bean = applicationContext.getBean(beanName);\r
- if (this.bean instanceof IExecutableExtension) {\r
- ((IExecutableExtension) this.bean).setInitializationData(config,\r
- propertyName, data);\r
- }\r
- }\r
-\r
- private String getBeanName(Object data, IConfigurationElement config) {\r
-\r
- // try the specific bean id the extension defines\r
- if (data != null && data.toString().length() > 0) {\r
- return data.toString();\r
- }\r
-\r
- // try the id of the config element\r
- if (config.getAttribute("id") != null) {\r
- return config.getAttribute("id");\r
- }\r
-\r
- // try the id of the extension element itself\r
- if (config.getParent() != null\r
- && config.getParent() instanceof IExtension) {\r
- IExtension extensionDefinition = (IExtension) config.getParent();\r
- return extensionDefinition.getSimpleIdentifier();\r
- }\r
-\r
- return null;\r
- }\r
-}\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.ext.rap.ui.workbench</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments />
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments />
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:util="http://www.springframework.org/schema/util"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/util\r
- http://www.springframework.org/schema/util/spring-util-2.5.xsd">\r
-\r
- <service interface="org.eclipse.rap.rwt.application.ApplicationConfiguration">\r
- <service-properties>\r
- <beans:entry key="contextName" value="ui" />\r
- </service-properties>\r
- <beans:bean\r
- class="org.eclipse.rap.ui.internal.servlet.WorkbenchApplicationConfiguration" />\r
- </service>\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-Bundle-SymbolicName: org.argeo.ext.rap.ui.workbench;singleton:=true
-Bundle-ActivationPolicy: lazy
-
-Fragment-Host: org.eclipse.rap.ui.workbench
+++ /dev/null
-source.. = src/,\
- ext/test/
+++ /dev/null
-<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.slc.legacy.commons</groupId>
- <artifactId>argeo-commons-legacy</artifactId>
- <version>2.1.104</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.ext.rap.ui.workbench</artifactId>
- <name>Extension RAP Workbench</name>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <groupId>org.argeo.slc.legacy.commons</groupId>
- <artifactId>argeo-commons-legacy</artifactId>
- <version>2.1.104</version>
- <name>Commons Legacy</name>
- <packaging>pom</packaging>
- <properties>
- <version.argeo-tp-extras>2.1.13</version.argeo-tp-extras>
- </properties>
- <modules>
- <module>org.argeo.cms.ui.workbench</module>
- <module>org.argeo.cms.ui.workbench.rap</module>
- <module>org.argeo.ext.rap.ui.workbench</module>
- <module>dep</module>
- </modules>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.argeo.tp.extras</groupId>
- <artifactId>argeo-tp-extras</artifactId>
- <version>${version.argeo-tp-extras}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <repositories>
- <repository>
- <id>argeo</id>
- <url>http://forge.argeo.org/data/java/argeo-2.1/</url>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>daily</updatePolicy>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>argeo-extras</id>
- <url>http://forge.argeo.org/data/java/argeo-extras-2.1/</url>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>daily</updatePolicy>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- </repository>
- </repositories>
- <profiles>
- <profile>
- <id>localrepo</id>
- <repositories>
- <repository>
- <id>argeo-extras</id>
- <url>http://localhost:7080/data/java/argeo-extras-2.1</url>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>daily</updatePolicy>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- </repository>
- </repositories>
- </profile>
- </profiles>
-
-</project>
\ No newline at end of file
+++ /dev/null
--include: ../../cnf/maven.bnd
\ No newline at end of file
+++ /dev/null
--include: ../../cnf/maven.bnd
\ No newline at end of file
+++ /dev/null
-/target/
-/org.argeo.slc.dep.backend-maven.target
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-properties.1.name=org.eclipse.equinox.p2.type.category
-properties.1.value=true
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy-dep</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.dep.backend</artifactId>
- <name>SLC Backend</name>
- <dependencies>
- <!-- SLC Minimal -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.dep.spring</artifactId>
- <version>2.1-SNAPSHOT</version>
- <type>pom</type>
- </dependency>
-
- <!-- SLC Libs -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.slc</groupId> -->
- <!-- <artifactId>org.argeo.slc.lib.repo</artifactId> -->
- <!-- <version>1.1.14-SNAPSHOT</version> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.slc</groupId> -->
- <!-- <artifactId>org.argeo.slc.lib.jcr</artifactId> -->
- <!-- <version>1.1.14-SNAPSHOT</version> -->
- <!-- </dependency> -->
-
- <!-- Extensions -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.support</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.server.repo</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.slc</groupId> -->
- <!-- <artifactId>org.argeo.slc.server.repo.webapp</artifactId> -->
- <!-- <version>2.1.1-SNAPSHOT</version> -->
- <!-- </dependency> -->
-
- <!-- UI -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.client.ui</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.client.ui.dist</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.client.rap</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- OSGi Boot for platform generation only, as it could be used by regular
- Java applications to launch an OSGi runtime. -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.osgi.boot</artifactId>
- <version>${version.argeo-commons}</version>
- <scope>test</scope>
- </dependency>
-
- <!-- Legacy Argeo Commons platform (Eclipse 3) -->
- <dependency>
- <groupId>org.argeo.slc.legacy.commons</groupId>
- <artifactId>org.argeo.dep.cms.platform</artifactId>
- <version>${version.argeo-commons-legacy}</version>
- <type>pom</type>
- </dependency>
-
- <dependency>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>com.googlecode.javaewah.JavaEWAH</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>org.eclipse.jgit</artifactId>
- </dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>rpmbuild</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-source</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>a2-source</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rpm-argeo</id>
- <phase>package</phase>
- <goals>
- <goal>rpm</goal>
- </goals>
- <configuration>
- <name>argeo-slc-platform${argeo.rpm.suffix}</name>
- <mappings>
- <mapping>
- <directory>/usr/share/osgi</directory>
- <username>root</username>
- <groupname>root</groupname>
- <filemode>644</filemode>
- <directoryIncluded>true</directoryIncluded>
- <sources>
- <source>
- <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
- <includes>
- <include>**/*.jar</include>
- </includes>
- </source>
- </sources>
- </mapping>
- </mappings>
- <requires>
- <require>argeo-cms-platform${argeo.rpm.suffix}</require>
- <require>argeo-slc-spring${argeo.rpm.suffix}</require>
- </requires>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-/target/
-/*.target
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy-dep</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.dep.spring</artifactId>
- <name>SLC Agent based on Spring</name>
- <dependencies>
- <!-- Parent dependencies -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.dep.minimal</artifactId>
- <version>2.1-SNAPSHOT</version>
- <type>pom</type>
- </dependency>
-
- <!-- Spring-based Agent -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.spring</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.support</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.agent</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.agent.jcr</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- Transitional fake Java 8 APIs, required by old version of Spring,
- in the process of being removed -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.legacy.fake.java8</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- Not strictly Spring dependencies but used by the old approach -->
- <dependency>
- <groupId>org.argeo.tp.apache.ant</groupId>
- <artifactId>org.apache.ant</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.apache.ant</groupId>
- <artifactId>org.apache.ant.launch</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.javax</groupId>
- <artifactId>javax.mail</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>com.jcraft.jsch</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.apache.commons</groupId>
- <artifactId>org.apache.commons.vfs</artifactId>
- </dependency>
-
- <!-- Base Spring dependency -->
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.beans</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.javax</groupId>
- <artifactId>javax.el</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.gemini</groupId>
- <artifactId>org.eclipse.gemini.blueprint.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.gemini</groupId>
- <artifactId>org.eclipse.gemini.blueprint.extender</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.gemini</groupId>
- <artifactId>org.eclipse.gemini.blueprint.io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>org.aspectj.weaver</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>org.aopalliance</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.aop</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.context</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.expression</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.instrument</artifactId>
- </dependency>
-
- <!-- Spring -->
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.aspects</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.context.support</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.jdbc</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.tx</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.web</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.web.servlet</artifactId>
- </dependency>
-
- <!-- CLI Agent -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.slc</groupId> -->
- <!-- <artifactId>org.argeo.slc.launcher</artifactId> -->
- <!-- <version>1.1.12-SNAPSHOT</version> -->
- <!-- </dependency> -->
- <!-- <dependency> -->
- <!-- <groupId>org.argeo.slc</groupId> -->
- <!-- <artifactId>org.argeo.slc.agent.cli</artifactId> -->
- <!-- <version>2.1.1-SNAPSHOT</version> -->
- <!-- </dependency> -->
- </dependencies>
- <profiles>
- <profile>
- <id>rpmbuild</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-source</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>a2-source</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rpm-argeo</id>
- <phase>package</phase>
- <goals>
- <goal>rpm</goal>
- </goals>
- <configuration>
- <name>argeo-slc-spring${argeo.rpm.suffix}</name>
- <mappings>
- <mapping>
- <directory>/usr/share/osgi</directory>
- <username>root</username>
- <groupname>root</groupname>
- <filemode>644</filemode>
- <directoryIncluded>true</directoryIncluded>
- <sources>
- <source>
- <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source</location>
- <includes>
- <include>**/*.jar</include>
- </includes>
- </source>
- </sources>
- </mapping>
- </mappings>
- <requires>
- <require>argeo-cms-node${argeo.rpm.suffix}</require>
- <require>argeo-slc${argeo.rpm.suffix}</require>
- <require>argeo-slc-tp${argeo.rpm.suffix}</require>
- <require>argeo-slc-spring-tp${argeo.rpm.suffix}</require>
- </requires>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>rpmbuild-tp</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-source-tp</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>a2-source-tp</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>rpm-tp</id>
- <phase>package</phase>
- <goals>
- <goal>rpm</goal>
- </goals>
- <configuration>
- <name>argeo-slc-spring-tp${argeo.rpm.suffix}</name>
- <projversion>${version.argeo-tp}</projversion>
- <release>${argeo.rpm.release.tp}</release>
- <mappings>
- <mapping>
- <directory>/usr/share/osgi</directory>
- <username>root</username>
- <groupname>root</groupname>
- <filemode>644</filemode>
- <directoryIncluded>false</directoryIncluded>
- <sources>
- <source>
- <location>${project.build.directory}/${project.artifactId}-${project.version}-a2-source-tp</location>
- <includes>
- <include>**/*.jar</include>
- </includes>
- </source>
- </sources>
- </mapping>
- </mappings>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>legacy-dep</artifactId>
- <name>SLC Legacy Dependencies</name>
- <packaging>pom</packaging>
- <modules>
- <module>org.argeo.slc.dep.spring</module>
- <module>org.argeo.slc.dep.backend</module>
- </modules>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <SLC-ModularDistribution>default</SLC-ModularDistribution>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>properties-maven-plugin</artifactId>
- <configuration>
- <quiet>true</quiet>
- <files>
- <file>../../../cnf/${version.context}.bnd</file>
- </files>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.argeo.maven.plugins</groupId>
- <artifactId>argeo-osgi-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-descriptors</id>
- <goals>
- <goal>descriptors</goal>
- </goals>
- <phase>generate-resources</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <attach>false</attach>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.argeo.tp.equinox</groupId>
- <artifactId>org.eclipse.osgi</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>org.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>org.hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>check-osgi</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.argeo.maven.plugins</groupId>
- <artifactId>argeo-osgi-plugin</artifactId>
- <executions>
- <execution>
- <id>check-osgi</id>
- <phase>test</phase>
- <goals>
- <goal>equinox</goal>
- </goals>
- <configuration>
- <onlyCheck>true</onlyCheck>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.osgi.boot</artifactId>
- <version>${version.argeo-commons}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>lib</artifactId>
- <packaging>pom</packaging>
- <name>SLC Standard Libs</name>
- <description>SLC execution modules for generic tasks, to be used as parent pom</description>
- <properties>
- <additionalImports.slc-lib>
- com.jcraft.jsch;resolution:=optional,
- org.apache.commons.exec;resolution:=optional,
- </additionalImports.slc-lib>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <SLC-ExecutionModule>default</SLC-ExecutionModule>
- <!-- Minimal imports + some optional convenience imports -->
- <Import-Package>
- org.argeo.security.jackrabbit;resolution:="optional",
- org.springframework.cglib.proxy;resolution:="optional",
- org.springframework.cglib.core;resolution:="optional",
- org.springframework.cglib.reflect;resolution:="optional",
- org.aopalliance.aop;resolution:="optional",
- org.argeo.slc.runtime,
- org.argeo.slc.core.execution;resolution:="optional",
- org.argeo.slc.core.execution.tasks;resolution:="optional",
- org.argeo.slc.execution,
- org.argeo.slc.osgi;resolution:="optional",
- org.argeo.slc.test,
- org.springframework.aop;resolution:="optional",
- org.springframework.aop.framework;resolution:="optional",
- org.springframework.aop.scope;resolution:="optional",
- org.springframework.beans.factory.config;resolution:="optional",
- org.springframework.core.io;resolution:="optional",
- ${additionalImports.slc-lib},
- *
- </Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.dep.minimal</artifactId>
- <version>2.1-SNAPSHOT</version>
- <type>pom</type>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>>>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+++ /dev/null
-/bin/
-/target/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.legacy.fake.java8</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-Export-Package: javax.*;version=0.0.0,\
-org.omg.*;version=0.0.0
+++ /dev/null
-bin.includes = META-INF/
-jars.compile.order = .
-source.. = src/
-output.. = target/classes/
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.legacy.fake.java8</artifactId>
- <name>Legacy Fake Java 8 APIs</name>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-RequiredExecutionEnvironment>JavaSE-11</Bundle-RequiredExecutionEnvironment>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
\ No newline at end of file
+++ /dev/null
-package javax.rmi;
-
-public class Fake {
-
-}
+++ /dev/null
-package javax.xml.ws;
-
-public class Fake {
-
-}
+++ /dev/null
-package org.omg.CORBA;
-
-public class Fake {
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.agent.jcr</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:util="http://www.springframework.org/schema/util"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/util\r
- http://www.springframework.org/schema/util/spring-util-2.5.xsd">\r
-\r
- <!-- REFERENCES -->\r
- <reference id="repository" interface="javax.jcr.Repository"\r
- filter="(cn=slc)" />\r
-\r
-<!-- <reference id="authenticationManager" -->\r
-<!-- interface="org.springframework.security.authentication.AuthenticationManager" /> -->\r
-\r
- <reference id="modulesManager"\r
- interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
-\r
- <!-- SERVICES -->\r
-<!-- <service ref="attachmentUploader" interface="org.argeo.slc.core.attachment.AttachmentUploader" /> -->\r
-\r
- <service interface="org.argeo.slc.execution.ExecutionModulesListener"\r
- ref="executionModulesListener" />\r
-\r
- <service ref="agent" interface="org.argeo.slc.execution.SlcAgent" />\r
- <service ref="agentCli" interface="org.argeo.slc.execution.SlcAgentCli" />\r
-\r
- <service ref="fileSystemManager" interface="org.apache.commons.vfs2.FileSystemManager" />\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <bean id="agent" class="org.argeo.slc.jcr.execution.JcrAgent"\r
- init-method="init" destroy-method="destroy">\r
- <property name="defaultModulePrefix" value="org.argeo.slc.lib" />\r
- <property name="repository" ref="repository" />\r
- <property name="modulesManager" ref="modulesManager" />\r
- </bean>\r
-\r
- <bean id="agentCli" class="org.argeo.slc.core.execution.DefaultAgentCli">\r
- <property name="agent" ref="agent" />\r
-<!-- <property name="authenticationManager" ref="authenticationManager" /> -->\r
- </bean>\r
-\r
- <bean id="executionModulesListener" class="org.argeo.slc.jcr.execution.JcrExecutionModulesListener"\r
- init-method="init" destroy-method="destroy">\r
- <property name="agent" ref="agent" />\r
- <property name="repository" ref="repository" />\r
- <property name="modulesManager" ref="modulesManager" />\r
- </bean>\r
-\r
- <!-- Thread-bound session is used when multiple threads with various authentication \r
- will call the component -->\r
-<!-- <bean id="session" class="org.argeo.security.jcr.SecureThreadBoundSession"> -->\r
-<!-- <property name="repository" ref="repository" /> -->\r
-<!-- </bean> -->\r
-\r
-<!-- <bean id="attachmentUploader" class="org.argeo.slc.jcr.execution.JcrAttachmentUploader"> -->\r
-<!-- </bean> -->\r
-\r
-\r
- <bean\r
- class="org.argeo.slc.spring.AuthenticatedApplicationContextInitialization">\r
- </bean>\r
-\r
-\r
- <bean name="fileSystemManager" class="org.apache.commons.vfs2.impl.StandardFileSystemManager"\r
- init-method="init" destroy-method="close" />\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-Import-Package: org.argeo.slc.jcr,\
-org.argeo.security.jackrabbit,\
-org.apache.commons.vfs2.provider.bzip2,\
-org.apache.commons.vfs2.provider.compressed,\
-org.apache.commons.vfs2.provider.ftp,\
-org.apache.commons.vfs2.provider.ftps,\
-org.apache.commons.vfs2.provider.gzip,\
-org.apache.commons.vfs2.provider.http,\
-org.apache.commons.vfs2.provider.https,\
-org.apache.commons.vfs2.provider.jar,\
-org.apache.commons.vfs2.provider.local,\
-org.apache.commons.vfs2.provider.ram,\
-org.apache.commons.vfs2.provider.res,\
-org.apache.commons.vfs2.provider.sftp,\
-org.apache.commons.vfs2.provider.tar,\
-org.apache.commons.vfs2.provider.url,\
-org.apache.commons.vfs2.provider.temp,\
-org.apache.commons.vfs2.provider.webdav,\
-org.apache.commons.vfs2.provider.zip,\
-org.osgi.*;version=0.0.0,\
-*
+++ /dev/null
-bin.includes = META-INF/,\
- .
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.agent.jcr</artifactId>
- <name>SLC Agent JCR</name>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.agent</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <bean\r
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">\r
- <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />\r
- <property name="locations">\r
- <value>osgibundle:agent.properties</value>\r
- </property>\r
- </bean>\r
-\r
- <!-- Manager -->\r
- <bean id="modulesManager" class="org.argeo.slc.osgi.OsgiExecutionModulesManager"\r
- init-method="init" destroy-method="destroy">\r
- <property name="bundlesManager" ref="bundlesManager" />\r
- </bean>\r
-\r
- <bean id="bundlesManager" class="org.argeo.slc.osgi.BundlesManager">\r
- <property name="defaultTimeout" value="${slc.agent.osgi.defaultTimeout}" />\r
- </bean>\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:util="http://www.springframework.org/schema/util"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <!-- REFERENCES -->\r
- <!-- No <set> so that the equals methods are not called -->\r
- <list id="executionContexts" interface="org.argeo.slc.execution.ExecutionContext"\r
- cardinality="0..N">\r
- <listener ref="modulesManager" bind-method="register"\r
- unbind-method="unregister" />\r
- </list>\r
-\r
- <list id="executionFlows" interface="org.argeo.slc.execution.ExecutionFlow"\r
- cardinality="0..N">\r
- <listener ref="modulesManager" bind-method="register"\r
- unbind-method="unregister" />\r
- </list>\r
-\r
- <list id="executionModulesListeners" interface="org.argeo.slc.execution.ExecutionModulesListener"\r
- cardinality="0..N">\r
- <listener ref="modulesManager" bind-method="register"\r
- unbind-method="unregister" />\r
- </list>\r
-\r
- <list id="executionFlowDescriptorConverters"\r
- interface="org.argeo.slc.execution.ExecutionFlowDescriptorConverter"\r
- cardinality="0..N">\r
- <listener ref="modulesManager" />\r
- </list>\r
- <reference id="userTransaction" interface="javax.transaction.UserTransaction" />\r
- <reference id="userAdmin" interface="org.osgi.service.useradmin.UserAdmin" />\r
-\r
- <!-- SERVICES -->\r
- <service ref="modulesManager" interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
-\r
- <!-- LABEL -->\r
-<!-- <beans:bean class="org.argeo.cms.spring.osgi.OsgiModuleLabel"> -->\r
-<!-- <beans:property name="bundleContext" ref="bundleContext" /> -->\r
-<!-- </beans:bean> -->\r
-\r
- <!-- ROLES -->\r
-<!-- <reference id="userAdminService" interface="org.argeo.security.UserAdminService" /> -->\r
-\r
- <beans:bean class="org.argeo.maintenance.SimpleRoleRegistration"\r
- init-method="run">\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
- </beans:bean>\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-slc.agent.osgi.defaultTimeout=60000
+++ /dev/null
-Import-Package: org.osgi.*;version=0.0.0,\
-*
\ No newline at end of file
+++ /dev/null
-bin.includes = META-INF/,\
- .
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.agent</artifactId>
- <name>SLC Agent</name>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<projectDescription>\r
- <name>org.argeo.slc.client.rap</name>\r
- <comment></comment>\r
- <projects>\r
- </projects>\r
- <buildSpec>\r
- <buildCommand>\r
- <name>org.eclipse.jdt.core.javabuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- <buildCommand>\r
- <name>org.eclipse.pde.ManifestBuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- <buildCommand>\r
- <name>org.eclipse.pde.SchemaBuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- </buildSpec>\r
- <natures>\r
- <nature>org.eclipse.pde.PluginNature</nature>\r
- <nature>org.eclipse.jdt.core.javanature</nature>\r
- </natures>\r
-</projectDescription>\r
+++ /dev/null
-#Thu Apr 14 17:49:18 CEST 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <!-- RAP Specific open JCR file service -->
- <!-- <bean id="openJcrFileService" class="org.argeo.slc.client.rap.OpenJcrFileService" -->
- <!-- scope="prototype" init-method="init" destroy-method="destroy"> -->
- <!-- <property name="repoService" ref="repoService" /> -->
- <!-- <property name="repositoryFactory" ref="repositoryFactory" /> -->
- <!-- <property name="keyring" ref="keyring" /> -->
- <!-- <property name="nodeRepository" ref="nodeRepository" /> -->
- <!-- </bean> -->
-
- <bean id="org.argeo.slc.client.rap.openJcrFile" class="org.argeo.slc.client.ui.specific.OpenJcrFile"
- scope="prototype">
- <property name="repoService" ref="repoService" />
- </bean>
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
- xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
- <bean id="repoService" class="org.argeo.slc.repo.core.RepoServiceImpl">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
-</beans>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans\r
- xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:osgi="http://www.springframework.org/schema/osgi"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- osgi:default-timeout="30000">\r
-\r
- <beans:description>SLC UI RAP</beans:description>\r
-\r
- <reference id="nodeRepository"\r
- interface="javax.jcr.Repository" />\r
- <reference id="repositoryFactory"\r
- interface="javax.jcr.RepositoryFactory" />\r
- <reference id="keyring"\r
- interface="org.argeo.api.security.CryptoKeyring" />\r
-</beans:beans>\r
+++ /dev/null
-Bundle-SymbolicName: org.argeo.slc.client.rap;singleton=true
-Bundle-ActivationPolicy: lazy
-Bundle-Activator: org.argeo.slc.client.rap.SlcRapPlugin
-Require-Bundle: org.eclipse.ui;resolution:=optional,\
-org.eclipse.core.runtime,\
-org.eclipse.rap.ui;resolution:=optional,\
-org.eclipse.rap.ui.workbench;resolution:=optional
-
-Import-Package: javax.jcr.nodetype,\
-javax.servlet,\
-javax.servlet.http,\
-org.argeo.eclipse.spring,\
-org.argeo.slc.repo.core,\
-org.argeo.cms.ui.util,\
-*
-
\ No newline at end of file
+++ /dev/null
-source.. = src/main/java/\r
-output.. = target/classes/\r
-bin.includes = plugin.xml,\\r
- META-INF/,\\r
- .\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<?eclipse version="3.6"?>\r
-<plugin>\r
- <extension\r
- point="org.eclipse.rap.ui.entrypoint">\r
- <entrypoint\r
- id="org.argeo.slc.client.rap.slcSecureRap"\r
- class="org.argeo.slc.client.rap.SlcSecureRap"\r
- path="/slc">\r
- </entrypoint>\r
- </extension>\r
- \r
- <!-- COMMANDS --> \r
- <extension\r
- point="org.eclipse.ui.commands">\r
- <command\r
- id="org.argeo.slc.client.rap.openJcrFile"\r
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"\r
- name="Open Workspace Editor">\r
- <commandParameter\r
- id="param.repoNodePath"\r
- name="Repo node path">\r
- </commandParameter>\r
- <commandParameter\r
- id="param.repoUri"\r
- name="Repo URI">\r
- </commandParameter>\r
- <commandParameter\r
- id="param.workspaceName"\r
- name="Workspace name">\r
- </commandParameter>\r
- <commandParameter\r
- id="param.filePath"\r
- name="File Path">\r
- </commandParameter>\r
- </command>\r
- </extension>\r
-</plugin>\r
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.client.rap</artifactId>
- <name>SLC Client RAP</name>
- <packaging>jar</packaging>
- <dependencies>
- <!-- SLC -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.repo</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- Argeo common distribution for Secured UI -->
- <dependency>
- <groupId>org.argeo.slc.legacy.commons</groupId>
- <artifactId>org.argeo.cms.ui.workbench.rap</artifactId>
- <version>${version.argeo-commons-legacy}</version>
- </dependency>
-
- <!-- RAP workbench -->
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp-rap-e3</artifactId>
- <version>${version.argeo-tp}</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-</project>
+++ /dev/null
-package org.argeo.slc.client.rap;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-//import org.eclipse.rap.rwt.service.IServiceHandler;
-
-/**
- * Basic Default service handler that retrieves a file from a NT_FILE JCR node
- * and launch the download.
- */
-public class OpenJcrFileService {//implements IServiceHandler {
-
- /* DEPENDENCY INJECTION */
- final private Node fileNode;
-
- public OpenJcrFileService(Node fileNode) {
- this.fileNode = fileNode;
- }
-
- public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
- // Get the file content
- byte[] download = getFileAsByteArray();
-
- // Send the file in the response
- //HttpServletResponse response = RWT.getResponse();
- response.setContentType("application/octet-stream");
- response.setContentLength(download.length);
- String contentDisposition = null;
- try {
- contentDisposition = "attachment; filename=\""
- + JcrUtils.lastPathElement(fileNode.getPath()) + "\"";
- } catch (RepositoryException e) {
- throw new SlcException("Error while getting file Path " + fileNode,
- e);
- }
- response.setHeader("Content-Disposition", contentDisposition);
-
- try {
- response.getOutputStream().write(download);
- } catch (IOException ioe) {
- throw new SlcException("Error while writing the file " + fileNode
- + " to the servlet response", ioe);
- }
- }
-
- protected byte[] getFileAsByteArray() {
-
- Session businessSession = null;
- try {
- boolean isValid = true;
- Node child = null;
- if (!fileNode.isNodeType(NodeType.NT_FILE))
- isValid = false;
- else {
- child = fileNode.getNode(Property.JCR_CONTENT);
- if (!(child.isNodeType(NodeType.NT_RESOURCE) || child
- .hasProperty(Property.JCR_DATA)))
- isValid = false;
- }
-
- if (!isValid)
- return null;
-
- byte[] ba = null;
- InputStream fis = null;
- try {
- fis = (InputStream) child.getProperty(Property.JCR_DATA)
- .getBinary().getStream();
- ba = IOUtils.toByteArray(fis);
- } catch (Exception e) {
- throw new SlcException("Stream error while opening file "
- + fileNode, e);
- } finally {
- IOUtils.closeQuietly(fis);
- }
- return ba;
-
- } catch (RepositoryException e) {
- throw new SlcException("Unexpected error while "
- + "opening file node " + fileNode, e);
- } finally {
- JcrUtils.logoutQuietly(businessSession);
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.rap;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- *
- * Enable life-cycle management of RAP specific services
- */
-public class SlcRapPlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.argeo.slc.client.rap"; //$NON-NLS-1$
-
- // The shared instance
- private static SlcRapPlugin plugin;
-
- /**
- * The constructor
- */
- public SlcRapPlugin() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
- * )
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
- * )
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static SlcRapPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns an image descriptor for the image file at the given plug-in
- * relative path
- *
- * @param path
- * the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.rap;
-
-import org.argeo.cms.ui.workbench.rap.RapWindowAdvisor;
-import org.argeo.cms.ui.workbench.rap.RapWorkbenchAdvisor;
-import org.argeo.cms.ui.workbench.rap.RapWorkbenchLogin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.application.WorkbenchWindowAdvisor;
-
-/**
- * This class controls all aspects of the application's execution and is
- * contributed through the plugin.xml.
- */
-public class SlcSecureRap extends RapWorkbenchLogin {
-
- @Override
- protected RapWorkbenchAdvisor createRapWorkbenchAdvisor(
- final String username) {
- return new RapWorkbenchAdvisor(username) {
- @Override
- public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
- IWorkbenchWindowConfigurer configurer) {
- return new SlcRapWorkbenchWindowAdvisor(configurer, username);
- }
-
- };
- }
-
- /** Workaround for resize issue */
- class SlcRapWorkbenchWindowAdvisor extends RapWindowAdvisor {
-
- public SlcRapWorkbenchWindowAdvisor(
- IWorkbenchWindowConfigurer configurer, String username) {
- super(configurer, username);
- }
-
- public void preWindowOpen() {
- IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
- configurer.setShowCoolBar(true);
- configurer.setShowMenuBar(false);
- configurer.setShowStatusLine(false);
- configurer.setShowPerspectiveBar(true);
- configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
- // Full screen, see
- // http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02697.html
- configurer.setShellStyle(SWT.NO_TRIM);
- Rectangle bounds = Display.getCurrent().getBounds();
- configurer.setInitialSize(new Point(bounds.width, bounds.height));
- }
-
- @Override
- public void postWindowCreate() {
- Shell shell = getWindowConfigurer().getWindow().getShell();
- shell.setMaximized(true);
- }
-
- @Override
- public void postWindowOpen() {
- String defaultPerspective = getWindowConfigurer()
- .getWorkbenchConfigurer().getWorkbench()
- .getPerspectiveRegistry().getDefaultPerspective();
- if (defaultPerspective == null) {
- IWorkbenchWindow window = getWindowConfigurer().getWindow();
- if (window == null)
- return;
-
- IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
- .create(window);
- openPerspectiveDialogAction.run();
- }
- }
-
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.specific;
-
-import java.net.URL;
-import java.util.UUID;
-
-import javax.jcr.Node;
-import javax.jcr.Session;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.rap.OpenJcrFileService;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.rap.rwt.RWT;
-//import org.eclipse.rap.rwt.service.IServiceHandler;
-//import org.eclipse.rap.rwt.service.IServiceManager;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Rap specific command handler to open a file retrieved from a distant JCR
- * Repository. It creates and register a service instantiated with the
- * corresponding JCR node, forwards the request, and un register the service on
- * dispose
- *
- * This command and the corresponding service are specific for RAP version [1.3,
- * 2)
- */
-public class OpenJcrFile extends AbstractHandler {
-
- // Use (new OpenJcrFileCmdId()).getCmdId() instead.
- // public final String ID = SlcRapPlugin.PLUGIN_ID + ".openJcrFile";
-
- public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
- public final static String PARAM_REPO_URI = "param.repoUri";
- public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
- public final static String PARAM_FILE_PATH = "param.filePath";
-
- private RepoService repoService;
- private String currentServiceId;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
- String repoUri = event.getParameter(PARAM_REPO_URI);
- String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
- String filePath = event.getParameter(PARAM_FILE_PATH);
-
- // TODO sanity check
- if (filePath == null || "".equals(filePath.trim()))
- return null;
- Session businessSession = null;
- try {
- businessSession = repoService.getRemoteSession(repoNodePath,
- repoUri, wkspName);
- Node result = businessSession.getNode(filePath);
-
- // Create a temporary service. No better solution has been found
- // yet.
- currentServiceId = UUID.randomUUID().toString();
- OpenJcrFileService ojfs = new OpenJcrFileService(result);
- // FIXME replace it
-// IServiceManager manager = RWT.getServiceManager();
-// manager.registerServiceHandler(currentServiceId, ojfs);
- String urlStr = createFullDownloadUrl(currentServiceId);
- URL url = new URL(urlStr);
- PlatformUI.getWorkbench().getBrowserSupport()
- .createBrowser("DownloadDialog").openURL(url);
- } catch (Exception e) {
- throw new SlcException("Unable to open Jcr File for path "
- + filePath, e);
- }
-
- return null;
- }
-
- @Override
- public void dispose() {
-// IServiceManager manager = RWT.getServiceManager();
-// manager.unregisterServiceHandler(currentServiceId);
- super.dispose();
- }
-
- private String createFullDownloadUrl(String serviceId) {
- StringBuilder url = new StringBuilder();
- url.append(RWT.getRequest().getRequestURL());
-
- StringBuilder params = new StringBuilder();
- params.append("?");
- // FIXME commented out so that it builds
- //params.append(IServiceHandler.REQUEST_PARAM).append("=");
- params.append(serviceId);
- String encodedURL = RWT.getResponse().encodeURL(params.toString());
- url.append(encodedURL);
- return url.toString();
- }
-
- /* Dependency Injection */
- public void setRepoService(RepoService repoService) {
- this.repoService = repoService;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.specific;
-
-import org.argeo.slc.client.rap.SlcRapPlugin;
-
-/**
- * Workaround a single sourcing problem:
- *
- * final static variable are imported at compilation time (we build against RCP)
- * and we still must have a different ID (the prefix must be the PLUGIN ID) for
- * RAP and RCP in order to be able to inject beans in the corresponding commands
- */
-public class OpenJcrFileCmdId {
-
- public String getCmdId() {
- return SlcRapPlugin.PLUGIN_ID + ".openJcrFile";
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.client.ui.dist</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Wed Dec 08 08:27:02 CET 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+++ /dev/null
-#Wed Dec 08 08:27:02 CET 2010
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <!-- DISTRIBUTIONS MANAGEMENT -->
- <bean id="normalizeDistribution"
- class="org.argeo.slc.client.ui.dist.commands.NormalizeDistribution">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="openModuleEditor" class="org.argeo.slc.client.ui.dist.commands.OpenModuleEditor"
- scope="prototype">
- <property name="repoService" ref="repoService" />
- </bean>
-
- <!-- REPOSITORY MANAGEMENT -->
- <bean id="registerRepository"
- class="org.argeo.slc.client.ui.dist.commands.RegisterRepository">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="unregisterRemoteRepo"
- class="org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo"
- scope="prototype">
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="displayRepoInformation"
- class="org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation"
- scope="prototype">
- <property name="repoService" ref="repoService" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
-
- <!-- WORKSPACE MANAGEMENT -->
- <bean id="openWorkspaceEditor"
- class="org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor"
- scope="prototype">
- <property name="localRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="fetch" class="org.argeo.slc.client.ui.dist.commands.Fetch"
- scope="prototype">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="manageWorkspaceAuth"
- class="org.argeo.slc.client.ui.dist.commands.ManageWorkspaceAuth"
- scope="prototype">
- <property name="repository" ref="javaRepository" />
- </bean>
-
- <bean id="publishWorkspace" class="org.argeo.slc.client.ui.dist.commands.PublishWorkspace">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="normalizeWorkspace"
- class="org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="openGenerateBinariesWizard"
- class="org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard">
- <property name="repoService" ref="repoService" />
- </bean>
-
- <!-- WORKSPACE CRUD -->
- <bean id="createWorkspace" class="org.argeo.slc.client.ui.dist.commands.CreateWorkspace">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="copyWorkspace" class="org.argeo.slc.client.ui.dist.commands.CopyWorkspace">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="copyLocalJavaWorkspace"
- class="org.argeo.slc.client.ui.dist.commands.CopyLocalJavaWorkspace">
- <property name="javaRepoManager">
- <bean factory-bean="slcRepoManager" factory-method="getJavaRepoManager" />
- </property>
- <property name="javaRepository" ref="javaRepository" />
- </bean>
-
- <bean id="createLocalJavaWorkspace"
- class="org.argeo.slc.client.ui.dist.commands.CreateLocalJavaWorkspace">
- <property name="javaRepoManager">
- <bean factory-bean="slcRepoManager" factory-method="getJavaRepoManager" />
- </property>
- </bean>
-
- <bean id="mergeWorkspaces" class="org.argeo.slc.client.ui.dist.commands.MergeWorkspaces">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="deleteWorkspace" class="org.argeo.slc.client.ui.dist.commands.DeleteWorkspace">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <!-- ADVANCED -->
- <bean id="runInOsgi" class="org.argeo.slc.client.ui.dist.commands.RunInOsgi"
- scope="prototype">
- <property name="repository" ref="javaRepository" />
- </bean>
-
- <!-- LEGACY -->
- <!-- <bean id="org.argeo.slc.client.ui.dist.openGenericJcrQueryEditor" class="org.argeo.eclipse.ui.jcr.commands.OpenGenericJcrQueryEditor"
- scope="prototype"> <property name="editorId" value="org.argeo.slc.client.ui.dist.genericJcrQueryEditor"
- /> </bean> -->
- <bean id="refreshDistributionsView"
- class="org.argeo.slc.client.ui.dist.commands.RefreshDistributionsView"
- scope="prototype">
- </bean>
-
- <bean id="org.argeo.slc.client.ui.dist.deleteArtifacts" class="org.argeo.slc.client.ui.dist.commands.DeleteArtifacts"
- scope="prototype">
- </bean>
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
- xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
- <bean id="distWorkspaceEditor"
- class="org.argeo.slc.client.ui.dist.editors.DistWorkspaceEditor"
- scope="prototype">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="localRepository" ref="nodeRepository" />
- </bean>
-
- <bean id="artifactVersionEditor"
- class="org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor"
- scope="prototype">
- <property name="repoService" ref="repoService" />
- </bean>
-
- <bean id="modularDistVersionEditor"
- class="org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor"
- scope="prototype">
- <property name="repoService" ref="repoService" />
- </bean>
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
- xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
- <bean id="repoService" class="org.argeo.slc.repo.core.RepoServiceImpl">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-
- <!-- For the record <property name="session"> <bean factory-bean="repository"
- factory-method="login" /> </property> -->
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:osgi="http://www.springframework.org/schema/osgi"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- osgi:default-timeout="30000">\r
-\r
- <reference id="javaRepository" interface="javax.jcr.Repository"\r
- filter="(cn=java)" />\r
-\r
- <reference id="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
- <reference id="keyring" interface="org.argeo.api.security.CryptoKeyring" />\r
-\r
- <reference id="nodeRepository" interface="javax.jcr.Repository"\r
- filter="(cn=ego)" />\r
-\r
- <reference id="slcRepoManager" interface="org.argeo.slc.repo.SlcRepoManager" />\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
- <!-- Views -->
-<!-- <bean id="artifactsBrowser" class="org.argeo.slc.client.ui.dist.views.ArtifactsBrowser" -->
-<!-- scope="prototype"> -->
-<!-- <property name="jcrSession" ref="slcSession" /> -->
-<!-- </bean> -->
-<!-- <bean id="queryArtifactsForm" class="org.argeo.slc.client.ui.dist.views.QueryArtifactsForm" -->
-<!-- scope="prototype"> -->
-<!-- <property name="session" ref="slcSession" /> -->
-<!-- <property name="columnProperties"> -->
-<!-- <list> -->
-<!-- <value>slc:artifactVersion.jcr:uuid</value> -->
-<!-- <value>slc:artifactVersion.slc:groupId</value> -->
-<!-- <value>slc:artifactVersion.slc:artifactId</value> -->
-<!-- <value>slc:artifactVersion.slc:artifactVersion</value> -->
-<!-- </list> -->
-<!-- </property> -->
-<!-- </bean> -->
-<!-- <bean id="queryBundlesForm" class="org.argeo.slc.client.ui.dist.views.QueryBundlesForm" -->
-<!-- scope="prototype"> -->
-<!-- <property name="session" ref="slcSession" /> -->
-<!-- <property name="columnProperties"> -->
-<!-- <list> -->
-<!-- <value>slc:artifactVersion.jcr:uuid</value> -->
-<!-- <value>slc:bundleArtifact.slc:symbolic-name</value> -->
-<!-- <value>slc:artifactVersion.slc:groupId</value> -->
-<!-- <value>slc:bundleArtifact.slc:bundle-version</value> -->
-<!-- <value>slc:bundleArtifact.slc:Fragment-Host</value> -->
-<!-- </list> -->
-<!-- </property> -->
-<!-- </bean> -->
-
-<!-- <bean id="queryArtifactsText" class="org.argeo.slc.client.ui.dist.views.QueryArtifactsText" -->
-<!-- scope="prototype"> -->
-<!-- <property name="session" ref="slcSession" /> -->
-<!-- </bean> -->
-
- <bean id="distributionsView" class="org.argeo.slc.client.ui.dist.views.DistributionsView"
- scope="prototype">
- <!-- <property name="repositoryFactory" ref="repositoryFactory" /> -->
- <!-- <property name="keyring" ref="keyring" /> -->
- <property name="nodeRepository" ref="nodeRepository" />
- <property name="treeContentProvider" ref="distTreeContentProvider" />
- </bean>
-
- <!-- Corresponding content provider -->
- <bean id="distTreeContentProvider"
- class="org.argeo.slc.client.ui.dist.controllers.DistTreeContentProvider"
- scope="prototype">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- </bean>
-
- <!-- ANONYMOUS DISTRIBUTION VIEW -->
- <bean id="anonymousDistributionsView"
- class="org.argeo.slc.client.ui.dist.views.AnonymousDistributionsView"
- scope="prototype">
- <property name="treeContentProvider" ref="anonymousDistTreeContentProvider" />
- </bean>
-
- <!-- Corresponding content provider -->
- <bean id="anonymousDistTreeContentProvider"
- class="org.argeo.slc.client.ui.dist.controllers.AnonymousDistTreeContentProvider"
- scope="prototype">
- <property name="repositoryFactory" ref="repositoryFactory" />
- </bean>
-
- <!-- <bean id="distributionPerspective" class="org.argeo.slc.client.ui.dist.DistributionPerspective"
- scope="prototype"> <property name="repositoryFactory" ref="repositoryFactory"
- /> <property name="nodeRepository" ref="nodeRepository" /> </bean> -->
-</beans>
\ No newline at end of file
+++ /dev/null
-Bundle-SymbolicName: org.argeo.slc.client.ui.dist;singleton=true
-Bundle-ActivationPolicy: lazy
-Require-Bundle: org.eclipse.ui;resolution:=optional,\
-org.eclipse.core.runtime,\
-org.eclipse.rap.ui;resolution:=optional,\
-org.eclipse.rap.ui.workbench;resolution:=optional
-
-Bundle-Activator: org.argeo.slc.client.ui.dist.DistPlugin
-Import-Package: org.argeo.eclipse.spring,\
-javax.jcr.nodetype,\
-javax.jcr.security,\
-aQute.lib.*;resolution:=optional,\
-org.osgi.*;version=0.0.0,\
-*
-
\ No newline at end of file
+++ /dev/null
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <!-- PERSPECTIVES -->
- <extension
- point="org.eclipse.ui.perspectives">
- <perspective
- name="SLC Factory"
- class="org.argeo.slc.client.ui.dist.DistributionPerspective"
- id="org.argeo.slc.client.ui.dist.distributionPerspective"
- icon="icons/distribution_perspective.gif">
- </perspective>
- <perspective
- name="SLC Distribution"
- class="org.argeo.slc.client.ui.dist.AnonymousDistributionPerspective"
- id="org.argeo.slc.client.ui.dist.anonymousDistributionPerspective"
- icon="icons/repo.gif">
- </perspective>
- </extension>
- <!-- VIEWS -->
- <extension
- point="org.eclipse.ui.views">
- <view
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.distributionsView"
- icon="icons/search.gif"
- name="Distributions">
- </view>
- <view
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.anonymousDistributionsView"
- icon="icons/search.gif"
- name="Public Repository">
- </view>
- <view
- class="org.argeo.slc.client.ui.dist.views.HelpView"
- id="org.argeo.slc.client.ui.dist.helpView"
- icon="icons/help.gif"
- name="About">
- </view>
- <!--
- <view
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.artifactsBrowser"
- icon="icons/packageBrowser.gif"
- name="Artifacts browser">
- </view>
- <view
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.queryArtifactsForm"
- icon="icons/searchForm.gif"
- name="Artifacts Form">
- </view>
- <view
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.queryBundlesForm"
- icon="icons/searchForm.gif"
- name="Bundles Form">
- </view>
- <view
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.queryArtifactsText"
- icon="icons/search.gif"
- name="Query builder">
- </view>
- -->
- <view
- name="Progress View"
- icon="icons/pview.gif"
- category="org.eclipse.ui"
- class="org.eclipse.ui.ExtensionFactory:progressView"
- id="org.eclipse.ui.views.ProgressView">
- </view>
- </extension>
- <!-- EDITORS -->
- <extension
- point="org.eclipse.ui.editors">
- <!-- <editor
- class="org.argeo.slc.client.ui.dist.editors.GenericBundleEditor"
- id="org.argeo.slc.client.ui.dist.genericBundleEditor"
- name="Bundle editor"
- icon="icons/artifactVersionBase.gif"
- default="false">
- </editor> -->
- <editor
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.artifactVersionEditor"
- name="Artifact Version Editor"
- icon="icons/artifactVersionBase.gif"
- default="false">
- </editor>
- <editor
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.modularDistVersionEditor"
- name="Modular Distribution Version Editor"
- icon="icons/modularDistributionVersion.gif"
- default="false">
- </editor>
- <editor
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- id="org.argeo.slc.client.ui.dist.distWorkspaceEditor"
- name="Distribution workspace editor"
- icon="icons/distribution_perspective.gif"
- default="false">
- </editor>
- </extension>
-
- <!-- COMMANDS -->
- <extension
- point="org.eclipse.ui.commands">
-
- <!-- Distribution Managemnt -->
- <command
- id="org.argeo.slc.client.ui.dist.normalizeDistribution"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Normalize Distribution">
- <commandParameter
- id="workspaceName"
- name="Workspace name">
- </commandParameter>
- <commandParameter
- id="targetRepoPath"
- name="Target repo node path">
- </commandParameter>
- </command>
-
- <command
- id="org.argeo.slc.client.ui.dist.openModuleEditor"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Open Workspace Editor">
- <commandParameter
- id="param.repoNodePath"
- name="Repo node path">
- </commandParameter>
- <commandParameter
- id="param.repoUri"
- name="Repo URI">
- </commandParameter>
- <commandParameter
- id="param.workspaceName"
- name="Workspace name">
- </commandParameter>
- <commandParameter
- id="param.modulePath"
- name="Module path name">
- </commandParameter>
- </command>
-
- <!-- Repository Management -->
- <command
- id="org.argeo.slc.client.ui.dist.registerRepository"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Add Repository">
- </command>
- <command
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- id="org.argeo.slc.client.ui.dist.unregisterRemoteRepo"
- name="Unregister remote repository">
- <commandParameter
- id="org.argeo.slc.client.ui.dist.repoNodePath"
- name="Remote Repo path">
- </commandParameter>
- </command>
- <command
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- id="org.argeo.slc.client.ui.dist.displayRepoInformation"
- name="Display repository information">
- </command>
-
- <!-- Workspace Management -->
- <command
- id="org.argeo.slc.client.ui.dist.openWorkspaceEditor"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Open Workspace Editor">
- <commandParameter
- id="param.repoNodePath"
- name="Repo node path">
- </commandParameter>
- <commandParameter
- id="param.repoUri"
- name="Repo URI">
- </commandParameter>
- <commandParameter
- id="param.workspaceName"
- name="Workspace name">
- </commandParameter>
- </command>
- <command
- id="org.argeo.slc.client.ui.dist.fetch"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Fetch repository">
- <commandParameter
- id="targetRepoPath"
- name="Target repo uri">
- </commandParameter>
- </command>
-
- <!-- <command
- defaultHandler="org.argeo.slc.client.ui.dist.commands.MarkAsRelevantCategory"
- id="org.argeo.slc.client.ui.dist.markAsRelevantCategory"
- name="Mark as relevant category">
- </command> -->
-
- <command
- id="org.argeo.slc.client.ui.dist.openGenerateBinariesWizard"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Generate Binaries...">
- <commandParameter
- id="param.repoNodePath"
- name="Repo node path">
- </commandParameter>
- <commandParameter
- id="param.workspaceName"
- name="Workspace name">
- </commandParameter>
- <commandParameter
- id="param.modulePath"
- name="Module path name">
- </commandParameter>
- </command>
-
- <command
- id="org.argeo.slc.client.ui.dist.normalizeWorkspace"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Normalize Workspace">
- <commandParameter
- id="workspaceName"
- name="Workspace name">
- </commandParameter>
- <commandParameter
- id="targetRepoPath"
- name="Target repo node path">
- </commandParameter>
- </command>
- <command
- id="org.argeo.slc.client.ui.dist.manageWorkspaceAuth"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Manage workspace authorizations">
- <commandParameter
- id="org.argeo.slc.client.ui.dist.workspaceName"
- name="Workspace Name">
- </commandParameter>
- </command>
-
- <command
- id="org.argeo.slc.client.ui.dist.publishWorkspace"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Publish selected workspace">
- <commandParameter
- id="workspaceName"
- name="Workspace name">
- </commandParameter>
- <commandParameter
- id="targetRepoPath"
- name="Target repo node path">
- </commandParameter>
- </command>
-
- <command
- id="org.argeo.slc.client.ui.dist.mergeWorkspaces"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Copy chosen Workspace">
- <commandParameter
- id="srcWkspName"
- name="Source Workspace Name">
- </commandParameter>
- <commandParameter
- id="srcRepoPath"
- name="Source Repo Node path ">
- </commandParameter>
- <commandParameter
- id="targetWkspName"
- name="Target Workspace Name">
- </commandParameter>
- <commandParameter
- id="targetRepoPath"
- name="Target repo node path">
- </commandParameter>
- </command>
-
- <!-- Workspaces CRUD -->
- <!-- Generic new and copy workspace -->
- <command
- id="org.argeo.slc.client.ui.dist.createWorkspace"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Create Workspace">
- <commandParameter
- id="workspacePrefix"
- name="Workspace prefix">
- </commandParameter>
- <commandParameter
- id="targetRepoPath"
- name="Target repo node path">
- </commandParameter>
- </command>
- <command
- id="org.argeo.slc.client.ui.dist.copyWorkspace"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Copy chosen Workspace">
- <commandParameter
- id="srcWkspName"
- name="Source Workspace Name">
- </commandParameter>
- <commandParameter
- id="targetRepoPath"
- name="Target repo node path">
- </commandParameter>
- </command>
- <!-- Specific for local java workspaces -->
- <command
- id="org.argeo.slc.client.ui.dist.createLocalJavaWorkspace"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Create Local Java Workspace">
- <commandParameter
- id="workspacePrefix"
- name="Workspace prefix">
- </commandParameter>
- </command>
- <command
- id="org.argeo.slc.client.ui.dist.copyLocalJavaWorkspace"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Copy chosen local Java Workspace">
- <commandParameter
- id="srcWkspName"
- name="Source Workspace Name">
- </commandParameter>
- </command>
-
- <!-- Not terminated delete command - does not really work -->
- <command
- id="org.argeo.slc.client.ui.dist.deleteWorkspace"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Delete chosen Workspace">
- <commandParameter
- id="workspaceName"
- name="Workspace name">
- </commandParameter>
- <commandParameter
- id="targetRepoPath"
- name="Target repo node path">
- </commandParameter>
- </command>
-
- <!-- Advanced commands -->
- <command
- id="org.argeo.slc.client.ui.dist.doNothing"
- defaultHandler="org.argeo.slc.client.ui.dist.commands.DoNothing"
- name="Advanced">
- </command>
- <command
- id="org.argeo.slc.client.ui.dist.runInOsgi"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Run in OSGi">
- <commandParameter
- id="workspaceName"
- name="Workspace Name">
- </commandParameter>
- <commandParameter
- id="modulePath"
- name="Module Path"
- optional="true">
- </commandParameter>
- </command>
- <command
- id="org.argeo.slc.client.ui.dist.refreshDistributionsView"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Refresh Distributions View">
- </command>
-
- <!-- Legacy -->
- <command
- defaultHandler="org.argeo.slc.client.ui.dist.commands.RefreshArtifactBrowser"
- id="org.argeo.slc.client.ui.dist.refreshArtifactBrowser"
- name="Refresh Artifact Browser">
- </command>
-
- <command
- defaultHandler="org.argeo.slc.client.ui.dist.commands.ShowSizeColumn"
- id="org.argeo.slc.client.ui.dist.showSizeColumn"
- name="Show size column">
- <state
- id="org.argeo.slc.client.ui.dist.showSizeColumn.toggleState">
- <class class="org.eclipse.jface.commands.ToggleState">
- <parameter
- name="default"
- value="true" />
- </class>
- </state>
- </command>
- <command
- id="org.argeo.slc.client.ui.dist.deleteArtifacts"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Remove selected artifacts">
- </command>
- </extension>
-
- <!-- MENU CONTRIBUTIONS -->
- <extension
- id="menu:org.eclipse.ui.main.menu"
- point="org.eclipse.ui.menus">
- <!-- Distributions view tool bar -->
- <menuContribution
- locationURI="toolbar:org.argeo.slc.client.ui.dist.distributionsView">
- <command
- commandId="org.argeo.slc.client.ui.dist.registerRepository"
- icon="icons/addRepo.gif"
- label="Register repository"
- tooltip="Register a remote repository">
- </command>
- <command
- commandId="org.argeo.slc.client.ui.dist.doNothing"
- id="org.argeo.slc.client.ui.dist.advancedMenu"
- icon="icons/more.gif"
- tooltip="Access to advanced commands"
- style="pulldown">
- </command>
- </menuContribution>
- <menuContribution locationURI="menu:org.argeo.slc.client.ui.dist.advancedMenu">
- <command
- commandId="org.argeo.slc.client.ui.dist.refreshDistributionsView"
- icon="icons/refresh.png"
- label="Refresh"
- tooltip="Force the full refresh of the distribution tree (close all open connections)">
- </command>
- <!-- <command
- commandId="org.argeo.slc.client.ui.dist.runInOSGi"
- icon="icons/showSize.gif"
- label="Run in OSGi"
- tooltip="Run in a spearate OSGi runtime">
- </command>
- -->
- </menuContribution>
- <!-- Anonymous distribution view toolbar -->
- <menuContribution
- locationURI="toolbar:org.argeo.slc.client.ui.dist.anonymousDistributionsView">
- <command
- commandId="org.argeo.slc.client.ui.dist.refreshDistributionsView"
- icon="icons/refresh.png"
- label="Refresh"
- tooltip="Force the full refresh of the distribution tree (close all open connections)">
- </command>
- </menuContribution>
- <!-- Artifact Browser Tool bar -->
- <menuContribution
- locationURI="toolbar:org.argeo.slc.client.ui.dist.artifactsBrowser">
- <command
- commandId="org.argeo.slc.client.ui.dist.showSizeColumn"
- icon="icons/showSize.gif"
- style="toggle"
- label="Show sizes"
- tooltip="Warning: showing size column might reduce overall browser reactivity">
- </command>
- <command
- commandId="org.argeo.slc.client.ui.dist.refreshArtifactBrowser"
- icon="icons/refresh.png"
- label="Refresh"
- tooltip="Refresh the whole browser">
- </command>
- </menuContribution>
- <!-- Queries -->
- <!-- <menuContribution
- allPopups="false"
- locationURI="menu:org.eclipse.ui.main.menu?after=edit">
- <menu label="Queries"
- mnemonic="Queries"
- id="org.argeo.slc.client.ui.dist.queryMenu">
- <command
- commandId="org.argeo.slc.client.ui.dist.openGenericJcrQueryEditor"
- disabledIcon="icons/saveDisabled.gif"
- icon="icons/results.gif"
- label="JCR Query"
- style="push"
- tooltip="Open JCR query editor">
- </command>
- </menu>
- </menuContribution> -->
- </extension>
- <extension
- point="org.eclipse.ui.activities">
- <!-- TODO: find a way to exclude evrything -->
- <activityPatternBinding
- activityId="org.argeo.slc.client.ui.slcActivity"
- isEqualityPattern="true"
- pattern="org.argeo.slc.client.ui.dist/org.argeo.slc.client.ui.dist.distributionPerspective">
- </activityPatternBinding>
- <activityPatternBinding
- activityId="org.argeo.security.ui.adminActivity"
- isEqualityPattern="true"
- pattern="org.argeo.slc.client.ui.dist/org.argeo.slc.client.ui.dist.distributionPerspective">
- </activityPatternBinding>
- </extension>
-</plugin>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.client.ui.dist</artifactId>
- <name>SLC Client UI Distribution</name>
- <packaging>jar</packaging>
- <dependencies>
- <!-- Commons UI -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.eclipse.ui</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc.legacy.commons</groupId>
- <artifactId>org.argeo.cms.ui.workbench</artifactId>
- <version>${version.argeo-commons-legacy}</version>
- </dependency>
-
-
- <!-- SLC repo -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.api</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.repo</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.spring</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.server.repo</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- Argeo Base dependencies -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.core</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <!-- RAP workbench -->
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp-rap-e3</artifactId>
- <version>${version.argeo-tp}</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist;
-
-import org.argeo.slc.client.ui.dist.views.AnonymousDistributionsView;
-import org.argeo.slc.client.ui.dist.views.HelpView;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Simple default perspective that presents public repositories */
-public class AnonymousDistributionPerspective implements IPerspectiveFactory {
-
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".anonymousDistributionPerspective";
-
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
- layout.setEditorAreaVisible(true);
- layout.setFixed(false);
-
- IFolderLayout main = layout.createFolder("main", IPageLayout.LEFT,
- 0.3f, editorArea);
- main.addView(AnonymousDistributionsView.ID);
- main.addView(HelpView.ID);
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist;
-
-import org.argeo.slc.SlcNames;
-import org.osgi.framework.Constants;
-
-/** Constants used across the application. */
-public interface DistConstants {
-
- /*
- * MISCEALLENEOUS
- */
- public final static String DATE_TIME_FORMAT = "MM/dd/yyyy, HH:mm";
- public final static String DATE_FORMAT = "MM/dd/yyyy";
- // this should be directly retrieved from JCR APIs once we have solved the
- // problem of the translation of name space to shortcut, typically
- // {http://www.jcp.org/jcr/1.0} to jcr:
- public final static String JCR_IDENTIFIER = "jcr:uuid";
- public final static String JCR_MIXIN_TYPES = "jcr:mixinTypes";
-
- // FIXME: should be defined in SlcNames
- public final static String SLC_BUNDLE_NAME = SlcNames.SLC_
- + Constants.BUNDLE_NAME;
- public final static String SLC_BUNDLE_LICENCE = SlcNames.SLC_
- + "Bundle-License";
- public final static String SLC_BUNDLE_VENDOR = SlcNames.SLC_
- + Constants.BUNDLE_VENDOR;
-
- public final static String SLC_BUNDLE_DESCRIPTION = SlcNames.SLC_
- + Constants.BUNDLE_DESCRIPTION;
-
- public final String DEFAULT_PUBLIC_REPOSITORY_URI = "vm:///java";
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist;
-
-import org.eclipse.swt.graphics.Image;
-
-/** Shared icons. */
-public class DistImages {
-
- public final static Image IMG_ARTIFACT_BASE = DistPlugin
- .getImageDescriptor("icons/artifactBase.gif").createImage();
- public final static Image IMG_PACKAGE = DistPlugin.getImageDescriptor(
- "icons/package.gif").createImage();
- public final static Image IMG_BUNDLE = DistPlugin.getImageDescriptor(
- "icons/packages.gif").createImage();
- public final static Image IMG_ARTIFACT_VERSION_BASE = DistPlugin
- .getImageDescriptor("icons/artifactVersionBase.gif").createImage();
- public final static Image IMG_FILE = DistPlugin.getImageDescriptor(
- "icons/file.gif").createImage();
-
- /* WORKSPACES */
- public final static Image IMG_WKSP = DistPlugin.getImageDescriptor(
- "icons/distribution_perspective.gif").createImage();
-
- /* REPOSITORIES */
- public final static Image IMG_REPO = DistPlugin.getImageDescriptor(
- "icons/repo.gif").createImage();
- public final static Image IMG_HOME_REPO = DistPlugin.getImageDescriptor(
- "icons/homeRepo.gif").createImage();
- public final static Image IMG_REPO_READONLY = DistPlugin
- .getImageDescriptor("icons/repoReadOnly.gif").createImage();
- public final static Image IMG_ADD_REPO = DistPlugin.getImageDescriptor(
- "icons/addRepo.gif").createImage();
- public final static Image IMG_REMOVE_REPO = DistPlugin.getImageDescriptor(
- "icons/artifactBase.gif").createImage();
- public final static Image IMG_FETCH_REPO = DistPlugin.getImageDescriptor(
- "icons/fetchRepo.png").createImage();
-
- /* DISTRIBUTIONS */
- public final static Image IMG_WKSP_GROUP = DistPlugin.getImageDescriptor(
- "icons/wkspGroup.gif").createImage();
- public final static Image IMG_DISTGRP = DistPlugin.getImageDescriptor(
- "icons/distGrp.gif").createImage();
- public final static Image IMG_DISTGRP_READONLY = DistPlugin
- .getImageDescriptor("icons/distGrpReadOnly.gif").createImage();
-
- public final static Image IMG_MODULAR_DIST_BASE = DistPlugin
- .getImageDescriptor("icons/packages.gif").createImage();
- public final static Image IMG_MODULAR_DIST_VERSION = DistPlugin
- .getImageDescriptor("icons/packages.gif").createImage();
-
- public final static Image IMG_GROUP_BASE = DistPlugin.getImageDescriptor(
- "icons/packages.gif").createImage();
-
- /* Various */
- public final static Image CHECKED = DistPlugin.getImageDescriptor(
- "icons/checked.gif").createImage();
- public final static Image UNCHECKED = DistPlugin.getImageDescriptor(
- "icons/unchecked.gif").createImage();
- public final static Image IMG_CLEAR = DistPlugin.getImageDescriptor(
- "icons/clear.gif").createImage();
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/** Default activator for the distribution bundle */
-public class DistPlugin extends AbstractUIPlugin {
- public final static String PLUGIN_ID = "org.argeo.slc.client.ui.dist";
-
- private static DistPlugin plugin;
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- public static DistPlugin getDefault() {
- return plugin;
- }
-
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist;
-
-import org.argeo.slc.client.ui.dist.views.DistributionsView;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Manage a set of software repositories */
-public class DistributionPerspective implements IPerspectiveFactory {
-
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".distributionPerspective";
-
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
- layout.setEditorAreaVisible(true);
- layout.setFixed(false);
-
- IFolderLayout main = layout.createFolder("main", IPageLayout.LEFT,
- 0.3f, editorArea);
- main.addView(DistributionsView.ID);
- IFolderLayout bottom = layout.createFolder("bottom",
- IPageLayout.BOTTOM, 0.75f, editorArea);
- bottom.addView("org.eclipse.ui.views.ProgressView");
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.jar.Manifest;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-import aQute.bnd.osgi.Builder;
-import aQute.bnd.osgi.Constants;
-import aQute.bnd.osgi.Jar;
-
-public class BndProcess extends AbstractHandler implements Constants {
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- try {
- Builder b = new Builder();
- b.setProperty(EXPORT_PACKAGE, "org.osgi.framework");
- b.setProperty(PRIVATE_PACKAGE, "*");
- b.addClasspath(new File(
- "/home/mbaudier/.m2/repository/org/eclipse/osgi/org.eclipse.osgi/3.6.1/org.eclipse.osgi-3.6.1.jar"));
-
- Jar jar = b.build();
- Manifest m = jar.getManifest();
- jar.write(new File(b.getBsn() + ".jar"));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return null;
- }
-
- public static void main(String[] args) {
- try {
- new BndProcess().execute(null);
- } catch (ExecutionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.JavaRepoManager;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Create a copy of the chosen workspace in the local Java repository using a
- * JavaRepoManager.
- */
-public class CopyLocalJavaWorkspace extends AbstractHandler {
- private static final Log log = LogFactory
- .getLog(CopyLocalJavaWorkspace.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".copyLocalJavaWorkspace";
- public final static String DEFAULT_LABEL = "Copy Java Workspace...";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/addItem.gif");
-
- public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
-
- // DEPENDENCY INJECTION
- private Repository javaRepository;
- private JavaRepoManager javaRepoManager;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String wkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
-
- InputDialog inputDialog = new InputDialog(HandlerUtil
- .getActiveWorkbenchWindow(event).getShell(),
- "New copy of workspace " + wkspName,
- "Choose a name for the workspace to create", "", null);
- int result = inputDialog.open();
- if (result == Window.OK) {
- String newWorkspaceName = inputDialog.getValue();
-
- if (newWorkspaceName == null || newWorkspaceName.trim().equals("")
- || newWorkspaceName.trim().equals(wkspName.trim())) {
- ErrorDialog
- .openError(HandlerUtil.getActiveShell(event),
- "Non valid workspace name", newWorkspaceName
- + " is not a valid workspace name.",
- new Status(IStatus.ERROR, "not valid", 0,
- "Error", null));
- return null;
- }
- Job copyWkspJob = new CopyWkspJob(javaRepoManager, javaRepository,
- wkspName, newWorkspaceName, HandlerUtil
- .getActiveWorkbenchWindow(event).getShell()
- .getDisplay());
- copyWkspJob.setUser(true);
- copyWkspJob.schedule();
- }
- return null;
- }
-
- private static class CopyWkspJob extends PrivilegedJob {
-
- private JavaRepoManager javaRepoManager;
- private Repository javaRepository;
- private String srcWkspName;
- private String targetWkspName;
- private Display display;
-
- public CopyWkspJob(JavaRepoManager javaRepoManager,
- Repository javaRepository, String srcWkspName,
- String targetWkspName, Display display) {
- super("Duplicate workspace");
- this.javaRepoManager = javaRepoManager;
- this.javaRepository = javaRepository;
- this.srcWkspName = srcWkspName;
- this.targetWkspName = targetWkspName;
- this.display = display;
- }
-
- @Override
- protected IStatus doRun(IProgressMonitor progressMonitor) {
- long begin = System.currentTimeMillis();
-
- JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
- monitor.beginTask("Copy workspace", -1);
- monitor.subTask("Copying nodes");
-
- Session srcSession = null;
- Session targetSession = null;
- try {
- // Initialize source
- srcSession = javaRepository.login(srcWkspName);
- Node srcRootNode = srcSession.getRootNode();
-
- // Create the workspace -
- // FIXME will throw an error if workspace already exists
- javaRepoManager.createWorkspace(targetWkspName);
- targetSession = javaRepository.login(targetWkspName);
- Node newRootNode = targetSession.getRootNode();
-
- RepoUtils.copy(srcRootNode, newRootNode, monitor);
- targetSession.save();
- JcrUtils.addPrivilege(targetSession, "/",
- SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
- monitor.worked(1);
-
- display.asyncExec(new Runnable() {
- public void run() {
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
- }
- });
-
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while creating the new workspace.",
- re);
- } finally {
- JcrUtils.logoutQuietly(srcSession);
- JcrUtils.logoutQuietly(targetSession);
- }
-
- monitor.done();
- long duration = (System.currentTimeMillis() - begin) / 1000;// in
- // s
- if (log.isDebugEnabled())
- log.debug("Duplicated local java workspace " + srcWkspName
- + " to workspace " + targetWkspName + " in "
- + (duration / 60) + "min " + (duration % 60) + "s");
- return Status.OK_STATUS;
- }
- }
-
- /* DEPENDENCY INJECTION */
- public void setJavaRepository(Repository javaRepository) {
- this.javaRepository = javaRepository;
- }
-
- public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
- this.javaRepoManager = javaRepoManager;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Create a copy of the chosen workspace in a remote repository */
-public class CopyWorkspace extends AbstractHandler {
- private static final Log log = LogFactory.getLog(CopyWorkspace.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".copyWorkspace";
- public final static String DEFAULT_LABEL = "Duplicate...";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/addItem.gif");
-
- public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
- public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
- // DEPENDENCY INJECTION
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Repository nodeRepository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
- String wkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
-
- InputDialog inputDialog = new InputDialog(HandlerUtil
- .getActiveWorkbenchWindow(event).getShell(),
- "New copy of workspace " + wkspName,
- "Choose a name for the workspace to create", "", null);
- int result = inputDialog.open();
- if (result == Window.OK) {
- String newWorkspaceName = inputDialog.getValue();
-
- if (newWorkspaceName == null || newWorkspaceName.trim().equals("")
- || newWorkspaceName.trim().equals(wkspName.trim())) {
- ErrorDialog
- .openError(HandlerUtil.getActiveShell(event),
- "Non valid workspace name", newWorkspaceName
- + " is not a valid workspace name.",
- new Status(IStatus.ERROR, "not valid", 0,
- "Error", null));
- return null;
- }
- Job copyWkspJob = new CopyWkspJob(repositoryFactory, keyring,
- nodeRepository, targetRepoPath, wkspName, newWorkspaceName,
- HandlerUtil.getActiveWorkbenchWindow(event).getShell()
- .getDisplay());
- copyWkspJob.setUser(true);
- copyWkspJob.schedule();
- }
- return null;
- }
-
- private static class CopyWkspJob extends PrivilegedJob {
-
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Repository localRepository;
- private String targetRepoPath;
- private String srcWkspName;
- private String targetWkspName;
- private Display display;
-
- public CopyWkspJob(RepositoryFactory repositoryFactory,
- Keyring keyring, Repository localRepository,
- String targetRepoPath, String srcWkspName,
- String targetWkspName, Display display) {
- super("Duplicate workspace");
- this.repositoryFactory = repositoryFactory;
- this.keyring = keyring;
- this.localRepository = localRepository;
- this.targetRepoPath = targetRepoPath;
- this.srcWkspName = srcWkspName;
- this.targetWkspName = targetWkspName;
- this.display = display;
- }
-
- @Override
- protected IStatus doRun(IProgressMonitor progressMonitor) {
- long begin = System.currentTimeMillis();
-
- JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
- monitor.beginTask("Copy workspace", -1);
- monitor.subTask("Copying nodes");
-
- Session nodeSession = null;
- Session srcSession = null;
- Session newSession = null;
- try {
- nodeSession = localRepository.login();
- Node repoNode = nodeSession.getNode(targetRepoPath);
- Repository repository = RepoUtils.getRepository(
- repositoryFactory, keyring, repoNode);
- Credentials credentials = RepoUtils.getRepositoryCredentials(
- keyring, repoNode);
-
- srcSession = repository.login(credentials, srcWkspName);
-
- // Create the workspace
- srcSession.getWorkspace().createWorkspace(targetWkspName);
- Node srcRootNode = srcSession.getRootNode();
- // log in the newly created workspace
- newSession = repository.login(credentials, targetWkspName);
- Node newRootNode = newSession.getRootNode();
- RepoUtils.copy(srcRootNode, newRootNode, monitor);
- newSession.save();
- JcrUtils.addPrivilege(newSession, "/", SlcConstants.ROLE_SLC,
- Privilege.JCR_ALL);
-
- display.asyncExec(new Runnable() {
- public void run() {
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
- }
- });
- monitor.worked(1);
-
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while creating the new workspace.",
- re);
- } finally {
- JcrUtils.logoutQuietly(newSession);
- JcrUtils.logoutQuietly(srcSession);
- JcrUtils.logoutQuietly(nodeSession);
- }
-
- monitor.done();
- long duration = (System.currentTimeMillis() - begin) / 1000;// in
- // s
- if (log.isDebugEnabled())
- log.debug("Created workspace " + targetWkspName + " in "
- + (duration / 60) + "min " + (duration % 60) + "s");
- return Status.OK_STATUS;
- }
-
- }
-
- /* DEPENDENCY INJECTION */
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.JavaRepoManager;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Create a new empty workspace in the default local java repository */
-public class CreateLocalJavaWorkspace extends AbstractHandler {
- private static final Log log = LogFactory
- .getLog(CreateLocalJavaWorkspace.class);
-
- // Exposes commands meta-info
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".createLocalJavaWorkspace";
- public final static String DEFAULT_LABEL = "Create local Java workspace...";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/addItem.gif");
-
- // Parameters
- public final static String PARAM_WORKSPACE_PREFIX = "workspacePrefix";
-
- /* DEPENDENCY INJECTION */
- private JavaRepoManager javaRepoManager;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- String prefix = event.getParameter(PARAM_WORKSPACE_PREFIX);
- // TODO : add an input validator
- InputDialog inputDialog = new InputDialog(HandlerUtil
- .getActiveWorkbenchWindow(event).getShell(), "Workspace name?",
- "Choose a name for the workspace to create",
- prefix == null ? "" : prefix + "-", null);
- int result = inputDialog.open();
-
- String enteredName = inputDialog.getValue();
- final String legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
- char[] arr = enteredName.toUpperCase().toCharArray();
- int count = 0;
- for (int i = 0; i < arr.length; i++) {
- if (legalChars.indexOf(arr[i]) == -1)
- count = count + 7;
- else
- count++;
- }
-
- if (count > 60) {
- ErrorFeedback.show("Workspace name '" + enteredName
- + "' is too long or contains"
- + " too many special characters such as '.' or '-'.");
- return null;
- }
-
- String workspaceName = enteredName;
- // Canceled by user
- if (result == Dialog.CANCEL || workspaceName == null
- || "".equals(workspaceName.trim()))
- return null;
-
- // FIXME will throw an exception if this workspace name is already used.
- javaRepoManager.createWorkspace(workspaceName);
-
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
- if (log.isTraceEnabled())
- log.trace("WORKSPACE " + workspaceName + " CREATED");
-
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setJavaRepoManager(JavaRepoManager javaRepoManager) {
- this.javaRepoManager = javaRepoManager;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Create a new empty workspace in a remote repository */
-public class CreateWorkspace extends AbstractHandler {
- private static final Log log = LogFactory.getLog(CreateWorkspace.class);
-
- // Exposes commands meta-info
- public final static String ID = DistPlugin.PLUGIN_ID + ".createWorkspace";
- public final static String DEFAULT_LABEL = "Create workspace...";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/addItem.gif");
-
- // Parameters
- public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
- public final static String PARAM_WORKSPACE_PREFIX = "workspacePrefix";
-
- // DEPENDENCY INJECTION
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Repository nodeRepository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
- String prefix = event.getParameter(PARAM_WORKSPACE_PREFIX);
-
- Session nodeSession = null;
- Session session = null;
- try {
- nodeSession = nodeRepository.login();
- Node repoNode = nodeSession.getNode(targetRepoPath);
- Repository repository = RepoUtils.getRepository(repositoryFactory,
- keyring, repoNode);
- Credentials credentials = RepoUtils.getRepositoryCredentials(
- keyring, repoNode);
-
- // TODO : add an input validator
- InputDialog inputDialog = new InputDialog(HandlerUtil
- .getActiveWorkbenchWindow(event).getShell(),
- "Workspace name?",
- "Choose a name for the workspace to create",
- prefix == null ? "" : prefix + "-", null);
- int result = inputDialog.open();
-
- String enteredName = inputDialog.getValue();
-
- final String legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
- char[] arr = enteredName.toUpperCase().toCharArray();
- int count = 0;
- for (int i = 0; i < arr.length; i++) {
- if (legalChars.indexOf(arr[i]) == -1)
- count = count + 7;
- else
- count++;
- }
-
- if (log.isTraceEnabled())
- log.trace("Translated workspace name length: " + count
- + " (name: " + enteredName + " )");
-
- if (count > 60) {
- ErrorFeedback.show("Workspace name '" + enteredName
- + "' is too long or contains"
- + " too many special characters such as '.' or '-'.");
- return null;
- }
-
- String workspaceName = enteredName;
-
- // Canceled by user
- if (result == Dialog.CANCEL || workspaceName == null
- || "".equals(workspaceName.trim()))
- return null;
-
- session = repository.login(credentials);
- session.getWorkspace().createWorkspace(workspaceName);
- JcrUtils.logoutQuietly(session);
- // init new workspace
- session = repository.login(credentials, workspaceName);
- JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
- Privilege.JCR_ALL);
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
- if (log.isTraceEnabled())
- log.trace("WORKSPACE " + workspaceName + " CREATED");
-
- } catch (RepositoryException re) {
- ErrorFeedback.show(
- "Unexpected error while creating the new workspace.", re);
- } finally {
- JcrUtils.logoutQuietly(session);
- JcrUtils.logoutQuietly(nodeSession);
- }
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import java.util.Iterator;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Delete chosen artifacts from the current workspace */
-public class DeleteArtifacts extends AbstractHandler {
- // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".deleteArtifacts";
- public final static String DEFAULT_LABEL = "Delete selected items";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/removeItem.gif");
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- try {
- IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
-
- if (activePart instanceof IEditorPart) {
- ISelection selector = ((IEditorPart) activePart)
- .getEditorSite().getSelectionProvider().getSelection();
- if (selector != null
- && selector instanceof IStructuredSelection) {
- Iterator<?> it = ((IStructuredSelection) selector)
- .iterator();
-
- String msg = "Your are about to definitively remove the "
- + ((IStructuredSelection) selector).size()
- + " selected artifacts.\n"
- + "Are you sure you want to proceed?";
-
- boolean result = MessageDialog.openConfirm(DistPlugin
- .getDefault().getWorkbench().getDisplay()
- .getActiveShell(), "Confirm Deletion", msg);
-
- if (result) {
- while (it.hasNext()) {
- Node node = (Node) it.next();
- if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
- // we remove the artifactVersion, that is the
- // parent
- node.getParent().remove();
- node.getSession().save();
- }
- }
- }
- }
- }
- // CommandHelpers.callCommand(RefreshDistributionOverviewPage.ID);
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while deleting artifacts.", re);
- }
- return null;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/**
- * Delete chosen workspace in the current repository.
- *
- * Due to current version of JackRabbit, it only cleans it for the time being,
- * removing all nodes of type {@code NodeType.NT_FOLDER} and
- * {@code NodeType.NT_UNSTRUCTURED}
- */
-public class DeleteWorkspace extends AbstractHandler {
- // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".deleteWorkspace";
- public final static String DEFAULT_LABEL = "Clear";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/removeItem.gif");
-
- public final static String PARAM_WORKSPACE_NAME = "workspaceName";
- public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
- // DEPENDENCY INJECTION
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Repository nodeRepository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
- String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
-
- Session nodeSession = null;
- Session session = null;
- try {
- nodeSession = nodeRepository.login();
- Node repoNode = nodeSession.getNode(targetRepoPath);
- Repository repository = RepoUtils.getRepository(repositoryFactory,
- keyring, repoNode);
- Credentials credentials = RepoUtils.getRepositoryCredentials(
- keyring, repoNode);
-
- String msg = "Your are about to completely delete workspace ["
- + workspaceName + "].\n Do you really want to proceed?";
- boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
- .getWorkbench().getDisplay().getActiveShell(),
- "Confirm workspace deletion", msg);
-
- if (result) {
- // msg =
- // "There is no possible turning back, are your REALLY sure you want to proceed ?";
- msg = "WARNING: \nCurrent Jackrabbit version used does "
- + "not support workspace deletion.\n"
- + "Thus, the workspace will only be cleaned so "
- + "that you can launch fetch process again.\n\n"
- + "Do you still want to proceed?";
- result = MessageDialog.openConfirm(DistPlugin.getDefault()
- .getWorkbench().getDisplay().getActiveShell(),
- "Confirm workspace deletion", msg);
- }
-
- if (result) {
- session = repository.login(credentials, workspaceName);
- // TODO use this with a newer version of Jackrabbit
- // Workspace wsp = session.getWorkspace();
- // wsp.deleteWorkspace(workspaceName);
- NodeIterator nit = session.getRootNode().getNodes();
- while (nit.hasNext()) {
- Node node = nit.nextNode();
- if (node.isNodeType(NodeType.NT_FOLDER)
- || node.isNodeType(NodeType.NT_UNSTRUCTURED)) {
- // String path = node.getPath();
- node.remove();
- session.save();
- }
- }
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while deleting workspace ["
- + workspaceName + "].", re);
- } finally {
- JcrUtils.logoutQuietly(session);
- JcrUtils.logoutQuietly(nodeSession);
- }
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Open a dialog that displays various information on the current repository.
- */
-public class DisplayRepoInformation extends AbstractHandler {
- public final static String ID = DistPlugin.PLUGIN_ID + ".displayRepoInformation";
- public final static String DEFAULT_LABEL = "Information";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/help.gif");
-
- /* DEPENDENCY INJECTION */
- private RepoService repoService;
- private Repository nodeRepository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IStructuredSelection iss = (IStructuredSelection) HandlerUtil
- .getActiveSite(event).getSelectionProvider().getSelection();
- if (iss.getFirstElement() instanceof RepoElem) {
- RepoElem re = (RepoElem) iss.getFirstElement();
-
- Session defaultSession = null;
- try {
- defaultSession = repoService.getRemoteSession(re.getRepoNodePath(),
- re.getUri(), null);
-
- InformationDialog inputDialog = new InformationDialog(
- HandlerUtil.getActiveSite(event).getShell());
- inputDialog.create();
- // TODO add more information.
- inputDialog.loginTxt.setText(defaultSession.getUserID());
- inputDialog.nameTxt.setText(re.getLabel());
- inputDialog.uriTxt.setText(re.getUri());
- inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
-
- inputDialog.open();
- // } catch (RepositoryException e) {
- // throw new SlcException("Unexpected error while "
- // + "getting repository information.", e);
- } finally {
- JcrUtils.logoutQuietly(defaultSession);
- }
- }
- return null;
- }
-
- private class InformationDialog extends Dialog {
- Text nameTxt;
- Text uriTxt;
- Text loginTxt;
- Button readOnlyBtn;
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- // No Cancel button
- createButton(parent, IDialogConstants.OK_ID, "OK", true);
- }
-
- public InformationDialog(Shell parentShell) {
- super(parentShell);
- }
-
- protected Point getInitialSize() {
- return new Point(500, 250);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogarea = (Composite) super.createDialogArea(parent);
- dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true));
- Composite composite = new Composite(dialogarea, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.horizontalSpacing = 15;
- composite.setLayout(layout);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- composite.setLayoutData(gd);
-
- nameTxt = createLT(composite, "Name");
- uriTxt = createLT(composite, "URI");
- loginTxt = createLT(composite, "Logged as");
- readOnlyBtn = createLC(composite, "Read only");
- parent.pack();
- return composite;
- }
-
- /** Creates label and text. */
- protected Text createLT(Composite parent, String label) {
- new Label(parent, SWT.RIGHT).setText(label);
- Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.NONE);
- text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- text.setEditable(false);
- return text;
- }
-
- /** Creates label and check. */
- protected Button createLC(Composite parent, String label) {
- new Label(parent, SWT.RIGHT).setText(label);
- Button check = new Button(parent, SWT.CHECK);
- check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- check.setEnabled(false);
- return check;
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText("Repository information");
- }
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepoService(RepoService repoService) {
- this.repoService = repoService;
- }
-
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Util command used to enable sub menus in various toolbars. Does nothing */
-public class DoNothing extends AbstractHandler {
- public final static String ID = DistPlugin.PLUGIN_ID + ".doNothing";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- return null;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.client.ui.dist.wizards.FetchWizard;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Wrap a {@code RepoSync} as an Eclipse command. Open a wizard that enable
- * definition of the fetch process parameters
- */
-public class Fetch extends AbstractHandler {
- // private final static Log log = LogFactory.getLog(Fetch.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".fetch";
- public final static String DEFAULT_LABEL = "Fetch...";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/fetchRepo.png");
-
- public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
- // DEPENDENCY INJECTION
- private Keyring keyring;
- private RepositoryFactory repositoryFactory;
- private Repository nodeRepository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- Session currSession = null;
- try {
- // Target Repository
- String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
- currSession = nodeRepository.login();
- Node targetRepoNode = currSession.getNode(targetRepoPath);
-
- FetchWizard wizard = new FetchWizard(keyring, repositoryFactory,
- nodeRepository);
- wizard.setTargetRepoNode(targetRepoNode);
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
-
- int result = dialog.open();
- if (result == Dialog.OK)
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
- return null;
- } catch (RepositoryException e) {
- throw new SlcException("Unable te retrieve repo node from path", e);
- } finally {
- JcrUtils.logoutQuietly(currSession);
- }
- }
-
- // DEPENDENCY INJECTION
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-
- public void setNodeRepository(Repository repository) {
- this.nodeRepository = repository;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.wizards.ChangeRightsWizard;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Open a dialog to manage rights on the current workspace's root node */
-public class ManageWorkspaceAuth extends AbstractHandler {
- // private static final Log log =
- // LogFactory.getLog(ManageWorkspaceAuth.class);
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".manageWorkspaceAuth";
- public final static String DEFAULT_LABEL = "Manage Rights";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/changeRights.gif");
-
- public final static String PARAM_WORKSPACE_NAME = DistPlugin.PLUGIN_ID
- + ".workspaceName";
-
- /* DEPENDENCY INJECTION */
- private Repository repository;
- private Session session;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
- try {
- session = repository.login(workspaceName);
- ChangeRightsWizard wizard = new ChangeRightsWizard(session);
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
- dialog.open();
- return null;
- } catch (RepositoryException re) {
- throw new SlcException("Cannot log in the repository "
- + repository + " in workspace " + workspaceName, re);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryResult;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-
-/** Merge two workspaces */
-public class MergeWorkspaces extends AbstractHandler {
- private final static Log log = LogFactory.getLog(MergeWorkspaces.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".mergeWorkspaces";
- public final static String DEFAULT_LABEL = "Merge";
-
- public final static String PARAM_SOURCE_WORKSPACE_NAME = "srcWkspName";
- public final static String PARAM_SOURCE_REPO_PATH = "srcRepoPath";
- public final static String PARAM_TARGET_WORKSPACE_NAME = "targetWkspName";
- public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
- // DEPENDENCY INJECTION
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Repository nodeRepository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
- String targetWkspName = event.getParameter(PARAM_TARGET_WORKSPACE_NAME);
- String sourceRepoPath = event.getParameter(PARAM_SOURCE_REPO_PATH);
- String sourceWkspName = event.getParameter(PARAM_SOURCE_WORKSPACE_NAME);
-
- Session nodeSession = null;
- try {
- nodeSession = nodeRepository.login();
- Node srcRepoNode = nodeSession.getNode(sourceRepoPath);
- Repository srcRepository = RepoUtils.getRepository(repositoryFactory, keyring, srcRepoNode);
- Credentials srcCredentials = RepoUtils.getRepositoryCredentials(keyring, srcRepoNode);
-
- Node targetRepoNode = nodeSession.getNode(targetRepoPath);
- Repository targetRepository = RepoUtils.getRepository(repositoryFactory, keyring, targetRepoNode);
- Credentials targetCredentials = RepoUtils.getRepositoryCredentials(keyring, targetRepoNode);
-
- // String msg = "Are you sure you want to merge distribution ["
- // + sourceWkspName + "] in distribution [" + targetWkspName
- // + "] ?";
- //
- // boolean result = MessageDialog.openConfirm(
- // HandlerUtil.getActiveShell(event), "Confirm Merge", msg);
-
- // if (result) {
- // Open sessions here since the background thread
- // won't necessarily be authenticated.
- // Job should close the sessions.
- Session sourceSession = srcRepository.login(srcCredentials, sourceWkspName);
- Session targetSession;
- try {
- targetSession = targetRepository.login(targetCredentials, targetWkspName);
- } catch (NoSuchWorkspaceException e) {
- Session defaultSession = targetRepository.login(targetCredentials);
- try {
- defaultSession.getWorkspace().createWorkspace(targetWkspName);
- } catch (Exception e1) {
- throw new SlcException("Cannot create new workspace " + targetWkspName, e);
- } finally {
- JcrUtils.logoutQuietly(defaultSession);
- }
- targetSession = targetRepository.login(targetCredentials, targetWkspName);
- }
-
- Job workspaceMergeJob = new WorkspaceMergeJob(sourceSession, targetSession);
- workspaceMergeJob.setUser(true);
- workspaceMergeJob.schedule();
- } catch (RepositoryException re) {
- throw new SlcException("Unexpected error while merging workspaces.", re);
- } finally {
- JcrUtils.logoutQuietly(nodeSession);
- }
- return null;
- }
-
- private static class WorkspaceMergeJob extends Job {
- private Session sourceSession;
- private Session targetSession;
-
- public WorkspaceMergeJob(Session sourceSession, Session targetSession) {
- super("Workspace merge");
- this.sourceSession = sourceSession;
- this.targetSession = targetSession;
- }
-
- @Override
- protected IStatus run(IProgressMonitor eclipseMonitor) {
- long begin = System.currentTimeMillis();
- try {
- Query countQuery = sourceSession.getWorkspace().getQueryManager()
- .createQuery("select file from [nt:file] as file", Query.JCR_SQL2);
- QueryResult result = countQuery.execute();
- Long expectedCount = result.getNodes().getSize();
- if (log.isDebugEnabled())
- log.debug("Will copy " + expectedCount + " files...");
-
- JcrMonitor monitor = new EclipseJcrMonitor(eclipseMonitor);
- eclipseMonitor.beginTask("Copy files", expectedCount.intValue());
-
- Long count = JcrUtils.copyFiles(sourceSession.getRootNode(), targetSession.getRootNode(), true, monitor,
- true);
-
- monitor.done();
- long duration = (System.currentTimeMillis() - begin) / 1000;// in
- // s
- if (log.isDebugEnabled())
- log.debug("Copied " + count + " files in " + (duration / 60) + "min " + (duration % 60) + "s");
-
- return Status.OK_STATUS;
- } catch (RepositoryException e) {
- return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID, "Cannot merge", e);
- } finally {
- JcrUtils.logoutQuietly(sourceSession);
- JcrUtils.logoutQuietly(targetSession);
- }
- }
- }
-
- /* DEPENDENCY INJECTION */
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Binary;
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-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 javax.jcr.util.TraversingItemVisitor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.ArtifactIndexer;
-import org.argeo.slc.repo.JarFileIndexer;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.maven.AetherUtils;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.argeo.slc.repo.osgi.NormalizeGroup;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Legacy - Make sure than Maven and OSGi metadata are consistent */
-public class NormalizeDistribution extends AbstractHandler implements SlcNames {
- private final static Log log = LogFactory
- .getLog(NormalizeDistribution.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".normalizeDistribution";
- public final static String DEFAULT_LABEL = "Legacy Normalization...";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/normalize.gif");
-
- public final static String PARAM_WORKSPACE_NAME = "workspaceName";
- public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
- private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
-
- private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
- private JarFileIndexer jarFileIndexer = new JarFileIndexer();
-
- // DEPENDENCY INJECTION
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Repository nodeRepository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
- String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
-
- Session nodeSession = null;
- NormalizeJob job;
- try {
-
- NormalizationDialog dialog = new NormalizationDialog(
- HandlerUtil.getActiveShell(event));
- if (dialog.open() != Dialog.OK)
- return null;
-
- nodeSession = nodeRepository.login();
- Node repoNode = nodeSession.getNode(targetRepoPath);
- Repository repository = RepoUtils.getRepository(repositoryFactory,
- keyring, repoNode);
- Credentials credentials = RepoUtils.getRepositoryCredentials(
- keyring, repoNode);
-
- String version = dialog.getVersion();
- Boolean overridePoms = dialog.getOverridePoms();
-
- job = new NormalizeJob(repository.login(credentials, wkspName),
- version, overridePoms);
- job.setUser(true);
- job.schedule();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot normalize " + wkspName, e);
- } finally {
- JcrUtils.logoutQuietly(nodeSession);
- }
- return null;
- }
-
- protected void packageSourcesAsPdeSource(Node sourcesNode) {
- Binary origBinary = null;
- Binary osgiBinary = null;
- try {
- Session session = sourcesNode.getSession();
- Artifact sourcesArtifact = AetherUtils.convertPathToArtifact(
- sourcesNode.getPath(), null);
-
- // read name version from manifest
- Artifact osgiArtifact = new DefaultArtifact(
- sourcesArtifact.getGroupId(),
- sourcesArtifact.getArtifactId(),
- sourcesArtifact.getExtension(),
- sourcesArtifact.getVersion());
- String osgiPath = MavenConventionsUtils.artifactPath(
- artifactBasePath, osgiArtifact);
- osgiBinary = session.getNode(osgiPath).getNode(Node.JCR_CONTENT)
- .getProperty(Property.JCR_DATA).getBinary();
-
- NameVersion nameVersion = RepoUtils.readNameVersion(osgiBinary
- .getStream());
-
- // create PDe sources artifact
- Artifact pdeSourceArtifact = new DefaultArtifact(
- sourcesArtifact.getGroupId(),
- sourcesArtifact.getArtifactId() + ".source",
- sourcesArtifact.getExtension(),
- sourcesArtifact.getVersion());
- String targetSourceParentPath = MavenConventionsUtils
- .artifactParentPath(artifactBasePath, pdeSourceArtifact);
- String targetSourceFileName = MavenConventionsUtils
- .artifactFileName(pdeSourceArtifact);
- String targetSourceJarPath = targetSourceParentPath + '/'
- + targetSourceFileName;
-
- Node targetSourceParentNode = JcrUtils.mkfolders(session,
- targetSourceParentPath);
- origBinary = sourcesNode.getNode(Node.JCR_CONTENT)
- .getProperty(Property.JCR_DATA).getBinary();
- byte[] targetJarBytes = RepoUtils.packageAsPdeSource(
- origBinary.getStream(), nameVersion);
- JcrUtils.copyBytesAsFile(targetSourceParentNode,
- targetSourceFileName, targetJarBytes);
-
- // reindex
- Node targetSourceJarNode = session.getNode(targetSourceJarPath);
- artifactIndexer.index(targetSourceJarNode);
- jarFileIndexer.index(targetSourceJarNode);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot add PDE sources for " + sourcesNode,
- e);
- } finally {
- JcrUtils.closeQuietly(origBinary);
- JcrUtils.closeQuietly(osgiBinary);
- }
-
- }
-
- private class NormalizeJob extends Job {
- private Session session;
- private String version;
- private Boolean overridePoms;
-
- public NormalizeJob(Session session, String version,
- Boolean overridePoms) {
- super("Normalize Distribution");
- this.session = session;
- this.version = version;
- this.overridePoms = overridePoms;
- }
-
- @Override
- protected IStatus run(IProgressMonitor progressMonitor) {
-
- try {
- JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
- // normalize artifacts
- Query countQuery = session
- .getWorkspace()
- .getQueryManager()
- .createQuery("select file from [nt:file] as file",
- Query.JCR_SQL2);
- QueryResult result = countQuery.execute();
- Long expectedCount = result.getNodes().getSize();
- monitor.beginTask("Normalize artifacts of "
- + session.getWorkspace().getName(),
- expectedCount.intValue());
- NormalizingTraverser tiv = new NormalizingTraverser(monitor);
- session.getNode(artifactBasePath).accept(tiv);
-
- // normalize groups
- Query groupQuery = session
- .getWorkspace()
- .getQueryManager()
- .createQuery(
- "select group from [" + SlcTypes.SLC_GROUP_BASE
- + "] as group", Query.JCR_SQL2);
- NodeIterator groups = groupQuery.execute().getNodes();
- monitor.beginTask("Normalize groups of "
- + session.getWorkspace().getName(),
- (int) groups.getSize());
- while (groups.hasNext()) {
- NormalizeGroup.processGroupNode(groups.nextNode(), version,
- overridePoms, monitor);
- }
- } catch (Exception e) {
- return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
- "Cannot normalize distribution "
- + session.getWorkspace().getName(), e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- return Status.OK_STATUS;
- }
-
- }
-
- private class NormalizingTraverser extends TraversingItemVisitor {
- JcrMonitor monitor;
-
- public NormalizingTraverser(JcrMonitor monitor) {
- super();
- this.monitor = monitor;
- }
-
- @Override
- protected void entering(Property property, int level)
- throws RepositoryException {
- }
-
- @Override
- protected void entering(Node node, int level)
- throws RepositoryException {
- if (node.isNodeType(NodeType.NT_FILE)) {
- if (node.getName().endsWith("-sources.jar")) {
- monitor.subTask(node.getName());
- packageSourcesAsPdeSource(node);
- node.getSession().save();
- monitor.worked(1);
- if (log.isDebugEnabled())
- log.debug("Processed source artifact " + node.getPath());
- } else if (node.getName().endsWith(".jar")) {
- if (jarFileIndexer.support(node.getPath()))
- if (artifactIndexer.support(node.getPath())) {
- monitor.subTask(node.getName());
- artifactIndexer.index(node);
- jarFileIndexer.index(node);
- node.getSession().save();
- monitor.worked(1);
- if (log.isDebugEnabled())
- log.debug("Processed artifact "
- + node.getPath());
- }
- } else {
- monitor.worked(1);
- }
- }
- }
-
- @Override
- protected void leaving(Property property, int level)
- throws RepositoryException {
- }
-
- @Override
- protected void leaving(Node node, int level) throws RepositoryException {
- }
-
- }
-
- public class NormalizationDialog extends TitleAreaDialog {
- private static final long serialVersionUID = -3103886455862638580L;
-
- private Text versionT;
- private String version;
- private Button overridePomsC;
- private Boolean overridePoms;
-
- public NormalizationDialog(Shell parentShell) {
- super(parentShell);
- }
-
- protected Point getInitialSize() {
- return new Point(300, 250);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogarea = (Composite) super.createDialogArea(parent);
- dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true));
- Composite composite = new Composite(dialogarea, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- false));
- versionT = createLT(composite, "Version");
- overridePomsC = createLC(composite, "Override POMs");
- setMessage("Configure normalization", IMessageProvider.NONE);
-
- parent.pack();
- return composite;
- }
-
- @Override
- protected void okPressed() {
- version = versionT.getText();
- overridePoms = overridePomsC.getSelection();
- super.okPressed();
- }
-
- /** Creates label and text. */
- protected Text createLT(Composite parent, String label) {
- new Label(parent, SWT.NONE).setText(label);
- Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER
- | SWT.NONE);
- text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- return text;
- }
-
- /** Creates label and check. */
- protected Button createLC(Composite parent, String label) {
- new Label(parent, SWT.NONE).setText(label);
- Button check = new Button(parent, SWT.CHECK);
- check.setSelection(false);
- check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- return check;
- }
-
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText("Normalize...");
- }
-
- public String getVersion() {
- return version;
- }
-
- public Boolean getOverridePoms() {
- return overridePoms;
- }
-
- }
-
- /* DEPENDENCY INJECTION */
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-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 javax.jcr.util.TraversingItemVisitor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.security.Keyring;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.ArtifactIndexer;
-import org.argeo.slc.repo.JarFileIndexer;
-import org.argeo.slc.repo.ModularDistributionIndexer;
-import org.argeo.slc.repo.PdeSourcesIndexer;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/**
- * Force the indexing of a given workspace by making sure than Maven and OSGi
- * metadata are consistent. This mechanism normally relies on JCR Listeners but
- * must sometimes be triggered manually
- */
-public class NormalizeWorkspace extends AbstractHandler implements SlcNames {
- private final static Log log = LogFactory.getLog(NormalizeWorkspace.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".normalizeWorkspace";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin.getImageDescriptor("icons/normalize.gif");
-
- public final static String PARAM_WORKSPACE_NAME = "workspaceName";
- public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
- private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
-
- // DEPENDENCY INJECTION
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Repository repository;
-
- // Relevant default node indexers
- private PdeSourcesIndexer pdeSourceIndexer = new PdeSourcesIndexer();
- // WARNING Order is important: must be called in the following order.
- private ModularDistributionIndexer modularDistributionIndexer = new ModularDistributionIndexer();
- private JarFileIndexer jarFileIndexer = new JarFileIndexer();
- private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
- String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
-
- Session currSession = null;
- NormalizeJob job;
- try {
- String msg = "Your are about to normalize workspace: " + wkspName
- + ".\nThis will index OSGi bundles and Maven artifacts, "
- + "it will also convert Maven sources to PDE Sources if needed.\n"
- + "Note that no information will be overwritten: " + "all existing information are kept."
- + "\n\n Do you really want to proceed ?";
-
- if (!MessageDialog.openConfirm(DistPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(),
- "Confirm workspace normalization", msg))
- return null;
-
- currSession = repository.login();
- Node repoNode = currSession.getNode(targetRepoPath);
- Repository repository = RepoUtils.getRepository(repositoryFactory, keyring, repoNode);
- Credentials credentials = RepoUtils.getRepositoryCredentials(keyring, repoNode);
-
- job = new NormalizeJob(repository.login(credentials, wkspName));
- job.setUser(true);
- job.schedule();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot normalize " + wkspName, e);
- } finally {
- JcrUtils.logoutQuietly(currSession);
- }
- return null;
- }
-
- private class NormalizeJob extends Job {
- private Session session;
-
- public NormalizeJob(Session session) {
- super("Normalize Distribution");
- this.session = session;
- }
-
- @Override
- protected IStatus run(IProgressMonitor progressMonitor) {
- try {
- JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
- // Normalize artifacts
- Query countQuery = session.getWorkspace().getQueryManager()
- .createQuery("select file from [nt:file] as file", Query.JCR_SQL2);
- QueryResult result = countQuery.execute();
- Long expectedCount = result.getNodes().getSize();
- monitor.beginTask("Normalize artifacts of " + session.getWorkspace().getName(),
- expectedCount.intValue());
- NormalizingTraverser tiv = new NormalizingTraverser(monitor);
- Node artifactBaseNode = session.getNode(artifactBasePath);
- artifactBaseNode.accept(tiv);
- } catch (Exception e) {
- log.error("Error normalizing workspace " + session.getWorkspace().getName() + ": " + e.getMessage());
- if (log.isErrorEnabled())
- e.printStackTrace();
- return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
- "Cannot normalize distribution " + session.getWorkspace().getName(), e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- return Status.OK_STATUS;
- }
- }
-
- private class NormalizingTraverser extends TraversingItemVisitor {
- JcrMonitor monitor;
-
- public NormalizingTraverser(JcrMonitor monitor) {
- super();
- this.monitor = monitor;
- }
-
- @Override
- protected void entering(Property property, int level) throws RepositoryException {
- }
-
- @Override
- protected void entering(Node node, int level) throws RepositoryException {
- if (node.getPath().startsWith(RepoConstants.DIST_DOWNLOAD_BASEPATH))
- return;
-
- if (node.isNodeType(NodeType.NT_FILE)) {
- if (node.getName().endsWith("-sources.jar")) {
- monitor.subTask(node.getName());
- pdeSourceIndexer.index(node);
- node.getSession().save();
- monitor.worked(1);
- if (log.isDebugEnabled())
- log.debug("Processed source artifact " + node.getPath());
- } else if (node.getName().endsWith("-javadoc.jar")) {
- if (log.isDebugEnabled())
- log.debug("Skip indexing of Javadoc jar " + node.getPath());
- } else if (node.getName().endsWith(".jar")) {
- if (jarFileIndexer.support(node.getPath()))
- if (artifactIndexer.support(node.getPath())) {
- monitor.subTask(node.getName());
- modularDistributionIndexer.index(node);
- jarFileIndexer.index(node);
- artifactIndexer.index(node);
- if (node.getSession().hasPendingChanges()) {
- node.getSession().save();
- if (log.isDebugEnabled())
- log.debug("Processed jar artifact " + node.getPath());
- }
- monitor.worked(1);
- }
- } else if (node.getName().endsWith(".pom")) {
- // Removed: we do not support binaries concept anymore.
- // if (distBundleIndexer.support(node.getPath()))
- // distBundleIndexer.index(node);
- if (artifactIndexer.support(node.getPath()))
- artifactIndexer.index(node);
- if (node.getSession().hasPendingChanges()) {
- node.getSession().save();
- if (log.isDebugEnabled())
- log.debug("Processed pom artifact " + node.getPath());
- }
- monitor.worked(1);
- } else {
- monitor.worked(1);
- }
- }
- }
-
- @Override
- protected void leaving(Property property, int level) throws RepositoryException {
- }
-
- @Override
- protected void leaving(Node node, int level) throws RepositoryException {
- }
- }
-
- /* DEPENDENCY INJECTION */
- public void setNodeRepository(Repository nodeRepository) {
- this.repository = nodeRepository;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.client.ui.dist.wizards.GenerateBinariesWizard;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Open a {@code GenerateBinariesWizard} wizard for the selected node */
-public class OpenGenerateBinariesWizard extends AbstractHandler {
- // private static final Log log = LogFactory.getLog(DeleteWorkspace.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".openGenerateBinariesWizard";
- public final static String DEFAULT_LABEL = "Generate Aether Index";
- public final static ImageDescriptor DEFAULT_ICON = null;
-
- /* DEPENDENCY INJECTION */
- private RepoService repoService;
-
- // Absolute Coordinates of the current group node
- public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
- public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
- public final static String PARAM_MODULE_PATH = "param.modulePath";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActivePart();
-
- String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
- String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
- String modulePath = event.getParameter(PARAM_MODULE_PATH);
-
- GenerateBinariesWizard wizard = new GenerateBinariesWizard(repoService,
- repoNodePath, workspaceName, modulePath);
-
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
- int result = dialog.open();
-
- if (result == Dialog.OK
- && (activePart instanceof RefreshDistributionsView))
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
-
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepoService(RepoService repoService) {
- this.repoService = repoService;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor;
-import org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor;
-import org.argeo.slc.client.ui.dist.editors.ModuleEditorInput;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Open the relevant editor for a given module node of a given repository
- * workspace. For the time being, modules can be artifacts or
- * modularDistributions
- */
-public class OpenModuleEditor extends AbstractHandler {
- public final static String ID = DistPlugin.PLUGIN_ID + ".openModuleEditor";
- public final static String DEFAULT_LABEL = "Open relevant editor";
-
- // use local node repo and repository factory to retrieve and log to
- // relevant repository
- public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
- // use URI and repository factory to retrieve and ANONYMOUSLY log in
- // relevant repository
- public final static String PARAM_REPO_URI = "param.repoUri";
- public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
- public final static String PARAM_MODULE_PATH = "param.modulePath";
-
- /* DEPENDENCY INJECTION */
- private RepoService repoService;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
- String repoUri = event.getParameter(PARAM_REPO_URI);
- String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
- String modulePath = event.getParameter(PARAM_MODULE_PATH);
-
- Session businessSession = null;
- try {
- businessSession = repoService.getRemoteSession(repoNodePath,
- repoUri, workspaceName);
-
- Node module = businessSession.getNode(modulePath);
- ModuleEditorInput mei = new ModuleEditorInput(repoNodePath,
- repoUri, workspaceName, modulePath);
-
- // Choose correct editor based on its mixin
- if (module.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION))
- HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .openEditor(mei, ModularDistVersionEditor.ID);
- else
- HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .openEditor(mei, ArtifactVersionEditor.ID);
- } catch (RepositoryException e) {
- throw new SlcException("Unexpected error while "
- + "getting repoNode info for repoNode at path "
- + repoNodePath, e);
- } catch (PartInitException e) {
- throw new SlcException("Unexpected error while "
- + "opening editor for workspace " + workspaceName
- + " with URI " + repoUri + " and repoNode at path "
- + repoNodePath, e);
- } finally {
- JcrUtils.logoutQuietly(businessSession);
- }
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepoService(RepoService repoService) {
- this.repoService = repoService;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.cms.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.editors.DistWkspEditorInput;
-import org.argeo.slc.client.ui.dist.editors.DistWorkspaceEditor;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Open a distribution workspace editor for a given workspace in a repository
- */
-public class OpenWorkspaceEditor extends AbstractHandler {
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".openWorkspaceEditor";
- public final static String DEFAULT_LABEL = "Open editor";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/distribution_perspective.gif");
-
- // Use local node repo and repository factory to retrieve and log to
- // relevant repository
- public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
- // Use URI and repository factory to retrieve and ANONYMOUSLY log in
- // relevant repository
- public final static String PARAM_REPO_URI = "param.repoUri";
- public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
-
- /* DEPENDENCY INJECTION */
- private Repository localRepository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
- String repoUri = event.getParameter(PARAM_REPO_URI);
- String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
-
- Session defaultSession = null;
- if (repoNodePath != null && repoUri == null) {
- try {
- defaultSession = localRepository.login();
- if (defaultSession.nodeExists(repoNodePath)) {
- Node repoNode = defaultSession.getNode(repoNodePath);
- repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
- .getString();
- }
- } catch (RepositoryException e) {
- throw new SlcException("Unexpected error while "
- + "getting repoNode at path " + repoNodePath, e);
- } finally {
- JcrUtils.logoutQuietly(defaultSession);
- }
- }
-
- DistWkspEditorInput wei = new DistWkspEditorInput(repoNodePath,
- repoUri, workspaceName);
- try {
- HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .openEditor(wei, DistWorkspaceEditor.ID);
- } catch (PartInitException e) {
- throw new SlcException("Unexpected error while "
- + "opening editor for workspace " + workspaceName
- + " with URI " + repoUri + " and repoNode at path "
- + repoNodePath, e);
- }
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setLocalRepository(Repository localRepository) {
- this.localRepository = localRepository;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.security.Privilege;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/** Publish the current workspace by giving READ_ONLY rights to anonymous */
-public class PublishWorkspace extends AbstractHandler {
- // private static final Log log = LogFactory.getLog(PublishWorkspace.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".publishWorkspace";
- public final static String DEFAULT_LABEL = "Make Public";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/publish.gif");
-
- public final static String PARAM_WORKSPACE_NAME = "workspaceName";
- public final static String PARAM_TARGET_REPO_PATH = "targetRepoPath";
-
- // DEPENDENCY INJECTION
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Repository nodeRepository;
-
- private String publicRole = SlcConstants.USER_ANONYMOUS;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- String targetRepoPath = event.getParameter(PARAM_TARGET_REPO_PATH);
- String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
-
- Session nodeSession = null;
- Session session = null;
-
- try {
- nodeSession = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
- Node repoNode = nodeSession.getNode(targetRepoPath);
- Repository repository = RepoUtils.getRepository(repositoryFactory,
- keyring, repoNode);
- Credentials credentials = RepoUtils.getRepositoryCredentials(
- keyring, repoNode);
-
- String msg = "Are you sure you want to publish this distribution: "
- + workspaceName + " ?";
- boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
- .getWorkbench().getDisplay().getActiveShell(),
- "Confirm publication", msg);
-
- if (result) {
- session = repository.login(credentials, workspaceName);
- JcrUtils.addPrivilege(session, "/", publicRole,
- Privilege.JCR_READ);
- session.save();
- JcrUtils.logoutQuietly(session);
- // CommandHelpers.callCommand(RefreshDistributionsView.ID);
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while publishing workspace "
- + workspaceName, re);
- } finally {
- JcrUtils.logoutQuietly(session);
- JcrUtils.logoutQuietly(nodeSession);
- }
- return null;
- }
-
- /* DEPENDENCY INJECTION */
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.views.ArtifactsBrowser;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Force the refresh of the artifact browser view */
-public class RefreshArtifactBrowser extends AbstractHandler {
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ArtifactsBrowser view = (ArtifactsBrowser) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage()
- .findView(ArtifactsBrowser.ID);
- view.refresh(null);
- return null;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.views.AnonymousDistributionsView;
-import org.argeo.slc.client.ui.dist.views.DistributionsView;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbenchPart;
-
-/** Force refresh of the Distributions View */
-public class RefreshDistributionsView extends AbstractHandler {
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".refreshDistributionsView";
- public final static String DEFAULT_LABEL = "Refresh the distribution view";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/refresh.png");
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActivePart();
- if (activePart instanceof DistributionsView)
- ((DistributionsView) activePart).refresh();
- else if (activePart instanceof AnonymousDistributionsView)
- ((AnonymousDistributionsView) activePart).refresh();
- return null;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryFactory;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
-import org.argeo.slc.client.ui.dist.wizards.RegisterRepoWizard;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Register a remote repository by creating a node in the current local node. */
-public class RegisterRepository extends AbstractHandler implements ArgeoNames,
- SlcNames {
-
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".registerRepository";
- public final static String DEFAULT_LABEL = "Register a repository...";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/addRepo.gif");
-
- /* DEPENDENCY INJECTION */
- private RepositoryFactory repositoryFactory;
- private Repository nodeRepository;
- private Keyring keyring;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- RegisterRepoWizard wizard = new RegisterRepoWizard(keyring,
- repositoryFactory, nodeRepository);
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
- int result = dialog.open();
- if (result == Dialog.OK)
- CommandHelpers.callCommand(RefreshDistributionsView.ID);
- return null;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.net.URL;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.core.execution.tasks.JvmProcess;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/** <b>UNDER DEVELOPMENT</b>. Download and prepare an OSGi runtime */
-public class RunInOsgi extends AbstractHandler implements SlcNames {
- private final static Log log = LogFactory.getLog(RunInOsgi.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".runInOsgi";
- public final static String DEFAULT_LABEL = "Run in OSGi";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin
- .getImageDescriptor("icons/runInOsgi.gif");
-
- public final static String PARAM_WORKSPACE_NAME = "workspaceName";
- public final static String PARAM_MODULE_PATH = "modulePath";
-
- /* DEPENDENCY INJECTION */
- private Repository repository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- String workspace = event.getParameter(PARAM_WORKSPACE_NAME);
- String modulePath = event.getParameter(PARAM_MODULE_PATH);
- String port = System.getProperty("argeo.server.port.http");
- // String localMavenBase = System.getProperty("user.home")
- // + "/.m2/repository";
-
- InputStream jarStream = null;
- OutputStream out = null;
- Writer writer = null;
- Session session = null;
- try {
- // Bundle distPluginBundle = DistPlugin.getDefault().getBundle();
- // File baseDir = distPluginBundle.getBundleContext().getDataFile(
- // "runInOSGi");
- File baseDir = new File(System.getProperty("java.io.tmpdir")
- + "/runInOSGi-" + System.getProperty("user.name"));
- if (baseDir.exists())
- FileUtils.deleteDirectory(baseDir);
- File libDir = new File(baseDir, "lib");
- libDir.mkdirs();
- File confDir = new File(baseDir, "configuration");
- confDir.mkdirs();
- File dataDir = new File(baseDir, "data");
- dataDir.mkdirs();
-
- session = repository.login(workspace);
-
- // NodeIterator bundles = listBundleArtifacts(session);
- // if (log.isDebugEnabled())
- // log.debug("## Copying to " + libDir);
- //
- // File equinoxJar = null;
- // List<File> files = new ArrayList<File>();
- // bundles: while (bundles.hasNext()) {
- // Node bundleNode = bundles.nextNode();
- // String symbolicName = JcrUtils.get(bundleNode,
- // SLC_SYMBOLIC_NAME);
- //
- // // skip sources
- // if (symbolicName.endsWith(".source"))
- // continue bundles;
- // // skip eclipse
- // if (symbolicName.startsWith("org.eclipse")
- // && !symbolicName.equals("org.eclipse.osgi"))
- // continue bundles;
- // if (symbolicName.equals("org.polymap.openlayers.rap.widget"))
- // continue bundles;
- //
- // File targetFile = new File(libDir, bundleNode.getName());
- // out = new FileOutputStream(targetFile);
- // jarStream = bundleNode.getNode(Node.JCR_CONTENT)
- // .getProperty(Property.JCR_DATA).getBinary().getStream();
- // IOUtils.copy(jarStream, out);
- // if (symbolicName.equals("org.eclipse.osgi"))
- // equinoxJar = targetFile;
- // else
- // files.add(targetFile);
- // if (log.isDebugEnabled())
- // log.debug("Copied " + targetFile.getName());
- //
- // IOUtils.closeQuietly(out);
- // IOUtils.closeQuietly(jarStream);
- // }
- //
- // StringBuffer osgiBundles = new StringBuffer("osgi.bundles=");
- // for (int i = 0; i < files.size(); i++) {
- // if (i != 0)
- // osgiBundles.append(',');
- // osgiBundles.append(files.get(i).getName());
- // }
-
- String equinoxJar = null;
-
- Node distModule = session.getNode(modulePath);
- NodeIterator coordinates = distModule.getNode(SLC_MODULES)
- .getNodes();
- StringBuilder conf = new StringBuilder(1024 * 1024);
- conf.append("osgi.clean=true\n");
- conf.append("osgi.console=7777\n");
- // conf.append("osgi.console.enable.builtin=true\n");
-
- conf.append("osgi.bundles=");
- coords: while (coordinates.hasNext()) {
- Node coord = coordinates.nextNode();
- // String category =
- // coord.getProperty(SLC_CATEGORY).getString();
- String name = coord.getProperty(SLC_NAME).getString();
- String version = coord.getProperty(SLC_VERSION).getString();
- Artifact artifact = RepoUtils.asArtifact(coord);
- String path = MavenConventionsUtils.artifactPath("", artifact);
- String url = "http://localhost:" + port + "/data/public/java/"
- + workspace + path;
- if (log.isDebugEnabled())
- log.debug(url);
- File f = new File(libDir, name + "-" + version + ".jar");
- FileUtils.copyURLToFile(new URL(url), f);
- if (name.equals("org.eclipse.osgi")) {
- // File f = new File(localMavenBase + path);
- // if (!f.exists())
- // FileUtils.copyURLToFile(new URL(url), f);
- equinoxJar = f.getCanonicalPath();
- continue coords;
- }
- conf.append(f.getName());
- if (coordinates.hasNext())
- conf.append(",\\\n");
- }
-
- File confIni = new File(confDir, "config.ini");
- writer = new FileWriter(confIni);
- writer.write(conf.toString());
- IOUtils.closeQuietly(writer);
-
- // Map<String, String> configuration = new HashMap<String,
- // String>();
- // configuration.put("osgi.configuration.area",
- // confDir.getCanonicalPath());
- // configuration.put("osgi.instance.area",
- // dataDir.getCanonicalPath());
- // // Do clean
- // configuration.put("osgi.clean", "true");
-
- JvmProcess osgiRuntime = new JvmProcess();
- osgiRuntime.setExecDir(baseDir.getCanonicalPath());
- if (equinoxJar == null)
- throw new SlcException("Cannot find OSGi runtime.");
- osgiRuntime.setMainJar(equinoxJar);
- osgiRuntime.arg("-configuration", confDir.getCanonicalPath()).arg(
- "-data", dataDir.getCanonicalPath());
- // .arg("-console", "7777").arg("-clean");
- osgiRuntime.setLogCommand(true);
- osgiRuntime.afterPropertiesSet();
- Job job = new RunInOsgiJob(osgiRuntime);
- job.schedule();
- // osgiRuntime.run();
-
- // Map<String, String> configuration = new HashMap<String,
- // String>();
- // configuration.put("osgi.configuration.area",
- // confDir.getCanonicalPath());
- // configuration.put("osgi.instance.area",
- // dataDir.getCanonicalPath());
- // // Do clean
- // configuration.put("osgi.clean", "true");
- // ServiceLoader<FrameworkFactory> ff = ServiceLoader
- // .load(FrameworkFactory.class);
- // FrameworkFactory frameworkFactory = ff.iterator().next();
- // Framework framework =
- // frameworkFactory.newFramework(configuration);
- // framework.start();
- // BundleContext testBundleContext = framework.getBundleContext();
-
- // for (int i = 0; i < files.size(); i++) {
- // testBundleContext.installBundle("file://"
- // + files.get(i).getCanonicalPath());
- // }
- //
- // Bundle[] testBundles = testBundleContext.getBundles();
- // for (Bundle bundle : testBundles) {
- // if (log.isDebugEnabled())
- // log.debug(bundle.getSymbolicName() + " "
- // + bundle.getVersion());
- // }
-
- } catch (Exception e) {
- ErrorFeedback.show("Cannot run in OSGi", e);
- } finally {
- IOUtils.closeQuietly(jarStream);
- IOUtils.closeQuietly(out);
- IOUtils.closeQuietly(writer);
- JcrUtils.logoutQuietly(session);
- }
-
- return null;
- }
-
- // private NodeIterator listBundleArtifacts(Session session)
- // throws RepositoryException {
-
- // QueryManager queryManager = session.getWorkspace().getQueryManager();
- // QueryObjectModelFactory factory = queryManager.getQOMFactory();
- //
- // final String bundleArtifactsSelector = "bundleArtifacts";
- // Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
- // bundleArtifactsSelector);
- //
- // Ordering order = factory.ascending(factory.propertyValue(
- // bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
- // Ordering[] orderings = { order };
- //
- // QueryObjectModel query = factory.createQuery(source, null, orderings,
- // null);
- //
- // QueryResult result = query.execute();
- // return result.getNodes();
- // }
-
- private class RunInOsgiJob extends Job {
- final JvmProcess osgiRuntime;
-
- public RunInOsgiJob(JvmProcess osgiRuntime) {
- super("OSGi Test");
- this.osgiRuntime = osgiRuntime;
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- osgiRuntime.setSynchronous(false);
- osgiRuntime.run();
- while (!monitor.isCanceled()) {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- // silent
- }
-
- if (monitor.isCanceled()) {
- osgiRuntime.kill();
- return Status.CANCEL_STATUS;
- }
- if (!osgiRuntime.isRunning())
- break;
- }
- return Status.OK_STATUS;
- }
-
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.views.ArtifactsBrowser;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.State;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Change visible state of the ArtifactBrower size column */
-public class ShowSizeColumn extends AbstractHandler {
- public final static String ID = DistPlugin.PLUGIN_ID + ".showSizeColumn";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ArtifactsBrowser view = (ArtifactsBrowser) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage()
- .findView(ArtifactsBrowser.ID);
-
- ICommandService service = (ICommandService) PlatformUI.getWorkbench()
- .getService(ICommandService.class);
- Command command = service.getCommand(ID);
- State state = command.getState(ID + ".toggleState");
-
- boolean wasVisible = (Boolean) state.getValue();
- view.setSizeVisible(!wasVisible);
- state.setValue(!wasVisible);
- return null;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/**
- * Un-register a remote repository by deleting the corresponding RepoNode from
- * the node Repository. It does not affect the repository instance
- */
-public class UnregisterRemoteRepo extends AbstractHandler {
- // private static final Log log = LogFactory
- // .getLog(UnregisterRemoteRepo.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".unregisterRemoteRepo";
- public final static String DEFAULT_LABEL = "Unregister";
- public final static ImageDescriptor DEFAULT_ICON = DistPlugin.getImageDescriptor("icons/removeItem.gif");
-
- public final static String PARAM_REPO_PATH = DistPlugin.PLUGIN_ID + ".repoNodePath";
-
- // DEPENCY INJECTION
- private Repository nodeRepository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- Session session = null;
- String repoPath = event.getParameter(PARAM_REPO_PATH);
- if (repoPath == null)
- return null;
-
- try {
- session = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
- Node rNode = session.getNode(repoPath);
- if (rNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
-
- String alias = rNode.getProperty(Property.JCR_TITLE).getString();
- String msg = "Your are about to unregister remote repository: " + alias + "\n"
- + "Are you sure you want to proceed ?";
-
- boolean result = MessageDialog.openConfirm(
- DistPlugin.getDefault().getWorkbench().getDisplay().getActiveShell(), "Confirm Delete", msg);
-
- if (result) {
- rNode.remove();
- session.save();
- }
- CommandUtils.callCommand(RefreshDistributionsView.ID);
- }
- } catch (RepositoryException e) {
- throw new SlcException("Unexpected error while unregistering remote repository.", e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- return null;
- }
-
- // DEPENCY INJECTION
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-}
\ No newline at end of file
+++ /dev/null
-<html>
-<head></head>
-<body>
-Eclipse commands wrapping Runnable objects define in non-ui specific code.
-</body>
-</html>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.controllers;
-
-import javax.jcr.RepositoryFactory;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Enable browsing in local public slc distribution repositories. For the time
- * being, it supports only one repository at a time. Repository factory must be
- * injected
- */
-public class AnonymousDistTreeContentProvider implements ITreeContentProvider {
- private static final long serialVersionUID = -4149180221319229128L;
-
- // List<RepoElem> repositories = new ArrayList<RepoElem>();
- private RepoElem publicRepo;
-
- private RepositoryFactory repositoryFactory;
-
- /**
- * @param input
- * the URI to the public repository to browse
- */
- public Object[] getElements(Object input) {
- String uri = (String) input;
- publicRepo = new RepoElem(repositoryFactory, uri,
- "Argeo Public Repository");
- // force connection and creation of the children UI object
- publicRepo.login();
- return publicRepo.getChildren();
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- // @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TreeParent)
- return ((TreeParent) parentElement).getChildren();
- else
- return null;
- }
-
- // @Override
- public Object getParent(Object element) {
- if (element instanceof TreeParent)
- return ((TreeParent) element).getParent();
- return null;
- }
-
- // @Override
- public boolean hasChildren(Object element) {
- if (element instanceof TreeParent)
- return ((TreeParent) element).hasChildren();
- else
- return false;
- }
-
- public void dispose() {
- publicRepo.dispose();
- }
-
- /*
- * DEPENDENCY INJECTION
- */
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.controllers;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.swt.graphics.Image;
-
-/** Retrieve artifact information to be displayed in an artifact tree or table */
-public class ArtifactLabelProvider extends ColumnLabelProvider implements
- DistConstants, SlcTypes {
- private static final long serialVersionUID = 8672622174076959016L;
-
- // To be able to change column order easily
- public static final int COLUMN_TREE = 0;
- public static final int COLUMN_DATE = 1;
- public static final int COLUMN_SIZE = 2;
-
- // Utils
- protected static DateFormat timeFormatter = new SimpleDateFormat(
- DATE_TIME_FORMAT);
-
- public void update(ViewerCell cell) {
- int colIndex = cell.getColumnIndex();
- Object element = cell.getElement();
- cell.setText(getColumnText(element, colIndex));
- if (element instanceof Node && colIndex == 0) {
- Node node = (Node) element;
- try {
- if (node.isNodeType(SLC_ARTIFACT_BASE))
- cell.setImage(DistImages.IMG_ARTIFACT_BASE);
- else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE))
- cell.setImage(DistImages.IMG_ARTIFACT_VERSION_BASE);
- } catch (RepositoryException e) {
- // Silent
- }
- }
- }
-
- @Override
- public Image getImage(Object element) {
-
- if (element instanceof Node) {
- Node node = (Node) element;
- try {
- if (node.isNodeType(SLC_ARTIFACT_BASE)) {
- return DistImages.IMG_ARTIFACT_BASE;
- } else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) {
- return DistImages.IMG_ARTIFACT_VERSION_BASE;
- }
- } catch (RepositoryException e) {
- // Silent
- }
- }
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- try {
- if (element instanceof Node) {
- Node node = (Node) element;
- switch (columnIndex) {
- case COLUMN_TREE:
- return node.getName();
- case COLUMN_SIZE:
- long size = JcrUtils.getNodeApproxSize(node) / 1024;
- if (size > 1024)
- return size / 1024 + " MB";
- else
- return size + " KB";
- case COLUMN_DATE:
- if (node.hasProperty(Property.JCR_LAST_MODIFIED))
- return timeFormatter.format(node
- .getProperty(Property.JCR_LAST_MODIFIED)
- .getDate().getTime());
- else
- return null;
- }
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexepected error while getting property values", re);
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.controllers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.jcr.util.JcrItemsComparator;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/** Enable specific browsing of an artifact tree */
-public class ArtifactsTreeContentProvider implements ITreeContentProvider,
- SlcTypes {
- private static final long serialVersionUID = -8097817288192073987L;
-
- // Utils
- private boolean sortChildren = true;
- private JcrItemsComparator itemComparator = new JcrItemsComparator();
-
- public Object[] getElements(Object parent) {
- return getChildren(parent);
- }
-
- public Object getParent(Object child) {
- return null;
- }
-
- public Object[] getChildren(Object parent) {
- Object[] elements = null;
- try {
- if (parent instanceof Node) {
- Node node = (Node) parent;
- NodeIterator ni = node.getNodes();
- List<Node> nodesList = new ArrayList<Node>();
- while (ni.hasNext()) {
- nodesList.add(ni.nextNode());
- }
- if (sortChildren) {
- Node[] arr = (Node[]) nodesList.toArray(new Node[nodesList
- .size()]);
- Arrays.sort(arr, itemComparator);
- return arr;
- } else
- return nodesList.toArray();
-
- }
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected exception while listing node properties", e);
- }
- return elements;
- }
-
- public boolean hasChildren(Object parent) {
- try {
- if (parent instanceof Node) {
- Node curNode = (Node) parent;
- // We manually stop digging at this level
- if (curNode.isNodeType(SLC_ARTIFACT_VERSION_BASE))
- return false;
- else if (curNode.hasNodes())
- return true;
- }
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected exception while checking if property is multiple",
- e);
- }
- return false;
- }
-
- public void setSortChildren(boolean sortChildren) {
- this.sortChildren = sortChildren;
- }
-
- public boolean getSortChildren() {
- return sortChildren;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.controllers;
-
-import javax.jcr.Credentials;
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.RepoUtils;
-
-/**
- * Provide shortcuts to retrieve sessions, repositories and workspaces that are
- * persisted in the current user node using path only.
- */
-public class DistSessionFactory {
-
- /* DEPENDENCY INJECTION */
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Repository nodeRepository;
-
- /**
- * Returns a new session on the given workspace. This session *must* be
- * disposed by the caller. If the workspace does not exist and
- * createIfNeeded==true, tries to create it
- *
- * */
- public Session getSessionFromWorkspacePath(String path,
- boolean createIfNeeded) {
- Session nodeSession = null;
- try {
- nodeSession = nodeRepository.login();
- Node localWksp = nodeSession.getNode(path);
- Repository repository = RepoUtils.getRepository(repositoryFactory,
- keyring, localWksp.getParent());
- Credentials credentials = RepoUtils.getRepositoryCredentials(
- keyring, localWksp.getParent());
-
- String wkspName = JcrUtils.lastPathElement(path);
- Session session = null;
- try {
- session = repository.login(credentials, wkspName);
- } catch (NoSuchWorkspaceException e) {
- if (createIfNeeded) {
- Session defaultSession = repository.login(credentials);
- try {
- defaultSession.getWorkspace().createWorkspace(wkspName);
- } catch (Exception e1) {
- throw new SlcException("Cannot create new workspace "
- + wkspName, e);
- } finally {
- JcrUtils.logoutQuietly(defaultSession);
- }
- session = repository.login(credentials, wkspName);
- } else
- throw new SlcException("Workspace" + wkspName
- + "does not exists and should not be created", e);
- }
- return session;
- } catch (RepositoryException e) {
- throw new SlcException("cannot create session" + " for workspace "
- + path, e);
- } finally {
- JcrUtils.logoutQuietly(nodeSession);
- }
- }
-
- /*
- * DEPENDENCY INJECTION
- */
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-
- public void setRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.controllers;
-
-import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
-import org.argeo.slc.client.ui.dist.utils.NameVersionComparator;
-import org.argeo.slc.client.ui.dist.utils.VersionComparator;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-
-/** Specific comparator to enhance Distribution tree browsers */
-public class DistTreeComparator extends ViewerComparator {
- private static final long serialVersionUID = -7386716562202568704L;
-
- private VersionComparator vc = new VersionComparator();
- private NameVersionComparator nvc = new NameVersionComparator();
-
- public int category(Object element) {
- if (element instanceof RepoElem)
- if (((RepoElem) element).inHome())
- // Home repository always first
- return 2;
- else
- return 5;
- else if (element instanceof WkspGroupElem)
- return 10;
- else if (element instanceof WorkspaceElem)
- return 15;
- else
- return 20;
- }
-
- public int compare(Viewer viewer, Object e1, Object e2) {
- int cat1 = category(e1);
- int cat2 = category(e2);
-
- if (cat1 != cat2) {
- return cat1 - cat2;
- }
-
- String s1, s2;
-
- if (e1 instanceof DistParentElem) {
- s1 = ((DistParentElem) e1).getName();
- s2 = ((DistParentElem) e2).getName();
- } else {
- s1 = e1.toString();
- s2 = e2.toString();
- }
-
- if (e1 instanceof WorkspaceElem)
- // Reverse order for nameversions
- return nvc.compare(viewer, s2, s1);
- else if (e1 instanceof ModularDistVersionElem)
- // Reverse order for versions
- return vc.compare(viewer, s2, s1);
- else
- return s1.compareTo(s2);
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.controllers;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.eclipse.jface.viewers.IElementComparer;
-
-/** Compares two elements of the Distribution tree */
-public class DistTreeComparer implements IElementComparer {
-
- public int hashCode(Object element) {
- if (element instanceof TreeParent)
- return ((TreeParent) element).hashCode();
- else
-
- return element.getClass().toString().hashCode();
- }
-
- public boolean equals(Object elementA, Object elementB) {
- if (!(elementA instanceof TreeParent)
- || !(elementB instanceof TreeParent)) {
- return elementA == null ? elementB == null : elementA
- .equals(elementB);
- } else {
- TreeParent tpA = ((TreeParent) elementA);
- TreeParent tpB = ((TreeParent) elementB);
- return tpA.compareTo(tpB) == 0;
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.controllers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Enables browsing in local and remote SLC software repositories. Keyring and
- * repository factory must be injected
- */
-public class DistTreeContentProvider implements ITreeContentProvider {
- private static final long serialVersionUID = -7640840211717811421L;
-
- /* DEPENDENCY INJECTION */
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
-
- // Context
- private Session nodeSession;
- List<RepoElem> repositories = new ArrayList<RepoElem>();
-
- public Object[] getElements(Object input) {
- Repository nodeRepository = (Repository) input;
- try {
- if (nodeSession != null)
- dispose();
- nodeSession = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
-
- String reposPath = NodeUtils.getUserHome(nodeSession).getPath() + RepoConstants.REPOSITORIES_BASE_PATH;
-
- if (!nodeSession.itemExists(reposPath))
- initializeModel(nodeSession);
-
- NodeIterator repos = nodeSession.getNode(reposPath).getNodes();
- while (repos.hasNext()) {
- Node repoNode = repos.nextNode();
- if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
- String label = repoNode.isNodeType(NodeType.MIX_TITLE)
- ? repoNode.getProperty(Property.JCR_TITLE).getString()
- : repoNode.getName();
- repositories.add(new RepoElem(repositoryFactory, keyring, repoNode, label));
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get base elements", e);
- }
- return repositories.toArray();
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- // @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TreeParent)
- return ((TreeParent) parentElement).getChildren();
- else
- return null;
- }
-
- // @Override
- public Object getParent(Object element) {
- if (element instanceof TreeParent)
- return ((TreeParent) element).getParent();
- return null;
- }
-
- // @Override
- public boolean hasChildren(Object element) {
- if (element instanceof TreeParent)
- return ((TreeParent) element).hasChildren();
- else
- return false;
- }
-
- public void dispose() {
- for (RepoElem repoElem : repositories)
- repoElem.dispose();
- repositories = new ArrayList<RepoElem>();
- JcrUtils.logoutQuietly(nodeSession);
- }
-
- private void initializeModel(Session nodeSession) {
- try {
- Node homeNode = NodeUtils.getUserHome(nodeSession);
- if (homeNode == null) // anonymous
- throw new SlcException("User must be authenticated.");
-
- // make sure base directory is available
- Node repos = JcrUtils.mkdirs(homeNode, RepoConstants.REPOSITORIES_BASE_PATH, null);
- if (nodeSession.hasPendingChanges())
- nodeSession.save();
-
- // register default local java repository
- String alias = RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS;
- Repository javaRepository = NodeUtils.getRepositoryByAlias(repositoryFactory, alias);
- if (javaRepository != null) {
- if (!repos.hasNode(alias)) {
- Node repoNode = repos.addNode(alias, ArgeoTypes.ARGEO_REMOTE_REPOSITORY);
- repoNode.setProperty(ArgeoNames.ARGEO_URI, "vm:///" + alias);
- repoNode.addMixin(NodeType.MIX_TITLE);
- repoNode.setProperty(Property.JCR_TITLE, RepoConstants.DEFAULT_JAVA_REPOSITORY_LABEL);
- nodeSession.save();
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot initialize model", e);
- }
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.controllers;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.client.ui.dist.commands.OpenWorkspaceEditor;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-
-/** Listen to double-clicks on the distributions view tree. */
-public class DistTreeDoubleClickListener implements IDoubleClickListener {
-
- private TreeViewer treeViewer;
-
- public DistTreeDoubleClickListener(TreeViewer treeViewer) {
- this.treeViewer = treeViewer;
- }
-
- public void doubleClick(DoubleClickEvent event) {
- if (event.getSelection() == null || event.getSelection().isEmpty())
- return;
- Object obj = ((IStructuredSelection) event.getSelection())
- .getFirstElement();
-
- if (obj instanceof RepoElem) {
- RepoElem rpNode = (RepoElem) obj;
- if (!rpNode.isConnected()) {
- rpNode.login();
- treeViewer.refresh(obj);
- }
- } else if (obj instanceof WorkspaceElem) {
- WorkspaceElem we = (WorkspaceElem) obj;
- RepoElem repoElem = we.getRepoElem();
- Map<String, String> params = new HashMap<String, String>();
- params.put(OpenWorkspaceEditor.PARAM_REPO_NODE_PATH,
- repoElem.getRepoNodePath());
- params.put(OpenWorkspaceEditor.PARAM_REPO_URI, repoElem.getUri());
- params.put(OpenWorkspaceEditor.PARAM_WORKSPACE_NAME,
- we.getWorkspaceName());
- CommandUtils.callCommand(OpenWorkspaceEditor.ID, params);
-
- } else if (obj instanceof ModularDistVersionElem) {
- ModularDistVersionElem modDistElem = (ModularDistVersionElem) obj;
- WorkspaceElem wkspElem = modDistElem.getWorkspaceElem();
- Node moduleNode = modDistElem.getModularDistVersionNode();
- RepoElem repoElem = wkspElem.getRepoElem();
- Map<String, String> params = new HashMap<String, String>();
- params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
- repoElem.getRepoNodePath());
- params.put(OpenModuleEditor.PARAM_REPO_URI, repoElem.getUri());
- params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
- wkspElem.getWorkspaceName());
- try {
- params.put(OpenModuleEditor.PARAM_MODULE_PATH,
- moduleNode.getPath());
- } catch (RepositoryException re) {
- throw new SlcException("Cannot get path for node " + moduleNode
- + " while setting parameters for "
- + "command OpenModuleEditor", re);
- }
- CommandUtils.callCommand(OpenModuleEditor.ID, params);
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.controllers;
-
-import org.argeo.cms.ui.jcr.JcrImages;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/** Manage icons and labels for the Distributions tree browser */
-public class DistTreeLabelProvider extends ColumnLabelProvider {
- private static final long serialVersionUID = -7889294105284404373L;
-
- @Override
- public String getText(Object element) {
- if (element instanceof DistParentElem)
- return ((DistParentElem) element).getName();
- else
- return element.toString();
- }
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof RepoElem) {
- RepoElem re = ((RepoElem) element);
- if (re.inHome())
- return DistImages.IMG_HOME_REPO;
- else if (re.isConnected())
- return JcrImages.REPOSITORY_CONNECTED;
- else
- return JcrImages.REPOSITORY_DISCONNECTED;
- } else if (element instanceof WorkspaceElem) {
- return JcrImages.WORKSPACE_CONNECTED;
- } else if (element instanceof WkspGroupElem)
- return DistImages.IMG_WKSP_GROUP;
- // else if (element instanceof GroupBaseElem)
- // return DistImages.IMG_GROUP_BASE;
- else if (element instanceof ModularDistVersionBaseElem)
- return DistImages.IMG_MODULAR_DIST_BASE;
- else if (element instanceof ModularDistVersionElem)
- return DistImages.IMG_MODULAR_DIST_VERSION;
- return super.getImage(element);
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/** Artifact editor in a multiple repository environment */
-public class ArtifactVersionEditor extends FormEditor implements SlcNames {
- private static final long serialVersionUID = 1109872666962757000L;
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".artifactVersionEditor";
-
- /* DEPENDENCY INJECTION */
- private RepoService repoService;
-
- // Business Objects
- private Session businessSession;
- private Node artifact;
-
- private ModuleEditorInput editorInput;
-
- @Override
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
- editorInput = (ModuleEditorInput) input;
- businessSession = repoService.getRemoteSession(
- editorInput.getRepoNodePath(), editorInput.getUri(),
- editorInput.getWorkspaceName());
- try {
- artifact = businessSession.getNode(editorInput.getModulePath());
- } catch (RepositoryException e) {
- throw new PartInitException(
- "Unable to initialise editor for artifact "
- + editorInput.getModulePath() + " in workspace "
- + editorInput.getWorkspaceName(), e);
- }
- super.init(site, input);
- }
-
- /** Override to provide a specific part name */
- protected String getFormattedName() {
- try {
- String partName = null;
- if (artifact.hasProperty(SLC_ARTIFACT_ID))
- partName = artifact.getProperty(SLC_ARTIFACT_ID).getString();
- else
- partName = artifact.getName();
-
- if (partName.length() > 10) {
- partName = "..." + partName.substring(partName.length() - 10);
- }
- return partName;
- } catch (RepositoryException re) {
- throw new SlcException(
- "unable to get slc:artifactId Property for node "
- + artifact, re);
- }
- }
-
- @Override
- protected void addPages() {
- setPartName(getFormattedName());
-
- try {
- addPage(new BundleDetailPage(this, "Details ", artifact));
- addPage(new BundleDependencyPage(this, "Dependencies ", artifact));
- addPage(new BundleRawPage(this, "Raw Meta-Data ", artifact));
- } catch (PartInitException e) {
- throw new SlcException("Cannot add distribution editor pages", e);
- }
-
- }
-
- @Override
- public void doSave(IProgressMonitor arg0) {
- }
-
- @Override
- public void dispose() {
- JcrUtils.logoutQuietly(businessSession);
- super.dispose();
- }
-
- @Override
- public void doSaveAs() {
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- protected RepoService getRepoService() {
- return repoService;
- }
-
- protected Node getArtifact() {
- return artifact;
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepoService(RepoService repoService) {
- this.repoService = repoService;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * Present main information of a given OSGI bundle
- */
-public class BundleDependencyPage extends FormPage implements SlcNames {
- // private final static Log log =
- // LogFactory.getLog(ArtifactDetailsPage.class);
-
- // Main business Objects
- private Node currBundle;
-
- // This page widgets
- private FormToolkit toolkit;
-
- public BundleDependencyPage(FormEditor editor, String title,
- Node currentNode) {
- super(editor, "id", title);
- this.currBundle = currentNode;
- }
-
- protected void createFormContent(IManagedForm managedForm) {
- ScrolledForm form = managedForm.getForm();
- toolkit = managedForm.getToolkit();
- try {
- if (currBundle.hasProperty(DistConstants.SLC_BUNDLE_NAME))
- form.setText(currBundle.getProperty(
- DistConstants.SLC_BUNDLE_NAME).getString());
- Composite body = form.getBody();
- GridLayout layout = new GridLayout(1, false);
- layout.horizontalSpacing = layout.marginWidth = 0;
- layout.verticalSpacing = layout.marginHeight = 0;
- body.setLayout(layout);
-
- Composite part = toolkit.createComposite(body);
- createExportPackageSection(part);
- GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
- gd.heightHint = 180;
- part.setLayoutData(gd);
-
- part = toolkit.createComposite(body);
- createImportPackageSection(part);
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- // gd.heightHint = 200;
- part.setLayoutData(gd);
-
- part = toolkit.createComposite(body);
- createReqBundleSection(part);
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- part.setLayoutData(gd);
-
- managedForm.reflow(true);
-
- } catch (RepositoryException e) {
- throw new SlcException("unexpected error "
- + "while creating bundle details page");
- }
- }
-
- // Workaround to add an artificial level to the export package browser
- private class LevelElem {
- private String label;
- private Object parent;
-
- public LevelElem(String label, Object parent) {
- this.label = label;
- this.parent = parent;
- }
-
- public String toString() {
- return label;
- }
-
- public Object getParent() {
- return parent;
- }
- }
-
- /** Export Package Section */
- private void createExportPackageSection(Composite parent)
- throws RepositoryException {
- parent.setLayout(new GridLayout());
-
- // Define the TableViewer
-
- Section section = addSection(parent, "Export packages");
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- TreeViewer viewer = new TreeViewer(section, SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.BORDER);
- final Tree tree = viewer.getTree();
- tree.setHeaderVisible(false);
- tree.setLinesVisible(true);
- tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.FILL);
- col.getColumn().setWidth(400);
-
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 1376400790495130862L;
-
- @Override
- public String getText(Object element) {
- if (element instanceof Node)
- return JcrUtils.get((Node) element, SlcNames.SLC_NAME);
- else
- return element.toString();
- }
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof Node) {
- try {
- Node node = (Node) element;
- if (node.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE))
- return DistImages.IMG_PACKAGE;
- } catch (RepositoryException e) {
- throw new SlcException("Error retriving "
- + "image for the labelProvider", e);
- }
- }
- return null;
- }
- });
-
- viewer.setContentProvider(new ITreeContentProvider() {
- private static final long serialVersionUID = 1898086304761992568L;
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- }
-
- public Object[] getElements(Object inputElement) {
- try {
- List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
- currBundle, SlcTypes.SLC_EXPORTED_PACKAGE,
- SlcNames.SLC_NAME));
- return nodes.toArray();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot list children Nodes", e);
- }
- }
-
- public Object[] getChildren(Object parentElement) {
- // Only 2 levels for the time being
- try {
- if (parentElement instanceof LevelElem) {
- Node node = (Node) ((LevelElem) parentElement)
- .getParent();
- List<Node> nodes = JcrUtils
- .nodeIteratorToList(listNodes(node,
- SlcTypes.SLC_JAVA_PACKAGE,
- SlcNames.SLC_NAME));
- return nodes.toArray();
- } else if (parentElement instanceof Node) {
- Node pNode = (Node) parentElement;
- if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
- if (listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
- SlcNames.SLC_NAME).getSize() > 0) {
- Object[] result = { new LevelElem("uses", pNode) };
- return result;
- }
- }
- }
- return null;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot list children Nodes", e);
- }
- }
-
- public Object getParent(Object element) {
- // useless
- return null;
- }
-
- public boolean hasChildren(Object element) {
- try {
- if (element instanceof LevelElem)
- return true;
- else {
- Node pNode = (Node) element;
- if (pNode.isNodeType(SlcTypes.SLC_EXPORTED_PACKAGE)) {
- return listNodes(pNode, SlcTypes.SLC_JAVA_PACKAGE,
- SlcNames.SLC_NAME).getSize() > 0;
- }
- }
- return false;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot check children Nodes", e);
- }
- }
- });
-
- section.setClient(tree);
- viewer.setInput("Initialize");
- // work around a display problem : the tree table has only a few lines
- // when the tree is not expended
- // viewer.expandToLevel(2);
- }
-
- /** Import Package Section */
- private void createImportPackageSection(Composite parent)
- throws RepositoryException {
- parent.setLayout(new GridLayout());
-
- // Define the TableViewer
- // toolkit.createLabel(parent, "Import packages", SWT.NONE).setFont(
- // EclipseUiUtils.getBoldFont(parent));
-
- Section section = addSection(parent, "Import packages");
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- TableViewer viewer = new TableViewer(section, SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.BORDER);
-
- final Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // Name
- TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(350);
- col.getColumn().setText("Name");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -7836022945221936898L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_NAME);
- }
-
- public Image getImage(Object element) {
- return DistImages.IMG_PACKAGE;
- }
-
- });
-
- // Version
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(100);
- col.getColumn().setText("Version");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -8277731617775091641L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_VERSION);
- }
- });
-
- // Optional
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(100);
- col.getColumn().setText("Optional");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -2388533169594840688L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_OPTIONAL);
- }
- });
-
- viewer.setContentProvider(new TableContentProvider(
- SlcTypes.SLC_IMPORTED_PACKAGE, SLC_NAME));
- section.setClient(table);
- viewer.setInput("Initialize");
- }
-
- /** Required Bundle Section */
- private void createReqBundleSection(Composite parent)
- throws RepositoryException {
- parent.setLayout(new GridLayout());
-
- // Define the TableViewer
- Section section = addSection(parent, "Required bundles");
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // toolkit.createLabel(parent, "Required bundles", SWT.NONE).setFont(
- // EclipseUiUtils.getBoldFont(parent));
- TableViewer viewer = new TableViewer(section, SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.BORDER);
-
- final Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // Name
- TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(300);
- col.getColumn().setText("Name");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 4423640365819800247L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
- }
-
- @Override
- public Image getImage(Object element) {
- return DistImages.IMG_BUNDLE;
- }
- });
-
- // Version
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(140);
- col.getColumn().setText("Version");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 1898477425996646270L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
- }
- });
-
- // Optional
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(100);
- col.getColumn().setText("Optional");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -7029999152302445581L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_OPTIONAL);
- }
- });
-
- viewer.setContentProvider(new TableContentProvider(
- SlcTypes.SLC_REQUIRED_BUNDLE, SLC_SYMBOLIC_NAME));
- section.setClient(table);
- viewer.setInput("Initialize");
- }
-
- /**
- * Build repository request
- *
- * FIXME Workaround for remote repository, the path to bundleartifact (for
- * instance
- * .../org/argeo/slc/org.argeo.slc.client.ui.dist/1.1.12/org.argeo.slc
- * .client.ui.dist-1.1.12/ ) is not valid for method factory.childNode(); it
- * fails parsing the "1.1.12" part, trying to cast it as a BigDecimal
- *
- * */
- private NodeIterator listNodes(Node parent, String nodeType, String orderBy)
- throws RepositoryException {
- // QueryManager queryManager = currBundle.getSession().getWorkspace()
- // .getQueryManager();
- // QueryObjectModelFactory factory = queryManager.getQOMFactory();
- //
- // final String nodeSelector = "nodes";
- // Selector source = factory.selector(nodeType, nodeSelector);
- //
- // Constraint childOf = factory.childNode(nodeSelector,
- // parent.getPath());
- //
- // Ordering order =
- // factory.ascending(factory.propertyValue(nodeSelector,
- // orderBy));
- // Ordering[] orderings = { order };
- //
- // QueryObjectModel query = factory.createQuery(source, childOf,
- // orderings, null);
- //
- // QueryResult result = query.execute();
-
- String pattern = null;
- if (SlcTypes.SLC_EXPORTED_PACKAGE.equals(nodeType))
- pattern = "slc:Export-Package*";
- else if (SlcTypes.SLC_JAVA_PACKAGE.equals(nodeType))
- pattern = "slc:uses*";
- else if (SlcTypes.SLC_IMPORTED_PACKAGE.equals(nodeType))
- pattern = "slc:Import-Package*";
- else if (SlcTypes.SLC_REQUIRED_BUNDLE.equals(nodeType))
- pattern = "slc:Require-Bundle*";
-
- return parent.getNodes(pattern);
- }
-
- private class TableContentProvider implements IStructuredContentProvider {
- private static final long serialVersionUID = 4133284637336320455L;
- private String nodeType;
- private String orderBy;
-
- TableContentProvider(String nodeType, String orderBy) {
- this.nodeType = nodeType;
- this.orderBy = orderBy;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public Object[] getElements(Object arg0) {
- try {
- List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
- currBundle, nodeType, orderBy));
- return nodes.toArray();
- } catch (RepositoryException e) {
- ErrorFeedback.show("Cannot list children Nodes", e);
- return null;
- }
- }
- }
-
- /* HELPERS */
- private Section addSection(Composite parent, String title) {
- Section section = toolkit.createSection(parent, Section.TITLE_BAR);
- section.setText(title);
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- return section;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.net.URL;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.build.License;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.utils.HyperlinkAdapter;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.browser.IWebBrowser;
-import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-
-/** Show details for a given bundle. */
-public class BundleDetailPage extends FormPage implements SlcNames {
- private final static Log log = LogFactory.getLog(BundleDetailPage.class);
-
- final static String PAGE_ID = "BundleDetailPage";
-
- // Business Objects
- private Node bundle;
-
- // This page widgets
- private FormToolkit tk;
-
- public BundleDetailPage(FormEditor formEditor, String title, Node bundle) {
- super(formEditor, PAGE_ID, title);
- this.bundle = bundle;
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- // General settings for this page
- ScrolledForm form = managedForm.getForm();
- tk = managedForm.getToolkit();
- Composite body = form.getBody();
-
- GridLayout layout = new GridLayout(1, false);
- layout.marginWidth = 5;
- layout.marginRight = 15;
- layout.verticalSpacing = 0;
- body.setLayout(layout);
- try {
- form.setText(bundle.hasProperty(SlcNames.SLC_SYMBOLIC_NAME) ? bundle
- .getProperty(SlcNames.SLC_SYMBOLIC_NAME).getString() : "");
- form.setMessage(bundle
- .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? bundle
- .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
- .getString() : "", IMessageProvider.NONE);
- } catch (RepositoryException re) {
- throw new SlcException("Unable to get bundle name for node "
- + bundle, re);
- }
-
- // Main layout
- Composite header = tk.createComposite(body);
- header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- populateHeaderPart(header);
-
- Composite mavenSnipet = tk.createComposite(body);
- mavenSnipet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- populateMavenSnippetPart(mavenSnipet);
- }
-
- private void populateHeaderPart(Composite parent) {
- GridLayout layout = new GridLayout(6, false);
- // layout.marginWidth = layout.horizontalSpacing = layout.marginHeight =
- // 0;
- layout.horizontalSpacing = 10;
- parent.setLayout(layout);
- try {
- // 1st Line: Category, name version
- createLT(parent, "Category",
- bundle.hasProperty(SlcNames.SLC_GROUP_ID) ? bundle
- .getProperty(SlcNames.SLC_GROUP_ID).getString()
- : "");
- createLT(parent, "Name",
- bundle.hasProperty(SlcNames.SLC_ARTIFACT_ID) ? bundle
- .getProperty(SlcNames.SLC_ARTIFACT_ID).getString()
- : "");
- createLT(parent, "Version",
- bundle.hasProperty(SlcNames.SLC_ARTIFACT_VERSION) ? bundle
- .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
- .getString() : "");
-
- // 3rd Line: Vendor, licence, sources
- createLT(
- parent,
- "Vendor",
- bundle.hasProperty(DistConstants.SLC_BUNDLE_VENDOR) ? bundle
- .getProperty(DistConstants.SLC_BUNDLE_VENDOR)
- .getString() : "N/A");
-
- createLicencesLink(parent, "Licence",
- DistConstants.SLC_BUNDLE_LICENCE);
- addSourceLink(parent);
-
- // 2nd Line: The Jar itself and the Manifest
- createJarLink(parent);
- createManifestLink(parent);
-
- // Last line
- createPomLink(parent);
-
- } catch (RepositoryException re) {
- throw new SlcException("Unable to get bundle name for node "
- + bundle, re);
- }
-
- }
-
- private void populateMavenSnippetPart(Composite parent) {
- GridLayout layout = new GridLayout(1, false);
- layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
- parent.setLayout(layout);
-
- Section section = tk.createSection(parent, Section.TITLE_BAR
- | Section.DESCRIPTION);
- section.setText("Maven");
- section.setDescription("Add the below tag to your Artifact pom dependencies");
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Text snippetTxt = createMavenSnippet(section);
- section.setClient(snippetTxt);
- }
-
- // /////////////////////
- // HELPERS
-
- private Text createLT(Composite parent, String labelValue, String textValue) {
- Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
- // label.setFont(EclipseUiUtils.getBoldFont(parent));
- label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
- // Add a trailing space to workaround a display glitch in RAP 1.3
- Text text = new Text(parent, SWT.LEFT);
- text.setText(textValue + " ");
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- text.setEditable(false);
- return text;
- }
-
- private void createLicencesLink(Composite parent, String label,
- String jcrPropName) throws RepositoryException {
- tk.createLabel(parent, label, SWT.NONE);
- if (bundle.hasProperty(jcrPropName)) {
-
- String licenceLinkVal = bundle.getProperty(jcrPropName).getString();
-
- // FIXME Hack until license generation is done cleanly
- // Problem is with description that contains a "," like
- // "Apache License, Version 2"
- String[] licenceVals;
- if (licenceLinkVal.contains("description="))
- licenceVals = new String[] { licenceLinkVal };
- else
- // multiple license, form non-regenerated manifests
- licenceVals = licenceLinkVal.split(", ");
-
- Composite body = tk.createComposite(parent);
- body.setLayout(new RowLayout(SWT.WRAP));
-
- for (final String value : licenceVals) {
- final License currLicense = parseLicenseString(value);
-
- Hyperlink link = tk.createHyperlink(body,
- currLicense.getName(), SWT.NONE);
- link.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent e) {
- try {
- IWorkbenchBrowserSupport browserSupport = PlatformUI
- .getWorkbench().getBrowserSupport();
- IWebBrowser browser = browserSupport
- .createBrowser(
- IWorkbenchBrowserSupport.LOCATION_BAR
- | IWorkbenchBrowserSupport.NAVIGATION_BAR,
- "SLC Distribution browser",
- "SLC Distribution browser",
- "A tool tip");
- browser.openURL(new URL(currLicense.getUri()));
- } catch (Exception ex) {
- throw new SlcException("error opening browser", ex); //$NON-NLS-1$
- }
- }
- });
- }
- } else
- tk.createLabel(parent, "N/A", SWT.NONE);
- }
-
- // TODO this must be moved to a better place once the standard has been
- // defined
- // Enable licence encoding in a single JCR Value
- private final static String LICENSE_SEPARATOR = ";";
- // The human readable name of the licence
- private final static String LICENSE_NAME = "description";
- // A link on the internet with some more info on this licence
- private final static String LICENSE_LINK = "link";
-
- private License parseLicenseString(String licenseStr) {
- String uri = null, name = null, link = null, text = null;
- // TODO enhance this
- String[] values = licenseStr.split(LICENSE_SEPARATOR);
- for (String value : values) {
- if (value.startsWith(LICENSE_NAME))
- name = value.substring(LICENSE_NAME.length() + 1); // +1 for the
- // '='
- else if (value.startsWith(LICENSE_LINK))
- link = value.substring(LICENSE_LINK.length() + 1);
- else if (uri == null)
- uri = value;
- // TODO manage text
- }
- return new SimpleLicense(name, uri, link, text);
- }
-
- class SimpleLicense implements License {
- private final String name;
- private final String uri;
- private final String link;
- private final String text;
-
- public SimpleLicense(String name, String uri, String link, String text) {
- if (uri == null)
- throw new SlcException(
- "Cannot manage a licence with a null URI ");
- this.uri = uri;
-
- this.name = name;
- this.link = link;
- this.text = text;
- }
-
- public String getUri() {
- return uri;
- }
-
- public String getText() {
- return text;
- }
-
- public String getName() {
- return name != null ? name : uri;
- }
-
- public String getLink() {
- return link;
- }
- }
-
- private void createJarLink(Composite parent) throws RepositoryException {
- Label label = tk.createLabel(parent, "Jar", SWT.RIGHT);
- label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
- Composite body = tk.createComposite(parent);
- RowLayout rl = new RowLayout(SWT.HORIZONTAL);
- rl.spacing = 6;
- body.setLayout(rl);
- body.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
-
- Hyperlink jarLink = tk
- .createHyperlink(body, bundle.getName(), SWT.NONE);
- jarLink.addHyperlinkListener(new OpenFileLinkListener(bundle.getPath()));
-
- // Corresponding check sums
-
- String name = bundle.getName() + ".md5";
- if (bundle.getParent().hasNode(name)) {
- Node md5 = bundle.getParent().getNode(name);
- Hyperlink md5Link = tk.createHyperlink(body, "MD5", SWT.NONE);
- md5Link.addHyperlinkListener(new OpenFileLinkListener(md5.getPath()));
- }
-
- name = bundle.getName() + ".sha1";
- if (bundle.getParent().hasNode(name)) {
- Node sha1 = bundle.getParent().getNode(name);
- Hyperlink sha1Link = tk.createHyperlink(body, "SHA1", SWT.NONE);
- sha1Link.addHyperlinkListener(new OpenFileLinkListener(sha1
- .getPath()));
- }
- }
-
- private void createPomLink(Composite parent) throws RepositoryException {
- Label label = tk.createLabel(parent, "Pom", SWT.RIGHT);
- label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
- String name = bundle.getName().substring(0,
- bundle.getName().length() - "jar".length())
- + "pom";
-
- if (bundle.getParent().hasNode(name)) {
- Node pom = bundle.getParent().getNode(name);
-
- Composite body = tk.createComposite(parent);
- RowLayout rl = new RowLayout(SWT.HORIZONTAL);
- rl.spacing = 6;
- body.setLayout(rl);
- body.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
- 3, 1));
-
- Hyperlink pomLink = tk.createHyperlink(body, "pom.xml", SWT.NONE);
- pomLink.addHyperlinkListener(new OpenFileLinkListener(pom.getPath()));
-
- // Corresponding check sums
- name = pom.getName() + ".md5";
- if (pom.getParent().hasNode(name)) {
- Node md5 = pom.getParent().getNode(name);
- Hyperlink md5Link = tk.createHyperlink(body, "MD5", SWT.NONE);
- md5Link.addHyperlinkListener(new OpenFileLinkListener(md5
- .getPath()));
- }
-
- name = pom.getName() + ".sha1";
- if (pom.getParent().hasNode(name)) {
- Node sha1 = pom.getParent().getNode(name);
- Hyperlink sha1Link = tk.createHyperlink(body, "SHA1", SWT.NONE);
- sha1Link.addHyperlinkListener(new OpenFileLinkListener(sha1
- .getPath()));
- }
- } else
- tk.createLabel(parent, "N/A", SWT.NONE);
- }
-
- private void createManifestLink(Composite parent)
- throws RepositoryException {
- tk.createLabel(parent, "Manifest", SWT.NONE);
- // Hyperlink link =
- // TODO fix this when file download has been implemented for the
- // manifest
- tk.createHyperlink(parent, "MANIFEST.MF", SWT.NONE);
- // link.addHyperlinkListener(new
- // OpenFileLinkListener(bundle.getPath()));
- }
-
- // private void createHyperlink(Composite parent, String label,
- // String jcrPropName) throws RepositoryException {
- // tk.createLabel(parent, label, SWT.NONE);
- // if (bundle.hasProperty(jcrPropName)) {
- // final Hyperlink link = tk.createHyperlink(parent, bundle
- // .getProperty(jcrPropName).getString(), SWT.NONE);
- // link.addHyperlinkListener(new AbstractHyperlinkListener() {
- // @Override
- // public void linkActivated(HyperlinkEvent e) {
- // try {
- // IWorkbenchBrowserSupport browserSupport = PlatformUI
- // .getWorkbench().getBrowserSupport();
- // IWebBrowser browser = browserSupport
- // .createBrowser(
- // IWorkbenchBrowserSupport.LOCATION_BAR
- // | IWorkbenchBrowserSupport.NAVIGATION_BAR,
- // "SLC Distribution browser",
- // "SLC Distribution browser",
- // "A tool tip");
- // browser.openURL(new URL(link.getText()));
- // } catch (Exception ex) {
- // throw new SlcException("error opening browser", ex); //$NON-NLS-1$
- // }
- // }
- // });
- // } else
- // tk.createLabel(parent, "N/A", SWT.NONE);
- // }
-
- // helper to check if sources are available
- private void addSourceLink(Composite parent) {
- try {
- String srcPath = RepoUtils.relatedPdeSourcePath(
- RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, bundle);
- if (!bundle.getSession().nodeExists(srcPath)) {
- createLT(parent, "Sources", "N/A");
- } else {
- final Node sourcesNode = bundle.getSession().getNode(srcPath);
-
- String srcName = null;
- if (sourcesNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME))
- srcName = sourcesNode.getProperty(
- SlcNames.SLC_SYMBOLIC_NAME).getString();
- else
- srcName = sourcesNode.getName();
- Label label = tk.createLabel(parent, "Sources", SWT.RIGHT);
- label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
- false));
- final Hyperlink link = tk.createHyperlink(parent, srcName,
- SWT.NONE);
- link.addHyperlinkListener(new OpenFileLinkListener(sourcesNode
- .getPath()));
-
- // {
- // @Override
- // public void linkActivated(HyperlinkEvent e) {
- // try {
- // ModuleEditorInput editorInput = (ModuleEditorInput)
- // getEditorInput();
- // Map<String, String> params = new HashMap<String, String>();
- // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
- // editorInput.getRepoNodePath());
- // params.put(OpenJcrFile.PARAM_REPO_URI,
- // editorInput.getUri());
- // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
- // editorInput.getWorkspaceName());
- // params.put(OpenJcrFile.PARAM_FILE_PATH,
- // );
- // CommandUtils.callCommand(OpenJcrFile.ID, params);
- // } catch (Exception ex) {
- // throw new SlcException("error opening browser", ex); //$NON-NLS-1$
- // }
- // }
- // });
-
- }
- } catch (RepositoryException e) {
- throw new SlcException("Unable to configure sources link for "
- + bundle, e);
- }
- }
-
- private class OpenFileLinkListener extends HyperlinkAdapter {
- final private String path;
-
- public OpenFileLinkListener(String path) {
- this.path = path;
- }
-
- @Override
- public void linkActivated(HyperlinkEvent e) {
- log.warn("File download must be implemented. Cannot provide access to "
- + path);
-
- // try {
- // ModuleEditorInput editorInput = (ModuleEditorInput)
- // getEditorInput();
- // Map<String, String> params = new HashMap<String, String>();
- // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
- // editorInput.getRepoNodePath());
- // params.put(OpenJcrFile.PARAM_REPO_URI, editorInput.getUri());
- // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
- // editorInput.getWorkspaceName());
- // params.put(OpenJcrFile.PARAM_FILE_PATH, path);
- //
- // String cmdId = (new OpenJcrFileCmdId()).getCmdId();
- // if (log.isTraceEnabled())
- // log.debug("Retrieved openFile Cmd ID: " + cmdId);
- // CommandUtils.callCommand(cmdId, params);
- // } catch (Exception ex) {
- // throw new SlcException("error opening browser", ex); //$NON-NLS-1$
- // }
- }
- }
-
- /** Creates a text area with corresponding maven snippet */
- private Text createMavenSnippet(Composite parent) {
- Text mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- gd.heightHint = 100;
- mavenSnippet.setLayoutData(gd);
- mavenSnippet.setText(generateXmlSnippet());
- return mavenSnippet;
- }
-
- private String generateXmlSnippet() {
- try {
- StringBuffer sb = new StringBuffer();
- sb.append("<dependency>\n");
- sb.append("\t<groupId>");
- sb.append(bundle.getProperty(SLC_GROUP_ID).getString());
- sb.append("</groupId>\n");
- sb.append("\t<artifactId>");
- sb.append(bundle.getProperty(SLC_ARTIFACT_ID).getString());
- sb.append("</artifactId>\n");
- sb.append("\t<version>");
- sb.append(bundle.getProperty(SLC_ARTIFACT_VERSION).getString());
- sb.append("</version>\n");
- sb.append("</dependency>");
- return sb.toString();
- } catch (RepositoryException re) {
- throw new SlcException(
- "unexpected error while generating maven snippet");
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.utils.DistUiHelpers;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/** List all properties of current bundle as a tree */
-public class BundleRawPage extends FormPage implements SlcNames, SlcTypes {
- // private final static Log log =
- // LogFactory.getLog(ArtifactDetailsPage.class);
-
- // Main business Objects
- private Node currBundle;
-
- // This page widgets
- private TreeViewer complexTree;
-
- public BundleRawPage(FormEditor editor, String title, Node currentNode) {
- super(editor, "id", title);
- this.currBundle = currentNode;
- }
-
- protected void createFormContent(IManagedForm managedForm) {
- ScrolledForm form = managedForm.getForm();
- GridLayout layout = new GridLayout(1, false);
- layout.marginWidth = 5;
- form.getBody().setLayout(layout);
- createViewer(form.getBody());
- }
-
- private void createViewer(Composite parent) {
-
- // Create the viewer
- int style = SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION;
- Tree tree = new Tree(parent, style);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = true;
- tree.setLayoutData(gd);
- createColumn(tree, "Attribute", SWT.LEFT, 200);
- createColumn(tree, "Value", SWT.LEFT, 200);
- tree.setLinesVisible(true);
- tree.setHeaderVisible(true);
-
- complexTree = new TreeViewer(tree);
- complexTree.setContentProvider(new TreeContentProvider());
- complexTree.setLabelProvider(new TreeLabelProvider());
-
- // Initialize
- complexTree.setInput(currBundle);
- // result.expandAll();
- complexTree.expandToLevel(2);
-
- }
-
- private static TreeColumn createColumn(Tree parent, String name, int style,
- int width) {
- TreeColumn result = new TreeColumn(parent, style);
- result.setText(name);
- result.setWidth(width);
- result.setMoveable(true);
- result.setResizable(true);
- return result;
- }
-
- // View specific object
- private class ViewSpecificItems {
- private String key;
- private Object value;
- private boolean isFolder;
- private Node curNode;
-
- public ViewSpecificItems(String key, Object value, boolean isFolder) {
- this.key = key;
- this.value = value;
- this.isFolder = isFolder;
- }
-
- public String getKey() {
- return key;
- }
-
- public void setNode(Node node) {
- this.curNode = node;
- }
-
- public Node getNode() {
- return curNode;
- }
-
- public Object getValue() {
- return value;
- }
-
- public boolean isFolder() {
- return isFolder;
- }
-
- }
-
- // providers
- private class TreeLabelProvider extends ColumnLabelProvider implements
- SlcTypes, SlcNames {
- private static final long serialVersionUID = -6385445983392621937L;
-
- public void update(ViewerCell cell) {
- try {
-
- int colIndex = cell.getColumnIndex();
- Object element = cell.getElement();
- if (element instanceof Property) {
- Property prop = (Property) element;
- if (colIndex == 0)
- cell.setText(DistUiHelpers.getLabelJcrName(prop
- .getName()));
- else if (colIndex == 1)
- cell.setText(DistUiHelpers.formatValueAsString(prop
- .getValue()));
-
- } else if (element instanceof ViewSpecificItems) {
- if (colIndex == 0)
- cell.setText(((ViewSpecificItems) element).getKey());
- else if (colIndex == 1)
- cell.setText(DistUiHelpers
- .formatAsString(((ViewSpecificItems) element)
- .getValue()));
-
- } else if (element instanceof Node) {
- Node node = (Node) element;
- if (colIndex == 0) {
- if (node.isNodeType(NodeType.NT_FILE)) {
- cell.setImage(DistImages.IMG_FILE);
- cell.setText(node.getName());
- } else if (node.isNodeType(SLC_IMPORTED_PACKAGE))
- cell.setText("Import package");
- else if (node.isNodeType(SLC_EXPORTED_PACKAGE))
- cell.setText("Export package");
-
- } else if (colIndex == 1) {
- if (node.isNodeType(SLC_ARTIFACT)) {
- StringBuffer sb = new StringBuffer("");
- if (node.hasProperty(SLC_ARTIFACT_CLASSIFIER)) {
- sb.append(node.getProperty(
- SLC_ARTIFACT_CLASSIFIER).getString());
- sb.append(" ");
- }
- if (node.hasProperty(SLC_ARTIFACT_EXTENSION))
- sb.append(node.getProperty(
- SLC_ARTIFACT_EXTENSION).getString());
- cell.setText(sb.toString());
- } else if (node.isNodeType(SLC_IMPORTED_PACKAGE)
- || node.isNodeType(SLC_EXPORTED_PACKAGE))
- cell.setText(node.getProperty(SLC_NAME).getString());
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException(
- "unexpected error while getting artifact information",
- e);
- }
- }
- }
-
- private class TreeContentProvider implements ITreeContentProvider {
- private static final long serialVersionUID = -4315686158836938052L;
-
- public Object[] getElements(Object parent) {
- List<Object> elements = new ArrayList<Object>();
-
- try {
- Node node = (Node) parent;
- elements = new ArrayList<Object>();
-
- // Maven coordinates
-// elements.add(node.getProperty(SLC_GROUP_ID));
-// elements.add(node.getProperty(SLC_ARTIFACT_ID));
-// elements.add(node.getProperty(SLC_ARTIFACT_VERSION));
-
- // Meta information
- // boolean gotSource = false;
- // // TODO: implement this check
- // elements.add(new ViewSpecificItems("Sources available",
- // gotSource));
-
- // Jars
- NodeIterator ni = node.getNodes();
- while (ni.hasNext()) {
- Node child = ni.nextNode();
- if (child.isNodeType(SLC_ARTIFACT)) {
- // we skip sha1 files for the time being.
- elements.add(child);
- }
- }
-
- // Properties
- PropertyIterator pi = node.getProperties();
- while (pi.hasNext()) {
- Property curProp = pi.nextProperty();
- if (!curProp.getName().startsWith("jcr:")
- && !curProp.isMultiple())
- elements.add(curProp);
- }
-
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected exception while listing node properties", e);
- }
- return elements.toArray();
- }
-
- public Object getParent(Object child) {
- return null;
- }
-
- public Object[] getChildren(Object parent) {
- Object[] result = null;
- try {
- if (parent instanceof Property) {
- Property prop = (Property) parent;
- if (prop.isMultiple()) {
- Value[] values = prop.getValues();
- return values;
- }
- } else if (parent instanceof Node) {
- Node node = (Node) parent;
- if (node.hasNodes()) {
- List<Object> elements = new ArrayList<Object>();
- PropertyIterator pi = node.getProperties();
- while (pi.hasNext()) {
- Property curProp = pi.nextProperty();
- if (!curProp.getName().startsWith("jcr:")
- && !curProp.isMultiple())
- elements.add(curProp);
- }
-
- NodeIterator ni = node.getNodes();
- while (ni.hasNext()) {
- Node curNode = ni.nextNode();
- if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
- || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
- ViewSpecificItems vsi = new ViewSpecificItems(
- "Bundle dependencies", "", true);
- vsi.setNode(node);
- elements.add(vsi);
- break;
- }
- }
- return elements.toArray();
- }
- } else if (parent instanceof ViewSpecificItems
- && ((ViewSpecificItems) parent).isFolder()) {
- NodeIterator ni = ((ViewSpecificItems) parent).getNode()
- .getNodes();
- List<Node> elements = new ArrayList<Node>();
- while (ni.hasNext()) {
- Node curNode = ni.nextNode();
- if (curNode.isNodeType(SLC_IMPORTED_PACKAGE)
- || curNode.isNodeType(SLC_EXPORTED_PACKAGE)) {
- elements.add(curNode);
- }
- }
- return elements.toArray();
- }
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected error getting multiple values property.", e);
- }
- return result;
- }
-
- public boolean hasChildren(Object parent) {
- try {
- if (parent instanceof Property
- && ((Property) parent).isMultiple()) {
- return true;
- } else if (parent instanceof Node && ((Node) parent).hasNodes()
- && ((Node) parent).isNodeType(SLC_BUNDLE_ARTIFACT)) {
- return true;
- } else if (parent instanceof ViewSpecificItems
- && ((ViewSpecificItems) parent).isFolder()) {
- return true;
- }
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected exception while checking if property is multiple",
- e);
- }
- return false;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Ordering;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Expose Maven artifacts of a given workspace as a tree. Artifacts are grouped
- * by Maven group.
- */
-public class DistWkspBrowserPage extends FormPage implements DistConstants,
- RepoConstants {
- // private final static Log log = LogFactory
- // .getLog(ArtifactsBrowserPage.class);
-
- final static String PAGE_ID = "artifactsBrowserPage";
-
- // Business object
- private Session session;
-
- // This page widgets
- private TreeViewer artifactTreeViewer;
-
- public DistWkspBrowserPage(FormEditor editor, String title, Session session) {
- super(editor, PAGE_ID, title);
- this.session = session;
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- try {
- ScrolledForm form = managedForm.getForm();
- Composite parent = form.getBody();
- parent.setLayout(new FillLayout());
- createMavenBrowserPart(parent);
- getEditor().getSite().setSelectionProvider(artifactTreeViewer);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot create artifact browser page", e);
- }
- }
-
- /** Aether specific browser for the current workspace */
- private void createMavenBrowserPart(Composite parent)
- throws RepositoryException {
-
- int style = SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.FULL_SELECTION | SWT.BORDER;
-
- Tree tree = new Tree(parent, style);
- createColumn(tree, "Maven browser", SWT.LEFT, 450);
- tree.setLinesVisible(true);
- tree.setHeaderVisible(true);
-
- artifactTreeViewer = new TreeViewer(tree);
-
- artifactTreeViewer.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 2648269889876058461L;
-
- @Override
- public String getText(Object element) {
- Node node = (Node) element;
- try {
- if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
- return JcrUtils.get((Node) element,
- SlcNames.SLC_GROUP_BASE_ID);
- else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
- return JcrUtils.get((Node) element,
- SlcNames.SLC_ARTIFACT_ID);
- else
- return node.getName();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot browse artifacts", e);
- }
- }
-
- @Override
- public Image getImage(Object element) {
- Node node = (Node) element;
- try {
-
- if (node.isNodeType(SlcTypes.SLC_GROUP_BASE))
- return DistImages.IMG_GROUP_BASE;
- else if (node.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
- return DistImages.IMG_ARTIFACT_BASE;
- else if (node
- .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE))
- return DistImages.IMG_ARTIFACT_VERSION_BASE;
- else
- return null;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get images for artifacts", e);
- }
- }
- });
-
- artifactTreeViewer.setContentProvider(new ITreeContentProvider() {
- private static final long serialVersionUID = -2381555428857519326L;
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- }
-
- public Object[] getElements(Object inputElement) {
- try {
- List<Node> nodes = JcrUtils.nodeIteratorToList(listNodes(
- SlcTypes.SLC_GROUP_BASE, SlcNames.SLC_NAME));
- return nodes.toArray();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot list children Nodes", e);
- }
- }
-
- public Object[] getChildren(Object parentElement) {
- // Only 3 levels for the time being
- try {
- Node pNode = (Node) parentElement;
- if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)) {
- return getArtifactBase(pNode,
- SlcTypes.SLC_ARTIFACT_BASE);
- } else if (pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
- return getArtifactBase(pNode,
- SlcTypes.SLC_ARTIFACT_VERSION_BASE);
- }
- return null;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot list children Nodes", e);
- }
- }
-
- // Helper to get children because current version of Jackrabbit is
- // buggy in remote
- private Object[] getArtifactBase(Node parent, String nodeType)
- throws RepositoryException {
- List<Node> nodes = new ArrayList<Node>();
- NodeIterator ni = parent.getNodes();
- while (ni.hasNext()) {
- Node node = ni.nextNode();
- if (node.isNodeType(nodeType))
- nodes.add(node);
- }
- return nodes.toArray();
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- try {
- Node pNode = (Node) element;
- if (pNode.isNodeType(SlcTypes.SLC_GROUP_BASE)
- || pNode.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
- // might return true even if there is no "valid" child
- return pNode.hasNodes();
- } else
- return false;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot check children Nodes", e);
- }
- }
- });
-
- artifactTreeViewer.addDoubleClickListener(new DoubleClickListener());
-
- artifactTreeViewer.setInput("Initialize");
- }
-
- private class DoubleClickListener implements IDoubleClickListener {
-
- public void doubleClick(DoubleClickEvent event) {
- Object obj = ((IStructuredSelection) event.getSelection())
- .getFirstElement();
- if (obj instanceof Node) {
- Node node = (Node) obj;
- try {
- if (node.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
- NodeIterator nit = node.getNodes();
- while (nit.hasNext()) {
- Node curr = nit.nextNode();
- if (curr.isNodeType(SlcTypes.SLC_ARTIFACT)) {
- node = curr;
- break;
- }
- }
- }
-
- if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
- DistWkspEditorInput dwip = (DistWkspEditorInput) getEditorInput();
- Map<String, String> params = new HashMap<String, String>();
- params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
- dwip.getRepoNodePath());
- params.put(OpenModuleEditor.PARAM_REPO_URI,
- dwip.getUri());
- params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
- dwip.getWorkspaceName());
- String path = node.getPath();
- params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
- CommandUtils.callCommand(OpenModuleEditor.ID, params);
- }
- } catch (RepositoryException re) {
- throw new SlcException("Cannot get path for node " + node
- + " while setting parameters for "
- + "command OpenModuleEditor", re);
- }
-
- }
- }
- }
-
- private static TreeColumn createColumn(Tree parent, String name, int style,
- int width) {
- TreeColumn result = new TreeColumn(parent, style);
- result.setText(name);
- result.setWidth(width);
- result.setMoveable(true);
- result.setResizable(true);
- return result;
- }
-
- private NodeIterator listNodes(String nodeType, String orderBy)
- throws RepositoryException {
- QueryManager queryManager = session.getWorkspace().getQueryManager();
- QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
- final String nodeSelector = "nodes";
- Selector source = factory.selector(nodeType, nodeSelector);
-
- Ordering order = factory.ascending(factory.propertyValue(nodeSelector,
- orderBy));
- Ordering[] orderings = { order };
-
- QueryObjectModel query = factory.createQuery(source, null, orderings,
- null);
-
- QueryResult result = query.execute();
-
- return result.getNodes();
- }
-
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/** An editor input pointing to a distribution workspace */
-public class DistWkspEditorInput implements IEditorInput, SlcNames {
-
- // Injected
- // private RepositoryFactory repositoryFactory;
- // private Keyring keyring;
- // private Node repoNode;
- private String repoNodePath;
- private String uri;
-
- // Local variables
- private String workspaceName;
-
- // public WorkspaceEditorInput(RepositoryFactory repositoryFactory,
- // Keyring keyring, Repository localRepository, Node repoNode,
- // String uri) {
- // // this.repositoryFactory = repositoryFactory;
- // // this.keyring = keyring;
- // this.localRepository = localRepository;
- // // this.repoNode= repoNode;
- // this.uri = uri;
- //
- // }
-
- /** uri and workspace name cannot be null */
- public DistWkspEditorInput(String repoNodePath, String uri,
- String workspaceName) {
- if (workspaceName == null)
- throw new SlcException("Workspace name cannot be null");
- if (uri == null)
- throw new SlcException("URI for repository cannot be null");
- this.repoNodePath = repoNodePath;
- this.workspaceName = workspaceName;
- this.uri = uri;
- }
-
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public boolean exists() {
- return true;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- // Dummy compulsory methods
- public String getToolTipText() {
- return "Editor for workspace " + workspaceName
- + " in repository of URI " + uri;
- }
-
- public String getName() {
- return workspaceName + "@" + uri;
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof DistWkspEditorInput))
- return false;
-
- DistWkspEditorInput other = (DistWkspEditorInput) obj;
-
- if (!workspaceName.equals(other.getWorkspaceName()))
- return false;
- if (!uri.equals(other.getUri()))
- return false;
-
- if (repoNodePath == null)
- return other.getRepoNodePath() == null;
- else
- return repoNodePath.equals(other.getRepoNodePath());
- }
-
- public String getUri() {
- return uri;
- }
-
- public String getWorkspaceName() {
- return workspaceName;
- }
-
- public String getRepoNodePath() {
- return repoNodePath;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.Ordering;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-import javax.jcr.query.qom.StaticOperand;
-
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.commands.DeleteArtifacts;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-
-/** Show all bundles contained in a given workspace as filter-able table */
-public class DistWkspSearchPage extends FormPage implements SlcNames {
- // final private static Log log = LogFactory
- // .getLog(DistributionOverviewPage.class);
-
- final static String PAGE_ID = "distributionOverviewPage";
-
- // Business Objects
- private Session session;
-
- // This page widgets
- private DistWorkspaceEditor formEditor;
- private FormToolkit tk;
-
- private DistNodeViewerComparator comparator;
- private TableViewer viewer;
-
- // private Composite header;
- private Text artifactTxt;
- private final static String FILTER_HELP_MSG = "Filter criterion, separated by a space";
-
- public DistWkspSearchPage(DistWorkspaceEditor formEditor, String title,
- Session session) {
- super(formEditor, PAGE_ID, title);
- this.formEditor = formEditor;
- this.session = session;
- }
-
- private void asynchronousRefresh() {
- RefreshJob job = new RefreshJob(artifactTxt.getText(), viewer,
- getSite().getShell().getDisplay());
- job.setUser(true);
- job.schedule();
- }
-
- private class RefreshJob extends PrivilegedJob {
- private TableViewer viewer;
- private String filter;
- private Display display;
-
- public RefreshJob(String filter, TableViewer viewer, Display display) {
- super("Get bundle list");
- this.filter = filter;
- this.viewer = viewer;
- this.display = display;
- }
-
- @Override
- protected IStatus doRun(IProgressMonitor progressMonitor) {
- try {
- JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
- monitor.beginTask("Getting bundle list", -1);
- final List<Node> result = JcrUtils
- .nodeIteratorToList(listBundleArtifacts(session, filter));
-
- display.asyncExec(new Runnable() {
- public void run() {
- viewer.setInput(result);
- }
- });
- } catch (Exception e) {
- return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
- "Cannot get bundle list", e);
- }
- return Status.OK_STATUS;
- }
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- ScrolledForm form = managedForm.getForm();
- tk = managedForm.getToolkit();
-
- // Main Layout
- GridLayout layout = new GridLayout(1, false);
- Composite body = form.getBody();
- body.setLayout(layout);
-
- // Meta info about current workspace
- Composite header = tk.createComposite(body);
- header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- createHeaderPart(form, header);
-
- Composite modules = tk.createComposite(body);
- modules.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- populateModuleSection(modules);
- }
-
- private void createHeaderPart(ScrolledForm form, Composite parent) {
- GridLayout layout = new GridLayout(4, false);
- // layout.marginWidth = layout.marginHeight = layout.verticalSpacing =
- // 0;
- // layout.horizontalSpacing = 2;
- parent.setLayout(layout);
-
- String wkspName = ((DistWkspEditorInput) getEditorInput())
- .getWorkspaceName();
- wkspName = wkspName.replaceAll("-", " ");
- form.setText(wkspName);
-
- String repoAlias = "";
- Node repoNode = ((DistWorkspaceEditor) getEditor()).getRepoNode();
- if (repoNode != null)
- try {
- repoAlias = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
- .getProperty(Property.JCR_TITLE).getString() : repoNode
- .getName();
- } catch (RepositoryException e1) {
- throw new SlcException("Unable to get repository alias ", e1);
- }
- else
- repoAlias = " - ";
-
- createLT(parent, "Repository alias", repoAlias);
- createLT(parent, "URI",
- ((DistWkspEditorInput) getEditorInput()).getUri());
- }
-
- private void populateModuleSection(Composite parent) {
- GridLayout layout = new GridLayout(1, false);
- layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
- parent.setLayout(layout);
-
- Section section = tk.createSection(parent, Section.TITLE_BAR
- | Section.DESCRIPTION);
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- section.setText("Artifacts");
- section.setDescription("Search among all artifacts that are referenced in the current workspace");
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Composite body = tk.createComposite(section);
- layout = new GridLayout(1, false);
- layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
- body.setLayout(new GridLayout());
-
- // Filter
- Composite filter = tk.createComposite(body);
- filter.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- createFilterPart(filter);
-
- // Table
- Composite tableCmp = tk.createComposite(body);
- tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- createTableViewer(tableCmp);
-
- section.setClient(body);
- }
-
- /** Build repository request */
- private NodeIterator listBundleArtifacts(Session session, String filter)
- throws RepositoryException {
- QueryManager queryManager = session.getWorkspace().getQueryManager();
- QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
- final String bundleArtifactsSelector = "bundleArtifacts";
- Selector source = factory.selector(SlcTypes.SLC_BUNDLE_ARTIFACT,
- bundleArtifactsSelector);
-
- // Create a dynamic operand for each property on which we want to filter
- DynamicOperand symbNameDO = factory.propertyValue(
- source.getSelectorName(), SlcNames.SLC_SYMBOLIC_NAME);
- DynamicOperand versionDO = factory.propertyValue(
- source.getSelectorName(), SlcNames.SLC_BUNDLE_VERSION);
- DynamicOperand nameDO = factory.propertyValue(source.getSelectorName(),
- DistConstants.SLC_BUNDLE_NAME);
-
- // Default Constraint: no source artifacts
- Constraint defaultC = factory.not(factory.comparison(
- symbNameDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE,
- factory.literal(session.getValueFactory().createValue(
- "%.source"))));
-
- // Build constraints based the textArea content
- if (filter != null && !"".equals(filter.trim())) {
- // Parse the String
- String[] strs = filter.trim().split(" ");
- for (String token : strs) {
- token = token.replace('*', '%');
- StaticOperand so = factory.literal(session.getValueFactory()
- .createValue("%" + token + "%"));
-
- Constraint currC = factory.comparison(symbNameDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
- currC = factory.or(currC, factory.comparison(versionDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
- currC = factory.or(currC, factory.comparison(nameDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
-
- defaultC = factory.and(defaultC, currC);
- }
- }
-
- Ordering order = factory.descending(factory.propertyValue(
- bundleArtifactsSelector, SlcNames.SLC_BUNDLE_VERSION));
- Ordering order2 = factory.ascending(factory.propertyValue(
- bundleArtifactsSelector, SlcNames.SLC_SYMBOLIC_NAME));
- Ordering[] orderings = { order, order2 };
-
- QueryObjectModel query = factory.createQuery(source, defaultC,
- orderings, null);
-
- QueryResult result = query.execute();
- return result.getNodes();
-
- }
-
- private Text createLT(Composite parent, String labelValue, String textValue) {
- Label label = new Label(parent, SWT.RIGHT);
- label.setText(labelValue);
- // label.setFont(EclipseUiUtils.getBoldFont(parent));
- label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
- // Add a trailing space to workaround a display glitch in RAP 1.3
- Text text = new Text(parent, SWT.LEFT); // | SWT.BORDER
- text.setText(textValue + " ");
- text.setEditable(false);
- return text;
- }
-
- private void createFilterPart(Composite parent) {
- GridLayout layout = new GridLayout();
- layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
- layout.horizontalSpacing = 5;
- parent.setLayout(layout);
-
- // Text Area to filter
- artifactTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
- | SWT.SEARCH | SWT.CANCEL);
- artifactTxt.setMessage(FILTER_HELP_MSG);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
- gd.grabExcessHorizontalSpace = true;
- artifactTxt.setLayoutData(gd);
- artifactTxt.addModifyListener(new ModifyListener() {
- private static final long serialVersionUID = -2422321852703208573L;
-
- public void modifyText(ModifyEvent event) {
- if ("".equals(artifactTxt.getText().trim()))
- asynchronousRefresh();
- else
- refreshFilteredList();
- }
- });
- }
-
- private void refreshFilteredList() {
- List<Node> nodes;
- try {
- nodes = JcrUtils.nodeIteratorToList(listBundleArtifacts(session,
- artifactTxt.getText()));
- viewer.setInput(nodes);
- } catch (RepositoryException e) {
- throw new SlcException("Unable to list bundles", e);
- }
- }
-
- private void createTableViewer(Composite parent) {
- parent.setLayout(new FillLayout());
- // helpers to enable sorting by column
- List<String> propertiesList = new ArrayList<String>();
- List<Integer> propertyTypesList = new ArrayList<Integer>();
-
- // Define the TableViewer
- viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
-
- // Name
- TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(300);
- col.getColumn().setText("Name");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -760226161605987538L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element,
- DistConstants.SLC_BUNDLE_NAME);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(0));
- propertiesList.add(DistConstants.SLC_BUNDLE_NAME);
- propertyTypesList.add(PropertyType.STRING);
-
- // Symbolic name
- col = new TableViewerColumn(viewer, SWT.V_SCROLL);
- col.getColumn().setWidth(300);
- col.getColumn().setText("Symbolic Name");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 4431447542158431355L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_SYMBOLIC_NAME);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(1));
- propertiesList.add(SLC_SYMBOLIC_NAME);
- propertyTypesList.add(PropertyType.STRING);
-
- // Version
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(130);
- col.getColumn().setText("Version");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -5616215547236158504L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_BUNDLE_VERSION);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(2));
- propertiesList.add(SLC_BUNDLE_VERSION);
- propertyTypesList.add(DistNodeViewerComparator.VERSION_TYPE);
-
- final Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- viewer.setContentProvider(new DistributionsContentProvider());
- getSite().setSelectionProvider(viewer);
-
- comparator = new DistNodeViewerComparator(2,
- DistNodeViewerComparator.ASCENDING, propertiesList,
- propertyTypesList);
- viewer.setComparator(comparator);
-
- // Context Menu
- MenuManager menuManager = new MenuManager();
- Menu menu = menuManager.createContextMenu(viewer.getTable());
- menuManager.addMenuListener(new IMenuListener() {
- private static final long serialVersionUID = -3886983092940055195L;
-
- public void menuAboutToShow(IMenuManager manager) {
- contextMenuAboutToShow(manager);
- }
- });
- viewer.getTable().setMenu(menu);
- getSite().registerContextMenu(menuManager, viewer);
-
- // Double click
- viewer.addDoubleClickListener(new DoubleClickListener());
- }
-
- @Override
- public void setFocus() {
- viewer.getTable().setFocus();
- }
-
- /** force refresh of the artifact list */
- public void refresh() {
- asynchronousRefresh();
- }
-
- /** Programmatically configure the context menu */
- protected void contextMenuAboutToShow(IMenuManager menuManager) {
- IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow();
- // Build conditions
- // Delete selected artifacts
- CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
- DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
- true);
- }
-
- private SelectionAdapter getSelectionAdapter(final int index) {
- SelectionAdapter selectionAdapter = new SelectionAdapter() {
- private static final long serialVersionUID = 5515884441510882460L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- Table table = viewer.getTable();
- comparator.setColumn(index);
- int dir = table.getSortDirection();
- if (table.getSortColumn() == table.getColumn(index)) {
- dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
- } else {
- dir = SWT.DOWN;
- }
- table.setSortDirection(dir);
- table.setSortColumn(table.getColumn(index));
- viewer.refresh();
- }
- };
- return selectionAdapter;
- }
-
- /* LOCAL CLASSES */
- private class DistributionsContentProvider implements
- IStructuredContentProvider {
- private static final long serialVersionUID = -635451814876234147L;
-
- // we keep a cache of the Nodes in the content provider to be able to
- // manage long request
- private List<Node> nodes;
-
- public void dispose() {
- }
-
- // We expect a list of nodes as a new input
- @SuppressWarnings("unchecked")
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- nodes = (List<Node>) newInput;
- }
-
- public Object[] getElements(Object arg0) {
- return nodes.toArray();
- }
- }
-
- private class DoubleClickListener implements IDoubleClickListener {
-
- public void doubleClick(DoubleClickEvent event) {
- Object obj = ((IStructuredSelection) event.getSelection())
- .getFirstElement();
- if (obj instanceof Node) {
- Node node = (Node) obj;
- try {
- if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
- DistWkspEditorInput dwip = (DistWkspEditorInput) formEditor
- .getEditorInput();
- Map<String, String> params = new HashMap<String, String>();
- params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
- dwip.getRepoNodePath());
- params.put(OpenModuleEditor.PARAM_REPO_URI,
- dwip.getUri());
- params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
- dwip.getWorkspaceName());
- String path = node.getPath();
- params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
- CommandUtils.callCommand(OpenModuleEditor.ID, params);
- }
- } catch (RepositoryException re) {
- throw new SlcException("Cannot get path for node " + node
- + " while setting parameters for "
- + "command OpenModuleEditor", re);
- }
-
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.security.Keyring;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/** Browse, analyse and modify a workspace containing software distributions */
-public class DistWorkspaceEditor extends FormEditor implements SlcNames {
- private static final long serialVersionUID = 5373719580281643675L;
-
- // private final static Log log =
- // LogFactory.getLog(DistributionEditor.class);
- public final static String ID = DistPlugin.PLUGIN_ID + ".distWorkspaceEditor";
-
- /* DEPENDENCY INJECTION */
- private RepositoryFactory repositoryFactory;
- private Repository localRepository;
- private Keyring keyring;
-
- // Business objects
- private Node repoNode;
- // Session that provides the node in the home of the local repository
- private Session localSession = null;
- // The business Session on optionally remote repository
- private Session businessSession;
- private DistWkspEditorInput editorInput;
-
- @Override
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
- editorInput = (DistWkspEditorInput) input;
- try {
- localSession = localRepository.login();
- if (editorInput.getRepoNodePath() != null
- && localSession.nodeExists(editorInput.getRepoNodePath()))
- repoNode = localSession.getNode(editorInput.getRepoNodePath());
-
- businessSession = RepoUtils.getRemoteSession(
- repositoryFactory, keyring, repoNode, editorInput.getUri(),
- editorInput.getWorkspaceName());
- } catch (RepositoryException e) {
- throw new PartInitException("Cannot log to workspace "
- + editorInput.getName(), e);
- }
- setPartName(editorInput.getWorkspaceName());
- super.init(site, input);
- }
-
- @Override
- protected void addPages() {
- try {
- addPage(new DistWkspSearchPage(this, "Details ", businessSession));
- addPage(new DistWkspBrowserPage(this, "Maven ", businessSession));
- addPage(new WkspCategoryBaseListPage(this, "Groups ",
- businessSession));
- } catch (PartInitException e) {
- throw new SlcException("Cannot add distribution editor pages", e);
- }
- }
-
- @Override
- public void doSave(IProgressMonitor arg0) {
- }
-
- @Override
- public void dispose() {
- JcrUtils.logoutQuietly(businessSession);
- JcrUtils.logoutQuietly(localSession);
- super.dispose();
- }
-
- @Override
- public void doSaveAs() {
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- protected Node getRepoNode() {
- return repoNode;
- }
-
- protected Session getSession() {
- return businessSession;
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-
- public void setLocalRepository(Repository localRepository) {
- this.localRepository = localRepository;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-
-/** Show the details for a given bundle. */
-public class ModularDistVersionDetailPage extends FormPage implements SlcNames {
-
- final static String PAGE_ID = "ModularDistVersionDetailPage";
-
- // Business Objects
- private Node modularDistVersion;
-
- // This page widgets
- private FormToolkit tk;
-
- public ModularDistVersionDetailPage(FormEditor formEditor, String title,
- Node modularDistVersion) {
- super(formEditor, PAGE_ID, title);
- this.modularDistVersion = modularDistVersion;
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- // General settings for this page
- ScrolledForm form = managedForm.getForm();
- tk = managedForm.getToolkit();
- Composite body = form.getBody();
-
- GridLayout layout = new GridLayout(1, false);
- layout.marginWidth = 5;
- layout.marginRight = 15;
- layout.verticalSpacing = 0;
- body.setLayout(layout);
- try {
- form.setText(modularDistVersion.hasProperty(SLC_NAME) ? modularDistVersion
- .getProperty(SLC_NAME).getString() : "");
- } catch (RepositoryException re) {
- throw new SlcException("Unable to get slc:name for node "
- + modularDistVersion, re);
- }
-
- // Main layout
- Composite mavenSnipet = tk.createComposite(body);
- mavenSnipet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- populateMavenSnippetPart(mavenSnipet);
- }
-
- private void populateMavenSnippetPart(Composite parent) {
- GridLayout layout = new GridLayout(1, false);
- layout.marginWidth = layout.horizontalSpacing = layout.horizontalSpacing = layout.marginHeight = 0;
- parent.setLayout(layout);
-
- Section section = tk.createSection(parent, Section.TITLE_BAR
- | Section.DESCRIPTION);
- section.setText("Maven");
- section.setDescription("In order to rely on the versions defined by this distribution, "
- + "add the below tag to the dependency management of your parent pom.");
- section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Text snippetTxt = createMavenSnippet(section);
- section.setClient(snippetTxt);
- }
-
- // /////////////////////
- // HELPERS
- /** Creates a text area with corresponding maven snippet */
- private Text createMavenSnippet(Composite parent) {
- Text mavenSnippet = new Text(parent, SWT.MULTI | SWT.WRAP);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- gd.heightHint = 100;
- mavenSnippet.setLayoutData(gd);
- mavenSnippet.setText(generateXmlSnippet());
- mavenSnippet.setEditable(false);
- return mavenSnippet;
- }
-
- private String generateXmlSnippet() {
- try {
- StringBuffer sb = new StringBuffer();
- sb.append("<dependency>\n");
- sb.append("\t<groupId>");
- sb.append(modularDistVersion.getProperty(SLC_GROUP_ID).getString());
- sb.append("</groupId>\n");
- sb.append("\t<artifactId>");
- sb.append(modularDistVersion.getProperty(SLC_ARTIFACT_ID)
- .getString());
- sb.append("</artifactId>\n");
- sb.append("\t<version>");
- sb.append(modularDistVersion.getProperty(SLC_ARTIFACT_VERSION)
- .getString());
- sb.append("</version>\n");
- sb.append("\t<type>pom</type>\n");
- sb.append("\t<scope>import</scope>\n");
- sb.append("</dependency>");
- return sb.toString();
- } catch (RepositoryException re) {
- throw new SlcException(
- "unexpected error while generating maven snippet");
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-
-/**
- * Manage a modular distribution version contained in a specific workspace of a
- * repository
- */
-public class ModularDistVersionEditor extends ArtifactVersionEditor {
- private static final long serialVersionUID = -2223542780164288554L;
-
- // private final static Log log =
- // LogFactory.getLog(ModularDistVersionEditor.class);
- public final static String ID = DistPlugin.PLUGIN_ID + ".modularDistVersionEditor";
-
- @Override
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
- super.init(site, input);
- }
-
- @Override
- protected void addPages() {
- setPartName(getFormattedName());
- try {
- addPage(new ModularDistVersionOverviewPage(this, "Modules ",
- getArtifact()));
- addPage(new RunInOsgiPage(this, "Run as OSGi ", getArtifact()));
- addPage(new ModularDistVersionDetailPage(this, "Details",
- getArtifact()));
- } catch (PartInitException e) {
- throw new SlcException("Cannot add distribution editor pages", e);
- }
- }
-
- protected String getFormattedName() {
- try {
- String partName = null;
- if (getArtifact().hasProperty(SLC_NAME))
- partName = getArtifact().getProperty(SLC_NAME).getString();
- else
- partName = getArtifact().getName();
-
- if (partName.length() > 10) {
- partName = "..." + partName.substring(partName.length() - 10);
- }
- return partName;
- } catch (RepositoryException re) {
- throw new SlcException("unable to get slc:name property for node "
- + getArtifact(), re);
- }
- }
-
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-import javax.jcr.query.qom.StaticOperand;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
-import org.argeo.slc.client.ui.dist.utils.HyperlinkAdapter;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.maven.MavenConventionsUtils;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.aether.artifact.DefaultArtifact;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.browser.IWebBrowser;
-import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Show all modules contained in a given modular distribution as filter-able
- * table
- */
-public class ModularDistVersionOverviewPage extends FormPage implements
- SlcNames {
-
- private final static Log log = LogFactory
- .getLog(ModularDistVersionOverviewPage.class);
-
- final static String PAGE_ID = "ModularDistVersionOverviewPage";
-
- // Business Objects
- private Node modularDistribution;
- // private Node modularDistributionBase;
-
- // This page widgets
- private DistNodeViewerComparator comparator;
- private TableViewer viewer;
- private FormToolkit tk;
- private Text filterTxt;
- private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
-
- public ModularDistVersionOverviewPage(FormEditor formEditor, String title,
- Node modularDistribution) {
- super(formEditor, PAGE_ID, title);
- this.modularDistribution = modularDistribution;
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- // General settings for this page
- ScrolledForm form = managedForm.getForm();
- tk = managedForm.getToolkit();
- Composite body = form.getBody();
-
- GridLayout layout = new GridLayout(1, false);
- layout.marginWidth = 5;
- layout.marginRight = 15;
- layout.verticalSpacing = 0;
- body.setLayout(layout);
- try {
- form.setText(modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
- .getProperty(SlcNames.SLC_NAME).getString() : "");
- form.setMessage(
- modularDistribution
- .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? modularDistribution
- .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
- .getString() : "", IMessageProvider.NONE);
- } catch (RepositoryException re) {
- throw new SlcException("Unable to get bundle name for node "
- + modularDistribution, re);
- }
-
- // Main layout
- Composite header = tk.createComposite(body);
- header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- populateHeaderPart(header);
-
- Composite moduleTablePart = tk.createComposite(body);
- moduleTablePart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true));
- populateModuleTablePart(moduleTablePart);
- }
-
- private void populateHeaderPart(Composite parent) {
- GridLayout layout = new GridLayout(6, false);
- layout.horizontalSpacing = 10;
- parent.setLayout(layout);
- try {
- // 1st Line: Category, name version
- createLT(
- parent,
- "Category",
- modularDistribution.hasProperty(SlcNames.SLC_CATEGORY) ? modularDistribution
- .getProperty(SlcNames.SLC_CATEGORY).getString()
- : "");
- createLT(
- parent,
- "Name",
- modularDistribution.hasProperty(SlcNames.SLC_NAME) ? modularDistribution
- .getProperty(SlcNames.SLC_NAME).getString() : "");
- createLT(
- parent,
- "Version",
- modularDistribution.hasProperty(SlcNames.SLC_VERSION) ? modularDistribution
- .getProperty(SlcNames.SLC_VERSION).getString() : "");
-
- // 2nd Line: Vendor, licence, sources
- createLT(
- parent,
- "Vendor",
- modularDistribution
- .hasProperty(DistConstants.SLC_BUNDLE_VENDOR) ? modularDistribution
- .getProperty(DistConstants.SLC_BUNDLE_VENDOR)
- .getString() : "N/A");
-
- createHyperlink(parent, "Licence", DistConstants.SLC_BUNDLE_LICENCE);
- addSourceSourcesLink(parent);
- } catch (RepositoryException re) {
- throw new SlcException("Unable to get bundle name for node "
- + modularDistribution, re);
- }
-
- }
-
- private Text createLT(Composite parent, String labelValue, String textValue) {
- Label label = tk.createLabel(parent, labelValue, SWT.RIGHT);
- // label.setFont(EclipseUiUtils.getBoldFont(parent));
- label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-
- // Add a trailing space to workaround a display glitch in RAP 1.3
- Text text = new Text(parent, SWT.LEFT);
- text.setText(textValue + " ");
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- text.setEditable(false);
- return text;
- }
-
- private void createHyperlink(Composite parent, String label,
- String jcrPropName) throws RepositoryException {
- tk.createLabel(parent, label, SWT.NONE);
- if (modularDistribution.hasProperty(jcrPropName)) {
- final Hyperlink link = tk.createHyperlink(parent,
- modularDistribution.getProperty(jcrPropName).getString(),
- SWT.NONE);
- link.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent e) {
- try {
- IWorkbenchBrowserSupport browserSupport = PlatformUI
- .getWorkbench().getBrowserSupport();
- IWebBrowser browser = browserSupport
- .createBrowser(
- IWorkbenchBrowserSupport.LOCATION_BAR
- | IWorkbenchBrowserSupport.NAVIGATION_BAR,
- "SLC Distribution browser",
- "SLC Distribution browser",
- "A tool tip");
- browser.openURL(new URL(link.getText()));
- } catch (Exception ex) {
- throw new SlcException("error opening browser", ex); //$NON-NLS-1$
- }
- }
- });
- } else
- tk.createLabel(parent, "N/A", SWT.NONE);
- }
-
- // helper to check if sources are available
- private void addSourceSourcesLink(Composite parent) {
- try {
- String srcPath = RepoUtils.relatedPdeSourcePath(
- RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH,
- modularDistribution);
- if (!modularDistribution.getSession().nodeExists(srcPath)) {
- createLT(parent, "Sources", "N/A");
- } else {
- final Node sourcesNode = modularDistribution.getSession()
- .getNode(srcPath);
-
- String srcName = null;
- if (sourcesNode.hasProperty(SlcNames.SLC_SYMBOLIC_NAME))
- srcName = sourcesNode.getProperty(
- SlcNames.SLC_SYMBOLIC_NAME).getString();
- else
- srcName = sourcesNode.getName();
- Label label = tk.createLabel(parent, "Sources", SWT.RIGHT);
- label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
- false));
- Hyperlink link = tk.createHyperlink(parent, srcName, SWT.NONE);
- link.addHyperlinkListener(new OpenFileLinkListener(sourcesNode
- .getPath()));
- }
- } catch (RepositoryException e) {
- throw new SlcException("Unable to configure sources link for "
- + modularDistribution, e);
- }
- }
-
- private class OpenFileLinkListener extends HyperlinkAdapter {
- final private String path;
-
- public OpenFileLinkListener(String path) {
- this.path = path;
- }
-
- @Override
- public void linkActivated(HyperlinkEvent e) {
- log.warn("File download must be implemented. Cannot provide access to "
- + path);
-
- // try {
- // ModuleEditorInput editorInput = (ModuleEditorInput)
- // getEditorInput();
- // Map<String, String> params = new HashMap<String, String>();
- // params.put(OpenJcrFile.PARAM_REPO_NODE_PATH,
- // editorInput.getRepoNodePath());
- // params.put(OpenJcrFile.PARAM_REPO_URI, editorInput.getUri());
- // params.put(OpenJcrFile.PARAM_WORKSPACE_NAME,
- // editorInput.getWorkspaceName());
- // params.put(OpenJcrFile.PARAM_FILE_PATH, path);
- //
- // String cmdId = (new OpenJcrFileCmdId()).getCmdId();
- // CommandUtils.callCommand(cmdId, params);
- // } catch (Exception ex) {
- // throw new SlcException("error opening browser", ex); //$NON-NLS-1$
- // }
- }
- }
-
- private void populateModuleTablePart(Composite parent) {
- GridLayout layout = new GridLayout(1, false);
- layout.marginWidth = layout.horizontalSpacing = 0;
- layout.verticalSpacing = 5;
- layout.marginTop = 15;
- parent.setLayout(layout);
- // A sub title
- Label label = tk.createLabel(parent,
- "Modules included in the current distribution", SWT.NONE);
- label.setFont(EclipseUiUtils.getBoldFont(parent));
-
- // Add the filter section
- Composite filterPart = tk.createComposite(parent);
- filterPart.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- createFilterPart(filterPart);
-
- // Add the table
- Composite tablePart = tk.createComposite(parent);
- tablePart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- createTableViewer(tablePart);
- // populate it on first pass.
- refresh();
- }
-
- private void createFilterPart(Composite parent) {
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
- layout.horizontalSpacing = 5;
- parent.setLayout(layout);
-
- // Text Area to filter
- filterTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
- | SWT.SEARCH | SWT.CANCEL);
- filterTxt.setMessage(FILTER_HELP_MSG);
- filterTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- filterTxt.addModifyListener(new ModifyListener() {
- private static final long serialVersionUID = -276152321986407726L;
-
- public void modifyText(ModifyEvent event) {
- refresh();
- }
- });
-
- Button resetBtn = tk.createButton(parent, null, SWT.PUSH);
- resetBtn.setImage(DistImages.IMG_CLEAR);
- resetBtn.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = -3549303742841670919L;
-
- public void widgetSelected(SelectionEvent e) {
- filterTxt.setText("");
- filterTxt.setMessage(FILTER_HELP_MSG);
- }
- });
- }
-
- private void createTableViewer(Composite parent) {
- parent.setLayout(new FillLayout());
- // helpers to enable sorting by column
- List<String> propertiesList = new ArrayList<String>();
- List<Integer> propertyTypesList = new ArrayList<Integer>();
-
- // Define the TableViewer
- viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
-
- // Name
- TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(220);
- col.getColumn().setText("Category");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 5875398301711336875L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SlcNames.SLC_CATEGORY);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(0));
- propertiesList.add(SlcNames.SLC_CATEGORY);
- propertyTypesList.add(PropertyType.STRING);
-
- // Symbolic name
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(220);
- col.getColumn().setText("Name");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 3880240676256465072L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_NAME);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(1));
- propertiesList.add(SLC_NAME);
- propertyTypesList.add(PropertyType.STRING);
-
- // Version
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(160);
- col.getColumn().setText("Version");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -4706438113850571784L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_VERSION);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(2));
- propertiesList.add(SLC_VERSION);
- propertyTypesList.add(DistNodeViewerComparator.VERSION_TYPE);
-
- // Exists in workspace
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(160);
- col.getColumn().setText("Exists in workspace");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 8190063212920414300L;
-
- @Override
- public String getText(Object element) {
- return getRealizedModule((Node) element) != null ? "Yes" : "No";
- // return JcrUtils.get((Node) element, SLC_VERSION);
- }
- });
- // col.getColumn().addSelectionListener(getSelectionAdapter(2));
- // propertiesList.add(SLC_VERSION);
- // propertyTypesList.add(PropertyType.STRING);
-
- final Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- viewer.setContentProvider(new DistributionsContentProvider());
- getSite().setSelectionProvider(viewer);
-
- comparator = new DistNodeViewerComparator(2,
- DistNodeViewerComparator.ASCENDING, propertiesList,
- propertyTypesList);
- viewer.setComparator(comparator);
-
- // // Context Menu
- // MenuManager menuManager = new MenuManager();
- // Menu menu = menuManager.createContextMenu(viewer.getTable());
- // menuManager.addMenuListener(new IMenuListener() {
- // public void menuAboutToShow(IMenuManager manager) {
- // contextMenuAboutToShow(manager);
- // }
- // });
- // viewer.getTable().setMenu(menu);
- // getSite().registerContextMenu(menuManager, viewer);
-
- // Double click
- viewer.addDoubleClickListener(new DoubleClickListener());
- }
-
- private Node getRealizedModule(Node moduleCoordinates) {
- try {
- String category = JcrUtils.get(moduleCoordinates, SLC_CATEGORY);
- String name = JcrUtils.get(moduleCoordinates, SLC_NAME);
- String version = JcrUtils.get(moduleCoordinates, SLC_VERSION);
- Artifact artifact = new DefaultArtifact(category + ":" + name + ":"
- + version);
- String parentPath = MavenConventionsUtils.artifactParentPath(
- RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH, artifact);
-
- Session session = modularDistribution.getSession();
- if (session.nodeExists(parentPath)) {
- Node parent = session.getNode(parentPath);
- NodeIterator nit = parent.getNodes();
- while (nit.hasNext()) {
- Node currN = nit.nextNode();
- if (currN.isNodeType(SlcTypes.SLC_ARTIFACT))
- return currN;
- }
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "unable to retrieve realized module with coordinates "
- + moduleCoordinates, re);
- }
- return null;
- }
-
- private void refresh() {
- final List<Node> result = JcrUtils
- .nodeIteratorToList(listBundleArtifacts());
- viewer.setInput(result);
- }
-
- /** Build repository request */
- private NodeIterator listBundleArtifacts() {
- try {
- Session session = modularDistribution.getSession();
- QueryManager queryManager = session.getWorkspace()
- .getQueryManager();
- QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
- Selector source = factory.selector(SlcTypes.SLC_MODULE_COORDINATES,
- SlcTypes.SLC_MODULE_COORDINATES);
-
- // Create a dynamic operand for each property on which we want to
- // filter
- DynamicOperand catDO = factory.propertyValue(
- source.getSelectorName(), SlcNames.SLC_CATEGORY);
- DynamicOperand nameDO = factory.propertyValue(
- source.getSelectorName(), SlcNames.SLC_NAME);
- DynamicOperand versionDO = factory.propertyValue(
- source.getSelectorName(), SlcNames.SLC_VERSION);
-
- String path = modularDistribution.getPath() + "/"
- + SlcNames.SLC_MODULES;
-
- // Default Constraint: correct children
- Constraint defaultC = factory.descendantNode(
- source.getSelectorName(), path);
-
- String filter = filterTxt.getText();
-
- // Build constraints based the textArea content
- if (filter != null && !"".equals(filter.trim())) {
- // Parse the String
- String[] strs = filter.trim().split(" ");
- for (String token : strs) {
- token = token.replace('*', '%');
- StaticOperand so = factory.literal(session
- .getValueFactory().createValue("%" + token + "%"));
-
- Constraint currC = factory.comparison(catDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
- currC = factory.or(currC, factory.comparison(versionDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
- currC = factory.or(currC, factory.comparison(nameDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
-
- defaultC = factory.and(defaultC, currC);
- }
- }
-
- QueryObjectModel query = factory.createQuery(source, defaultC,
- null, null);
- QueryResult result = query.execute();
- return result.getNodes();
- } catch (RepositoryException re) {
- throw new SlcException("Unable to refresh module list for node "
- + modularDistribution, re);
- }
- }
-
- @Override
- public void setFocus() {
- viewer.getTable().setFocus();
- }
-
- // /** Programmatically configure the context menu */
- // protected void contextMenuAboutToShow(IMenuManager menuManager) {
- // IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
- // .getActiveWorkbenchWindow();
- // // Build conditions
- // // Delete selected artifacts
- // // CommandUtils.refreshCommand(menuManager, window, DeleteArtifacts.ID,
- // // DeleteArtifacts.DEFAULT_LABEL, DeleteArtifacts.DEFAULT_ICON,
- // // true);
- // }
-
- private SelectionAdapter getSelectionAdapter(final int index) {
- SelectionAdapter selectionAdapter = new SelectionAdapter() {
- private static final long serialVersionUID = 1260801795934660840L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- Table table = viewer.getTable();
- comparator.setColumn(index);
- int dir = table.getSortDirection();
- if (table.getSortColumn() == table.getColumn(index)) {
- dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
- } else {
- dir = SWT.DOWN;
- }
- table.setSortDirection(dir);
- table.setSortColumn(table.getColumn(index));
- viewer.refresh();
- }
- };
- return selectionAdapter;
- }
-
- /* LOCAL CLASSES */
- private class DistributionsContentProvider implements
- IStructuredContentProvider {
- private static final long serialVersionUID = 8385338190908823791L;
- // we keep a cache of the Nodes in the content provider to be able to
- // manage long request
- private List<Node> nodes;
-
- public void dispose() {
- }
-
- // We expect a list of nodes as a new input
- @SuppressWarnings("unchecked")
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- nodes = (List<Node>) newInput;
- }
-
- public Object[] getElements(Object arg0) {
- return nodes.toArray();
- }
- }
-
- private class DoubleClickListener implements IDoubleClickListener {
-
- public void doubleClick(DoubleClickEvent event) {
- Object obj = ((IStructuredSelection) event.getSelection())
- .getFirstElement();
- if (obj instanceof Node) {
- Node node = (Node) obj;
- try {
- if (node.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
- Node realizedModule = getRealizedModule(node);
- if (realizedModule != null) {
- ModuleEditorInput dwip = (ModuleEditorInput) getEditorInput();
- Map<String, String> params = new HashMap<String, String>();
- params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
- dwip.getRepoNodePath());
- params.put(OpenModuleEditor.PARAM_REPO_URI,
- dwip.getUri());
- params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
- dwip.getWorkspaceName());
- String path = realizedModule.getPath();
- params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
- CommandUtils.callCommand(OpenModuleEditor.ID,
- params);
- }
- }
- } catch (RepositoryException re) {
- throw new SlcException("Cannot get path for node " + node
- + " while setting parameters for "
- + "command OpenModuleEditor", re);
- }
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-/** Editor input for a JCR node object in a multi-repository environment */
-public class ModuleEditorInput implements IEditorInput, SlcNames {
-
- // Define relevant workspace on a given repository
- private String repoNodePath;
- private String uri;
- private String workspaceName;
- private String modulePath;
-
- public ModuleEditorInput(String repoNodePath, String uri,
- String workspaceName, String artifactPath) {
- if (workspaceName == null)
- throw new SlcException("Workspace name cannot be null");
- if (uri == null && repoNodePath == null)
- throw new SlcException("Define at least one of the 2 "
- + "parameters URI or Repo Node Path");
- if (artifactPath == null)
- throw new SlcException("Module path cannot be null");
- this.repoNodePath = repoNodePath;
- this.uri = uri;
- this.workspaceName = workspaceName;
- this.modulePath = artifactPath;
- }
-
- public String getModulePath() {
- return modulePath;
- }
-
- public String getWorkspaceName() {
- return workspaceName;
- }
-
- public String getRepoNodePath() {
- return repoNodePath;
- }
-
- public String getUri() {
- return uri;
- }
-
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public boolean exists() {
- return true;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- // Dummy compulsory methods
- public String getToolTipText() {
- return getModulePath();
- }
-
- public String getName() {
- return JcrUtils.lastPathElement(modulePath);
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- /**
- * equals method based on coordinates
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
-
- ModuleEditorInput other = (ModuleEditorInput) obj;
-
- if (!modulePath.equals(other.getModulePath()))
- return false;
- if (!workspaceName.equals(other.getWorkspaceName()))
- return false;
-
- if (uri == null && other.getUri() != null
- || !uri.equals(other.getUri()))
- return false;
-
- if (repoNodePath == null && other.getRepoNodePath() != null
- || !repoNodePath.equals(other.getRepoNodePath()))
- return false;
-
- return true;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import javax.jcr.Node;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Enable launch of the current distribution in a separate osgi run time.
- * Display also a console to interract with the launched runtime
- */
-public class RunInOsgiPage extends FormPage implements SlcNames {
-
- final static String PAGE_ID = "RunInOsgiPage";
-
- // Business Objects
- private Node modularDistribution;
-
- // This page widgets
- private Button launchBtn;
- private Text consoleTxt;
-
- private FormToolkit tk;
-
- public RunInOsgiPage(FormEditor formEditor, String title,
- Node modularDistribution) {
- super(formEditor, PAGE_ID, title);
- this.modularDistribution = modularDistribution;
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- ScrolledForm form = managedForm.getForm();
- tk = managedForm.getToolkit();
- // Main Layout
- Composite body = form.getBody();
- GridLayout layout = new GridLayout();
- layout.marginTop = layout.marginWidth = 0;
- body.setLayout(layout);
-
- // The header
- Composite header = tk.createComposite(body);
- header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- createHeaderPart(header);
-
- // The console
- Composite console = tk.createComposite(body);
- console.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- createConsolePart(console);
- body.layout();
- }
-
- private void createHeaderPart(Composite parent) {
- GridLayout layout = new GridLayout();
- parent.setLayout(layout);
-
- // Text Area to filter
- launchBtn = tk.createButton(parent, " Launch ", SWT.PUSH);
- launchBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
-
- launchBtn.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = -1633658484882130602L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- throw new SlcException("Implement this");
- }
- });
- }
-
- private void createConsolePart(Composite parent) {
- parent.setLayout(new GridLayout());
- consoleTxt = tk.createText(parent, "OSGi > ", SWT.MULTI | SWT.WRAP
- | SWT.BORDER);
- consoleTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- }
-
- @Override
- public void setFocus() {
- launchBtn.setFocus();
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.editors;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.observation.Event;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-import javax.jcr.query.qom.StaticOperand;
-
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
-import org.argeo.slc.client.ui.dist.commands.OpenModuleEditor;
-import org.argeo.slc.client.ui.dist.utils.DistNodeViewerComparator;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * Show all category base (currently only Aether group base) contained in a
- * given workspace as filter-able table. Enable to definition of which of them
- * should be managed as modular distribution
- */
-public class WkspCategoryBaseListPage extends FormPage implements SlcNames {
-
- final static String PAGE_ID = "WkspCategoryBaseListPage";
-
- // Business Objects
- private Session session;
-
- // This page widgets
- private DistNodeViewerComparator comparator;
- private TableViewer viewer;
- private FormToolkit tk;
- private Text filterTxt;
- private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
-
- // Observes changes
- // private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE
- // };
- // private CategoryObserver categoriesObserver;
-
- public WkspCategoryBaseListPage(FormEditor formEditor, String title,
- Session session) {
- super(formEditor, PAGE_ID, title);
- this.session = session;
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- ScrolledForm form = managedForm.getForm();
- tk = managedForm.getToolkit();
-
- form.setText("Define Relevant Categories");
- form.setMessage("Choose in the below list "
- + "the categories that can be used as base for "
- + "modular distributions maintained via the current workspace",
- IMessageProvider.NONE);
-
- // Main Layout
- GridLayout layout = new GridLayout(1, false);
- Composite body = form.getBody();
- body.setLayout(layout);
-
- // filter section
- Composite header = tk.createComposite(body);
- header.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- createFilterPart(header);
-
- // the table
- Composite tableCmp = tk.createComposite(body);
- tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- createTableViewer(tableCmp);
-
- // categoriesObserver = new CategoryObserver(viewer.getTable()
- // .getDisplay());
- // try {
- // ObservationManager observationManager = session.getWorkspace()
- // .getObservationManager();
- // // FIXME Will not be notified if empty result is deleted
- // observationManager.addEventListener(categoriesObserver,
- // Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
- // false);
- // } catch (RepositoryException e) {
- // throw new SlcException("Cannot register listeners", e);
- // }
-
- refresh();
- }
-
- private void refresh() {
- final List<Node> result = JcrUtils.nodeIteratorToList(listGroupBase());
- viewer.setInput(result);
- }
-
- /** Build repository request */
- private NodeIterator listGroupBase() {
- try {
- QueryManager queryManager = session.getWorkspace()
- .getQueryManager();
- QueryObjectModelFactory factory = queryManager.getQOMFactory();
-
- Selector source = factory.selector(SlcTypes.SLC_GROUP_BASE,
- SlcTypes.SLC_MODULE_COORDINATES);
-
- // Create a dynamic operand for each property on which we want to
- // filter
- DynamicOperand catDO = factory.propertyValue(
- source.getSelectorName(), SlcNames.SLC_CATEGORY);
- DynamicOperand nameDO = factory.propertyValue(
- source.getSelectorName(), SlcNames.SLC_NAME);
-
- String filter = filterTxt.getText();
-
- Constraint defaultC = null;
- // Build constraints based the textArea content
- if (filter != null && !"".equals(filter.trim())) {
- // Parse the String
- String[] strs = filter.trim().split(" ");
- for (String token : strs) {
- token = token.replace('*', '%');
- StaticOperand so = factory.literal(session
- .getValueFactory().createValue("%" + token + "%"));
-
- Constraint currC = factory.comparison(catDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so);
- currC = factory.or(currC, factory.comparison(nameDO,
- QueryObjectModelFactory.JCR_OPERATOR_LIKE, so));
-
- if (defaultC == null)
- defaultC = currC;
- else
- defaultC = factory.and(defaultC, currC);
- }
- }
-
- QueryObjectModel query = factory.createQuery(source, defaultC,
- null, null);
- QueryResult result = query.execute();
- return result.getNodes();
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unable to refresh group list for workspace "
- + getEditorInput().getName(), re);
- }
- }
-
- private void createFilterPart(Composite parent) {
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = layout.marginHeight = layout.verticalSpacing = 0;
- layout.horizontalSpacing = 5;
- parent.setLayout(layout);
-
- // Text Area to filter
- filterTxt = tk.createText(parent, "", SWT.BORDER | SWT.SINGLE
- | SWT.SEARCH | SWT.CANCEL);
- filterTxt.setMessage(FILTER_HELP_MSG);
- filterTxt.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- filterTxt.addModifyListener(new ModifyListener() {
- private static final long serialVersionUID = 8727389523069041623L;
-
- public void modifyText(ModifyEvent event) {
- refresh();
- }
- });
-
- Button resetBtn = tk.createButton(parent, null, SWT.PUSH);
- resetBtn.setImage(DistImages.IMG_REPO_READONLY);
- resetBtn.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = -6523538838444581321L;
-
- public void widgetSelected(SelectionEvent e) {
- resetFilter();
- }
- });
- }
-
- private void resetFilter() {
- filterTxt.setText("");
- filterTxt.setMessage(FILTER_HELP_MSG);
- }
-
- private void createTableViewer(Composite parent) {
- parent.setLayout(new FillLayout());
- // helpers to enable sorting by column
- List<String> propertiesList = new ArrayList<String>();
- List<Integer> propertyTypesList = new ArrayList<Integer>();
-
- // Define the TableViewer
- viewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
-
- TableViewerColumn col;
- // Name
- // TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE);
- // col.getColumn().setWidth(220);
- // col.getColumn().setText("Category");
- // col.setLabelProvider(new ColumnLabelProvider() {
- // @Override
- // public String getText(Object element) {
- // return JcrUtils.get((Node) element, SlcNames.SLC_CATEGORY);
- // }
- // });
- // col.getColumn().addSelectionListener(getSelectionAdapter(0));
- // propertiesList.add(SlcNames.SLC_CATEGORY);
- // propertyTypesList.add(PropertyType.STRING);
-
- // Group base name
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(220);
- col.getColumn().setText("Group Name");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 6186787928630825293L;
-
- @Override
- public String getText(Object element) {
- return JcrUtils.get((Node) element, SLC_GROUP_BASE_ID);
- }
- });
- col.getColumn().addSelectionListener(getSelectionAdapter(0));
- propertiesList.add(SLC_GROUP_BASE_ID);
- propertyTypesList.add(PropertyType.STRING);
-
- // Version
- col = new TableViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(80);
- col.getColumn().setText("Has binaries");
- col.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -2017377132642062464L;
-
- @Override
- public String getText(Object element) {
- try {
- Node currNode = (Node) element;
-
- return currNode.hasNode(RepoConstants.BINARIES_ARTIFACT_ID) ? "Yes"
- : "No";
- } catch (RepositoryException e) {
- throw new SlcException("unable to check type of node "
- + element, e);
- }
- }
- });
- // col.getColumn().addSelectionListener(getSelectionAdapter(2));
- // propertiesList.add(SLC_VERSION);
- // propertyTypesList.add(PropertyType.STRING);
-
- final Table table = viewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- viewer.setContentProvider(new DistributionsContentProvider());
- getSite().setSelectionProvider(viewer);
-
- comparator = new DistNodeViewerComparator(0,
- DistNodeViewerComparator.ASCENDING, propertiesList,
- propertyTypesList);
- viewer.setComparator(comparator);
-
- // Context Menu
- MenuManager menuManager = new MenuManager();
- Menu menu = menuManager.createContextMenu(viewer.getTable());
- menuManager.addMenuListener(new IMenuListener() {
- private static final long serialVersionUID = 739004528695501335L;
-
- public void menuAboutToShow(IMenuManager manager) {
- contextMenuAboutToShow(manager);
- }
- });
- viewer.getTable().setMenu(menu);
- getSite().registerContextMenu(menuManager, viewer);
-
- // Double click
- viewer.addDoubleClickListener(new DoubleClickListener());
- }
-
- @Override
- public void setFocus() {
- viewer.getTable().setFocus();
- }
-
- /** Programmatically configure the context menu */
- protected void contextMenuAboutToShow(IMenuManager menuManager) {
- IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow();
- // Build conditions
- // Mark as category base
- Object firstElement = ((IStructuredSelection) viewer.getSelection())
- .getFirstElement();
- Node currSelected = (Node) firstElement;
-
- DistWkspEditorInput input = (DistWkspEditorInput) getEditorInput();
-
- Map<String, String> params = new HashMap<String, String>();
- params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
- input.getRepoNodePath());
- try {
- params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
- currSelected.getPath());
- } catch (RepositoryException e) {
- throw new SlcException("Unable to get path for " + currSelected, e);
- }
- params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
- input.getWorkspaceName());
-
- CommandUtils.refreshParameterizedCommand(menuManager, window,
- OpenGenerateBinariesWizard.ID,
- OpenGenerateBinariesWizard.DEFAULT_LABEL,
- OpenGenerateBinariesWizard.DEFAULT_ICON, true, params);
-
- // boolean isRelevant = false;
- // try {
- // isRelevant = currSelected.isNodeType(SlcTypes.SLC_CATEGORY);
- // boolean canEdit = currSelected.canAddMixin(SlcTypes.SLC_CATEGORY);
- //
- // } catch (RepositoryException e) {
- // throw new SlcException("unable to check type of node "
- // + firstElement, e);
- // }
- // // Add
- // if (isRelevant) {// Remove
- // CommandUtils.refreshCommand(menuManager, window,
- // MarkAsRelevantCategory.ID,
- // MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
- // MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
- // } else {
- // CommandUtils.refreshCommand(menuManager, window,
- // MarkAsRelevantCategory.ID,
- // MarkAsRelevantCategory.DEFAULT_LABEL,
- // MarkAsRelevantCategory.DEFAULT_ICON, true);
- // }
- }
-
- private SelectionAdapter getSelectionAdapter(final int index) {
- SelectionAdapter selectionAdapter = new SelectionAdapter() {
- private static final long serialVersionUID = -1723894288128081757L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- Table table = viewer.getTable();
- comparator.setColumn(index);
- int dir = table.getSortDirection();
- if (table.getSortColumn() == table.getColumn(index)) {
- dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
- } else {
- dir = SWT.DOWN;
- }
- table.setSortDirection(dir);
- table.setSortColumn(table.getColumn(index));
- viewer.refresh();
- }
- };
- return selectionAdapter;
- }
-
- /* LOCAL CLASSES */
- private class DistributionsContentProvider implements
- IStructuredContentProvider {
- private static final long serialVersionUID = -5939763615620837492L;
-
- // we keep a cache of the Nodes in the content provider to be able to
- // manage long request
- private List<Node> nodes;
-
- public void dispose() {
- }
-
- // We expect a list of nodes as a new input
- @SuppressWarnings("unchecked")
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- nodes = (List<Node>) newInput;
- }
-
- public Object[] getElements(Object arg0) {
- return nodes.toArray();
- }
- }
-
- private class DoubleClickListener implements IDoubleClickListener {
-
- public void doubleClick(DoubleClickEvent event) {
- Object obj = ((IStructuredSelection) event.getSelection())
- .getFirstElement();
- if (obj instanceof Node) {
- Node node = (Node) obj;
- try {
- if (node.isNodeType(SlcTypes.SLC_ARTIFACT)) {
- DistWkspEditorInput dwip = (DistWkspEditorInput) getEditorInput();
- Map<String, String> params = new HashMap<String, String>();
- params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
- dwip.getRepoNodePath());
- params.put(OpenModuleEditor.PARAM_REPO_URI,
- dwip.getUri());
- params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
- dwip.getWorkspaceName());
- String path = node.getPath();
- params.put(OpenModuleEditor.PARAM_MODULE_PATH, path);
- CommandUtils.callCommand(OpenModuleEditor.ID, params);
- }
- } catch (RepositoryException re) {
- throw new SlcException("Cannot get path for node " + node
- + " while setting parameters for "
- + "command OpenModuleEditor", re);
- }
-
- }
- }
- }
-
- class CategoryObserver extends AsyncUiEventListener {
-
- public CategoryObserver(Display display) {
- super(display);
- }
-
- @Override
- protected Boolean willProcessInUiThread(List<Event> events)
- throws RepositoryException {
- for (Event event : events) {
- String path = event.getPath();
- if (JcrUtils.lastPathElement(path).equals(
- DistConstants.JCR_MIXIN_TYPES))
- return true;
- }
- return false;
- }
-
- protected void onEventInUiThread(List<Event> events)
- throws RepositoryException {
- if (getLog().isTraceEnabled())
- getLog().trace("Refresh table");
- viewer.refresh();
- }
- }
-
- @Override
- public void setActive(boolean active) {
- super.setActive(active);
- if (active) {
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.argeo.eclipse.ui.TreeParent;
-
-/** Common super class for all tree elements of the Distributions View */
-public abstract class DistParentElem extends TreeParent {
- protected final static Character VERSION_SEP = '-';
-
- protected static final List<String> ARGEO_SYSTEM_WKSP;
- static {
- List<String> tmpList = new ArrayList<String>();
- tmpList.add("main");
- tmpList.add("proxy");
- tmpList.add("security");
- tmpList.add("localrepo");
- ARGEO_SYSTEM_WKSP = Collections.unmodifiableList(tmpList);
- }
-
- private boolean inHome = false;
- private boolean isReadOnly = false;
-
- public DistParentElem(String name, boolean inHome, boolean isReadOnly) {
- super(name);
- this.inHome = inHome;
- this.isReadOnly = isReadOnly;
- }
-
- public DistParentElem(String name) {
- super(name);
- }
-
- // public abstract String getLabel();
- //
- // public abstract Object[] getChildren();
- //
- // public boolean hasChildren() {
- // return true;
- // }
- //
- // public void dispose() {
- // }
-
- public void setInHome(boolean inHome) {
- this.inHome = inHome;
- }
-
- public void setReadOnly(boolean isReadOnly) {
- this.isReadOnly = isReadOnly;
- }
-
- public boolean inHome() {
- return inHome;
- }
-
- public boolean isReadOnly() {
- return isReadOnly;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.model;
-
-/**
- * Abstract a node of type slc:groupBase that gathers a set of artifacts that
- * have the same group ID
- */
-public class GroupBaseElem extends DistParentElem {
- // private WorkspaceElem wkspElem;
- private String groupId;
-
- public GroupBaseElem(WorkspaceElem wkspElem, String groupId) {
- super(groupId, wkspElem.inHome(), wkspElem.isReadOnly());
-
- setParent(wkspElem);
- // this.wkspElem = wkspElem;
- this.groupId = groupId;
- }
-
- public Object[] getChildren() {
- return null;
- }
-
- public String getLabel() {
- return groupId;
- }
-
- // public String toString() {
- // return getLabel();
- // }
-
- // public void dispose() {
- // }
-
- public WorkspaceElem getWorkspaceElem() {
- return (WorkspaceElem) getParent();
- }
-
- public String getGroupId() {
- return getName();
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/**
- * Abstract the base of a given modular distribution set i.e. the parent of all
- * versions of a given modular distribution
- */
-public class ModularDistVersionBaseElem extends DistParentElem {
-
- // final static public String AETHER_CATEGORY_BASE = "categoryBase";
- final static public String AETHER_BINARIES_TYPE = "binaries";
- final static public String AETHER_DEP_TYPE = "dep";
- private String type;
- private Node modularDistVersionBase;
-
- public ModularDistVersionBaseElem(WorkspaceElem wkspElem, String name,
- Node modularDistVersionBase, String type) {
- super(name, wkspElem.inHome(), wkspElem.isReadOnly());
- setParent(wkspElem);
- this.modularDistVersionBase = modularDistVersionBase;
- this.type = type;
- }
-
- public Node getModularDistBase() {
- // // TODO clean this
- // if (type.equals(AETHER_CATEGORY_BASE))
- // return modularDistVersionBase;
- // else
- try {
- return modularDistVersionBase.getParent();
- } catch (RepositoryException e) {
- throw new SlcException("unable to get parent node for "
- + modularDistVersionBase, e);
- }
- }
-
- public WorkspaceElem getWkspElem() {
- return (WorkspaceElem) getParent();
- }
-
- /**
- * Override normal behaviour to initialise children only when first
- * requested
- */
- @Override
- public synchronized boolean hasChildren() {
- if (isLoaded()) {
- return super.hasChildren();
- } else {
- return true;
- }
- };
-
- /**
- * Override normal behaviour to initialise children only when first
- * requested
- */
- @Override
- public synchronized Object[] getChildren() {
- if (isLoaded()) {
- return super.getChildren();
- } else {
- try {
- NodeIterator ni = getDistVersions();
- while (ni != null && ni.hasNext()) {
- Node curNode = ni.nextNode();
- if (curNode.hasProperty(SlcNames.SLC_ARTIFACT_VERSION))
- addChild(new ModularDistVersionElem(this, curNode
- .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
- .getString(), curNode));
- }
- return super.getChildren();
- } catch (RepositoryException re) {
- throw new SlcException("Unable to retrieve children for "
- + modularDistVersionBase, re);
- }
- }
- }
-
- private NodeIterator getDistVersions() {
- try {
- // if (AETHER_CATEGORY_BASE.equals(type))
- // return null;
-
- QueryManager queryManager = modularDistVersionBase.getSession()
- .getWorkspace().getQueryManager();
- QueryObjectModelFactory factory = queryManager.getQOMFactory();
- Selector source = factory.selector(
- SlcTypes.SLC_MODULAR_DISTRIBUTION,
- SlcTypes.SLC_MODULAR_DISTRIBUTION);
- Constraint constraint = factory.descendantNode(
- source.getSelectorName(), modularDistVersionBase.getPath());
- // Ordering order = factory.descending(factory.propertyValue(
- // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
- // Ordering[] orderings = { order };
- QueryObjectModel query = factory.createQuery(source, constraint,
- null, null);
- QueryResult queryResult = query.execute();
- return queryResult.getNodes();
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unable to version for modular distribution: " + getName(),
- e);
- }
- }
-
- public String getType() {
- return type;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.Node;
-
-/**
- * Abstract a node of type slc:modularDistribution that has a child node that
- * lists the modules contained in the current distribution
- */
-public class ModularDistVersionElem extends DistParentElem {
- private final Node modularDistVersionNode;
-
- public ModularDistVersionElem(ModularDistVersionBaseElem modularDistGroupElem,
- String version, Node modularDistVersionNode) {
- super(version, modularDistGroupElem.inHome(), modularDistGroupElem
- .isReadOnly());
- setParent(modularDistGroupElem);
- this.modularDistVersionNode = modularDistVersionNode;
- }
-
- public Object[] getChildren() {
- return null;
- }
-
- public String getLabel() {
- return getName();
- }
-
- public WorkspaceElem getWorkspaceElem() {
- return (WorkspaceElem) getParent().getParent();
- }
-
- public Node getModularDistVersionNode() {
- return modularDistVersionNode;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.model;
-
-import java.security.AccessControlException;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoUtils;
-
-/**
- * Abstract a repository. It might be persisted by a node in the current user
- * home Node or just an URI and a label if user is anonymous
- */
-public class RepoElem extends DistParentElem {
- // private final static Log log = LogFactory.getLog(RepoElem.class);
-
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
- private Credentials credentials;
- private Session defaultSession = null;
-
- // Defines current repo
- private Node repoNode = null;
- private String label;
- private String uri;
-
- private Repository repository;
-
- /**
- * Creates a RepoElement for anonymous user. The {@code RepositoryFactory}
- * is used to enable lazy initialisation
- */
- public RepoElem(RepositoryFactory repoFactory, String uri, String label) {
- super(label);
- this.repositoryFactory = repoFactory;
- this.uri = uri;
- this.label = label;
- }
-
- /**
- * Creates a RepoElement for an authenticated user. The
- * {@code RepositoryFactory} and {@code Keyring} are used to enable lazy
- * initialisation
- *
- */
- public RepoElem(RepositoryFactory repoFactory, Keyring keyring, Node repoNode, String alias) {
- super(alias);
- this.label = alias;
- // label = repoNode.isNodeType(NodeType.MIX_TITLE) ? repoNode
- // .getProperty(Property.JCR_TITLE).getString() : repoNode
- // .getName();
- this.repoNode = repoNode;
- this.repositoryFactory = repoFactory;
- this.keyring = keyring;
- try {
- // Initialize this repo information
- setInHome(RepoConstants.DEFAULT_JAVA_REPOSITORY_ALIAS.equals(repoNode.getName()));
- if (inHome())
- // Directly log and retrieve children for local repository
- login();
- else
- setReadOnly(!repoNode.hasNode(ArgeoNames.ARGEO_PASSWORD));
- uri = JcrUtils.get(repoNode, ArgeoNames.ARGEO_URI);
- } catch (RepositoryException e) {
- throw new SlcException("Unable to " + "initialize repo element", e);
- }
- }
-
- /** Effective login. Does nothing if the session is already there. */
- public void login() {
- if (isConnected())
- return;
-
- if (repository == null)
- if (repoNode == null)
- // Anonymous
- repository = NodeUtils.getRepositoryByUri(repositoryFactory, uri);
- else {
- repository = RepoUtils.getRepository(repositoryFactory, keyring, repoNode);
- credentials = RepoUtils.getRepositoryCredentials(keyring, repoNode);
- }
-
- try {
- // FIXME make it more generic
- String defaultWorkspace = NodeConstants.SYS_WORKSPACE;
- defaultSession = repository.login(credentials, defaultWorkspace);
- refreshChildren();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot login repository " + label + " with credential " + credentials, e);
- }
- }
-
- protected void refreshChildren() {
- try {
- // TODO also remove deleted children (only adds for the time being
- String[] workspaceNames = defaultSession.getWorkspace().getAccessibleWorkspaceNames();
- buildWksp: for (String workspaceName : workspaceNames) {
- if (!isWorkspaceVisible(workspaceName))
- continue buildWksp;
-
- String prefix = getPrefix(workspaceName);
- if (getChildByName(prefix) == null) {
- WkspGroupElem wkspGpElem = new WkspGroupElem(RepoElem.this, prefix);
- addChild(wkspGpElem);
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot list workspaces for " + repoNode, e);
- }
- }
-
- @Override
- public synchronized void dispose() {
- JcrUtils.logoutQuietly(defaultSession);
- super.dispose();
- }
-
- private String getPrefix(String workspaceName) {
- // Here is the tricks - we rely on a "hard coded" convention
- // Workspace name should be like: name-major.minor
- if (workspaceName.lastIndexOf(VERSION_SEP) > 0)
- return workspaceName.substring(0, workspaceName.lastIndexOf(VERSION_SEP));
- else
- return workspaceName;
- }
-
- /* Exposes this to the children workspace group */
- protected boolean isWorkspaceVisible(String wkspName) {
- Boolean result = true;
- if (ARGEO_SYSTEM_WKSP.contains(wkspName))
- return false;
- // Add a supplementary check to hide workspace that are not
- // public to anonymous user
- if (repoNode == null) {
- Session tmpSession = null;
- try {
- tmpSession = repository.login(wkspName);
- try {
- tmpSession.checkPermission("/", "read");
- } catch (AccessControlException e) {
- result = false;
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot list workspaces for anonymous user", e);
- } finally {
- JcrUtils.logoutQuietly(tmpSession);
- }
- }
- return result;
- }
-
- /**
- * Actual call to the
- * {@link Repository#login(javax.jcr.Credentials, String)} method. To be
- * overridden.
- *
- * Creates a new session with correct credentials using the information
- * contained in the corresponding repo node. It provides all UI children
- * elements an unique entry point to retrieve a new Session. Caller must
- * close the session when it is not in use anymore.
- *
- */
- protected Session repositoryLogin(String workspaceName) {
- try {
- if (workspaceName == null)
- workspaceName = NodeConstants.SYS_WORKSPACE;// FIXME make it more generic
- return repository.login(credentials, workspaceName);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot login repository " + label + " with credential " + credentials, e);
- }
- }
-
- public Boolean isConnected() {
- if (defaultSession != null && defaultSession.isLive())
- return true;
- else
- return false;
- }
-
- /** Exposes URI to the current repository */
- public String getUri() {
- return uri;
- }
-
- public String getRepoNodePath() {
- if (repoNode == null)
- return null;
- else
- try {
- return repoNode.getPath();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get node path for repository " + label, e);
- }
- }
-
- /**
- * Exposes the local repoNode that completely define a connection to a
- * repository (including a set of credentials). Might return null in case of
- * an anonymous user
- */
- protected Node getRepoNode() {
- return repoNode;
- }
-
- protected Repository getRepository() {
- return repository;
- }
-
- protected Credentials getCredentials() {
- return credentials;
- }
-
- // META INFO
- public String getDescription() {
- String desc = label;
- if (repoNode != null)
- desc = label + " (" + uri + ")";
- return desc;
- }
-
- public String getLabel() {
- return label;
- }
-
- public String toString() {
- return repoNode != null ? repoNode.toString() : label;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-
-/**
- * Abstract set of similar workspaces, that is a bunch of workspaces with same
- * prefix.
- */
-public class WkspGroupElem extends DistParentElem {
-
- private Session defaultSession;
-
- public WkspGroupElem(RepoElem repoElem, String prefix) {
- super(prefix, repoElem.inHome(), repoElem.isReadOnly());
- setParent(repoElem);
- // Directly adds children upon creation
- try {
- defaultSession = repoElem.repositoryLogin(null);
- String[] wkpNames = defaultSession.getWorkspace()
- .getAccessibleWorkspaceNames();
- for (String wkpName : wkpNames) {
- if (prefix.equals(getPrefix(wkpName))
- // if (wkpName.startsWith(prefix)
- && repoElem.isWorkspaceVisible(wkpName))
- addChild(new WorkspaceElem(WkspGroupElem.this, repoElem,
- wkpName));
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot retrieve workspace names", e);
- }
- }
-
- // FIXME - we rely on a "hard coded" convention : Workspace name must have
- // this format: name-major.minor
- // We might expose this method as static public, to be used among others by
- // the RepoElem parent objects when building its children
- private String getPrefix(String workspaceName) {
- if (workspaceName.lastIndexOf(VERSION_SEP) > 0)
- return workspaceName.substring(0,
- workspaceName.lastIndexOf(VERSION_SEP));
- else
- return workspaceName;
- }
-
- public void dispose() {
- JcrUtils.logoutQuietly(defaultSession);
- super.dispose();
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.InvalidQueryException;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/** Abstract a workspace that contains a software distribution */
-public class WorkspaceElem extends DistParentElem {
- private final RepoElem repoElem;
- private String workspaceName;
- private Session currSession;
-
- public WorkspaceElem(WkspGroupElem parent, RepoElem repoElem,
- String workspaceName) {
- super(workspaceName, repoElem.inHome(), repoElem.isReadOnly());
- this.repoElem = repoElem;
- this.workspaceName = workspaceName;
- setParent(parent);
- }
-
- public String getWorkspaceName() {
- return workspaceName;
- }
-
- public RepoElem getRepoElem() {
- return repoElem;
- }
-
- public Boolean isConnected() {
- if (currSession != null && currSession.isLive())
- return true;
- else
- return false;
- }
-
- public void login() {
- currSession = repoElem.repositoryLogin(getName());
- }
-
- /** Utility to create a new Session with correct credential in this context */
- public Session getNewSession() {
- return repoElem.repositoryLogin(getName());
- }
-
- public boolean hasChildren() {
- try {
- if (isConnected())
- return currSession.getRootNode().hasNodes();
- else
- return true;
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while checking children node existence",
- re);
- }
- }
-
- /** Override normal behaviour to initialize display of the workspace */
- @Override
- public synchronized Object[] getChildren() {
- if (isLoaded()) {
- return super.getChildren();
- } else {
- // initialize current object
- try {
- // Lazy connect the first time we retrieve children
- if (currSession == null)
- login();
-
- // Retrieve already existing distribution
-
- // Use QOM rather than SQL2 - it seems more robust for remoting
- // with JCR 2.2 (might also be some model refresh issue with the
- // remoting)
- QueryManager queryManager = currSession.getWorkspace()
- .getQueryManager();
- QueryObjectModelFactory factory = queryManager.getQOMFactory();
- Selector selector = factory.selector(
- SlcTypes.SLC_MODULAR_DISTRIBUTION,
- SlcTypes.SLC_MODULAR_DISTRIBUTION);
- // Curiously this works...
- // Selector selector = factory.selector(
- // SlcTypes.SLC_JAR_FILE,
- // SlcTypes.SLC_JAR_FILE);
-
- QueryObjectModel query = factory.createQuery(selector, null,
- null, null);
-
- // Query groupQuery = currSession
- // .getWorkspace()
- // .getQueryManager()
- // .createQuery(
- // "select * from ["
- // + SlcTypes.SLC_MODULAR_DISTRIBUTION
- // + "]", Query.JCR_SQL2);
- NodeIterator distributions = null;
- try {
- distributions = query.execute().getNodes();
- } catch (InvalidQueryException iqe) {
- // For legacy only does not throw an exception while
- // browsing
- // legacy repositories that does not know
- // SLC_MODULAR_DISTRIBUTION type
- }
- distribs: while (distributions != null
- && distributions.hasNext()) {
- Node currDist = distributions.nextNode();
- Node distBase = currDist.getParent().getParent();
- if (!distBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
- continue distribs;
- String groupId = distBase
- .getProperty(SlcNames.SLC_GROUP_ID).getString();
- String artifactId = distBase.getProperty(
- SlcNames.SLC_ARTIFACT_ID).getString();
-
- String name;
- String type;
- if (ModularDistVersionBaseElem.AETHER_BINARIES_TYPE
- .equals(artifactId)) {
- name = groupId;
- type = ModularDistVersionBaseElem.AETHER_BINARIES_TYPE;
- } else {
- name = artifactId;
- type = ModularDistVersionBaseElem.AETHER_DEP_TYPE;
- }
- if (getChildByName(name) == null)
- addChild(new ModularDistVersionBaseElem(
- WorkspaceElem.this, name, distBase, type));
- }
- return super.getChildren();
- } catch (RepositoryException e) {
- throw new SlcException(
- "Cannot initialize WorkspaceNode UI object."
- + getName(), e);
- }
- }
- }
-
- @Override
- public synchronized void dispose() {
- JcrUtils.logoutQuietly(currSession);
- super.dispose();
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.utils;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.query.Row;
-
-import org.argeo.eclipse.ui.GenericTableComparator;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.TableColumn;
-
-/**
- * Centralizes and factorizes useful methods to create and manage tables that
- * display artifacts for both editors and views.
- */
-public class ArtifactsTableConfigurer implements SlcNames, SlcTypes,
- DistConstants {
- // private final static Log log = LogFactory
- // .getLog(ArtifactsTableConfigurer.class);
- // Used in the comparator to be able to retrieve the value from a row
- // knowing the corresponding column index.
- private Map<Integer, String> indexToName = new HashMap<Integer, String>();
-
- private CurrentTableComparator comparator;
- private TableViewer viewer;
-
- protected DateFormat timeFormatter = new SimpleDateFormat(DATE_TIME_FORMAT);
-
- /**
- * Create and initialize the table configurer.
- */
- public ArtifactsTableConfigurer(TableViewer viewer,
- int defaultSortColumnIndex, int direction) {
- this.viewer = viewer;
- comparator = new CurrentTableComparator(defaultSortColumnIndex,
- direction);
- }
-
- public GenericTableComparator getComparator() {
- return comparator;
- }
-
- /**
- * Configure column width and header label depending on the value that will
- * be displayed in the current column.
- *
- * @param jcrColumnName
- * @param column
- * @param columnIndex
- */
- public void configureColumn(String jcrColumnName, TableViewerColumn column,
- int columnIndex) {
-
- if (columnIndex != -1
- && getSelectionAdapter(column.getColumn(), columnIndex) != null) {
- column.getColumn().addSelectionListener(
- getSelectionAdapter(column.getColumn(), columnIndex));
- indexToName.put(new Integer(columnIndex), jcrColumnName);
- }
- Object[] objs = DistUiHelpers
- .getLabelAndDefaultValueWidth(jcrColumnName);
- column.getColumn().setWidth((Integer) objs[1]);
- column.getColumn().setText((String) objs[0]);
- }
-
- /**
- * Might be used by client classes to sort the table with based on selected
- * columns.
- *
- * @param column
- * @param index
- * @return
- */
- public SelectionAdapter getSelectionAdapter(final TableColumn column,
- final int index) {
-
- // A comparator must be define
- if (comparator == null)
- return null;
-
- SelectionAdapter selectionAdapter = new SelectionAdapter() {
- private static final long serialVersionUID = 5239138629878556374L;
-
- @Override
- public void widgetSelected(SelectionEvent e) {
-
- try {
-
- comparator.setColumn(index);
- int dir = viewer.getTable().getSortDirection();
- if (viewer.getTable().getSortColumn() == column) {
- dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
- } else {
-
- dir = SWT.DOWN;
- }
- viewer.getTable().setSortDirection(dir);
- viewer.getTable().setSortColumn(column);
- viewer.refresh();
- } catch (Exception exc) {
- exc.printStackTrace();
- }
- }
- };
- return selectionAdapter;
- }
-
- /**
- * provides a label provider that returns the content of a specific cell.
- * Specific treatment is done for some columns when the query returns a code
- * that must be translated to the corresponding value at display time.
- */
- public ColumnLabelProvider getLabelProvider(final String columnName) {
- boolean test = false;
-
- if (test) {
- return new ColumnLabelProvider() {
- private static final long serialVersionUID = 7996387354459551737L;
-
- public String getText(Object element) {
- return null;
- }
-
- public Image getImage(Object element) {
- return null;
- }
- };
- } else
- return new ColumnLabelProvider() {
- private static final long serialVersionUID = 6746632988975282759L;
-
- public String getText(Object element) {
- Row row = (Row) element;
- try {
- return row.getValue(columnName).getString();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot display row " + row, e);
- }
- }
-
- public Image getImage(Object element) {
- return null;
- }
- };
- }
-
- /** Implements comparator for various types of Artifact Table row */
- private class CurrentTableComparator extends GenericTableComparator {
- private static final long serialVersionUID = -4737460932326339442L;
-
- public CurrentTableComparator(int colIndex, int direction) {
- super(colIndex, direction);
- }
-
- @Override
- public int compare(Viewer viewer, Object e1, Object e2) {
- int rc = 0;
-
- if (e1 instanceof Row) {
- try {
-
- Value v1 = ((Row) e1).getValue(indexToName
- .get(propertyIndex));
- Value v2 = ((Row) e2).getValue(indexToName
- .get(propertyIndex));
-
- if (v1.getType() == PropertyType.STRING)
- rc = v1.getString().compareTo(v2.getString());
- else if (v1.getType() == PropertyType.DATE)
- rc = v1.getDate().compareTo(v2.getDate());
- else
- throw new SlcException("comparator for object type "
- + v1.getType() + " is not yet implemented");
- } catch (Exception e) {
- throw new SlcException("rows cannot be compared ", e);
- }
- } else
- throw new SlcException("Unsupported row type");
- // If descending order, flip the direction
- if (direction == DESCENDING) {
- rc = -rc;
- }
- return rc;
- }
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.utils;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.Parameterization;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.menus.CommandContributionItem;
-import org.eclipse.ui.menus.CommandContributionItemParameter;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * Centralizes useful methods to manage command updates
- */
-public class CommandHelpers {
-
- /**
- * Refresh the given command.
- */
- public static void refreshCommand(IMenuManager menuManager,
- IServiceLocator locator, String cmdId, String label, String iconPath,
- boolean showCommand) {
- IContributionItem ici = menuManager.find(cmdId);
- if (ici != null)
- menuManager.remove(ici);
-
- if (showCommand) {
- // Set Params
- CommandContributionItemParameter contributionItemParameter = new CommandContributionItemParameter(
- locator, null, cmdId, SWT.PUSH);
- contributionItemParameter.label = label;
- contributionItemParameter.icon = DistPlugin.getImageDescriptor(iconPath);
- CommandContributionItem cci = new CommandContributionItem(
- contributionItemParameter);
- cci.setId(cmdId);
- menuManager.add(cci);
- }
- }
-
- /**
- * Refresh the given command and optionally corresponding parameters.
- *
- * @param menuManager
- * @param locator
- * @param cmdId
- * @param label
- * @param showCommand
- * Command must be explicitly removed from the context menu at
- * each refresh setting this to false.
- * @param params
- * maps a paramId with a String value
- */
- public static void refreshParameterizedCommand(IMenuManager menuManager,
- IServiceLocator locator, String cmdId, String label, String iconPath,
- boolean showCommand, Map<String, String> params) {
- IContributionItem ici = menuManager.find(cmdId);
- if (ici != null)
- menuManager.remove(ici);
-
- if (showCommand) {
- // Set Params
- CommandContributionItemParameter contributionItemParameter = new CommandContributionItemParameter(
- locator, null, cmdId, SWT.PUSH);
- contributionItemParameter.label = label;
- contributionItemParameter.icon = DistPlugin.getImageDescriptor(iconPath);
-
- if (params != null)
- contributionItemParameter.parameters = params;
-
- CommandContributionItem cci = new CommandContributionItem(
- contributionItemParameter);
- cci.setId(cmdId);
- menuManager.add(cci);
- }
- }
-
- /** Helper to call a command without parameter easily */
- public static void callCommand(String commandID) {
- callCommand(commandID, null);
- }
-
- /** Helper to call a command with a single parameter easily */
- public static void callCommand(String commandID, String parameterID,
- String parameterValue) {
- Map<String, String> params = new HashMap<String, String>();
- params.put(parameterID, parameterValue);
- callCommand(commandID, params);
- }
-
- /**
- * Helper to call a command with a map of parameters easily
- *
- * @param paramMap
- * a map that links various commands ids with corresponding
- * String values.
- */
- public static void callCommand(String commandID,
- Map<String, String> paramMap) {
- try {
- IWorkbench iw = DistPlugin.getDefault().getWorkbench();
- IHandlerService handlerService = (IHandlerService) iw
- .getService(IHandlerService.class);
- ICommandService cmdService = (ICommandService) iw
- .getActiveWorkbenchWindow().getService(
- ICommandService.class);
- Command cmd = cmdService.getCommand(commandID);
-
- ArrayList<Parameterization> parameters = null;
- ParameterizedCommand pc;
-
- if (paramMap != null) {
- // Set parameters of the command to launch :
- parameters = new ArrayList<Parameterization>();
- Parameterization parameterization;
- for (String id : paramMap.keySet()) {
- parameterization = new Parameterization(
- cmd.getParameter(id), paramMap.get(id));
- parameters.add(parameterization);
- }
- pc = new ParameterizedCommand(cmd,
- parameters.toArray(new Parameterization[parameters.size()]));
- } else
- pc = new ParameterizedCommand(cmd, null);
-
- // build the parameterized command
- // execute the command
- handlerService.executeCommand(pc, null);
- } catch (Exception e) {
- throw new SlcException(
- "Unexepected exception while opening node editor", e);
- }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.utils;
-
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.GenericTableComparator;
-import org.argeo.slc.SlcException;
-import org.eclipse.jface.viewers.Viewer;
-
-/** Add ability to order by name version and version */
-public class DistNodeViewerComparator extends GenericTableComparator {
- private static final long serialVersionUID = -5966120108210992211L;
-
- private final static Log log = LogFactory
- .getLog(DistNodeViewerComparator.class);
-
- // Jcr property type goes to 12
- public final static int NAME_VERSION_TYPE = 100;
- public final static int VERSION_TYPE = 101;
-
- protected List<String> propertiesList;
- protected List<Integer> propertyTypesList;
- protected Integer propertyType;
- protected String property;
-
- private NameVersionComparator nvc = new NameVersionComparator();
- private VersionComparator vc = new VersionComparator();
-
- public DistNodeViewerComparator(int defaultColIndex, int defaultDirection,
- List<String> propertiesList, List<Integer> propertyTypesList) {
- super(defaultColIndex, defaultDirection);
- this.propertiesList = propertiesList;
- this.propertyTypesList = propertyTypesList;
- this.propertyIndex = defaultColIndex;
- this.propertyType = propertyTypesList.get(defaultColIndex);
- this.property = propertiesList.get(defaultColIndex);
- setColumn(defaultColIndex);
- }
-
- @Override
- public int compare(Viewer viewer, Object e1, Object e2) {
- int rc = 0;
- long lc = 0;
-
- try {
- Node n1 = (Node) e1;
- Node n2 = (Node) e2;
-
- Value v1 = null;
- Value v2 = null;
- if (n1.hasProperty(property))
- v1 = n1.getProperty(property).getValue();
- if (n2.hasProperty(property))
- v2 = n2.getProperty(property).getValue();
-
- if (v2 == null && v1 == null)
- return 0;
- else if (v2 == null)
- return -1;
- else if (v1 == null)
- return 1;
-
- switch (propertyType) {
- case NAME_VERSION_TYPE:
- rc = nvc.compare(viewer, v1.getString(), v2.getString());
- break;
- case VERSION_TYPE:
- rc = vc.compare(viewer, v1.getString(), v2.getString());
- break;
- case PropertyType.STRING:
- rc = v1.getString().compareTo(v2.getString());
- break;
- case PropertyType.BOOLEAN:
- boolean b1 = v1.getBoolean();
- boolean b2 = v2.getBoolean();
- if (b1 == b2)
- rc = 0;
- else
- // we assume true is greater than false
- rc = b1 ? 1 : -1;
- break;
- case PropertyType.DATE:
- Calendar c1 = v1.getDate();
- Calendar c2 = v2.getDate();
- if (c1 == null || c2 == null)
- log.trace("undefined date");
- lc = c1.getTimeInMillis() - c2.getTimeInMillis();
- if (lc < Integer.MIN_VALUE)
- // rc = Integer.MIN_VALUE;
- rc = -1;
- else if (lc > Integer.MAX_VALUE)
- // rc = Integer.MAX_VALUE;
- rc = 1;
- else
- rc = (int) lc;
- break;
- case PropertyType.LONG:
- long l1;
- long l2;
- // FIXME sometimes an empty string is set instead of the id
- try {
- l1 = v1.getLong();
- } catch (ValueFormatException ve) {
- l1 = 0;
- }
- try {
- l2 = v2.getLong();
- } catch (ValueFormatException ve) {
- l2 = 0;
- }
-
- lc = l1 - l2;
- if (lc < Integer.MIN_VALUE)
- // rc = Integer.MIN_VALUE;
- rc = -1;
- else if (lc > Integer.MAX_VALUE)
- // rc = Integer.MAX_VALUE;
- rc = 1;
- else
- rc = (int) lc;
- break;
- case PropertyType.DECIMAL:
- BigDecimal bd1 = v1.getDecimal();
- BigDecimal bd2 = v2.getDecimal();
- rc = bd1.compareTo(bd2);
- break;
- default:
- throw new SlcException(
- "Unimplemented comparaison for PropertyType "
- + propertyType);
- }
-
- // If descending order, flip the direction
- if (direction == DESCENDING) {
- rc = -rc;
- }
-
- } catch (RepositoryException re) {
- throw new SlcException("Unexpected error "
- + "while comparing nodes", re);
- }
- return rc;
- }
-
- @Override
- public void setColumn(int column) {
- if (column == this.propertyIndex) {
- // Same column as last sort; toggle the direction
- direction = 1 - direction;
- } else {
- // New column; do a descending sort
- this.propertyIndex = column;
- this.propertyType = propertyTypesList.get(column);
- this.property = propertiesList.get(column);
- direction = ASCENDING;
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.utils;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-
-public class DistUiHelpers implements DistConstants, SlcTypes, SlcNames {
- private final static Log log = LogFactory.getLog(DistUiHelpers.class);
- private final static DateFormat df = new SimpleDateFormat(DATE_TIME_FORMAT);
-
- /**
- * Returns a user-friendly label for a given jcr property name. If the
- * corresponding mapping is not found, the input String is returned. If
- * input String is null "(No name)" is returned
- */
- public static String getLabelJcrName(String jcrName) {
- return (String) getLabelAndDefaultValueWidth(jcrName)[0];
- }
-
- /**
- * Returns a label ( (String) object[0] )and default value width ( (int)
- * object[1] ) for a given property name
- */
- public static Object[] getLabelAndDefaultValueWidth(String propertyName) {
- // to avoid npe :
- if (propertyName == null)
- return new Object[] { "(No name)", 60 };
-
- // ArtifactId
- if (propertyName.equals(SLC_ARTIFACT + "." + SLC_ARTIFACT_ID)
- || propertyName.equals(SLC_ARTIFACT_BASE + "."
- + SLC_ARTIFACT_ID)
- || propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
- + SLC_ARTIFACT_ID)
- || propertyName.equals(SLC_ARTIFACT_ID)) {
- return new Object[] { "Artifact ID", 200 };
- } // GroupId
- else if (propertyName.equals(SLC_ARTIFACT + "." + SLC_GROUP_ID)
- || propertyName.equals(SLC_ARTIFACT_BASE + "." + SLC_GROUP_ID)
- || propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
- + SLC_GROUP_ID) || propertyName.equals(SLC_GROUP_ID)) {
- return new Object[] { "Group ID", 120 };
- } // Version
- else if (propertyName.equals(SLC_ARTIFACT + "." + SLC_ARTIFACT_VERSION)
- || propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
- + SLC_ARTIFACT_VERSION)
- || propertyName.equals(SLC_ARTIFACT_VERSION)) {
- return new Object[] { "Version", 60 };
- } else if (propertyName.equals(SLC_ARTIFACT + "."
- + SLC_ARTIFACT_CLASSIFIER)
- || propertyName.equals(SLC_ARTIFACT_CLASSIFIER)) {
- return new Object[] { "Classifier", 60 };
- } else if (propertyName.equals(SLC_ARTIFACT + "."
- + SLC_ARTIFACT_EXTENSION)
- || propertyName.equals(SLC_ARTIFACT_EXTENSION)) {
- return new Object[] { "Type", 40 };
- } else if (propertyName.equals(SLC_BUNDLE_ARTIFACT + "."
- + SLC_SYMBOLIC_NAME)
- || propertyName.equals(SLC_SYMBOLIC_NAME)) {
- return new Object[] { "Symbolic name", 180 };
- } else if (propertyName.equals(SLC_BUNDLE_ARTIFACT + "."
- + SLC_BUNDLE_VERSION)
- || propertyName.equals(SLC_BUNDLE_VERSION)) {
- return new Object[] { "Bundle version", 120 };
- } else if (propertyName
- .equals(SLC_BUNDLE_ARTIFACT + "." + SLC_MANIFEST)
- || propertyName.equals(SLC_MANIFEST)) {
- return new Object[] { "Manifest", 60 };
- } // TODO remove hard coded strings
- else if (propertyName.equals("slc:Bundle-ManifestVersion")) {
- return new Object[] { "Bundle Manifest Version", 60 };
- } else if (propertyName.equals("slc:Manifest-Version")) {
- return new Object[] { "Manifest Version", 60 };
- } else if (propertyName.equals("slc:Bundle-Vendor")) {
- return new Object[] { "Bundle Vendor", 60 };
- } else if (propertyName.equals("slc:Bundle-SymbolicName")) {
- return new Object[] { "Bundle symbolic name", 60 };
- } else if (propertyName.equals("slc:Bundle-Name")) {
- return new Object[] { "Bundle name", 60 };
- } else if (propertyName.equals("slc:Bundle-DocURL")) {
- return new Object[] { "Doc URL", 120 };
- } else if (propertyName.equals("slc:Bundle-Licence")) {
- return new Object[] { "Bundle licence", 120 };
- } else if (propertyName.equals(SLC_ARTIFACT_VERSION_BASE + "."
- + JCR_IDENTIFIER)) {
- return new Object[] { "UUID", 0 };
- } else {
- if (log.isTraceEnabled())
- log.trace("No Column label provider defined for property: ["
- + propertyName + "]");
- return new Object[] { propertyName, 60 };
- }
- }
-
- public static String formatValueAsString(Value value) {
- try {
- String strValue;
-
- if (value.getType() == PropertyType.BINARY)
- strValue = "<binary>";
- else if (value.getType() == PropertyType.DATE)
- strValue = df.format(value.getDate().getTime());
- else
- strValue = value.getString();
- return strValue;
- } catch (RepositoryException e) {
- throw new SlcException("unexpected error while formatting value",
- e);
- }
- }
-
- public static String formatAsString(Object value) {
- String strValue;
- if (value instanceof Calendar)
- strValue = df.format(((Calendar) value).getTime());
- else
- strValue = value.toString();
- return strValue;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.utils;
-
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
-
-/** Convenience class to reduce the number of methods to implement */
-public abstract class HyperlinkAdapter implements IHyperlinkListener {
-
- public void linkEntered(HyperlinkEvent e) {
- }
-
- public void linkExited(HyperlinkEvent e) {
- }
-
- /** Must be overriden **/
- public abstract void linkActivated(HyperlinkEvent e);
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.utils;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-
-/**
- * Enable comparison of two names version string with form org.argeo.slc-1.2.x.
- * with following rules and assumptions:
- * <ul>
- * <li>
- * Names are ordered using Lexicographical order</li>
- * <li>
- * Version are parsed and compared segment by segment; doing best effort to
- * convert major, minor and micro to integer and compare them as such (to have
- * 0.1 < 0.9 < 0.10 not 0.1 < 0.10 < 0.9).</li>
- * <li>Version should not contain any dash (-), version segments should be
- * separated by dots (.)</li>
- * </ul>
- */
-
-public class NameVersionComparator extends ViewerComparator {
- private static final long serialVersionUID = 8290130681918221197L;
-
- private VersionComparator vc = new VersionComparator();
-
- @Override
- public int category(Object element) {
- if (element instanceof String) {
- int lastInd = ((String) element).lastIndexOf('-');
- if (lastInd > 0)
- return 10;
- }
- // unvalid names always last
- return 5;
- }
-
- @Override
- public int compare(Viewer viewer, Object e1, Object e2) {
- int cat1 = category(e1);
- int cat2 = category(e2);
-
- if (cat1 != cat2) {
- return cat1 - cat2;
- }
-
- int result = 0;
-
- String s1, s2;
-
- if (e1 instanceof TreeParent) {
- s1 = ((TreeParent) e1).getName();
- s2 = ((TreeParent) e2).getName();
- } else {
- s1 = e1.toString();
- s2 = e2.toString();
- }
-
- int i1 = s1.lastIndexOf('-');
- int i2 = s2.lastIndexOf('-');
-
- // Specific cases, unvalid Strings
- if (i1 < 0)
- if (i2 < 0)
- return s1.compareTo(s2);
- else
- return 1;
- else if (i2 < 0)
- return -1;
-
- String aName = s1.substring(0, s1.lastIndexOf('-'));
- String aVersion = s1.substring(s1.lastIndexOf('-'));
-
- String bName = s2.substring(0, s2.lastIndexOf('-'));
- String bVersion = s2.substring(s2.lastIndexOf('-'));
-
- result = aName.compareTo(bName);
- if (result != 0)
- return result;
- else
- return vc.compare(viewer, aVersion, bVersion);
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.utils;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-
-/**
- * Enable comparison of two version string with form "1.2.5.qualifier" with
- * following rules and assumptions:
- * <ul>
- * <li>
- * Version are parsed and compared segment by segment; doing best effort to
- * convert major, minor and micro to integer and compare them as such (to have
- * 0.1 < 0.9 < 0.10 not 0.1 < 0.10 < 0.9).</li>
- * <li>Version should not contain any dash (-), version segments should be
- * separated by dots (.)</li>
- * </ul>
- */
-
-public class VersionComparator extends ViewerComparator {
- private static final long serialVersionUID = 3760077835650538982L;
-
- @Override
- public int compare(Viewer viewer, Object e1, Object e2) {
- String s1 = (String) e1;
- String s2 = (String) e2;
- return compareVersion(s1, s2);
- }
-
- /**
- * Enable comparison of two versions of the form
- * "major.minor.micro.qualifier". We assume the separator is always a "."
- * and make best effort to convert major, minor and micro to int.
- */
- private int compareVersion(String v1, String v2) {
- String[] t1 = v1.split("\\.");
- String[] t2 = v2.split("\\.");
-
- for (int i = 0; i < t1.length && i < t2.length; i++) {
- int result = compareToken(t1[i], t2[i]);
- if (result != 0)
- return result;
- }
- if (t1.length > t2.length)
- return 1;
- else if (t1.length < t2.length)
- return -1;
- else
- return 0;
- }
-
- private int compareToken(String t1, String t2) {
- if (t1 == null && t2 == null)
- return 0;
- else if (t1 == null)
- return -1;
- else if (t2 == null)
- return 1;
-
- Integer i1 = null, i2 = null;
- try {
- i1 = new Integer(t1);
- i2 = new Integer(t2);
- } catch (NumberFormatException nfe) {
- // the format is not valid we silently compare as String
- return t1.compareTo(t2);
- }
- return i1.compareTo(i2);
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.utils;
-
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TreeColumn;
-
-/** Useful methods to manage table to display nodes list. */
-public class ViewerUtils {
-
- /**
- * Creates a basic column for the given table. For the time being, we do not
- * support moveable columns.
- */
- public static TableColumn createColumn(Table parent, String name,
- int style, int width) {
- TableColumn result = new TableColumn(parent, style);
- result.setText(name);
- result.setWidth(width);
- result.setResizable(true);
- return result;
- }
-
- /**
- * Creates a TableViewerColumn for the given viewer. For the time being, we
- * do not support moveable columns.
- */
- public static TableViewerColumn createTableViewerColumn(TableViewer parent,
- String name, int style, int width) {
- TableViewerColumn tvc = new TableViewerColumn(parent, style);
- final TableColumn column = tvc.getColumn();
- column.setText(name);
- column.setWidth(width);
- column.setResizable(true);
- return tvc;
- }
-
- /**
- * Creates a TreeViewerColumn for the given viewer. For the time being, we
- * do not support moveable columns.
- */
- public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent,
- String name, int style, int width) {
- TreeViewerColumn tvc = new TreeViewerColumn(parent, style);
- final TreeColumn column = tvc.getColumn();
- column.setText(name);
- column.setWidth(width);
- column.setResizable(true);
- return tvc;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.views;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.Row;
-import javax.jcr.query.RowIterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.GenericTableComparator;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.utils.ArtifactsTableConfigurer;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.part.ViewPart;
-
-/** Factorizes useful methods to build a query view in a sashForm */
-public abstract class AbstractQueryArtifactsView extends ViewPart implements
- SlcTypes {
- private static final Log log = LogFactory
- .getLog(AbstractQueryArtifactsView.class);
-
- // shortcuts
- final protected static String SAVB = "[" + SLC_ARTIFACT_VERSION_BASE + "]";
- final protected static String SBA = "[" + SLC_BUNDLE_ARTIFACT + "]";
- final protected static String SIP = "[" + SLC_IMPORTED_PACKAGE + "]";
- final protected static String SEP = "[" + SLC_EXPORTED_PACKAGE + "]";
-
- /* DEPENDENCY INJECTION */
- private Session session;
- private List<String> columnProperties;
-
- // This page widgets
- private TableViewer viewer;
- private List<TableViewerColumn> tableViewerColumns = new ArrayList<TableViewerColumn>();
- private ArtifactsTableConfigurer tableConfigurer;
- private GenericTableComparator comparator;
-
- // to be set by client to display all columns
- private boolean displayAllColumns = false;
-
- protected void createResultPart(Composite parent) {
- viewer = new TableViewer(parent);
- Table table = viewer.getTable();
- table.getParent().setLayout(new GridLayout(1, false));
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- viewer.getTable().setHeaderVisible(true);
- viewer.getTable().setLinesVisible(true);
-
- viewer.setLabelProvider(new ViewLabelProvider());
- viewer.setContentProvider(new ViewContentProvider());
- // viewer.addDoubleClickListener(new GenericDoubleClickListener());
-
- tableConfigurer = new ArtifactsTableConfigurer(viewer, 1,
- GenericTableComparator.DESCENDING);
-
- comparator = tableConfigurer.getComparator();
- viewer.setComparator(comparator);
- }
-
- protected void executeQuery(String statement) {
- try {
- Calendar stStamp = new GregorianCalendar();
- if (log.isDebugEnabled()) {
- log.debug("Executed query: " + statement);
- }
- QueryResult qr = session.getWorkspace().getQueryManager()
- .createQuery(statement, Query.JCR_SQL2).execute();
-
- if (log.isDebugEnabled()) {
- Calendar enStamp = new GregorianCalendar();
- long duration = enStamp.getTimeInMillis()
- - stStamp.getTimeInMillis();
- log.debug("Query executed in : " + duration / 1000 + "s.");
- }
-
- // remove previous columns
- for (TableViewerColumn tvc : tableViewerColumns)
- tvc.getColumn().dispose();
-
- // If a pre(-defined list of columns has been injected, we use it,
- // otherwise we display all results of the resultSet
- if (!displayAllColumns && columnProperties != null) {
- int i = 0;
-
- Iterator<String> it = columnProperties.iterator();
- while (it.hasNext()) {
- String columnName = it.next();
-
- TableViewerColumn tvc = new TableViewerColumn(viewer,
- SWT.NONE);
- tableConfigurer.configureColumn(columnName, tvc, i);
- tvc.setLabelProvider(tableConfigurer
- .getLabelProvider(columnName));
- tableViewerColumns.add(tvc);
- i++;
- }
- } else {
- int i = 0;
- for (final String columnName : qr.getColumnNames()) {
- TableViewerColumn tvc = new TableViewerColumn(viewer,
- SWT.NONE);
- // Small hack to remove prefix from the column name
- // String tmpStr = columnName.substring(columnName
- // .lastIndexOf(".") + 1);
- tableConfigurer.configureColumn(columnName, tvc, i);
- tvc.setLabelProvider(tableConfigurer
- .getLabelProvider(columnName));
- tableViewerColumns.add(tvc);
- i++;
- }
- }
- // We must create a local list because query result can be read only
- // once.
- try {
- List<Row> rows = new ArrayList<Row>();
- RowIterator rit = qr.getRows();
- while (rit.hasNext()) {
- rows.add(rit.nextRow());
- }
- viewer.setInput(rows);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot read query result", e);
- }
-
- } catch (RepositoryException e) {
- ErrorDialog.openError(null, "Error", "Cannot execute JCR query: "
- + statement, new Status(IStatus.ERROR,
- "org.argeo.eclipse.ui.jcr", e.getMessage()));
- }
- }
-
- /**
- * Client must use this method to display all columns of the result set
- * instead of a limited predifined and injected set
- **/
- public void displayAllColumns(boolean flag) {
- displayAllColumns = flag;
- }
-
- // Can be overridden by subclasses.
- protected String generateSelectStatement() {
- StringBuffer sb = new StringBuffer("select " + SAVB + ".* ");
- return sb.toString();
- }
-
- protected String generateFromStatement() {
- StringBuffer sb = new StringBuffer(" from ");
- sb.append(SAVB);
- sb.append(" ");
- return sb.toString();
- }
-
- // Providers
- protected class ViewContentProvider implements IStructuredContentProvider {
- private static final long serialVersionUID = 5286293288979552056L;
-
- public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
- }
-
- public void dispose() {
- }
-
- @SuppressWarnings("unchecked")
- public Object[] getElements(Object obj) {
- return ((List<String[]>) obj).toArray();
- }
- }
-
- protected class ViewLabelProvider extends LabelProvider implements
- ITableLabelProvider {
- private static final long serialVersionUID = -2407263563879116348L;
-
- public String getColumnText(Object obj, int index) {
- if (!(obj instanceof String[]))
- return "Object is not properly formatted ";
-
- String[] value = (String[]) obj;
-
- return value[index];
- }
-
- public Image getColumnImage(Object obj, int index) {
- return null;
- }
- }
-
- /* DEPENDENCY INJECTION */
- public void setSession(Session session) {
- this.session = session;
- }
-
- public void setColumnProperties(List<String> columnProperties) {
- this.columnProperties = columnProperties;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.cms.ArgeoNames;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeComparator;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Browse, manipulate and manage distributions accross multiple repositories
- * (like fetch, merge, publish, etc.).
- */
-public class AnonymousDistributionsView extends ViewPart implements SlcNames,
- ArgeoNames {
- // private final static Log log = LogFactory
- // .getLog(AnonymousDistributionsView.class);
- public final static String ID = DistPlugin.PLUGIN_ID
- + ".anonymousDistributionsView";
-
- /* DEPENDENCY INJECTION */
- private ITreeContentProvider treeContentProvider;
-
- // This view widgets
- private TreeViewer viewer;
-
- @Override
- public void createPartControl(Composite parent) {
- // Define the TableViewer
- viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.FULL_SELECTION | SWT.BORDER);
-
- TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(400);
- col.setLabelProvider(new DistTreeLabelProvider());
-
- final Tree tree = viewer.getTree();
- tree.setHeaderVisible(false);
- tree.setLinesVisible(false);
-
- // viewer.setContentProvider(new DistTreeContentProvider());
- viewer.setContentProvider(treeContentProvider);
- viewer.addDoubleClickListener(new DistTreeDoubleClickListener(viewer));
- viewer.setComparator(new DistTreeComparator());
-
- // Initialize
- refresh();
- }
-
- /**
- * Force refresh of the whole view
- */
- public void refresh() {
- Object[] ee = viewer.getExpandedElements();
- viewer.setInput(DistConstants.DEFAULT_PUBLIC_REPOSITORY_URI);
- // viewer.expandToLevel(2);
- viewer.setExpandedElements(ee);
- }
-
- @Override
- public void setFocus() {
- viewer.getTree().setFocus();
- }
-
- /*
- * DEPENDENCY INJECTION
- */
- public void setTreeContentProvider(ITreeContentProvider treeContentProvider) {
- this.treeContentProvider = treeContentProvider;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.views;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistConstants;
-import org.argeo.slc.client.ui.dist.DistImages;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.controllers.ArtifactsTreeContentProvider;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Basic View to browse a maven based repository.
- *
- * By Default size of the various bundles is not computed but it can be
- * activated the view command.
- */
-
-public class ArtifactsBrowser extends ViewPart implements DistConstants,
- RepoConstants {
- // private final static Log log = LogFactory.getLog(ArtifactsBrowser.class);
- public final static String ID = DistPlugin.PLUGIN_ID + ".artifactsBrowser";
-
- /* DEPENDENCY INJECTION */
- private Session jcrSession;
-
- // Business objects
- private Node rootNode;
-
- // This page widgets
- private TreeViewer artifactTreeViewer;
- private boolean isSizeVisible = false;
-
- // To be able to configure columns easily
- public static final int COLUMN_TREE = 0;
- public static final int COLUMN_DATE = 1;
- public static final int COLUMN_SIZE = 2;
- private static final int SIZE_COL_WIDTH = 55;
-
- @Override
- public void createPartControl(Composite parent) {
- // Enable the different parts to fill the whole page when the tab is
- // maximized
- parent.setLayout(new FillLayout());
- artifactTreeViewer = createArtifactsTreeViewer(parent);
-
- // context menu : it is completely defined in the plugin.xml file.
- // Nothing in the context menu for the time being
- // MenuManager menuManager = new MenuManager();
- // Menu menu =
- // menuManager.createContextMenu(artifactTreeViewer.getTree());
- // artifactTreeViewer.getTree().setMenu(menu);
- // getSite().registerContextMenu(menuManager, artifactTreeViewer);
-
- getSite().setSelectionProvider(artifactTreeViewer);
- // packagesViewer.setComparer(new NodeViewerComparer());
-
- // Model initialisation
- if (jcrSession != null) {
- try {
- rootNode = jcrSession.getNode(DEFAULT_ARTIFACTS_BASE_PATH);
- artifactTreeViewer.setInput(rootNode);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot load base artifact nodes", e);
- }
- }
- }
-
- protected TreeViewer createArtifactsTreeViewer(Composite parent) {
- int style = SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION;
- Tree tree = new Tree(parent, style);
- createColumn(tree, "Artifacts", SWT.LEFT, 300);
- createColumn(tree, "Date created", SWT.LEFT, 105);
- createColumn(tree, "Size", SWT.RIGHT, 0);
- tree.setLinesVisible(true);
- tree.setHeaderVisible(true);
-
- TreeViewer viewer = new TreeViewer(tree);
-
- viewer.setContentProvider(new ArtifactsTreeContentProvider());
- viewer.setLabelProvider(new ArtifactLabelProvider());
- viewer.addSelectionChangedListener(new ArtifactTreeSelectionListener());
- // viewer.addDoubleClickListener(new GenericDoubleClickListener());
- viewer.setInput(rootNode);
-
- return viewer;
- }
-
- private static TreeColumn createColumn(Tree parent, String name, int style,
- int width) {
- TreeColumn result = new TreeColumn(parent, style);
- result.setText(name);
- result.setWidth(width);
- result.setMoveable(true);
- result.setResizable(true);
- return result;
- }
-
- protected TreeViewer getArtifactTreeViewer() {
- return artifactTreeViewer;
- }
-
- @Override
- public void setFocus() {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * Refresh the given element of the tree browser. If null is passed as a
- * parameter, it refreshes the whole tree
- */
- public void refresh(Object element) {
- if (element == null) {
- artifactTreeViewer.refresh(rootNode);
- } else
- artifactTreeViewer.refresh(element);
- }
-
- /** Returns wether size column is visible or not */
- public boolean isSizeVisible() {
- return isSizeVisible;
- }
-
- /** Sets the visibility of the size column */
- public void setSizeVisible(boolean visible) {
- if (isSizeVisible == visible)
- return; // nothing has changed
- else
- isSizeVisible = visible;
-
- if (visible) {
- artifactTreeViewer.getTree().getColumn(COLUMN_SIZE)
- .setWidth(SIZE_COL_WIDTH);
- } else {
- // we just hide the column, we don't refresh the whole tree.
- artifactTreeViewer.getTree().getColumn(COLUMN_SIZE).setWidth(0);
- }
- }
-
- private class ArtifactLabelProvider extends ColumnLabelProvider implements
- DistConstants, SlcTypes {
- private static final long serialVersionUID = 7516705499556141806L;
-
- // Utils
- protected DateFormat timeFormatter = new SimpleDateFormat(
- DATE_TIME_FORMAT);
-
- public void update(ViewerCell cell) {
- int colIndex = cell.getColumnIndex();
- Object element = cell.getElement();
- cell.setText(getColumnText(element, colIndex));
-
- if (element instanceof Node && colIndex == 0) {
- Node node = (Node) element;
- try {
- if (node.isNodeType(SLC_ARTIFACT_BASE))
- cell.setImage(DistImages.IMG_ARTIFACT_BASE);
- else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE))
- cell.setImage(DistImages.IMG_ARTIFACT_VERSION_BASE);
- } catch (RepositoryException e) {
- // Silent
- }
- }
- }
-
- @Override
- public Image getImage(Object element) {
-
- if (element instanceof Node) {
- Node node = (Node) element;
- try {
- if (node.isNodeType(SLC_ARTIFACT_BASE)) {
- return DistImages.IMG_ARTIFACT_BASE;
- } else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) {
- return DistImages.IMG_ARTIFACT_VERSION_BASE;
- }
- } catch (RepositoryException e) {
- // Silent
- }
- }
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- try {
- if (element instanceof Node) {
- Node node = (Node) element;
- switch (columnIndex) {
- case COLUMN_TREE:
- return node.getName();
- case COLUMN_SIZE:
- if (isSizeVisible) {
- long size = JcrUtils.getNodeApproxSize(node) / 1024;
- if (size > 1024)
- return size / 1024 + " MB";
- else
- return size + " KB";
- } else
- return "";
- case COLUMN_DATE:
- if (node.hasProperty(Property.JCR_CREATED))
- return timeFormatter.format(node
- .getProperty(Property.JCR_CREATED)
- .getDate().getTime());
- else
- return null;
- }
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexepected error while getting property values", re);
- }
- return null;
- }
-
- // private String formatValueAsString(Value value) {
- // // TODO enhance this method
- // try {
- // String strValue;
- //
- // if (value.getType() == PropertyType.BINARY)
- // strValue = "<binary>";
- // else if (value.getType() == PropertyType.DATE)
- // strValue = timeFormatter.format(value.getDate().getTime());
- // else
- // strValue = value.getString();
- // return strValue;
- // } catch (RepositoryException e) {
- // throw new SlcException(
- // "unexpected error while formatting value", e);
- // }
- // }
- }
-
- private class ArtifactTreeSelectionListener implements
- ISelectionChangedListener {
-
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = event.getSelection();
- if (selection != null && selection instanceof IStructuredSelection) {
- IStructuredSelection iss = (IStructuredSelection) selection;
- if (iss.size() == 1) {
- artifactTreeViewer.refresh(iss.getFirstElement());
- }
- }
-
- }
-
- }
-
- /* DEPENDENCY INJECTION */
- public void setJcrSession(Session jcrSession) {
- this.jcrSession = jcrSession;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.views;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.commands.CopyLocalJavaWorkspace;
-import org.argeo.slc.client.ui.dist.commands.CopyWorkspace;
-import org.argeo.slc.client.ui.dist.commands.CreateLocalJavaWorkspace;
-import org.argeo.slc.client.ui.dist.commands.CreateWorkspace;
-import org.argeo.slc.client.ui.dist.commands.DeleteWorkspace;
-import org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation;
-import org.argeo.slc.client.ui.dist.commands.Fetch;
-import org.argeo.slc.client.ui.dist.commands.NormalizeDistribution;
-import org.argeo.slc.client.ui.dist.commands.NormalizeWorkspace;
-import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
-import org.argeo.slc.client.ui.dist.commands.PublishWorkspace;
-import org.argeo.slc.client.ui.dist.commands.RegisterRepository;
-import org.argeo.slc.client.ui.dist.commands.RunInOsgi;
-import org.argeo.slc.client.ui.dist.commands.UnregisterRemoteRepo;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeComparator;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeComparer;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeContentProvider;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
-import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
-import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
-import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Browse, manipulate and manage distributions across multiple repositories
- * (like fetch, merge, publish, etc.).
- */
-public class DistributionsView extends ViewPart implements SlcNames, ArgeoNames {
- // private final static Log log =
- // LogFactory.getLog(DistributionsView.class);
-
- public final static String ID = DistPlugin.PLUGIN_ID + ".distributionsView";
-
- /* DEPENDENCY INJECTION */
- private Repository nodeRepository;
- private DistTreeContentProvider treeContentProvider;
-
- private TreeViewer viewer;
-
- @Override
- public void createPartControl(Composite parent) {
- // Define the TableViewer
- viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.FULL_SELECTION | SWT.BORDER);
-
- TreeViewerColumn col = new TreeViewerColumn(viewer, SWT.NONE);
- col.getColumn().setWidth(400);
- col.setLabelProvider(new DistTreeLabelProvider());
-
- final Tree tree = viewer.getTree();
- tree.setHeaderVisible(false);
- tree.setLinesVisible(false);
-
- // viewer.setContentProvider(new DistTreeContentProvider());
- viewer.setContentProvider(treeContentProvider);
- viewer.addDoubleClickListener(new DistTreeDoubleClickListener(viewer));
- viewer.setComparer(new DistTreeComparer());
- viewer.setComparator(new DistTreeComparator());
-
- @SuppressWarnings("unused")
- ViewerComparator vc = viewer.getComparator();
-
- // Enable retrieving current tree selected items from outside the view
- getSite().setSelectionProvider(viewer);
-
- MenuManager menuManager = new MenuManager();
- Menu menu = menuManager.createContextMenu(viewer.getTree());
- menuManager.addMenuListener(new IMenuListener() {
- private static final long serialVersionUID = -1454108001335038652L;
-
- public void menuAboutToShow(IMenuManager manager) {
- contextMenuAboutToShow(manager);
- }
- });
- viewer.getTree().setMenu(menu);
- getSite().registerContextMenu(menuManager, viewer);
-
- // Initialize
- refresh();
- }
-
- /** Programatically configure the context menu */
- protected void contextMenuAboutToShow(IMenuManager menuManager) {
- IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow();
-
- // Most of the implemented commands support only one selected
- // element
- boolean singleElement = ((IStructuredSelection) viewer.getSelection())
- .size() == 1;
- // Get Current selected item :
- Object firstElement = ((IStructuredSelection) viewer.getSelection())
- .getFirstElement();
-
- try {
-
- if (firstElement instanceof TreeParent
- || firstElement instanceof DistParentElem) {
-
- String targetRepoPath = null, workspaceName = null, workspacePrefix = null;
- String modularDistBasePath = null;
- String modularDistPath = null;
- // String targetRepoUri = null;
- // Build conditions depending on element type
- boolean isDistribElem = false, isModularDistVersionBaseElem = false, isRepoElem = false, isDistribGroupElem = false;
- boolean isLocal = false, isReadOnly = true;
-
- RepoElem re = null;
-
- if (firstElement instanceof RepoElem) {
- re = (RepoElem) firstElement;
- isRepoElem = true;
- isLocal = re.inHome();
- isReadOnly = re.isReadOnly();
- } else if (firstElement instanceof WkspGroupElem) {
- WkspGroupElem wge = (WkspGroupElem) firstElement;
- isReadOnly = wge.isReadOnly();
- isDistribGroupElem = true;
- re = (RepoElem) wge.getParent();
- workspacePrefix = wge.getName();
- } else if (firstElement instanceof WorkspaceElem) {
- WorkspaceElem we = (WorkspaceElem) firstElement;
- re = we.getRepoElem();
- isDistribElem = true;
- isReadOnly = we.isReadOnly();
- workspaceName = we.getWorkspaceName();
- isLocal = we.inHome();
- } else if (firstElement instanceof ModularDistVersionBaseElem) {
- ModularDistVersionBaseElem mdbe = (ModularDistVersionBaseElem) firstElement;
- isModularDistVersionBaseElem = true;
- re = mdbe.getWkspElem().getRepoElem();
- isLocal = re.inHome();
- isReadOnly = re.isReadOnly();
- workspaceName = mdbe.getWkspElem().getWorkspaceName();
- modularDistBasePath = mdbe.getModularDistBase().getPath();
- } else if (firstElement instanceof ModularDistVersionElem) {
- ModularDistVersionElem mdbe = (ModularDistVersionElem) firstElement;
- re = mdbe.getWorkspaceElem().getRepoElem();
- isLocal = re.inHome();
- isReadOnly = re.isReadOnly();
- workspaceName = mdbe.getWorkspaceElem().getWorkspaceName();
- modularDistPath = mdbe.getModularDistVersionNode()
- .getPath();
- }
-
- if (re != null) {
- targetRepoPath = re.getRepoNodePath();
- }
-
- // Display repo info
- CommandUtils.refreshCommand(menuManager, window,
- DisplayRepoInformation.ID,
- DisplayRepoInformation.DEFAULT_LABEL,
- DisplayRepoInformation.DEFAULT_ICON, isRepoElem
- && singleElement);
-
- // create workspace
- Map<String, String> params = new HashMap<String, String>();
- params.put(CreateWorkspace.PARAM_TARGET_REPO_PATH,
- targetRepoPath);
- params.put(CreateWorkspace.PARAM_WORKSPACE_PREFIX,
- workspacePrefix);
- CommandUtils.refreshParameterizedCommand(menuManager, window,
- CreateWorkspace.ID, CreateWorkspace.DEFAULT_LABEL,
- CreateWorkspace.DEFAULT_ICON,
- (isRepoElem || isDistribGroupElem) && singleElement
- && !isReadOnly && !isLocal, params);
-
- // TODO Manage the case where it is not a java workspace
- params = new HashMap<String, String>();
- params.put(CreateLocalJavaWorkspace.PARAM_WORKSPACE_PREFIX,
- workspacePrefix);
- CommandUtils.refreshParameterizedCommand(menuManager, window,
- CreateLocalJavaWorkspace.ID,
- CreateLocalJavaWorkspace.DEFAULT_LABEL,
- CreateLocalJavaWorkspace.DEFAULT_ICON,
- (isRepoElem || isDistribGroupElem) && singleElement
- && !isReadOnly && isLocal, params);
-
- // Register a remote repository
- CommandUtils.refreshCommand(menuManager, window,
- RegisterRepository.ID,
- RegisterRepository.DEFAULT_LABEL,
- RegisterRepository.DEFAULT_ICON, isRepoElem
- && singleElement);
-
- // Unregister a remote repository
- params = new HashMap<String, String>();
- params.put(UnregisterRemoteRepo.PARAM_REPO_PATH, targetRepoPath);
- CommandUtils.refreshParameterizedCommand(menuManager, window,
- UnregisterRemoteRepo.ID,
- UnregisterRemoteRepo.DEFAULT_LABEL,
- UnregisterRemoteRepo.DEFAULT_ICON, isRepoElem
- && !isLocal && singleElement, params);
-
- // Fetch repository
- params = new HashMap<String, String>();
- params.put(Fetch.PARAM_TARGET_REPO_PATH, targetRepoPath);
- CommandUtils.refreshParameterizedCommand(menuManager, window,
- Fetch.ID, Fetch.DEFAULT_LABEL, Fetch.DEFAULT_ICON,
- isRepoElem && isLocal && singleElement && !isReadOnly,
- params);
-
- // Normalize workspace
- params = new HashMap<String, String>();
- params.put(NormalizeWorkspace.PARAM_TARGET_REPO_PATH,
- targetRepoPath);
- params.put(NormalizeWorkspace.PARAM_WORKSPACE_NAME,
- workspaceName);
-
- CommandUtils.refreshParameterizedCommand(menuManager, window,
- NormalizeWorkspace.ID, "Normalize...",
- NormalizeWorkspace.DEFAULT_ICON, isDistribElem
- && singleElement && !isReadOnly, params);
-
- // Copy workspace
- params = new HashMap<String, String>();
- params.put(CopyWorkspace.PARAM_TARGET_REPO_PATH, targetRepoPath);
- params.put(CopyWorkspace.PARAM_SOURCE_WORKSPACE_NAME,
- workspaceName);
- CommandUtils.refreshParameterizedCommand(menuManager, window,
- CopyWorkspace.ID, CopyWorkspace.DEFAULT_LABEL,
- CopyWorkspace.DEFAULT_ICON, isDistribElem
- && singleElement && !isLocal, params);
-
- params = new HashMap<String, String>();
- params.put(CopyLocalJavaWorkspace.PARAM_SOURCE_WORKSPACE_NAME,
- workspaceName);
- CommandUtils.refreshParameterizedCommand(menuManager, window,
- CopyLocalJavaWorkspace.ID,
- CopyLocalJavaWorkspace.DEFAULT_LABEL,
- CopyLocalJavaWorkspace.DEFAULT_ICON, isDistribElem
- && singleElement && isLocal, params);
-
- // Clear Workspace
- params = new HashMap<String, String>();
- params.put(DeleteWorkspace.PARAM_TARGET_REPO_PATH,
- targetRepoPath);
- params.put(DeleteWorkspace.PARAM_WORKSPACE_NAME, workspaceName);
- CommandUtils.refreshParameterizedCommand(menuManager, window,
- DeleteWorkspace.ID, DeleteWorkspace.DEFAULT_LABEL,
- DeleteWorkspace.DEFAULT_ICON, isDistribElem
- && singleElement && !isReadOnly, params);
-
- // Advanced submenu
- MenuManager submenu = new MenuManager("Advanced",
- DistPlugin.PLUGIN_ID + ".advancedSubmenu");
- IContributionItem ici = menuManager.find(DistPlugin.PLUGIN_ID
- + ".advancedSubmenu");
- if (ici != null)
- menuManager.remove(ici);
-
- // Publish workspace
- params = new HashMap<String, String>();
- params.put(PublishWorkspace.PARAM_TARGET_REPO_PATH,
- targetRepoPath);
- params.put(PublishWorkspace.PARAM_WORKSPACE_NAME, workspaceName);
- CommandUtils.refreshParameterizedCommand(submenu, window,
- PublishWorkspace.ID, PublishWorkspace.DEFAULT_LABEL,
- PublishWorkspace.DEFAULT_ICON, isDistribElem
- && singleElement && !isReadOnly, params);
-
- // Normalize distribution (Legacy)
- params = new HashMap<String, String>();
- params.put(NormalizeDistribution.PARAM_TARGET_REPO_PATH,
- targetRepoPath);
- params.put(NormalizeDistribution.PARAM_WORKSPACE_NAME,
- workspaceName);
- CommandUtils.refreshParameterizedCommand(submenu, window,
- NormalizeDistribution.ID,
- NormalizeDistribution.DEFAULT_LABEL,
- NormalizeDistribution.DEFAULT_ICON, isDistribElem
- && singleElement && !isReadOnly, params);
-
- // Run in OSGi
- params = new HashMap<String, String>();
- params.put(RunInOsgi.PARAM_MODULE_PATH, modularDistPath);
- params.put(RunInOsgi.PARAM_WORKSPACE_NAME, workspaceName);
- CommandUtils.refreshParameterizedCommand(submenu, window,
- RunInOsgi.ID, RunInOsgi.DEFAULT_LABEL,
- RunInOsgi.DEFAULT_ICON, modularDistPath != null
- && singleElement && isLocal, params);
-
- // Open generate binaries
- params = new HashMap<String, String>();
- params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
- targetRepoPath);
- params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
- modularDistBasePath);
- params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
- workspaceName);
-
- CommandUtils.refreshParameterizedCommand(submenu, window,
- OpenGenerateBinariesWizard.ID,
- OpenGenerateBinariesWizard.DEFAULT_LABEL,
- OpenGenerateBinariesWizard.DEFAULT_ICON,
- isModularDistVersionBaseElem && !isReadOnly, params);
-
- if (submenu.getSize() > 0)
- menuManager.add(submenu);
-
- // // Manage workspace authorizations
- // params = new HashMap<String, String>();
- // params.put(ManageWorkspaceAuth.PARAM_WORKSPACE_NAME, wsName);
- // CommandHelpers.refreshParameterizedCommand(menuManager,
- // window,
- // ManageWorkspaceAuth.ID, ManageWorkspaceAuth.DEFAULT_LABEL,
- // ManageWorkspaceAuth.DEFAULT_ICON_PATH, isDistribElem
- // && singleElement && !isReadOnly, params);
- }
- } catch (RepositoryException e) {
- throw new SlcException("unexpected errror while "
- + "building context menu for element " + firstElement, e);
- }
- }
-
- @Override
- public void setFocus() {
- viewer.getTree().setFocus();
- }
-
- /**
- * Force refresh of the whole view
- */
- public void refresh() {
- viewer.setInput(nodeRepository);
- viewer.expandToLevel(2);
- }
-
- /* DEPENDENCY INJECTION */
- public void setNodeRepository(Repository nodeRepository) {
- this.nodeRepository = nodeRepository;
- }
-
- public void setTreeContentProvider(
- DistTreeContentProvider treeContentProvider) {
- this.treeContentProvider = treeContentProvider;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.part.ViewPart;
-
-/** Display some info about the distribution */
-public class HelpView extends ViewPart {
- public final static String ID = DistPlugin.PLUGIN_ID + ".helpView";
-
- @Override
- public void createPartControl(Composite parent) {
- parent.setLayout(new GridLayout(2, false));
- Browser browser = new Browser(parent, SWT.NONE);
- browser.setUrl("/repo/howto.html");
- browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
- }
-
- /** Force refresh of the whole view */
- public void refresh() {
- }
-
- @Override
- public void setFocus() {
- }
-
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/** Query SLC Repo to get some artifacts given some predefined parameters */
-public class QueryArtifactsForm extends AbstractQueryArtifactsView implements
- SlcNames {
- // private static final Log log = LogFactory.getLog(QueryArtifactsForm.class);
- public static final String ID = DistPlugin.PLUGIN_ID + ".queryArtifactsForm";
-
- // widgets
- private Button executeBtn;
- private Text groupId;
- private Text artifactId;
- private Text version;
- private SashForm sashForm;
-
- private Composite top, bottom;
-
- @Override
- public void createPartControl(Composite parent) {
-
- sashForm = new SashForm(parent, SWT.VERTICAL);
- sashForm.setSashWidth(4);
- // Enable the different parts to fill the whole page when the tab is
- // maximized
- sashForm.setLayout(new FillLayout());
-
- top = new Composite(sashForm, SWT.NONE);
- top.setLayout(new GridLayout(1, false));
-
- bottom = new Composite(sashForm, SWT.NONE);
- bottom.setLayout(new GridLayout(1, false));
-
- sashForm.setWeights(new int[] { 25, 75 });
-
- createQueryForm(top);
- createResultPart(bottom);
- }
-
- public void createQueryForm(Composite parent) {
- Label lbl;
- GridData gd;
-
- GridLayout gl = new GridLayout(2, false);
- gl.marginTop = 5;
- parent.setLayout(gl);
-
- // lbl = new Label(parent, SWT.SINGLE);
- // lbl.setText("Query by coordinates");
- // gd = new GridData();
- // gd.horizontalSpan = 2;
- // lbl.setLayoutData(gd);
-
- // Group ID
- lbl = new Label(parent, SWT.SINGLE);
- lbl.setText("Group ID");
- groupId = new Text(parent, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- groupId.setLayoutData(gd);
-
- // Artifact ID
- lbl = new Label(parent, SWT.SINGLE);
- lbl.setText("Artifact ID");
- artifactId = new Text(parent, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- artifactId.setLayoutData(gd);
-
- // Version
- lbl = new Label(parent, SWT.SINGLE);
- lbl.setText("Version");
- version = new Text(parent, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- version.setLayoutData(gd);
-
- executeBtn = new Button(parent, SWT.PUSH);
- executeBtn.setText("Search");
- gd = new GridData();
- gd.horizontalSpan = 2;
- executeBtn.setLayoutData(gd);
-
- Listener executeListener = new Listener() {
- private static final long serialVersionUID = 7161585477628774129L;
-
- public void handleEvent(Event event) {
- refreshQuery();
- }
- };
- executeBtn.addListener(SWT.Selection, executeListener);
- }
-
- public void refreshQuery() {
- String queryStr = generateSelectStatement() + generateFromStatement()
- + generateWhereStatement();
- executeQuery(queryStr);
- bottom.layout();
- sashForm.layout();
- }
-
- private String generateWhereStatement() {
- try {
- boolean hasFirstClause = false;
- StringBuffer sb = new StringBuffer(" where ");
-
- if (groupId.getText() != null
- && !groupId.getText().trim().equals("")) {
- sb.append("[" + SLC_GROUP_ID + "] like '"
- + groupId.getText().replace('*', '%') + "'");
- hasFirstClause = true;
- }
-
- if (artifactId.getText() != null
- && !artifactId.getText().trim().equals("")) {
- if (hasFirstClause)
- sb.append(" AND ");
- sb.append("[" + SLC_ARTIFACT_ID + "] like '"
- + artifactId.getText().replace('*', '%') + "'");
- hasFirstClause = true;
- }
-
- if (version.getText() != null
- && !version.getText().trim().equals("")) {
- if (hasFirstClause)
- sb.append(" AND ");
- sb.append("[" + SLC_ARTIFACT_VERSION + "] like '"
- + version.getText().replace('*', '%') + "'");
- }
-
- return sb.toString();
- } catch (Exception e) {
- throw new SlcException(
- "Cannot generate where statement to get artifacts", e);
- }
- }
-
- @Override
- public void setFocus() {
- executeBtn.setFocus();
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/** Query SLC Repo to get some artifacts with a JCR SQL 2 request. */
-public class QueryArtifactsText extends AbstractQueryArtifactsView implements
- SlcNames {
- // private static final Log log =
- // LogFactory.getLog(QueryArtifactsText.class);
- public static final String ID = DistPlugin.PLUGIN_ID + ".queryArtifactsText";
-
- // widgets
- private Button executeBtn;
- private Text queryText;
- private SashForm sashForm;
-
- private Composite top, bottom;
-
- @Override
- public void createPartControl(Composite parent) {
-
- sashForm = new SashForm(parent, SWT.VERTICAL);
- sashForm.setSashWidth(4);
- // Enable the different parts to fill the whole page when the tab is
- // maximized
- sashForm.setLayout(new FillLayout());
-
- top = new Composite(sashForm, SWT.NONE);
- top.setLayout(new GridLayout(1, false));
-
- bottom = new Composite(sashForm, SWT.NONE);
- bottom.setLayout(new GridLayout(1, false));
-
- sashForm.setWeights(new int[] { 25, 75 });
-
- createQueryForm(top);
- createResultPart(bottom);
- }
-
- public void createQueryForm(Composite parent) {
- Label lbl;
- GridData gd;
-
- GridLayout gl = new GridLayout(2, false);
- gl.marginTop = 5;
- parent.setLayout(gl);
-
- lbl = new Label(parent, SWT.SINGLE);
- lbl.setText("Enter a JCR:SQL2 Query");
-
- executeBtn = new Button(parent, SWT.PUSH);
- executeBtn.setText("Search");
-
- queryText = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- gd.heightHint = 100;
- gd.horizontalSpan = 2;
- queryText.setLayoutData(gd);
-
- String query = generateSelectStatement() + generateFromStatement()
- + generateWhereStatement();
- queryText.setText(query);
-
- Listener executeListener = new Listener() {
- private static final long serialVersionUID = -5028331930076117569L;
-
- public void handleEvent(Event event) {
- refreshQuery();
- }
- };
- executeBtn.addListener(SWT.Selection, executeListener);
- }
-
- public void refreshQuery() {
- String queryStr = queryText.getText();
- executeQuery(queryStr);
- bottom.layout();
- sashForm.layout();
- }
-
- private String generateWhereStatement() {
- StringBuffer sb = new StringBuffer(" where ");
- return sb.toString();
- }
-
- @Override
- public void setFocus() {
- executeBtn.setFocus();
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.views;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/** Query SLC Repo to get some artifacts given some predefined parameters */
-public class QueryBundlesForm extends AbstractQueryArtifactsView implements
- SlcNames, SlcTypes {
- // private static final Log log = LogFactory.getLog(QueryBundlesForm.class);
- public static final String ID = DistPlugin.PLUGIN_ID + ".queryBundlesForm";
-
- // widgets
- private Button executeBtn;
- private Text symbolicName;
- private Text importedPackage;
- private Text exportedPackage;
- private SashForm sashForm;
-
- private Composite top, bottom;
-
- @Override
- public void createPartControl(Composite parent) {
-
- sashForm = new SashForm(parent, SWT.VERTICAL);
- sashForm.setSashWidth(4);
- // Enable the different parts to fill the whole page when the tab is
- // maximized
- sashForm.setLayout(new FillLayout());
-
- top = new Composite(sashForm, SWT.NONE);
- top.setLayout(new GridLayout(1, false));
-
- bottom = new Composite(sashForm, SWT.NONE);
- bottom.setLayout(new GridLayout(1, false));
-
- sashForm.setWeights(new int[] { 25, 75 });
-
- createQueryForm(top);
- createResultPart(bottom);
- }
-
- public void createQueryForm(Composite parent) {
- Label lbl;
- GridData gd;
-
- GridLayout gl = new GridLayout(2, false);
- gl.marginTop = 5;
- parent.setLayout(gl);
-
- // Bundle Name
- lbl = new Label(parent, SWT.SINGLE);
- lbl.setText("Symbolic name");
- symbolicName = new Text(parent, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- symbolicName.setLayoutData(gd);
-
- // imported package
- lbl = new Label(parent, SWT.SINGLE);
- lbl.setText("Imported package");
- importedPackage = new Text(parent, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- importedPackage.setLayoutData(gd);
-
- // exported package
- lbl = new Label(parent, SWT.SINGLE);
- lbl.setText("Exported package");
- exportedPackage = new Text(parent, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- exportedPackage.setLayoutData(gd);
-
- executeBtn = new Button(parent, SWT.PUSH);
- executeBtn.setText("Search");
- gd = new GridData();
- gd.horizontalSpan = 2;
- executeBtn.setLayoutData(gd);
-
- Listener executeListener = new Listener() {
- private static final long serialVersionUID = 6267263421349073712L;
-
- public void handleEvent(Event event) {
- refreshQuery();
- }
- };
- executeBtn.addListener(SWT.Selection, executeListener);
- }
-
- public void refreshQuery() {
- String queryStr = generateStatement();
- executeQuery(queryStr);
- bottom.layout();
- sashForm.layout();
- }
-
- private String generateStatement() {
- try {
- // shortcuts
- boolean hasFirstClause = false;
- boolean ipClause = importedPackage.getText() != null
- && !importedPackage.getText().trim().equals("");
- boolean epClause = exportedPackage.getText() != null
- && !exportedPackage.getText().trim().equals("");
-
- StringBuffer sb = new StringBuffer();
- // Select
- sb.append("select " + SBA + ".*, " + SAVB + ".* ");
- sb.append(" from " + SAVB);
-
- // join
- sb.append(" inner join ");
- sb.append(SBA);
- sb.append(" on isdescendantnode(" + SBA + ", " + SAVB + ") ");
- if (ipClause) {
- sb.append(" inner join ");
- sb.append(SIP);
- sb.append(" on isdescendantnode(" + SIP + ", " + SBA + ") ");
- }
-
- if (epClause) {
- sb.append(" inner join ");
- sb.append(SEP);
- sb.append(" on isdescendantnode(" + SEP + ", " + SBA + ") ");
- }
-
- // where
- sb.append(" where ");
- if (symbolicName.getText() != null
- && !symbolicName.getText().trim().equals("")) {
- sb.append(SBA + ".[" + SLC_SYMBOLIC_NAME + "] like '"
- + symbolicName.getText().replace('*', '%') + "'");
- hasFirstClause = true;
- }
-
- if (ipClause) {
- if (hasFirstClause)
- sb.append(" AND ");
- sb.append(SIP + ".[" + SLC_NAME + "] like '"
- + importedPackage.getText().replace('*', '%') + "'");
- hasFirstClause = true;
- }
-
- if (epClause) {
- if (hasFirstClause)
- sb.append(" AND ");
- sb.append(SEP + ".[" + SLC_NAME + "] like '"
- + exportedPackage.getText().replace('*', '%') + "'");
- }
- return sb.toString();
- } catch (Exception e) {
- throw new SlcException(
- "Cannot generate where statement to get artifacts", e);
- }
- }
-
- @Override
- public void setFocus() {
- executeBtn.setFocus();
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.wizards;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.eclipse.jface.wizard.Wizard;
-
-/**
- * Small wizard to manage authorizations on the root node of the current
- * workspace
- */
-public class ChangeRightsWizard extends Wizard {
-
- private Session currentSession;
-
- // This page widget
- private ChooseRightsPage page;
-
- public ChangeRightsWizard(Session currentSession) {
- super();
- this.currentSession = currentSession;
- }
-
- @Override
- public void addPages() {
- try {
- page = new ChooseRightsPage();
- addPage(page);
- } catch (Exception e) {
- throw new SlcException("Cannot add page to wizard ", e);
- }
- }
-
- @Override
- public boolean performFinish() {
- if (!canFinish())
- return false;
- try {
- JcrUtils.addPrivilege(currentSession, "/", page.getGroupName(),
- page.getAuthTypeStr());
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while setting privileges", re);
- }
- return true;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.wizards;
-
-import javax.jcr.security.Privilege;
-
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-public class ChooseRightsPage extends WizardPage implements ModifyListener {
- private static final long serialVersionUID = 3016024222014878781L;
-
- // This page widget
- private Text groupNameTxt;
- private Combo authorizationCmb;
-
- // Define acceptable chars for the technical name
- // private static Pattern p = Pattern.compile("^[A-Za-z0-9]+$");
-
- // USABLE SHORTCUTS
- protected final static String[] validAuthType = { Privilege.JCR_READ,
- Privilege.JCR_WRITE, Privilege.JCR_ALL };
-
- public ChooseRightsPage() {
- super("Main");
- setTitle("Manage authorizations on the current workspace");
- }
-
- public void createControl(Composite parent) {
- // specify subject
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- Label lbl = new Label(composite, SWT.LEAD);
- lbl.setText("Group or user name (no blank, no special chars)");
- lbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
- groupNameTxt = new Text(composite, SWT.LEAD | SWT.BORDER);
- groupNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
- false));
- if (groupNameTxt != null)
- groupNameTxt.addModifyListener(this);
-
- // Choose rigths
- new Label(composite, SWT.NONE).setText("Choose corresponding rights");
- authorizationCmb = new Combo(composite, SWT.BORDER | SWT.V_SCROLL);
- authorizationCmb.setItems(validAuthType);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- authorizationCmb.setLayoutData(gd);
-
- authorizationCmb.select(0);
-
- // Compulsory
- setControl(composite);
- }
-
- protected String getGroupName() {
- return groupNameTxt.getText();
- }
-
- protected String getAuthTypeStr() {
- return authorizationCmb.getItem(authorizationCmb.getSelectionIndex());
- }
-
- // private static boolean match(String s) {
- // return p.matcher(s).matches();
- // }
-
- public void modifyText(ModifyEvent event) {
- String message = checkComplete();
- if (message != null)
- setMessage(message, WizardPage.ERROR);
- else {
- setMessage("Complete", WizardPage.INFORMATION);
- setPageComplete(true);
- }
- }
-
- /** @return error message or null if complete */
- protected String checkComplete() {
- String groupStr = groupNameTxt.getText();
- if (groupStr == null || "".equals(groupStr))
- return "Please enter the name of the corresponding group.";
- // Remove regexp check for the time being.
- // else if (!match(groupStr))
- // return
- // "Please use only alphanumerical chars for the short technical name.";
- return null;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.dist.wizards;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.ViewerUtils;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoSync;
-import org.argeo.slc.repo.RepoUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Defines parameters for the fetch process and run it using a {@link RepoSync}
- * object.
- */
-public class FetchWizard extends Wizard {
- // private final static Log log = LogFactory.getLog(FetchWizard.class);
-
- // Business objects
- private Keyring keyring;
- private RepositoryFactory repositoryFactory;
- private Session currSession;
- private Node targetRepoNode, sourceRepoNode;
-
- private List<WkspObject> selectedWorkspaces = new ArrayList<WkspObject>();
-
- // The pages
- private ChooseWkspPage chooseWkspPage;
- private RecapPage recapPage;
-
- // Cache the advanced pages
- private Map<WkspObject, AdvancedFetchPage> advancedPages = new HashMap<FetchWizard.WkspObject, FetchWizard.AdvancedFetchPage>();
-
- // Controls with parameters
- private Button filesOnlyBtn;
- private Button advancedBtn;
- private CheckboxTableViewer wkspViewer;
-
- public FetchWizard(Keyring keyring, RepositoryFactory repositoryFactory,
- Repository nodeRepository) {
- super();
- this.keyring = keyring;
- this.repositoryFactory = repositoryFactory;
- try {
- currSession = nodeRepository.login();
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected error while initializing fetch wizard", e);
- }
- }
-
- @Override
- public void dispose() {
- JcrUtils.logoutQuietly(currSession);
- super.dispose();
- }
-
- @Override
- public void addPages() {
- try {
- chooseWkspPage = new ChooseWkspPage();
- addPage(chooseWkspPage);
- recapPage = new RecapPage();
- addPage(recapPage);
- setWindowTitle("Define Fetch Procedure");
- } catch (Exception e) {
- throw new SlcException("Cannot add page to wizard ", e);
- }
- }
-
- @Override
- public boolean performFinish() {
- if (!canFinish())
- return false;
- try {
- // Target Repository
- String targetRepoUri = targetRepoNode.getProperty(
- ArgeoNames.ARGEO_URI).getString();
- Repository targetRepo = RepoUtils.getRepository(repositoryFactory,
- keyring, targetRepoNode);
- Credentials targetCredentials = RepoUtils.getRepositoryCredentials(
- keyring, targetRepoNode);
-
- // Source Repository
- String sourceRepoUri = sourceRepoNode.getProperty(
- ArgeoNames.ARGEO_URI).getString();
- Repository sourceRepo = RepoUtils.getRepository(repositoryFactory,
- keyring, sourceRepoNode);
- Credentials sourceCredentials = RepoUtils.getRepositoryCredentials(
- keyring, sourceRepoNode);
-
- String msg = "Your are about to fetch data from repository: \n\t"
- + sourceRepoUri + "\ninto target repository: \n\t"
- + targetRepoUri + "\nDo you really want to proceed ?";
-
- boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
- .getWorkbench().getDisplay().getActiveShell(),
- "Confirm Fetch Launch", msg);
-
- if (result) {
- RepoSync repoSync = new RepoSync(sourceRepo, sourceCredentials,
- targetRepo, targetCredentials);
- repoSync.setTargetRepoUri(targetRepoUri);
- repoSync.setSourceRepoUri(sourceRepoUri);
-
- // Specify workspaces to synchronise
- Map<String, String> wksps = new HashMap<String, String>();
- for (Object obj : wkspViewer.getCheckedElements()) {
- WkspObject stn = (WkspObject) obj;
- wksps.put(stn.srcName, stn.targetName);
- }
- repoSync.setWkspMap(wksps);
-
- // Set the import files only option
- repoSync.setFilesOnly(filesOnlyBtn.getSelection());
- FetchJob job = new FetchJob(repoSync);
- job.setUser(true);
- job.schedule();
- }
- } catch (Exception e) {
- throw new SlcException(
- "Unexpected error while launching the fetch", e);
- }
- return true;
- }
-
- // ///////////////////////////////
- // ////// THE PAGES
-
- private class ChooseWkspPage extends WizardPage {
- private static final long serialVersionUID = 211336700788047638L;
-
- private Map<String, Node> sourceReposMap;
- private Combo chooseSourceRepoCmb;
-
- public ChooseWkspPage() {
- super("Main");
- setTitle("Choose workspaces to fetch");
- setDescription("Check 'advanced fetch' box to "
- + "rename workspaces and fine tune the process");
-
- // Initialise with registered Repositories
- sourceReposMap = getSourceRepoUris();
- }
-
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NO_FOCUS);
- composite.setLayout(new GridLayout(2, false));
-
- // Choose source repository combo
- new Label(composite, SWT.NONE)
- .setText("Choose a source repository");
- chooseSourceRepoCmb = new Combo(composite, SWT.BORDER
- | SWT.V_SCROLL);
- chooseSourceRepoCmb.setItems(sourceReposMap.keySet().toArray(
- new String[sourceReposMap.size()]));
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- chooseSourceRepoCmb.setLayoutData(gd);
-
- // Check boxes
- final Button selectAllBtn = new Button(composite, SWT.CHECK);
- selectAllBtn.setText("Select/Unselect all");
-
- advancedBtn = new Button(composite, SWT.CHECK);
- advancedBtn.setText("Advanced fetch");
- advancedBtn.setToolTipText("Check this for further "
- + "parameterization of the fetch process");
-
- // Workspace table
- Table table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.BORDER | SWT.CHECK);
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- gd.horizontalSpan = 2;
- table.setLayoutData(gd);
- configureWkspTable(table);
-
- // Import only files
- filesOnlyBtn = new Button(composite, SWT.CHECK | SWT.WRAP);
- filesOnlyBtn
- .setText("Import only files (faster, a normalized action should be launched once done)");
- filesOnlyBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false,
- false, 2, 1));
-
- // Listeners
- selectAllBtn.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = -2071840477444152170L;
-
- public void widgetSelected(SelectionEvent e) {
- wkspViewer.setAllChecked(selectAllBtn.getSelection());
- getContainer().updateButtons();
- }
- });
-
- // advancedBtn.addSelectionListener(new SelectionAdapter() {
- // public void widgetSelected(SelectionEvent e) {
- // if (advancedBtn.getSelection()){
- //
- // }
- // wkspViewer.setAllChecked();
- // }
- // });
-
- chooseSourceRepoCmb.addModifyListener(new ModifyListener() {
- private static final long serialVersionUID = 932462568382594523L;
-
- public void modifyText(ModifyEvent e) {
- String chosenUri = chooseSourceRepoCmb
- .getItem(chooseSourceRepoCmb.getSelectionIndex());
- sourceRepoNode = sourceReposMap.get(chosenUri);
- wkspViewer.setInput(sourceRepoNode);
- }
- });
-
- wkspViewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- getContainer().updateButtons();
- }
- });
-
- // Initialise to first available repo
- if (chooseSourceRepoCmb.getItemCount() > 0)
- chooseSourceRepoCmb.select(0);
-
- // Compulsory
- setControl(composite);
- }
-
- @Override
- public boolean isPageComplete() {
- return wkspViewer.getCheckedElements().length != 0;
- }
-
- @Override
- public IWizardPage getNextPage() {
- // WARNING: page are added and never removed.
- if (advancedBtn.getSelection()
- && wkspViewer.getCheckedElements().length != 0) {
- IWizardPage toReturn = null;
- for (Object obj : wkspViewer.getCheckedElements()) {
- WkspObject curr = (WkspObject) obj;
- // currSelecteds.add(curr);
- AdvancedFetchPage page;
- if (!advancedPages.containsKey(curr)) {
- page = new AdvancedFetchPage(curr.srcName, curr);
- addPage(page);
- advancedPages.put(curr, page);
- } else
- page = advancedPages.get(curr);
- if (toReturn == null)
- toReturn = page;
- }
- return toReturn;
- } else {
- return recapPage;
- }
- }
-
- // Configure the workspace table
- private void configureWkspTable(Table table) {
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
- wkspViewer = new CheckboxTableViewer(table);
-
- // WORKSPACE COLUMNS
- TableViewerColumn column = ViewerUtils.createTableViewerColumn(
- wkspViewer, "Source names", SWT.NONE, 250);
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 5906079281065061967L;
-
- @Override
- public String getText(Object element) {
- return ((WkspObject) element).srcName;
- }
- });
-
- // column = ViewerUtils.createTableViewerColumn(wkspViewer, "Size",
- // SWT.NONE, 250);
- // column.setLabelProvider(new ColumnLabelProvider() {
- // @Override
- // public String getText(Object element) {
- // return ((WkspObject) element).getFormattedSize();
- // }
- // });
-
- wkspViewer.setContentProvider(new WkspContentProvider());
- // A basic comparator
- wkspViewer.setComparator(new ViewerComparator());
- }
- }
-
- private class AdvancedFetchPage extends WizardPage {
- private static final long serialVersionUID = 1109183561920445169L;
-
- private final WkspObject currentWorkspace;
-
- private Text targetNameTxt;
-
- protected AdvancedFetchPage(String pageName, WkspObject currentWorkspace) {
- super(pageName);
- this.currentWorkspace = currentWorkspace;
- }
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- String msg = "Define advanced parameters to fetch workspace "
- + currentWorkspace.srcName;
- setMessage(msg);
- targetNameTxt.setText(currentWorkspace.targetName);
- }
- // else
- // currentWorkspace.targetName = targetNameTxt.getText();
- }
-
- public void createControl(Composite parent) {
- Composite body = new Composite(parent, SWT.NO_FOCUS);
- body.setLayout(new GridLayout(2, false));
- new Label(body, SWT.NONE).setText("Choose a new name");
- targetNameTxt = new Text(body, SWT.BORDER);
- targetNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
- true, false));
- setControl(body);
- }
-
- protected WkspObject getWorkspaceObject() {
- currentWorkspace.targetName = targetNameTxt.getText();
- return currentWorkspace;
- }
-
- @Override
- public IWizardPage getNextPage() {
- // WARNING: page are added and never removed.
- // IWizardPage toReturn = null;
- // IWizardPage[] pages = ((Wizard) getContainer()).getPages();
- Object[] selected = wkspViewer.getCheckedElements();
- for (int i = 0; i < selected.length - 1; i++) {
- WkspObject curr = (WkspObject) selected[i];
- if (curr.equals(currentWorkspace))
- return advancedPages.get((WkspObject) selected[i + 1]);
- }
- return recapPage;
- }
- }
-
- private class RecapPage extends WizardPage {
- private static final long serialVersionUID = -7064862323304300989L;
- private TableViewer recapViewer;
-
- public RecapPage() {
- super("Validate and launch");
- setTitle("Validate and launch");
- }
-
- @Override
- public boolean isPageComplete() {
- return isCurrentPage();
- }
-
- public IWizardPage getNextPage() {
- // always last....
- return null;
- }
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- try {
- String targetRepoUri = targetRepoNode.getProperty(
- ArgeoNames.ARGEO_URI).getString();
- String sourceRepoUri = sourceRepoNode.getProperty(
- ArgeoNames.ARGEO_URI).getString();
-
- String msg = "Fetch data from: " + sourceRepoUri
- + "\ninto target repository: " + targetRepoUri;
- // + "\nDo you really want to proceed ?";
- setMessage(msg);
-
- // update values that will be used for the fetch
- selectedWorkspaces.clear();
-
- for (Object obj : wkspViewer.getCheckedElements()) {
- WkspObject curr = (WkspObject) obj;
-
- if (advancedBtn.getSelection()) {
- AdvancedFetchPage page = advancedPages.get(curr);
- selectedWorkspaces.add(page.getWorkspaceObject());
- } else
- selectedWorkspaces.add(curr);
- }
- recapViewer.setInput(selectedWorkspaces);
- recapViewer.refresh();
-
- } catch (RepositoryException re) {
- throw new SlcException("Unable to get repositories URIs",
- re);
- }
- }
- }
-
- public void createControl(Composite parent) {
- Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.BORDER);
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
- recapViewer = new TableViewer(table);
-
- // WORKSPACE COLUMNS
- TableViewerColumn column = ViewerUtils.createTableViewerColumn(
- recapViewer, "Sources", SWT.NONE, 250);
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 3913459002502680377L;
-
- @Override
- public String getText(Object element) {
- return ((WkspObject) element).srcName;
- }
- });
-
- column = ViewerUtils.createTableViewerColumn(recapViewer,
- "targets", SWT.NONE, 250);
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -517920072332563632L;
-
- @Override
- public String getText(Object element) {
- return ((WkspObject) element).targetName;
- }
- });
-
- recapViewer.setContentProvider(new IStructuredContentProvider() {
- private static final long serialVersionUID = 4926999891003040865L;
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- // TODO Auto-generated method stub
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- return selectedWorkspaces.toArray();
- }
- });
-
- // A basic comparator
- recapViewer.setComparator(new ViewerComparator());
- setControl(table);
- }
- }
-
- /**
- * Define the privileged job that will be run asynchronously to accomplish
- * the sync
- */
- private class FetchJob extends PrivilegedJob {
- private RepoSync repoSync;
-
- public FetchJob(RepoSync repoSync) {
- super("Fetch");
- this.repoSync = repoSync;
- }
-
- @Override
- protected IStatus doRun(IProgressMonitor progressMonitor) {
- try {
- JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
- repoSync.setMonitor(monitor);
- repoSync.run();
- } catch (Exception e) {
- return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
- "Cannot fetch repository", e);
- }
- return Status.OK_STATUS;
- }
- }
-
- // ///////////////////////
- // Local classes
- private class WkspObject {
- protected final String srcName;
- protected String targetName;
-
- protected WkspObject(String srcName) {
- this.srcName = srcName;
- this.targetName = srcName;
- }
-
- @Override
- public String toString() {
- return "[" + srcName + " to " + targetName + "]";
- }
- }
-
- // private class WkspComparator extends ViewerComparator {
- //
- // }
-
- private class WkspContentProvider implements IStructuredContentProvider {
- private static final long serialVersionUID = -925058051598536307L;
- // caches current repo
- private Node currSourceNodeRepo;
- private Repository currSourceRepo;
- private Credentials currSourceCred;
-
- private List<WkspObject> workspaces = new ArrayList<WkspObject>();
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput != null && newInput instanceof Node) {
- Session session = null;
- try {
- Node newRepoNode = (Node) newInput;
- if (currSourceNodeRepo == null
- || !newRepoNode.getPath().equals(
- currSourceNodeRepo.getPath())) {
-
- // update cache
- currSourceNodeRepo = newRepoNode;
- currSourceRepo = RepoUtils.getRepository(
- repositoryFactory, keyring, currSourceNodeRepo);
- currSourceCred = RepoUtils.getRepositoryCredentials(
- keyring, currSourceNodeRepo);
-
- // reset workspace list
- wkspViewer.setAllChecked(false);
- workspaces.clear();
- // FIXME make it more generic
- session = currSourceRepo.login(currSourceCred,RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
- // remove unvalid elements
- for (String name : session.getWorkspace()
- .getAccessibleWorkspaceNames())
- // TODO implement a cleaner way to filter
- // workspaces out
- if (name.lastIndexOf('-') > 0) {
- WkspObject currWksp = new WkspObject(name);
- // compute wkspace size
- // TODO implement this
- // Session currSession = null;
- // try {
- // currSession = currSourceRepo.login(
- // currSourceCred, name);
- // currWksp.size = JcrUtils
- // .getNodeApproxSize(currSession
- // .getNode("/"));
- //
- // } catch (RepositoryException re) {
- // log.warn(
- // "unable to compute size of workspace "
- // + name, re);
- // } finally {
- // JcrUtils.logoutQuietly(currSession);
- // }
- workspaces.add(currWksp);
- }
- }
-
- } catch (RepositoryException e) {
- throw new SlcException("Unexpected error while "
- + "initializing fetch wizard", e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- viewer.refresh();
- }
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object obj) {
- return workspaces.toArray();
- }
- }
-
- // ////////////////////////////
- // // Helpers
-
- // populate available source repo list
- private Map<String, Node> getSourceRepoUris() {
- try {
- Node repoList = currSession.getNode(NodeUtils.getUserHome(
- currSession).getPath()
- + RepoConstants.REPOSITORIES_BASE_PATH);
-
- String targetRepoUri = null;
- if (targetRepoNode != null) {
- targetRepoUri = targetRepoNode
- .getProperty(ArgeoNames.ARGEO_URI).getString();
- }
- NodeIterator ni = repoList.getNodes();
- // List<String> sourceRepoNames = new ArrayList<String>();
- // // caches a map of the source repo nodes with their URI as a key
- // // to ease further processing
- Map<String, Node> sourceReposMap = new HashMap<String, Node>();
- while (ni.hasNext()) {
- Node currNode = ni.nextNode();
- if (currNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
- String currUri = currNode.getProperty(ArgeoNames.ARGEO_URI)
- .getString();
- if (targetRepoUri == null || !targetRepoUri.equals(currUri)) {
- sourceReposMap.put(currUri, currNode);
- // sourceRepoNames.add(currUri);
- }
- }
- }
- return sourceReposMap;
- // sourceRepoNames.toArray(new String[sourceRepoNames
- // .size()]);
- } catch (RepositoryException e) {
- throw new SlcException("Error while getting repo aliases", e);
- }
- }
-
- public void setTargetRepoNode(Node targetRepoNode) {
- this.targetRepoNode = targetRepoNode;
- }
-
- public void setSourceRepoNode(Node sourceRepoNode) {
- this.sourceRepoNode = sourceRepoNode;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.wizards;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ui.workbench.util.PrivilegedJob;
-import org.argeo.eclipse.ui.EclipseJcrMonitor;
-import org.argeo.jcr.JcrMonitor;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.utils.ViewerUtils;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.repo.RepoService;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.slc.repo.maven.GenerateBinaries;
-import org.eclipse.aether.artifact.Artifact;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Define parameters to asynchronously generate binaries, sources and sdk pom
- * artifacts for this group using a {@link GenerateBinaries} runnable
- */
-public class GenerateBinariesWizard extends Wizard {
- private final static Log log = LogFactory
- .getLog(GenerateBinariesWizard.class);
-
- // Business objects
- private final RepoService repoService;
- private final String repoNodePath;
- private String wkspName;
- private String groupNodePath;
-
- // The pages
- private RecapPage recapPage;
-
- // Controls with parameters
- private Text versionTxt;
- private Text latestVersionTxt;
- private Text highestArtifactVersionTxt;
-
- public GenerateBinariesWizard(RepoService repoService, String repoNodePath,
- String wkspName, String groupNodePath) {
- super();
- this.repoService = repoService;
- this.repoNodePath = repoNodePath;
- this.wkspName = wkspName;
- this.groupNodePath = groupNodePath;
- }
-
- @Override
- public void dispose() {
- super.dispose();
- }
-
- @Override
- public void addPages() {
- try {
- recapPage = new RecapPage();
- addPage(recapPage);
- setWindowTitle("Define Binary Generation Procedure");
- } catch (Exception e) {
- throw new SlcException("Cannot add page to wizard ", e);
- }
- }
-
- @Override
- public boolean performFinish() {
- if (!canFinish())
- return false;
- try {
- String msg = "Your are about to generate binaries, sources and sdk "
- + "pom artifacts for this group, "
- + "do you really want to proceed ?";
-
- boolean result = MessageDialog.openConfirm(DistPlugin.getDefault()
- .getWorkbench().getDisplay().getActiveShell(),
- "Confirm Launch", msg);
-
- if (result) {
- GenerateBinaryJob job = new GenerateBinaryJob(repoService,
- repoNodePath, wkspName, groupNodePath,
- versionTxt.getText());
- job.setUser(true);
- job.schedule();
- }
- } catch (Exception e) {
- throw new SlcException(
- "Unexpected error while launching the fetch", e);
- }
- return true;
- }
-
- // ///////////////////////////////
- // ////// THE PAGES
- private class RecapPage extends WizardPage {
- private static final long serialVersionUID = 904196417910874087L;
- private TableViewer recapViewer;
-
- public RecapPage() {
- super("Define parameters and launch");
- setTitle("Define parameters and launch");
- }
-
- @Override
- public boolean isPageComplete() {
- return isCurrentPage();
- }
-
- public IWizardPage getNextPage() {
- return null; // always last
- }
-
- private void refreshValues() {
- Session session = null;
- try {
- session = repoService.getRemoteSession(repoNodePath, null,
- wkspName);
- Node groupNode = session.getNode(groupNodePath);
- GenerateBinaries gb = GenerateBinaries.preProcessGroupNode(
- groupNode, null);
-
- List<Artifact> binaries = new ArrayList<Artifact>();
- binaries.addAll(gb.getBinaries());
-
- Artifact highestVersion = gb.getHighestArtifactVersion();
- if (highestVersion != null)
- highestArtifactVersionTxt.setText(highestVersion
- .getBaseVersion());
-
- if (groupNode.hasNode(RepoConstants.BINARIES_ARTIFACT_ID)) {
- Node binaryNode = groupNode
- .getNode(RepoConstants.BINARIES_ARTIFACT_ID);
- Artifact currHighestVersion = null;
- for (NodeIterator ni = binaryNode.getNodes(); ni.hasNext();) {
- Node currN = ni.nextNode();
- if (currN
- .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
- Artifact currVersion = RepoUtils.asArtifact(currN);
-
- if (currHighestVersion == null
- || currVersion.getBaseVersion()
- .compareTo(
- currHighestVersion
- .getBaseVersion()) > 0)
- currHighestVersion = currVersion;
- }
- }
- if (currHighestVersion != null)
- latestVersionTxt.setText(currHighestVersion
- .getBaseVersion());
- }
- recapViewer.setInput(binaries);
- recapViewer.refresh();
- } catch (RepositoryException re) {
- throw new SlcException("Unable to get repositories URIs", re);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- }
-
- public void createControl(Composite parent) {
- setMessage("Configure Maven Indexing", IMessageProvider.NONE);
-
- Composite composite = new Composite(parent, SWT.NO_FOCUS);
- composite.setLayout(new GridLayout(2, false));
-
- versionTxt = createLT(composite, "Version");
- versionTxt
- .setToolTipText("Enter a version for the new Modular Distribution");
-
- latestVersionTxt = createLT(composite, "Latest version");
- latestVersionTxt.setEditable(false);
- latestVersionTxt
- .setToolTipText("The actual latest version of this modular distribution");
-
- highestArtifactVersionTxt = createLT(composite,
- "Highest version in current category");
- highestArtifactVersionTxt.setEditable(false);
- highestArtifactVersionTxt
- .setToolTipText("The highest version among all version of the below listed modules.");
-
- // Creates the table
- Table table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.BORDER);
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2,
- 1));
- recapViewer = new TableViewer(table);
-
- TableViewerColumn column = ViewerUtils.createTableViewerColumn(
- recapViewer, "Name", SWT.NONE, 250);
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = -9145709097621022043L;
-
- @Override
- public String getText(Object element) {
- return ((Artifact) element).getArtifactId();
- }
- });
-
- column = ViewerUtils.createTableViewerColumn(recapViewer,
- "Version", SWT.NONE, 250);
- column.setLabelProvider(new ColumnLabelProvider() {
- private static final long serialVersionUID = 5524185741667651628L;
-
- @Override
- public String getText(Object element) {
- return ((Artifact) element).getBaseVersion();
- }
- });
-
- recapViewer.setContentProvider(new IStructuredContentProvider() {
- private static final long serialVersionUID = -4579434453554442858L;
-
-
- List<Artifact> artifacts;
-
- @SuppressWarnings("unchecked")
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- artifacts = (List<Artifact>) newInput;
- if (artifacts != null)
- recapViewer.refresh();
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- return artifacts == null ? null : artifacts.toArray();
- }
- });
-
- // A basic comparator
- recapViewer.setComparator(new ViewerComparator());
- refreshValues();
- setControl(composite);
- }
- }
-
- /**
- * Define the privileged job that will be run asynchronously generate
- * corresponding artifacts
- */
- private class GenerateBinaryJob extends PrivilegedJob {
-
- private final RepoService repoService;
- private final String repoNodePath;
- private final String wkspName;
- private final String groupNodePath;
- private final String version;
-
- public GenerateBinaryJob(RepoService repoService, String repoNodePath,
- String wkspName, String groupNodePath, String version) {
- super("Fetch");
- this.version = version;
- this.repoService = repoService;
- this.repoNodePath = repoNodePath;
- this.wkspName = wkspName;
- this.groupNodePath = groupNodePath;
- }
-
- @Override
- protected IStatus doRun(IProgressMonitor progressMonitor) {
- Session session = null;
- try {
- JcrMonitor monitor = new EclipseJcrMonitor(progressMonitor);
- session = repoService.getRemoteSession(repoNodePath, null,
- wkspName);
- Node groupBaseNode = session.getNode(groupNodePath);
- GenerateBinaries.processGroupNode(groupBaseNode, version,
- monitor);
- } catch (Exception e) {
- if (log.isDebugEnabled())
- e.printStackTrace();
- return new Status(IStatus.ERROR, DistPlugin.PLUGIN_ID,
- "Cannot normalize group", e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- return Status.OK_STATUS;
- }
- }
-
- // ////////////////////////////
- // // Helpers
- /** Creates label and text. */
- protected Text createLT(Composite parent, String label) {
- new Label(parent, SWT.NONE).setText(label);
- Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER
- | SWT.NONE);
- text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- return text;
- }
-
- /** Creates label and check. */
- protected Button createLC(Composite parent, String label) {
- new Label(parent, SWT.NONE).setText(label);
- Button check = new Button(parent, SWT.CHECK);
- check.setSelection(false);
- check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- return check;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.dist.wizards;
-
-import java.net.URI;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.cms.ArgeoTypes;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.RepoConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- *
- * Registers a new remote repository in the current Node.
- *
- */
-public class RegisterRepoWizard extends Wizard {
-
- // Business objects
- private Keyring keyring;
- private RepositoryFactory repositoryFactory;
- private Repository nodeRepository;
-
- // Pages
- private DefineModelPage page;
-
- // Widgets of model page
- private Text name;
- private Text uri;
- private Text username;
- private Text password;
- private Button saveInKeyring;
-
- // Default values
- private final static String DEFAULT_NAME = "Argeo Public Repository";
- private final static String DEFAULT_URI = "https://forge.argeo.org/jcr/java";
- private final static String DEFAULT_USER_NAME = "anonymous";
- private final static boolean DEFAULT_ANONYMOUS = true;
-
- public RegisterRepoWizard(Keyring keyring, RepositoryFactory repositoryFactory, Repository nodeRepository) {
- super();
- this.keyring = keyring;
- this.repositoryFactory = repositoryFactory;
- this.nodeRepository = nodeRepository;
- }
-
- @Override
- public void addPages() {
- try {
- page = new DefineModelPage();
- addPage(page);
- setWindowTitle("Register a new remote repository");
- } catch (Exception e) {
- throw new SlcException("Cannot add page to wizard ", e);
- }
- }
-
- @Override
- public boolean performFinish() {
- if (!canFinish())
- return false;
-
- Session nodeSession = null;
- try {
- nodeSession = nodeRepository.login(NodeConstants.HOME_WORKSPACE);
- String reposPath = NodeUtils.getUserHome(nodeSession).getPath() + RepoConstants.REPOSITORIES_BASE_PATH;
-
- Node repos = nodeSession.getNode(reposPath);
- String repoNodeName = JcrUtils.replaceInvalidChars(name.getText());
- if (repos.hasNode(repoNodeName))
- throw new SlcException("There is already a remote repository named " + repoNodeName);
-
- // check if the same URI has already been registered
- NodeIterator ni = repos.getNodes();
- while (ni.hasNext()) {
- Node node = ni.nextNode();
- if (node.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY) && node.hasProperty(ArgeoNames.ARGEO_URI)
- && node.getProperty(ArgeoNames.ARGEO_URI).getString().equals(uri.getText()))
- throw new SlcException("This URI " + uri.getText() + " is already registered, "
- + "for the time being, only one instance of a single "
- + "repository at a time is implemented.");
- }
-
- Node repoNode = repos.addNode(repoNodeName, ArgeoTypes.ARGEO_REMOTE_REPOSITORY);
- repoNode.setProperty(ArgeoNames.ARGEO_URI, uri.getText());
- repoNode.setProperty(ArgeoNames.ARGEO_USER_ID, username.getText());
- repoNode.addMixin(NodeType.MIX_TITLE);
- repoNode.setProperty(Property.JCR_TITLE, name.getText());
- nodeSession.save();
- if (saveInKeyring.getSelection()) {
- String pwdPath = repoNode.getPath() + '/' + ArgeoNames.ARGEO_PASSWORD;
- keyring.set(pwdPath, password.getText().toCharArray());
- nodeSession.save();
- }
- MessageDialog.openInformation(getShell(), "Repository Added",
- "Remote repository " + uri.getText() + "' added");
- } catch (Exception e) {
- ErrorFeedback.show("Cannot add remote repository", e);
- } finally {
- JcrUtils.logoutQuietly(nodeSession);
- }
- return true;
- }
-
- private class DefineModelPage extends WizardPage {
- private static final long serialVersionUID = 874386824101995060L;
-
- public DefineModelPage() {
- super("Main");
- setTitle("Fill information to register a repository");
- }
-
- public void createControl(Composite parent) {
-
- // main layout
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- // Create various fields
- // setMessage("Login to remote repository", IMessageProvider.NONE);
- name = createLT(composite, "Name", DEFAULT_NAME);
- uri = createLT(composite, "URI", DEFAULT_URI);
-
- final Button anonymousLogin = createLC(composite, "Log as anonymous", true);
- anonymousLogin.addSelectionListener(new SelectionListener() {
- private static final long serialVersionUID = 4874716406036981039L;
-
- public void widgetSelected(SelectionEvent e) {
- if (anonymousLogin.getSelection()) {
- username.setText(DEFAULT_USER_NAME);
- password.setText("");
- username.setEnabled(false);
- password.setEnabled(false);
- } else {
- username.setText("");
- password.setText("");
- username.setEnabled(true);
- password.setEnabled(true);
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- username = createLT(composite, "User", DEFAULT_USER_NAME);
- password = createLP(composite, "Password");
- saveInKeyring = createLC(composite, "Remember password", false);
-
- if (DEFAULT_ANONYMOUS) {
- username.setEnabled(false);
- password.setEnabled(false);
- }
-
- Button test = createButton(composite, "Test");
- GridData gd = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1);
- gd.widthHint = 140;
- test.setLayoutData(gd);
-
- test.addSelectionListener(new SelectionAdapter() {
- private static final long serialVersionUID = -4034851916548656293L;
-
- public void widgetSelected(SelectionEvent arg0) {
- testConnection();
- }
- });
-
- // Compulsory
- setControl(composite);
- }
-
- /** Creates label and text. */
- protected Text createLT(Composite parent, String label, String initial) {
- new Label(parent, SWT.RIGHT).setText(label);
- Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
- text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
- text.setText(initial);
- return text;
- }
-
- /** Creates label and check. */
- protected Button createLC(Composite parent, String label, Boolean initial) {
- new Label(parent, SWT.RIGHT).setText(label);
- Button check = new Button(parent, SWT.CHECK);
- check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- check.setSelection(initial);
- return check;
- }
-
- /** Creates a button with a label. */
- protected Button createButton(Composite parent, String label) {
- Button button = new Button(parent, SWT.PUSH);
- button.setText(label);
- button.setFont(JFaceResources.getDialogFont());
- setButtonLayoutData(button);
- return button;
- }
-
- /** Creates label and password field */
- protected Text createLP(Composite parent, String label) {
- new Label(parent, SWT.NONE).setText(label);
- Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER | SWT.PASSWORD);
- text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- return text;
- }
-
- }
-
- void testConnection() {
- Session session = null;
- try {
- if (uri.getText().startsWith("http")) {// http, https
- URI checkedUri = new URI(uri.getText());
- String checkedUriStr = checkedUri.toString();
- Repository repository = NodeUtils.getRepositoryByUri(repositoryFactory, checkedUriStr);
- if (username.getText().trim().equals("")) {// anonymous
- session = repository.login(RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
- } else {
- char[] pwd = password.getTextChars();
- SimpleCredentials sc = new SimpleCredentials(username.getText(), pwd);
- session = repository.login(sc, RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
- }
- } else {// alias
- Repository repository = NodeUtils.getRepositoryByAlias(repositoryFactory, uri.getText());
- session = repository.login();
- }
- MessageDialog.openInformation(getShell(), "Success", "Connection to '" + uri.getText() + "' successful");
- } catch (Exception e) {
- ErrorFeedback.show("Connection test failed for " + uri.getText(), e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.client.ui</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Wed Aug 04 16:31:36 CEST 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+++ /dev/null
-#Tue Jul 27 14:24:51 CEST 2010
-eclipse.preferences.version=1
-resolve.requirebundle=false
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="updateModule"
- class="org.argeo.slc.client.ui.commands.UpdateModule"
- scope="prototype">
- <property name="modulesManager" ref="modulesManager"/>
- </bean>
-<!-- <bean name="runSlc/Flow" -->
-<!-- class="org.argeo.slc.client.ui.commands.RunSlcFlow" -->
-<!-- scope="prototype"> -->
-<!-- <property name="modulesManager" ref="modulesManager"/> -->
-<!-- </bean> -->
-
- <!-- Result list view commands-->
-<!-- <bean id="org.argeo.slc.client.ui.refreshResultList" -->
-<!-- class="org.argeo.slc.client.ui.commands.ResultListViewRefreshHandler" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-
-<!-- <bean id="org.argeo.slc.client.ui.removeSelectedResultFromResultList" -->
-<!-- class="org.argeo.slc.client.ui.commands.RemoveSelectedResultFromResultList" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-
-
-<!-- <bean id="org.argeo.slc.client.ui.refreshExecutionModulesView" -->
-<!-- class="org.argeo.slc.client.ui.commands.ExecutionModulesViewRefreshHandler" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-<!-- <bean id="org.argeo.slc.client.ui.refreshProcessList" -->
-<!-- class="org.argeo.slc.client.ui.commands.ProcessListViewRefreshHandler" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-<!-- <bean id="org.argeo.slc.client.ui.displayProcessDetails" -->
-<!-- class="org.argeo.slc.client.ui.commands.ProcessDetailsDisplayHandler" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-<!-- <bean id="org.argeo.slc.client.ui.displayResultDetails" -->
-<!-- class="org.argeo.slc.client.ui.commands.ResultDetailsDisplayHandler" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-<!-- <bean id="org.argeo.slc.client.ui.launchBatch" class="org.argeo.slc.client.ui.commands.LaunchBatchHandler" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-<!-- <bean id="org.argeo.slc.client.ui.removeSelectedFromBatch" -->
-<!-- class="org.argeo.slc.client.ui.commands.RemoveSelectedProcessFromBatchHandler" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-<!-- <bean id="org.argeo.slc.client.ui.clearBatch" class="org.argeo.slc.client.ui.commands.ClearBatchHandler" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-<!-- <bean id="org.argeo.slc.client.ui.manageBundles" class="org.argeo.slc.client.ui.commands.ManageBundlesHandler" -->
-<!-- scope="prototype"> -->
-<!-- </bean> -->
-</beans>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="processController" class="org.argeo.slc.client.ui.controllers.ProcessController">
- <property name="agent" ref="agent" />
- </bean>
-</beans>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="processEditor" class="org.argeo.slc.client.ui.editors.ProcessEditor"
- scope="prototype">
- <property name="processController" ref="processController" />
- <property name="modulesManager" ref="modulesManager" />
- <property name="repository" ref="repository" />
- </bean>
-</beans>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:osgi="http://www.springframework.org/schema/osgi"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- osgi:default-timeout="30000">\r
-\r
- <beans:description>SLC UI</beans:description>\r
-\r
- <!-- REFERENCES -->\r
- <reference id="repository" interface="javax.jcr.Repository"\r
- filter="(cn=ego)" />\r
-\r
- <reference id="agent" interface="org.argeo.slc.execution.SlcAgent" />\r
-\r
- <reference id="modulesManager"\r
- interface="org.argeo.slc.execution.ExecutionModulesManager" />\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="jcrExecutionModulesView" class="org.argeo.slc.client.ui.views.JcrExecutionModulesView"
- scope="prototype">
- <property name="repository" ref="repository" />
- <property name="modulesManager" ref="modulesManager" />
- </bean>
-
- <bean id="jcrProcessListView" class="org.argeo.slc.client.ui.views.JcrProcessListView"
- scope="prototype">
- <property name="repository" ref="repository" />
- </bean>
-
- <bean id="jcrResultListView" class="org.argeo.slc.client.ui.views.JcrResultListView"
- scope="prototype">
- <property name="repository" ref="repository" />
- </bean>
-
- <bean id="jcrResultTreeView" class="org.argeo.slc.client.ui.views.JcrResultTreeView"
- scope="prototype">
- <property name="repository" ref="repository" />
- </bean>
-
-</beans>
\ No newline at end of file
+++ /dev/null
-Bundle-SymbolicName: org.argeo.slc.client.ui;singleton=true
-Bundle-ActivationPolicy: lazy
-Require-Bundle: org.eclipse.ui;resolution:=optional,\
-org.eclipse.core.runtime,\
-org.eclipse.rap.ui;resolution:=optional,\
-org.eclipse.rap.ui.workbench;resolution:=optional
-
-Bundle-Activator: org.argeo.slc.client.ui.ClientUiPlugin
-Import-Package: org.argeo.eclipse.spring,\
-org.argeo.api,\
-org.eclipse.core.runtime,\
-org.osgi.*;version=0.0.0,\
-*
+++ /dev/null
-source.. = src
-bin.includes = plugin.xml,\
- META-INF/,\
- .,\
- icons/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
- <!-- Views -->
- <extension
- point="org.eclipse.ui.views">
- <view
- id="org.argeo.slc.client.ui.jcrExecutionModulesView"
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- icon="icons/execution_module.gif"
- name="Execution"
- restorable="true">
- </view>
- <view
- id="org.argeo.slc.client.ui.jcrResultListView"
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- icon="icons/results.gif"
- name="Results"
- restorable="true">
- </view>
- <view
- id="org.argeo.slc.client.ui.jcrResultTreeView"
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- icon="icons/results.gif"
- name="Results"
- restorable="true">
- </view>
- <view
- id="org.argeo.slc.client.ui.jcrProcessListView"
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- name="Processes"
- icon="icons/processes.gif"
- restorable="true">
- </view>
- </extension>
-
- <!-- Commands definitions -->
- <extension
- point="org.eclipse.ui.commands">
- <command
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- id="org.argeo.slc.client.ui.updateModule"
- name="Update Module">
- </command>
-
- <!-- Commands that do not need dependency injection -->
- <command
- defaultHandler="org.argeo.slc.client.ui.commands.AddResultFolder"
- id="org.argeo.slc.client.ui.addResultFolder"
- name="Add result folder">
- </command>
- <command
- id="org.argeo.slc.client.ui.deleteItems"
- defaultHandler="org.argeo.slc.client.ui.commands.DeleteItems"
- name="Delete selected item(s)">
- </command>
- <command
- defaultHandler="org.argeo.slc.client.ui.commands.RenameResultFolder"
- id="org.argeo.slc.client.ui.renameResultFolder"
- name="Rename folder">
- </command>
- <command
- defaultHandler="org.argeo.slc.client.ui.commands.RenameResultNode"
- id="org.argeo.slc.client.ui.renameResultNode"
- name="Rename result">
- </command>
- <command
- defaultHandler="org.argeo.slc.client.ui.commands.RefreshJcrResultTreeView"
- id="org.argeo.slc.client.ui.refreshJcrResultTreeView"
- name="Refresh">
- <commandParameter
- id="org.argeo.slc.client.ui.param.refreshType"
- name="Refresh type">
- </commandParameter>
- </command>
- </extension>
-
- <!-- Menu definitions -->
- <extension
- id="menu:org.eclipse.ui.main.menu"
- point="org.eclipse.ui.menus">
- <menuContribution
- locationURI="toolbar:org.argeo.slc.client.ui.jcrExecutionModulesView">
- <command
- commandId="org.argeo.slc.client.ui.updateModule"
- icon="icons/refresh.png"
- label="Update module"
- tooltip="Update module">
- </command>
- </menuContribution>
- </extension>
- <extension
- point="org.eclipse.ui.perspectives">
- <perspective
- class="org.argeo.slc.client.ui.SlcExecutionPerspective"
- icon="icons/slc_execution_perspective.gif"
- id="org.argeo.slc.client.ui.slcExecutionPerspective"
- name="SLC Execution">
- </perspective>
- </extension>
- <extension
- point="org.eclipse.ui.editors">
- <editor
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- default="false"
- icon="icons/batch.gif"
- id="org.argeo.slc.client.ui.processEditor"
- name="Process">
- </editor>
- </extension>
- <extension
- point="org.eclipse.ui.elementFactories">
- <factory
- class="org.argeo.slc.client.ui.editors.ProcessEditorInputFactory"
- id="org.argeo.slc.client.ui.processEditorInputFactory">
- </factory>
- </extension>
- <extension
- point="org.eclipse.ui.activities">
- </extension>
- <extension
- point="org.eclipse.ui.activities">
- <activity
- description="SLC users"
- id="org.argeo.slc.client.ui.slcActivity"
- name="SLC">
- <enabledWhen>
- <with variable="roles">
- <iterate ifEmpty="false" operator="or">
- <equals value="cn=org.argeo.slc.user,ou=roles,ou=node" />
- </iterate>
- </with>
- </enabledWhen>
- </activity>
- <!-- TODO: find a way to exclude evrything -->
- <activityPatternBinding
- activityId="org.argeo.slc.client.ui.slcActivity"
- isEqualityPattern="true"
- pattern="org.argeo.slc.client.ui/org.argeo.slc.client.ui.slcExecutionPerspective">
- </activityPatternBinding>
- <activityPatternBinding
- activityId="org.argeo.security.ui.adminActivity"
- isEqualityPattern="true"
- pattern="org.argeo.slc.client.ui/org.argeo.slc.client.ui.slcExecutionPerspective">
- </activityPatternBinding>
- <activityPatternBinding
- activityId="org.argeo.security.ui.adminActivity"
- isEqualityPattern="true"
- pattern="org.argeo.jcr.ui.explorer/org.argeo.jcr.ui.explorer.perspective">
- </activityPatternBinding>
- <activityPatternBinding
- activityId="org.argeo.security.ui.adminActivity"
- isEqualityPattern="true"
- pattern="org.argeo.security.ui/org.argeo.security.ui.userHomePerspective">
- </activityPatternBinding>
- </extension>
-</plugin>
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.client.ui</artifactId>
- <name>SLC Client UI</name>
- <packaging>jar</packaging>
- <dependencies>
- <!-- SLC -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.spring</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- Argeo Commons -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.api</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.eclipse.ui</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.eclipse.ui.rap</artifactId>
- <version>${version.argeo-commons}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc.legacy.commons</groupId>
- <artifactId>org.argeo.cms.ui.workbench</artifactId>
- <version>${version.argeo-commons-legacy}</version>
- </dependency>
-
- <!-- RAP workbench -->
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp-rap-e3</artifactId>
- <version>${version.argeo-tp}</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-</project>
+++ /dev/null
-package org.argeo.slc.client.ui;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.BasicNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.deploy.ModulesManager;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/** The activator class controls the plug-in life cycle */
-public class ClientUiPlugin extends AbstractUIPlugin implements SlcNames {
- public static final String ID = "org.argeo.slc.client.ui";
- private static ClientUiPlugin plugin;
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- public static ClientUiPlugin getDefault() {
- return plugin;
- }
-
- /** Creates the image */
- public static Image img(String path) {
- return getImageDescriptor(path).createImage();
- }
-
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(ID, path);
- }
-
- /** Start execution module if it was stopped and vice-versa */
- public static void startStopExecutionModule(
- final ModulesManager modulesManager, Node node) {
- try {
- if (!node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE))
- throw new SlcException(node + " is not an execution module");
-
- String name = node.getProperty(SLC_NAME).getString();
- String version = node.getProperty(SLC_VERSION).getString();
- final NameVersion nameVersion = new BasicNameVersion(name, version);
- Boolean started = node.getProperty(SLC_STARTED).getBoolean();
-
- Job job;
- if (started) {
- job = new Job("Stop " + nameVersion) {
- protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("Stop " + nameVersion, 1);
- modulesManager.stop(nameVersion);
- monitor.worked(1);
- return Status.OK_STATUS;
- }
-
- protected void canceling() {
- getThread().interrupt();
- super.canceling();
- }
- };
- } else {
- job = new Job("Start " + nameVersion) {
- protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("Start " + nameVersion, 1);
- modulesManager.start(nameVersion);
- monitor.worked(1);
- return Status.OK_STATUS;
- }
-
- protected void canceling() {
- getThread().interrupt();
- super.canceling();
- }
- };
- }
- job.setUser(true);
- job.schedule();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot start " + node, e);
- }
-
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui;
-
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Perspective to manage SLC execution flows. */
-public class SlcExecutionPerspective implements IPerspectiveFactory {
-
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
- layout.setEditorAreaVisible(true);
- layout.setFixed(false);
-
- IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
- 0.35f, editorArea);
- left.addView(ClientUiPlugin.ID + ".jcrExecutionModulesView");
- // left.addView(ClientUiPlugin.ID + ".jcrResultListView");
- left.addView(ClientUiPlugin.ID + ".jcrResultTreeView");
- // Sleak view for SWT resource debugging
- // left.addView("org.eclipse.swt.tools.views.SleakView");
-
- IFolderLayout bottom = layout.createFolder("bottom",
- IPageLayout.BOTTOM, 0.65f, editorArea);
-// BOTTOM.ADDVIEW(SECURITYUIPLUGIN.PLUGIN_ID + ".LOGVIEW");
- bottom.addView(ClientUiPlugin.ID + ".jcrProcessListView");
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui;
-
-import static org.argeo.slc.client.ui.ClientUiPlugin.getImageDescriptor;
-import static org.argeo.slc.client.ui.ClientUiPlugin.img;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-
-/** Shared images. */
-public class SlcImages {
- public final static Image AGENT = img("icons/agent.gif");
- public final static Image AGENT_FACTORY = img("icons/agentFactory.gif");
- public final static Image MODULE = img("icons/module.png");
- public final static Image MODULE_STOPPED = img("icons/module_stopped.gif");
- public final static Image FOLDER = img("icons/folder.gif");
- public final static Image MY_RESULTS_FOLDER = img("icons/myResult.png");
- public final static Image RENAME = img("icons/rename.png");
- public final static Image FLOW = img("icons/flow.png");
- public final static Image PROCESSES = img("icons/processes.gif");
- public final static Image PASSED = img("icons/passed.gif");
- public final static Image ERROR = img("icons/error.gif");
- public final static Image LAUNCH = img("icons/launch.gif");
- public final static Image RELAUNCH = img("icons/relaunch.gif");
- public final static Image KILL = img("icons/kill.png");
- public final static Image REMOVE_ONE = img("icons/remove_one.gif");
- public final static Image REMOVE_ALL = img("icons/removeAll.png");
- public final static Image EXECUTION_SPECS = img("icons/executionSpecs.gif");
- public final static Image EXECUTION_SPEC = img("icons/executionSpec.gif");
- public final static Image EXECUTION_SPEC_ATTRIBUTE = img("icons/executionSpecAttribute.gif");
- public final static Image CHOICES = img("icons/choices.gif");
- public final static Image PROCESS_ERROR = img("icons/process_error.png");
- public final static Image PROCESS_SCHEDULED = img("icons/process_scheduled.gif");
- public final static Image PROCESS_RUNNING = img("icons/process_running.png");
- public final static Image PROCESS_COMPLETED = img("icons/process_completed.png");
-
- // Decorators
- public final static ImageDescriptor EXECUTION_ERROR = getImageDescriptor("icons/executionError.gif");
- public final static ImageDescriptor EXECUTION_PASSED = getImageDescriptor("icons/executionPassed.gif");
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui;
-
-/** SLC UI common constants */
-public interface SlcUiConstants {
-
- /*
- * Labels
- */
- public final static String DEFAULT_MY_RESULTS_FOLDER_LABEL = "My Results";
-
- /*
- * MISCEALLENEOUS
- */
- public final static String DEFAULT_DISPLAY_DATE_TIME_FORMAT = "yyyy-MM-dd, HH:mm:ss";
-}
+++ /dev/null
-package org.argeo.slc.client.ui.commands;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.eclipse.ui.dialogs.SingleValue;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.ParentNodeFolder;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Add a new SlcType.SLC_RESULT_FOLDER node to the current user "my result"
- * tree. This handler is only intended to bu used with JcrResultTreeView and its
- * descendants.
- */
-
-public class AddResultFolder extends AbstractHandler {
- public final static String ID = ClientUiPlugin.ID + ".addResultFolder";
- public final static String DEFAULT_ICON_REL_PATH = "icons/addFolder.gif";
- public final static String DEFAULT_LABEL = "Add folder...";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IStructuredSelection selection = (IStructuredSelection) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage().getSelection();
-
- // Sanity check, already done when populating the corresponding popup
- // menu.
- if (selection != null && selection.size() == 1) {
- Object obj = selection.getFirstElement();
- try {
- Node parentNode = null;
- if (obj instanceof ResultFolder) {
- ResultFolder rf = (ResultFolder) obj;
- parentNode = rf.getNode();
- } else if (obj instanceof ParentNodeFolder) {
- Node node = ((ParentNodeFolder) obj).getNode();
- if (node.getPath().startsWith(
- SlcJcrResultUtils.getMyResultsBasePath(node
- .getSession())))
- parentNode = node;
- }
-
- if (parentNode != null) {
- String folderName = SingleValue.ask("Folder name",
- "Enter folder name");
- if (folderName != null) {
- if (folderName.contains("/")) {
- ErrorFeedback
- .show("Folder names can't contain a '/'.");
- return null;
- }
-
- String absPath = parentNode.getPath() + "/"
- + folderName;
- SlcJcrResultUtils.createResultFolderNode(
- parentNode.getSession(), absPath);
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected exception while creating result folder", e);
- }
- } else {
- ErrorFeedback.show("Can only add file folder to a node");
- }
- return null;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.commands;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.model.ResultParentUtils;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Deletes one or many results */
-public class DeleteItems extends AbstractHandler {
- public final static String ID = ClientUiPlugin.ID + ".deleteItems";
- public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
- .getImageDescriptor("icons/removeAll.png");
- public final static String DEFAULT_LABEL = "Delete selected item(s)";
-
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- final ISelection selection = HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage().getSelection();
-
- // confirmation
- StringBuilder buf = new StringBuilder("");
- Iterator<?> lst = ((IStructuredSelection) selection).iterator();
- while (lst.hasNext()) {
- Object obj = lst.next();
- if (obj instanceof ResultParent) {
- ResultParent rp = ((ResultParent) obj);
- buf.append(rp.getName()).append(", ");
- }
- }
-
- String msg = "Nothing to delete";
- // remove last separator
- if (buf.lastIndexOf(", ") > -1) {
- msg = "Do you want to delete following objects (and their children): "
- + buf.substring(0, buf.lastIndexOf(", ")) + "?";
- }
- Boolean ok = MessageDialog.openConfirm(
- HandlerUtil.getActiveShell(event), "Confirm deletion", msg);
-
- if (!ok)
- return null;
-
- Job job = new Job("Delete results") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- if (selection != null
- && selection instanceof IStructuredSelection) {
- Map<String, Node> nodes = new HashMap<String, Node>();
- Iterator<?> it = ((IStructuredSelection) selection)
- .iterator();
- Object obj = null;
- try {
-
- while (it.hasNext()) {
- obj = it.next();
- if (obj instanceof ResultFolder) {
- Node node = ((ResultFolder) obj).getNode();
- nodes.put(node.getPath(), node);
- } else if (obj instanceof SingleResultNode) {
- Node node = ((SingleResultNode) obj).getNode();
- nodes.put(node.getPath(), node);
- }
- }
- if (!nodes.isEmpty()) {
- Session session = null;
- monitor.beginTask("Delete results", nodes.size());
- for (String path : nodes.keySet()) {
- if (session == null)
- session = nodes.get(path).getSession();
-
- // check if the item has not already been
- // deleted while deleting one of its ancestor
- if (session.itemExists(path)) {
- Node parent = nodes.get(path).getParent();
- nodes.get(path).remove();
- ResultParentUtils.updatePassedStatus(
- parent, true);
- }
- monitor.worked(1);
- }
- session.save();
- }
-
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected error while deleteting node(s)", e);
- }
- monitor.done();
- }
- return Status.OK_STATUS;
- }
-
- };
- job.setUser(true);
- job.schedule();
- return null;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.commands;
-
-import java.util.Iterator;
-
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.views.JcrResultTreeView;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Force refresh the ResultTreeView. This command is only intended to be called
- * by either the toolbar menu of the view or by the popup menu. Refresh due to
- * data changes must be triggered by Observers
- */
-public class RefreshJcrResultTreeView extends AbstractHandler {
- public final static String ID = ClientUiPlugin.ID
- + ".refreshJcrResultTreeView";
- public final static String PARAM_REFRESH_TYPE = ClientUiPlugin.ID
- + ".param.refreshType";
- public final static String PARAM_REFRESH_TYPE_FULL = "fullRefresh";
- public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
- .getImageDescriptor("icons/refresh.png");
- public final static String DEFAULT_LABEL = "Refresh selected";
-
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- String refreshType = event.getParameter(PARAM_REFRESH_TYPE);
- JcrResultTreeView view = (JcrResultTreeView) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage()
- .getActivePart();
-
- // force full refresh without preserving selection from the tool bar
- if (PARAM_REFRESH_TYPE_FULL.equals(refreshType))
- view.refresh(null);
- else {
- IStructuredSelection selection = (IStructuredSelection) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage()
- .getSelection();
- @SuppressWarnings("rawtypes")
- Iterator it = selection.iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof ResultParent) {
- view.refresh((ResultParent) obj);
- }
- }
- }
- return null;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.commands;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.eclipse.ui.dialogs.SingleValue;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Rename a node of type SlcType.SLC_RESULT_FOLDER by moving it.
- */
-
-public class RenameResultFolder extends AbstractHandler {
- public final static String ID = ClientUiPlugin.ID + ".renameResultFolder";
- public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
- .getImageDescriptor("icons/rename.png");
- public final static String DEFAULT_LABEL = "Rename...";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IStructuredSelection selection = (IStructuredSelection) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage().getSelection();
-
- // Sanity check, already done when populating the corresponding popup
- // menu.
- if (selection != null && selection.size() == 1) {
- Object obj = selection.getFirstElement();
- try {
- if (obj instanceof ResultFolder) {
- ResultFolder rf = (ResultFolder) obj;
- Node sourceNode = rf.getNode();
- String folderName = SingleValue.ask("Rename folder",
- "Enter a new folder name");
- if (folderName != null) {
- String sourcePath = sourceNode.getPath();
- String targetPath = JcrUtils.parentPath(sourcePath)
- + "/" + folderName;
- Session session = sourceNode.getSession();
- session.move(sourcePath, targetPath);
- session.save();
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected exception while refactoring result folder",
- e);
- }
- }
- return null;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.commands;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.eclipse.ui.dialogs.SingleValue;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Rename a node of type SlcType.SLC_RESULT_FOLDER by moving it.
- */
-
-public class RenameResultNode extends AbstractHandler {
- public final static String ID = ClientUiPlugin.ID + ".renameResultNode";
- public final static ImageDescriptor DEFAULT_IMG_DESCRIPTOR = ClientUiPlugin
- .getImageDescriptor("icons/rename.png");
- public final static String DEFAULT_LABEL = "Rename result";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IStructuredSelection selection = (IStructuredSelection) HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage().getSelection();
-
- // Sanity check, already done when populating the corresponding popup
- // menu.
- if (selection != null && selection.size() == 1) {
- Object obj = selection.getFirstElement();
- try {
- if (obj instanceof SingleResultNode) {
- SingleResultNode rf = (SingleResultNode) obj;
- Node sourceNode = rf.getNode();
- String folderName = SingleValue.ask("Rename result",
- "Enter a new result name");
- if (folderName != null) {
-
- if (sourceNode.getParent().hasNode(folderName)) {
- MessageDialog
- .openError(Display.getDefault()
- .getActiveShell(), "Error",
- "Another object with the same name already exists.");
- return null;
- }
-
- String sourcePath = sourceNode.getPath();
- String targetPath = JcrUtils.parentPath(sourcePath)
- + "/" + folderName;
- Session session = sourceNode.getSession();
- session.move(sourcePath, targetPath);
- session.getNode(targetPath).setProperty(
- Property.JCR_TITLE, folderName);
- session.save();
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected exception while refactoring result folder",
- e);
- }
- }
- return null;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.commands;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.RealizedFlow;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IParameter;
-
-@Deprecated
-public class RunSlcFlow extends AbstractHandler {
- private ExecutionModulesManager modulesManager;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- try {
- Command command = event.getCommand();
- String name = command.getName();
- String module = name.substring(0, name.indexOf(':'));
- String flowName = name.substring(name.indexOf(':') + 1);
-
- final RealizedFlow realizedFlow = new RealizedFlow();
- realizedFlow.setModuleName(module);
- // FIXME deal with version
- String version = "0.0.0";
- realizedFlow.setModuleVersion(version);
- ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor();
- efd.setName(flowName);
-
- Map<String, Object> values = new HashMap<String, Object>();
- if (command.getParameters() != null) {
- for (IParameter param : command.getParameters()) {
- String argName = param.getId();
- // FIXME make it safer
- Object value = param.getValues().getParameterValues()
- .values().iterator().next();
- values.put(argName, value);
- }
- efd.setValues(values);
- }
- realizedFlow.setFlowDescriptor(efd);
- // new Thread("SLC Flow " + name + " from Eclipse command "
- // + command.getId()) {
- // public void run() {
- modulesManager.start(realizedFlow.getModuleNameVersion());
- modulesManager.execute(realizedFlow);
- // }
- // }.start();
- return null;
- } catch (Exception e) {
- throw new SlcException("Could not execute command "
- + event.getCommand() + " as SLC flow", e);
- }
- }
-
- public void setModulesManager(
- ExecutionModulesManager executionModulesManager) {
- this.modulesManager = executionModulesManager;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.commands;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jcr.Node;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.BasicNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.deploy.ModulesManager;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Deletes one or many results */
-public class UpdateModule extends AbstractHandler {
- private final static Log log = LogFactory.getLog(UpdateModule.class);
-
- private ModulesManager modulesManager;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- final ISelection selection = HandlerUtil
- .getActiveWorkbenchWindow(event).getActivePage().getSelection();
- if (selection != null && selection instanceof IStructuredSelection) {
- UpdateJob job = new UpdateJob(selection);
- job.setUser(true);
- job.schedule();
- }
- return null;
- }
-
- private class UpdateJob extends Job {
- private final IStructuredSelection selection;
-
- public UpdateJob(ISelection selection) {
- super("Update modules");
- this.selection = ((IStructuredSelection) selection);
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- Iterator<?> it = selection.iterator();
- Object obj = null;
- try {
- Map<String, Node> nodes = new HashMap<String, Node>();
- nodes: while (it.hasNext()) {
- obj = it.next();
- if (obj instanceof Node) {
- Node node = (Node) obj;
- Node executionModuleNode = null;
- while (executionModuleNode == null) {
- if (node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) {
- executionModuleNode = node;
- }
- node = node.getParent();
- if (node.getPath().equals("/"))// root
- continue nodes;
- }
-
- if (!nodes.containsKey(executionModuleNode.getPath()))
- nodes.put(executionModuleNode.getPath(),
- executionModuleNode);
- }
- }
-
- monitor.beginTask("Update modules", nodes.size());
- for (Node executionModuleNode : nodes.values()) {
- monitor.subTask("Update " + executionModuleNode.getName());
- NameVersion nameVersion = new BasicNameVersion(
- executionModuleNode.getProperty(SlcNames.SLC_NAME)
- .getString(), executionModuleNode
- .getProperty(SlcNames.SLC_VERSION)
- .getString());
- modulesManager.upgrade(nameVersion);
- monitor.worked(1);
- log.info("Module " + nameVersion + " updated");
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- } catch (Exception e) {
- throw new SlcException("Cannot update module " + obj, e);
- // return Status.CANCEL_STATUS;
- }
- }
-
- @Override
- protected void canceling() {
- getThread().interrupt();
- super.canceling();
- }
-
- }
-
- public void setModulesManager(ModulesManager modulesManager) {
- this.modulesManager = modulesManager;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.controllers;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.execution.SlcAgent;
-import org.argeo.slc.jcr.execution.JcrExecutionProcess;
-
-/**
- * We use a separate class (not in UI components) so that it can be a singleton
- * in an application context.
- */
-public class ProcessController {
- // private final static Log log =
- // LogFactory.getLog(ProcessController.class);
- // private Map<String, SlcAgentFactory> agentFactories = new HashMap<String,
- // SlcAgentFactory>();
-
- private SlcAgent agent;
-
- public ExecutionProcess process(Node processNode) {
- JcrExecutionProcess process = new JcrExecutionProcess(processNode);
- try {
- SlcAgent slcAgent = findAgent(processNode);
- if (slcAgent == null)
- throw new SlcException("Cannot find agent for " + processNode);
- slcAgent.process(process);
- return process;
- } catch (Exception e) {
- if (!process.getStatus().equals(ExecutionProcess.ERROR))
- process.setStatus(ExecutionProcess.ERROR);
- throw new SlcException("Cannot execute " + processNode, e);
- }
- }
-
- public void kill(Node processNode) {
- JcrExecutionProcess process = new JcrExecutionProcess(processNode);
- try {
- SlcAgent slcAgent = findAgent(processNode);
- if (slcAgent == null)
- throw new SlcException("Cannot find agent for " + processNode);
- slcAgent.kill(process.getUuid());
- } catch (Exception e) {
- if (!process.getStatus().equals(ExecutionProcess.ERROR))
- process.setStatus(ExecutionProcess.ERROR);
- throw new SlcException("Cannot execute " + processNode, e);
- }
- }
-
- /** Always return the default runtime agent */
- protected SlcAgent findAgent(Node processNode) throws RepositoryException {
- // we currently only deal with single agents
- // Node realizedFlowNode = processNode.getNode(SlcNames.SLC_FLOW);
- // NodeIterator nit = realizedFlowNode.getNodes();
- // if (nit.hasNext()) {
- // // TODO find a better way to determine which agent to use
- // // currently we check the agent of the first registered flow
- // Node firstRealizedFlow = nit.nextNode();
- // // we assume there is an nt:address
- // String firstFlowPath = firstRealizedFlow
- // .getNode(SlcNames.SLC_ADDRESS)
- // .getProperty(Property.JCR_PATH).getString();
- // Node flowNode = processNode.getSession().getNode(firstFlowPath);
- // String agentFactoryPath = SlcJcrUtils
- // .flowAgentFactoryPath(firstFlowPath);
- // if (!agentFactories.containsKey(agentFactoryPath))
- // throw new SlcException("No agent factory registered under "
- // + agentFactoryPath);
- // SlcAgentFactory agentFactory = agentFactories.get(agentFactoryPath);
- // Node agentNode = ((Node) flowNode
- // .getAncestor(SlcJcrUtils.AGENT_FACTORY_DEPTH + 1));
- // String agentUuid = agentNode.getProperty(SlcNames.SLC_UUID)
- // .getString();
- //
- // // process
- // return agentFactory.getAgent(agentUuid);
- // }
-
- return agent;
- }
-
- public void setAgent(SlcAgent agent) {
- this.agent = agent;
- }
-
- // public synchronized void register(SlcAgentFactory agentFactory,
- // Map<String, String> properties) {
- // String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
- // if (log.isDebugEnabled())
- // log.debug("Agent factory registered under " + path);
- // agentFactories.put(path, agentFactory);
- // }
- //
- // public synchronized void unregister(SlcAgentFactory agentFactory,
- // Map<String, String> properties) {
- // String path = properties.get(SlcJcrConstants.PROPERTY_PATH);
- // if (log.isDebugEnabled())
- // log.debug("Agent factory unregistered from " + path);
- // agentFactories.remove(path);
- // }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.decorators;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.client.ui.SlcUiConstants;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DecorationOverlayIcon;
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-
-/** Dynamically decorates the results tree. */
-public class ResultFailedDecorator extends LabelProvider implements
- ILabelDecorator {
-
- // FIXME why not use? org.eclipse.jface.viewers.DecoratingLabelProvider
-
- // private final static Log log = LogFactory
- // .getLog(ResultFailedDecorator.class);
-
- private final static DateFormat dateFormat = new SimpleDateFormat(
- SlcUiConstants.DEFAULT_DISPLAY_DATE_TIME_FORMAT);
-
- // hack for SWT resource leak
- // see http://www.eclipse.org/articles/swt-design-2/swt-design-2.html
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=181215
- private final Image passedFolder;
- private final Image failedFolder;
- private final Image failedSingleResult;
- private final Image errorSingleResult;
- private final Image passedSingleResult;
-
- public ResultFailedDecorator() {
- super();
- ImageDescriptor failedDesc = ClientUiPlugin.getDefault().getWorkbench()
- .getSharedImages()
- .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR);
- failedFolder = new DecorationOverlayIcon(SlcImages.FOLDER, failedDesc,
- IDecoration.TOP_LEFT).createImage();
- passedFolder = new DecorationOverlayIcon(SlcImages.FOLDER,
- SlcImages.EXECUTION_PASSED, IDecoration.TOP_LEFT).createImage();
- failedSingleResult = new DecorationOverlayIcon(
- SlcImages.PROCESS_COMPLETED, failedDesc, IDecoration.TOP_LEFT)
- .createImage();
- errorSingleResult = new DecorationOverlayIcon(
- SlcImages.PROCESS_COMPLETED, SlcImages.EXECUTION_ERROR,
- IDecoration.TOP_LEFT).createImage();
- passedSingleResult = new DecorationOverlayIcon(
- SlcImages.PROCESS_COMPLETED, SlcImages.EXECUTION_PASSED,
- IDecoration.TOP_LEFT).createImage();
- }
-
- // Method to decorate Image
- public Image decorateImage(Image image, Object object) {
-
- // This method returns an annotated image or null if the
- // image need not be decorated. Returning a null image
- // decorates resource icon with basic decorations provided
- // by Eclipse
- if (object instanceof ResultParent) {
- if (((ResultParent) object).isPassed()) {
- if (object instanceof SingleResultNode)
- return passedSingleResult;
- else if (object instanceof ResultFolder)
- return passedFolder;
- else
- return null;
- } else {
- // ImageDescriptor desc = ClientUiPlugin.getDefault()
- // .getWorkbench().getSharedImages()
- // .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR);
- // DecorationOverlayIcon decoratedImage = new
- // DecorationOverlayIcon(
- // image, desc, IDecoration.TOP_LEFT);
- // return decoratedImage.createImage();
- if (object instanceof SingleResultNode) {
- SingleResultNode srn = (SingleResultNode) object;
- boolean isError = false;
- try {
- isError = srn.getNode()
- .getNode(SlcNames.SLC_AGGREGATED_STATUS)
- .hasProperty(SlcNames.SLC_ERROR_MESSAGE);
- } catch (RepositoryException re) {
- // Silent node might not exist
- }
- if (isError)
- return errorSingleResult;
- else
- return failedSingleResult;
-
- } else
- return failedFolder;
- }
- }
- return null;
- }
-
- // Method to decorate Text
- public String decorateText(String label, Object object) {
- if (object instanceof SingleResultNode) {
- SingleResultNode srNode = (SingleResultNode) object;
- Node node = srNode.getNode();
- String decoration = null;
- try {
- if (node.hasProperty(SlcNames.SLC_COMPLETED))
- decoration = dateFormat.format(node
- .getProperty(SlcNames.SLC_COMPLETED).getDate()
- .getTime());
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error defining text decoration for result",
- re);
- }
- return label + " [" + decoration + "]";
- } else
- return null;
- }
-
- @Override
- public void dispose() {
- failedFolder.dispose();
- failedSingleResult.dispose();
- super.dispose();
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.editors;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.jcr.LoginException;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.argeo.slc.primitive.PrimitiveAccessor;
-import org.argeo.slc.primitive.PrimitiveUtils;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnViewer;
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowData;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.forms.AbstractFormPart;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/** Definition of the process. */
-public class ProcessBuilderPage extends FormPage implements SlcNames {
- // private final static Log log =
- // LogFactory.getLog(ProcessBuilderPage.class);
-
- public final static String ID = "processBuilderPage";
-
- /** To be displayed in empty lists */
- final static String NONE = "<none>";
-
- private Node processNode;
- private Session agentSession;
-
- private TreeViewer flowsViewer;
- private TableViewer valuesViewer;
- private Label statusLabel;
- private Button run;
- private Button remove;
- private Button clear;
-
- private AbstractFormPart formPart;
- private EventListener statusObserver;
-
- public ProcessBuilderPage(ProcessEditor editor, Node processNode) {
- super(editor, ID, "Definition");
- this.processNode = processNode;
- try {
- this.agentSession = processNode.getSession().getRepository().login();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot open agent session", e);
- }
- }
-
- @Override
- protected void createFormContent(IManagedForm mf) {
- try {
- ScrolledForm form = mf.getForm();
- form.setExpandHorizontal(true);
- form.setExpandVertical(true);
- form.setText("Process " + processNode.getName());
- GridLayout mainLayout = new GridLayout(1, true);
- form.getBody().setLayout(mainLayout);
-
- createControls(form.getBody());
- createBuilder(form.getBody());
-
- // form
- formPart = new AbstractFormPart() {
-
- };
- getManagedForm().addPart(formPart);
-
- // observation
- statusObserver = new AsyncUiEventListener(form.getDisplay()) {
- protected void onEventInUiThread(List<Event> events) {
- statusChanged();
- }
- };
- ObservationManager observationManager = processNode.getSession().getWorkspace().getObservationManager();
- observationManager.addEventListener(statusObserver, Event.PROPERTY_CHANGED, processNode.getPath(), true,
- null, null, false);
-
- // make sure all controls are in line with status
- statusChanged();
-
- // add initial flows
- addInitialFlows();
-
- } catch (RepositoryException e) {
- throw new SlcException("Cannot create form content", e);
- }
- }
-
- protected void createControls(Composite parent) {
- FormToolkit tk = getManagedForm().getToolkit();
-
- Composite controls = tk.createComposite(parent);
- controls.setLayout(new RowLayout());
- controls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- run = tk.createButton(controls, null, SWT.PUSH);
- run.setToolTipText("Run");
- run.setImage(SlcImages.LAUNCH);
- run.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- if (isFinished(getProcessStatus())) {
- ((ProcessEditor) getEditor()).relaunch();
- } else if (isRunning(getProcessStatus())) {
- ((ProcessEditor) getEditor()).kill();
- } else {
- ((ProcessEditor) getEditor()).process();
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- });
-
- remove = tk.createButton(controls, null, SWT.PUSH);
- remove.setImage(SlcImages.REMOVE_ONE);
- remove.setToolTipText("Remove selected flows");
- remove.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- removeSelectedFlows();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- });
-
- clear = tk.createButton(controls, null, SWT.PUSH);
- clear.setImage(SlcImages.REMOVE_ALL);
- clear.setToolTipText("Clear all flows");
- clear.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- removeAllFlows();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- });
-
- Composite statusComposite = tk.createComposite(controls);
- RowData rowData = new RowData();
- rowData.width = 100;
- rowData.height = 16;
- statusComposite.setLayoutData(rowData);
- statusComposite.setLayout(new FillLayout());
- statusLabel = tk.createLabel(statusComposite, getProcessStatus());
-
- }
-
- protected void createBuilder(Composite parent) {
- FormToolkit tk = getManagedForm().getToolkit();
- SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
- sashForm.setSashWidth(4);
- GridData sahFormGd = new GridData(SWT.FILL, SWT.FILL, true, true);
- sahFormGd.widthHint = 400;
- sashForm.setLayoutData(sahFormGd);
-
- Composite flowsComposite = tk.createComposite(sashForm);
- flowsComposite.setLayout(new GridLayout(1, false));
-
- flowsViewer = new TreeViewer(flowsComposite);
- flowsViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- flowsViewer.setLabelProvider(new FlowsLabelProvider());
- flowsViewer.setContentProvider(new FlowsContentProvider());
- flowsViewer.addSelectionChangedListener(new FlowsSelectionListener());
-
- int operations = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
- flowsViewer.addDropSupport(operations, tt, new FlowsDropListener(flowsViewer));
-
- // Context menu
- addContextMenu();
-
- flowsViewer.setInput(getEditorSite());
- flowsViewer.setInput(processNode);
-
- Composite valuesComposite = tk.createComposite(sashForm);
- valuesComposite.setLayout(new GridLayout(1, false));
-
- valuesViewer = new TableViewer(valuesComposite);
- GridData valuedGd = new GridData(SWT.FILL, SWT.FILL, true, true);
- // valuedGd.widthHint = 200;
- valuesViewer.getTable().setLayoutData(valuedGd);
- valuesViewer.getTable().setHeaderVisible(true);
-
- valuesViewer.setContentProvider(new ValuesContentProvider());
- initializeValuesViewer(valuesViewer);
- sashForm.setWeights(getWeights());
- valuesViewer.setInput(getEditorSite());
- }
-
- /** Creates the columns of the values viewer */
- protected void initializeValuesViewer(TableViewer viewer) {
- String[] titles = { "Name", "Value" };
- int[] bounds = { 200, 100 };
-
- for (int i = 0; i < titles.length; i++) {
- TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
- column.getColumn().setText(titles[i]);
- column.getColumn().setWidth(bounds[i]);
- column.getColumn().setResizable(true);
- column.getColumn().setMoveable(true);
- if (i == 0) {
- column.setLabelProvider(new ColumnLabelProvider() {
- public String getText(Object element) {
- try {
- Node specAttrNode = (Node) element;
- return specAttrNode.getName();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get value", e);
- }
- }
- });
- } else if (i == 1) {
- column.setLabelProvider(new ColumnLabelProvider() {
- public String getText(Object element) {
- return getAttributeSpecText((Node) element);
- }
- });
- column.setEditingSupport(new ValuesEditingSupport(viewer));
- }
-
- }
- Table table = viewer.getTable();
- table.setHeaderVisible(false);
- table.setLinesVisible(true);
- }
-
- protected int[] getWeights() {
- return new int[] { 50, 50 };
- }
-
- /*
- * CONTROLLERS
- */
- /** Reflects a status change */
- protected void statusChanged() {
- String status = getProcessStatus();
- statusLabel.setText(status);
- Boolean isEditable = isEditable(status);
- run.setEnabled(status.equals(ExecutionProcess.RUNNING) || isEditable);
- remove.setEnabled(isEditable);
- clear.setEnabled(isEditable);
- // flowsViewer.getTree().setEnabled(isEditable);
- if (status.equals(ExecutionProcess.RUNNING)) {
- run.setEnabled(true);
- run.setImage(SlcImages.KILL);
- run.setToolTipText("Kill");
- } else if (isFinished(status)) {
- run.setEnabled(true);
- run.setImage(SlcImages.RELAUNCH);
- run.setToolTipText("Relaunch");
- }
-
- if (flowsViewer != null)
- flowsViewer.refresh();
- }
-
- /** Adds initial flows from the editor input if any */
- protected void addInitialFlows() {
- for (String path : ((ProcessEditorInput) getEditorInput()).getInitialFlowPaths()) {
- addFlow(path);
- }
- }
-
- /**
- * Adds a new flow.
- *
- * @param path the path of the flow
- */
- protected void addFlow(String path) {
- try {
- Node flowNode = agentSession.getNode(path);
- Node realizedFlowNode = processNode.getNode(SLC_FLOW).addNode(SLC_FLOW);
- realizedFlowNode.setProperty(SLC_NAME, flowNode.getProperty(SLC_NAME).getString());
- realizedFlowNode.addMixin(SlcTypes.SLC_REALIZED_FLOW);
- Node address = realizedFlowNode.addNode(SLC_ADDRESS, NodeType.NT_ADDRESS);
- address.setProperty(Property.JCR_PATH, path);
-
- // copy spec attributes
- Node specAttrsBase;
- if (flowNode.hasProperty(SLC_SPEC)) {
- Node executionSpecNode = flowNode.getProperty(SLC_SPEC).getNode();
- specAttrsBase = executionSpecNode;
- String executionSpecName = executionSpecNode.getProperty(SLC_NAME).getString();
- realizedFlowNode.setProperty(SLC_SPEC, executionSpecName);
- } else
- specAttrsBase = flowNode;
-
- specAttrs: for (NodeIterator nit = specAttrsBase.getNodes(); nit.hasNext();) {
- Node specAttrNode = nit.nextNode();
- String attrName = specAttrNode.getName();
- if (!specAttrNode.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
- continue specAttrs;
- Node realizedAttrNode = realizedFlowNode.addNode(specAttrNode.getName());
- JcrUtils.copy(specAttrNode, realizedAttrNode);
-
- // override with flow value
- if (flowNode.hasNode(attrName)) {
- // assuming this is a primitive
- Node attrNode = flowNode.getNode(attrName);
- if (attrNode.hasProperty(SLC_VALUE))
- realizedAttrNode.setProperty(SLC_VALUE, attrNode.getProperty(SLC_VALUE).getValue());
- }
- }
-
- // Part title
- StringBuilder editorTitle = new StringBuilder();
- NodeIterator it = realizedFlowNode.getParent().getNodes(SLC_FLOW);
- while (it.hasNext()) {
- Node rFlowNode = it.nextNode();
- String name = rFlowNode.getProperty(SLC_NAME).getString();
- editorTitle.append(name).append(' ');
- }
- ((ProcessEditor) getEditor()).setEditorTitle(editorTitle.toString());
-
- flowsViewer.refresh();
- formPart.markDirty();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot add flow " + path, e);
- }
- }
-
- @SuppressWarnings("unchecked")
- protected void removeSelectedFlows() {
- if (!flowsViewer.getSelection().isEmpty()) {
- Iterator<Object> it = ((StructuredSelection) flowsViewer.getSelection()).iterator();
- while (it.hasNext()) {
- Node node = (Node) it.next();
- try {
- node.remove();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot remove " + node, e);
- }
- }
- flowsViewer.refresh();
- formPart.markDirty();
- }
- }
-
- protected void removeAllFlows() {
- try {
- for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit.hasNext();) {
- nit.nextNode().remove();
- }
- flowsViewer.refresh();
- formPart.markDirty();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot remove flows from " + processNode, e);
- }
- }
-
- public void commit(Boolean onSave) {
- if (onSave)
- statusLabel.setText(getProcessStatus());
- formPart.commit(onSave);
- }
-
- /*
- * STATE
- */
- protected String getProcessStatus() {
- try {
- return processNode.getProperty(SLC_STATUS).getString();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot retrieve status for " + processNode, e);
- }
- }
-
- /** Optimization so that we don't call the node each time */
- protected static Boolean isEditable(String status) {
- return status.equals(ExecutionProcess.NEW) || status.equals(ExecutionProcess.INITIALIZED);
- }
-
- protected static Boolean isFinished(String status) {
- return status.equals(ExecutionProcess.COMPLETED) || status.equals(ExecutionProcess.ERROR)
- || status.equals(ExecutionProcess.KILLED);
- }
-
- protected static Boolean isRunning(String status) {
- return status.equals(ExecutionProcess.RUNNING);
- }
-
- /*
- * LIFECYCLE
- */
- @Override
- public void dispose() {
- JcrUtils.unregisterQuietly(processNode, statusObserver);
- JcrUtils.logoutQuietly(agentSession);
- super.dispose();
- }
-
- /*
- * UTILITIES
- */
- protected static String getAttributeSpecText(Node specAttrNode) {
- try {
- if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
- if (!specAttrNode.hasProperty(SLC_VALUE))
- return "";
- String type = specAttrNode.getProperty(SLC_TYPE).getString();
- if (PrimitiveAccessor.TYPE_PASSWORD.equals(type))
- return "****************";
- Object value = PrimitiveUtils.convert(type, specAttrNode.getProperty(SLC_VALUE).getString());
- return value.toString();
- } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
- if (specAttrNode.hasProperty(SLC_VALUE)) {
- int value = (int) specAttrNode.getProperty(SLC_VALUE).getLong();
- NodeIterator children = specAttrNode.getNodes();
- int index = 0;
- while (children.hasNext()) {
- Node child = children.nextNode();
- if (index == value)
- return child.getProperty(Property.JCR_TITLE).getString();
- index++;
- }
- throw new SlcException("No child node with index " + value + " for spec attribute " + specAttrNode);
- } else
- return "";
- }
- throw new SlcException("Unsupported type for spec attribute " + specAttrNode);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get value", e);
- }
- }
-
- /*
- * FLOWS SUBCLASSES
- */
- class FlowsContentProvider implements ITreeContentProvider {
- public Object[] getElements(Object obj) {
- if (!(obj instanceof Node))
- return new Object[0];
-
- try {
- Node node = (Node) obj;
- List<Node> children = new ArrayList<Node>();
- for (NodeIterator nit = node.getNode(SLC_FLOW).getNodes(); nit.hasNext();) {
- Node flowNode = nit.nextNode();
- children.add(flowNode);
- }
- return children.toArray();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot list flows of " + obj, e);
- }
- }
-
- public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
- }
-
- public void dispose() {
- }
-
- public Object[] getChildren(Object parentElement) {
- // no children for the time being
- return null;
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return false;
- }
-
- }
-
- static class FlowsLabelProvider extends ColumnLabelProvider {
- @Override
- public String getText(Object element) {
- Node node = (Node) element;
- try {
- if (node.isNodeType(SlcTypes.SLC_REALIZED_FLOW)) {
- if (node.hasNode(SLC_ADDRESS)) {
- String path = node.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString();
- String executionModuleName = SlcJcrUtils.moduleName(path);
- // Node executionModuleNode = node.getSession().getNode(
- // SlcJcrUtils.modulePath(path));
- // String executionModuleName = executionModuleNode
- // .getProperty(SLC_NAME).getString();
- return executionModuleName + ":" + SlcJcrUtils.flowRelativePath(path);
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot display " + element, e);
- }
- return super.getText(element);
- }
-
- @Override
- public Image getImage(Object element) {
- Node node = (Node) element;
- try {
- if (node.isNodeType(SlcTypes.SLC_REALIZED_FLOW)) {
- if (node.hasProperty(SLC_STATUS)) {
- String status = node.getProperty(SLC_STATUS).getString();
- // TODO: factorize with process view ?
- if (status.equals(ExecutionProcess.RUNNING))
- return SlcImages.PROCESS_RUNNING;
- else if (status.equals(ExecutionProcess.ERROR) || status.equals(ExecutionProcess.KILLED))
- return SlcImages.PROCESS_ERROR;
- else if (status.equals(ExecutionProcess.COMPLETED))
- return SlcImages.PROCESS_COMPLETED;
- }
- return SlcImages.FLOW;
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot display " + element, e);
- }
- return super.getImage(element);
- }
-
- }
-
- /** Parameter view is updated each time a new line is selected */
- class FlowsSelectionListener implements ISelectionChangedListener {
- public void selectionChanged(SelectionChangedEvent evt) {
- if (evt.getSelection().isEmpty()) {
- valuesViewer.setInput(getEditorSite());
- return;
- }
- Node realizedFlowNode = (Node) ((IStructuredSelection) evt.getSelection()).getFirstElement();
- valuesViewer.setInput(realizedFlowNode);
- }
- }
-
- /**
- * Add a context menu that call private methods. It only relies on selected
- * item(s) not on parameter that are passed in the menuAboutToShow method
- **/
- private void addContextMenu() {
- Menu menu = new Menu(flowsViewer.getControl());
-
- MenuItem removeItems = new MenuItem(menu, SWT.PUSH);
- removeItems.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- removeSelectedFlows();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- removeItems.setText("Remove selected flow(s)");
-
- MenuItem removeAllItems = new MenuItem(menu, SWT.PUSH);
- removeAllItems.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- removeAllFlows();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
- removeAllItems.setText("Remove all flows");
- flowsViewer.getTree().setMenu(menu);
- }
-
- /** Manages drop event. */
- class FlowsDropListener extends ViewerDropAdapter {
-
- public FlowsDropListener(Viewer viewer) {
- super(viewer);
- }
-
- @Override
- public boolean performDrop(Object data) {
-
- // Parse the received String, paths are separated with a carriage
- // return
- String[] paths = data.toString().split(new String("\n"));
- SortedSet<String> resultPaths = new TreeSet<String>();
- for (String path : paths) {
- try {
- // either a node or a whole directory can have been dragged
- QueryManager qm = processNode.getSession().getWorkspace().getQueryManager();
- String statement = "SELECT * FROM [" + SlcTypes.SLC_EXECUTION_FLOW + "] WHERE ISDESCENDANTNODE(['"
- + path + "']) OR ISSAMENODE(['" + path + "'])";
- Query query = qm.createQuery(statement, Query.JCR_SQL2);
-
- // order paths
- for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
- String currPath = nit.nextNode().getPath();
- // do not add twice a same flow
- if (!resultPaths.contains(currPath))
- resultPaths.add(currPath);
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot query flows under " + path, e);
- }
- }
- for (String p : resultPaths) {
- addFlow(p);
- }
- return true;
-
- }
-
- @Override
- public boolean validateDrop(Object target, int operation, TransferData transferType) {
- return isEditable(getProcessStatus());
- }
- }
-
- /*
- * VALUES SUBCLASSES
- */
- static class ValuesContentProvider implements IStructuredContentProvider {
-
- public Object[] getElements(Object inputElement) {
- if (!(inputElement instanceof Node))
- return new Object[0];
-
- try {
- Node realizedFlowNode = (Node) inputElement;
- List<Node> specAttributes = new ArrayList<Node>();
- specAttrs: for (NodeIterator nit = realizedFlowNode.getNodes(); nit.hasNext();) {
- Node specAttrNode = nit.nextNode();
- if (!specAttrNode.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
- continue specAttrs;
- // workaround to enable hiding of necessary but unusable
- // flow parameters
- else if (specAttrNode.hasProperty(SlcNames.SLC_IS_HIDDEN)
- && specAttrNode.getProperty(SlcNames.SLC_IS_HIDDEN).getBoolean())
- continue specAttrs;
- specAttributes.add(specAttrNode);
- }
- return specAttributes.toArray();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get elements", e);
- }
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- class ValuesEditingSupport extends EditingSupport {
- private final TableViewer tableViewer;
-
- public ValuesEditingSupport(ColumnViewer viewer) {
- super(viewer);
- tableViewer = (TableViewer) viewer;
- }
-
- @Override
- protected CellEditor getCellEditor(Object element) {
- try {
- Node specAttrNode = (Node) element;
- if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
- String type = specAttrNode.getProperty(SLC_TYPE).getString();
- if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) {
- return new TextCellEditor(tableViewer.getTable(), SWT.PASSWORD);
- } else {
- return new TextCellEditor(tableViewer.getTable());
- }
- } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
- NodeIterator children = specAttrNode.getNodes();
- ArrayList<String> items = new ArrayList<String>();
- while (children.hasNext()) {
- Node child = children.nextNode();
- if (child.isNodeType(NodeType.MIX_TITLE))
- items.add(child.getProperty(Property.JCR_TITLE).getString());
- }
- return new ComboBoxCellEditor(tableViewer.getTable(), items.toArray(new String[items.size()]));
- }
- return null;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get cell editor", e);
- }
- }
-
- @Override
- protected boolean canEdit(Object element) {
- try {
- Node specAttrNode = (Node) element;
- Boolean cannotEdit = specAttrNode.getProperty(SLC_IS_IMMUTABLE).getBoolean()
- || specAttrNode.getProperty(SLC_IS_CONSTANT).getBoolean();
- return !cannotEdit && isSupportedAttributeType(specAttrNode);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot check whether " + element + " is editable", e);
- }
- }
-
- /**
- * Supports {@link SlcTypes#SLC_PRIMITIVE_SPEC_ATTRIBUTE} and
- * {@link SlcTypes#SLC_REF_SPEC_ATTRIBUTE}
- */
- protected boolean isSupportedAttributeType(Node specAttrNode) throws RepositoryException {
- return specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)
- || specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE);
- }
-
- @Override
- protected Object getValue(Object element) {
- Node specAttrNode = (Node) element;
- try {
- if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
- if (!specAttrNode.hasProperty(SLC_VALUE))
- return NONE;
- String type = specAttrNode.getProperty(SLC_TYPE).getString();
- // TODO optimize based on data type?
- Object value = PrimitiveUtils.convert(type, specAttrNode.getProperty(SLC_VALUE).getString());
- return value.toString();
- } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
- if (!specAttrNode.hasProperty(SLC_VALUE))
- return 0;
- // return the index of the sub node as set by setValue()
- // in the future we may manage references as well
- return (int) specAttrNode.getProperty(SLC_VALUE).getLong();
- }
- throw new SlcException("Unsupported type for spec attribute " + specAttrNode);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get value for " + element, e);
- }
- }
-
- @Override
- protected void setValue(Object element, Object value) {
- try {
- Node specAttrNode = (Node) element;
- if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) {
- String type = specAttrNode.getProperty(SLC_TYPE).getString();
- SlcJcrUtils.setPrimitiveAsProperty(specAttrNode, SLC_VALUE, type, value);
- valuesViewer.refresh();
- formPart.markDirty();
- } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) {
- specAttrNode.setProperty(SLC_VALUE, ((Integer) value).longValue());
- valuesViewer.refresh();
- formPart.markDirty();
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get celle editor", e);
- }
- }
-
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.editors;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.controllers.ProcessController;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.rap.rwt.service.ServerPushSession;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-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 homeSession;
- private Session agentSession;
- private Node processNode;
- private ProcessController processController;
- private ServerPushSession pushSession;
-
- private ProcessBuilderPage builderPage;
-
- private ExecutionModulesManager modulesManager;
-
- @Override
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- super.init(site, input);
- pushSession = new ServerPushSession();
- pushSession.start();
- try {
- homeSession = repository.login(NodeConstants.HOME_WORKSPACE);
- agentSession = repository.login();
- } catch (RepositoryException e1) {
- throw new SlcException("Cannot log in to repository");
- }
-
- ProcessEditorInput pei = (ProcessEditorInput) input;
- String processPath = pei.getProcessPath();
- try {
- if (processPath != null) {
- if (!homeSession.itemExists(processPath))
- throw new SlcException("Process " + processPath + " does not exist");
- processNode = homeSession.getNode(processPath);
- } else {// new
- processNode = newProcessNode(pei);
- }
- setPartName(processNode.getName());
- } catch (RepositoryException e) {
- throw new SlcException("Cannot initialize editor for " + pei, e);
- }
-
- }
-
- protected Node newProcessNode(ProcessEditorInput pei) throws RepositoryException {
- String uuid = UUID.randomUUID().toString();
- String processPath = SlcJcrUtils.createExecutionProcessPath(homeSession, uuid);
- Node processNode = JcrUtils.mkdirs(homeSession, processPath, SLC_PROCESS);
- processNode.setProperty(SLC_UUID, uuid);
- processNode.setProperty(SLC_STATUS, ExecutionProcess.NEW);
- Node processFlow = processNode.addNode(SLC_FLOW);
- processFlow.addMixin(SLC_REALIZED_FLOW);
- return processNode;
- }
-
- @Override
- public boolean isDirty() {
- if (getProcessStatus().equals(ExecutionProcess.NEW))
- return true;
- return super.isDirty();
- }
-
- protected String getProcessStatus() {
- try {
- return processNode.getProperty(SLC_STATUS).getString();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot retrieve status for " + processNode, e);
- }
- }
-
- @Override
- public void dispose() {
- JcrUtils.logoutQuietly(homeSession);
- JcrUtils.logoutQuietly(agentSession);
- if (pushSession != null)
- pushSession.stop();
- super.dispose();
- }
-
- /** Actually runs the process. */
- void process() {
- // the modifications have to be saved before execution
- try {
- processNode.setProperty(SLC_STATUS, ExecutionProcess.SCHEDULED);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot update status of " + processNode, e);
- }
-
- // save
- doSave(null);
-
- try {
- // make sure modules are started for all nodes
- for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit.hasNext();) {
- Node flowNode = nit.nextNode();
- try {
- String flowDefPath = flowNode.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString();
- Node executionModuleNode = agentSession.getNode(SlcJcrUtils.modulePath(flowDefPath));
- if (!executionModuleNode.getProperty(SLC_STARTED).getBoolean())
- ClientUiPlugin.startStopExecutionModule(modulesManager, executionModuleNode);
- } catch (Exception e) {
- ErrorFeedback.show("Cannot start execution module related to " + flowNode, e);
- }
- }
-
- // Actually process
- ExecutionProcess process = processController.process(processNode);
- Map<String, String> properties = new HashMap<String, String>();
- properties.put(ExecutionModulesManager.SLC_PROCESS_ID, process.getUuid());
- // modulesManager.registerProcessNotifier(this, properties);
- } catch (Exception e) {
- ErrorFeedback.show("Execution of " + processNode + " failed", e);
- }
- }
-
- void kill() {
- processController.kill(processNode);
- }
-
- /** Opens a new editor with a copy of this process */
- void relaunch() {
- try {
- Node duplicatedNode = duplicateProcess();
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- activePage.openEditor(new ProcessEditorInput(duplicatedNode.getPath()), ProcessEditor.ID);
- close(false);
- } catch (Exception e1) {
- throw new SlcException("Cannot relaunch " + processNode, e1);
- }
- }
-
- /** Duplicates the process */
- protected Node duplicateProcess() {
- try {
- Session session = processNode.getSession();
- String uuid = UUID.randomUUID().toString();
- String destPath = SlcJcrUtils.createExecutionProcessPath(session, uuid);
- Node newNode = JcrUtils.mkdirs(session, destPath, SlcTypes.SLC_PROCESS);
-
- Node rootRealizedFlowNode = newNode.addNode(SLC_FLOW);
- // copy node
- JcrUtils.copy(processNode.getNode(SLC_FLOW), rootRealizedFlowNode);
-
- newNode.setProperty(SLC_UUID, uuid);
- newNode.setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
-
- // reset realized flow status
- // we just manage one level for the time being
- NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW);
- while (nit.hasNext()) {
- nit.nextNode().setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
- }
-
- session.save();
- return newNode;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot duplicate process", e);
- }
- }
-
- @Override
- protected void addPages() {
- try {
- builderPage = new ProcessBuilderPage(this, processNode);
- addPage(builderPage);
- firePropertyChange(PROP_DIRTY);
- } catch (PartInitException e) {
- throw new SlcException("Cannot add pages", e);
- }
-
- }
-
- @Override
- public void doSave(IProgressMonitor monitor) {
- try {
- String status = processNode.getProperty(SLC_STATUS).getString();
- if (status.equals(ExecutionProcess.NEW))
- processNode.setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED);
- homeSession.save();
- builderPage.commit(true);
- editorDirtyStateChanged();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot save " + processNode, e);
- // } finally {
- // JcrUtils.discardQuietly(session);
- }
- }
-
- public void setEditorTitle(String title) {
- setPartName(title);
- }
-
- @Override
- public void doSaveAs() {
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-
- public void setProcessController(ProcessController processController) {
- this.processController = processController;
- }
-
- public void setModulesManager(ExecutionModulesManager modulesManager) {
- this.modulesManager = modulesManager;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.editors;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPersistableElement;
-
-public class ProcessEditorInput implements IEditorInput, IPersistableElement {
- private String processPath;
- private List<String> initialFlowPaths = new ArrayList<String>();
- private Boolean launchImmediately = false;
-
- /** New empty process */
- public ProcessEditorInput() {
- }
-
- /** New process with some flows */
- public ProcessEditorInput(List<String> initialFlowPaths,
- Boolean launchImmediately) {
- this.initialFlowPaths = initialFlowPaths;
- this.launchImmediately = launchImmediately;
- }
-
- /** Existing process */
- public ProcessEditorInput(String processPath) {
- this.processPath = processPath;
- }
-
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class arg0) {
- return null;
- }
-
- public boolean exists() {
- return processPath != null;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- return processPath != null ? processPath : "<new process>";
- }
-
- public IPersistableElement getPersistable() {
- return this;
- }
-
- public String getToolTipText() {
- return "";
- }
-
- public void saveState(IMemento memento) {
- memento.putString("processPath", processPath);
- }
-
- public String getFactoryId() {
- return ProcessEditorInputFactory.ID;
- }
-
- public String getProcessPath() {
- return processPath;
- }
-
- public List<String> getInitialFlowPaths() {
- return initialFlowPaths;
- }
-
- public Boolean getLaunchImmediately() {
- return launchImmediately;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof ProcessEditorInput))
- return false;
- ProcessEditorInput pei = (ProcessEditorInput) obj;
- if (processPath != null && pei.processPath != null)
- return processPath.equals(pei.processPath);
- return false;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.editors;
-
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.ui.IElementFactory;
-import org.eclipse.ui.IMemento;
-
-public class ProcessEditorInputFactory implements IElementFactory {
- public final static String ID = ClientUiPlugin.ID
- + ".processEditorInputFactory";
-
- public IAdaptable createElement(IMemento memento) {
- String path = memento.getString("processPath");
- return new ProcessEditorInput(path);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.editors;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Workspace;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.query.Query;
-
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.execution.ExecutionStep;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class ProcessLogPage extends FormPage {
- public final static String ID = "processLogPage";
-
- private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
-
- /** Where the log is displayed. */
- private Text text;
- /**
- * Stores logs received before the text was shown. TODO : rather store in in
- * JCR and reads it from there.
- */
- private StringBuffer beforeTextInit = new StringBuffer("");
-
- private Node processNode;
- /**
- * optimization field: we compute once the length of the path to slc:log so
- * that we can easily substring the relative path of logs.
- */
- //private Integer logPathLength;
-
- public ProcessLogPage(FormEditor editor, Node processNode) {
- super(editor, ID, "Log");
- this.processNode = processNode;
-
- EventListener listener = new LogListener(editor.getSite().getPage()
- .getWorkbenchWindow().getWorkbench().getDisplay());
-
- try {
- String logBasePath = processNode.getPath() + '/' + SlcNames.SLC_LOG;
- //logPathLength = logBasePath.length();
-
- Workspace ws = processNode.getSession().getWorkspace();
-
- String statement = "SELECT * FROM ["
- + SlcTypes.SLC_LOG_ENTRY
- + "] as logEntry"
- + " WHERE ISDESCENDANTNODE('"
- + logBasePath
- + "')"
- + " ORDER BY logEntry.[slc:timestamp] ASC, NAME(logEntry) ASC";
- StringBuffer buf = new StringBuffer("");
- NodeIterator it = ws.getQueryManager()
- .createQuery(statement, Query.JCR_SQL2).execute()
- .getNodes();
- while (it.hasNext())
- appendLogEntry(buf, it.nextNode());
- beforeTextInit = new StringBuffer(buf.toString());
- // text.setText(buf.toString());
- ws.getObservationManager().addEventListener(listener,
- Event.NODE_ADDED, logBasePath, true, null, null, false);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot register listener", e);
- }
- }
-
- @Override
- public synchronized void createPartControl(Composite parent) {
- // bypass createFormContent
- FormToolkit tk = getEditor().getToolkit();
- // parent.setLayout(new FillLayout());
- text = tk.createText(parent, "", SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL);
- text.setEditable(false);
-
- // transfer the existing buffer the first time
- if (beforeTextInit.length() > 0) {
- text.append(beforeTextInit.toString());
- // clear buffer
- beforeTextInit.setLength(0);
- }
-
- }
-
- // @Override
- // protected synchronized void createFormContent(IManagedForm mf) {
- // ScrolledForm form = mf.getForm();
- // form.setExpandHorizontal(true);
- // form.setExpandVertical(true);
- // // form.setText("Log");
- // FillLayout mainLayout = new FillLayout();
- // form.getBody().setLayout(mainLayout);
- //
- // FormToolkit tk = getManagedForm().getToolkit();
- // text = tk.createText(form.getBody(), "", SWT.MULTI | SWT.H_SCROLL
- // | SWT.V_SCROLL);
- // text.setEditable(false);
- // // transfer the existing buffer the first time
- // if (beforeTextInit.length() > 0) {
- // text.append(beforeTextInit.toString());
- // // clear buffer
- // beforeTextInit.setLength(0);
- // }
- // }
-
- protected void appendLogEntry(StringBuffer buf, Node logEntry)
- throws RepositoryException {
- // +1 in order to remove the first slash
-// String relPath = logEntry.getPath().substring(logPathLength + 1);
- //System.out.println("relPath=" + relPath);
-// int firstSlashIndex = relPath.indexOf('/');
-// int lastSlashIndex = relPath.lastIndexOf('/');
-// String thread = relPath.substring(0, firstSlashIndex);
-// String location = relPath.substring(firstSlashIndex, lastSlashIndex);
-
- // String date = dateFormat.format(logEntry
- // .getProperty(SlcNames.SLC_TIMESTAMP).getDate().getTime());
- String date = logEntry.getProperty(SlcNames.SLC_TIMESTAMP).getString();
- buf.append(date).append(' ');
- String type = logEntry.getPrimaryNodeType().getName().substring(7);
- buf.append(type).append('\t');
- // buf.append(thread).append('\t');
- // buf.append(location).append('\t');
- buf.append(logEntry.getProperty(SlcNames.SLC_MESSAGE).getString());
- buf.append('\n');
-
- }
-
- /** @deprecated */
- public synchronized void addSteps(List<ExecutionStep> steps) {
- final StringBuffer buf = new StringBuffer("");
- for (ExecutionStep step : steps) {
- buf.append(dateFormat.format(step.getTimestamp()));
- buf.append(' ');
- if (step.getType().equals(ExecutionStep.PHASE_START)) {
- buf.append("## START ").append(step.getLog());
- buf.append('\n');
- } else if (step.getType().equals(ExecutionStep.PHASE_END)) {
- buf.append("## END ").append(step.getLog());
- buf.append("\n");
- } else {
- buf.append(step.getLog());
- }
- }
-
- if (text != null) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- text.append(buf.toString());
- }
- });
- } else
- beforeTextInit.append(buf);
- }
-
- @Override
- public Control getPartControl() {
- return text;
- }
-
- @Override
- public void setFocus() {
- if (text != null)
- text.setFocus();
- }
-
- /** JCR event listener notifying when new nodes are added */
- private class LogListener extends AsyncUiEventListener {
-
- public LogListener(Display display) {
- super(display);
- }
-
- @Override
- protected void onEventInUiThread(List<Event> events)
- throws RepositoryException {
- // since we use batch save, order is not guaranteed
- // so we need to reorder, according to log line number for the time
- // being
- SortedMap<Long, Node> nodes = new TreeMap<Long, Node>();
-
- for (Event evt : events) {
- Node newNode = ProcessLogPage.this.processNode.getSession()
- .getNode(evt.getPath());
- if (newNode.isNodeType(SlcTypes.SLC_LOG_ENTRY)) {
- nodes.put(Long.parseLong(newNode.getName()), newNode);
- }
- }
-
- StringBuffer buf = new StringBuffer("");
- for (Node logEntry : nodes.values()) {
- appendLogEntry(buf, logEntry);
- }
-
- if (text != null)
- text.append(buf.toString());
- else
- beforeTextInit.append(buf);
- }
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/**
- * UI Tree component that wrap a node of type NT_UNSTRUCTURED or base node for
- * UI specific, user defined tree structure of type SLC_MY_RESULTS_ROOT_FOLDER.
- *
- * It is used for
- * <ul>
- * <li>automatically generated tree structure to store results (typically
- * Year/Month/Day...)</li>
- * <li>parent node for user defined tree structure (typically My Results node)</li>
- * </ul>
- * It thus lists either result folders, other folders and/or a list of results
- * and keeps a reference to its parent.
- */
-public class ParentNodeFolder extends ResultParent {
- // private final static Log log = LogFactory.getLog(ParentNodeFolder.class);
-
- private Node node = null;
-
- /**
- *
- * @param parent
- * @param node
- * throws an exception if null
- * @param name
- */
- public ParentNodeFolder(ParentNodeFolder parent, Node node, String name) {
- super(name);
- if (node == null)
- throw new SlcException("Node Object cannot be null");
- setParent(parent);
- this.node = node;
- }
-
- @Override
- protected void initialize() {
- try {
- NodeIterator ni = node.getNodes();
- while (ni.hasNext()) {
- Node currNode = ni.nextNode();
- if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
- SingleResultNode srn = new SingleResultNode(this, currNode,
- currNode.getProperty(SlcNames.SLC_TEST_CASE)
- .getString());
- addChild(srn);
- } else if (currNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
- // FIXME change label
- ResultFolder rf = new ResultFolder(this, currNode,
- currNode.getName());
- addChild(rf);
- } else if (currNode.isNodeType(SlcTypes.SLC_CHECK)) {
- // FIXME : manually skip node types that are not to be
- // displayed
- // Do nothing
- } else if (currNode.isNodeType(NodeType.NT_UNSTRUCTURED))
- addChild(new ParentNodeFolder(this, currNode,
- currNode.getName()));
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while initializing ParentNodeFolder : "
- + getName(), re);
- }
- }
-
- public Node getNode() {
- return node;
- }
-
- // /**
- // * Overriden in the specific case of "My result" root object to return an
- // * ordered list of children
- // */
- // public synchronized Object[] getChildren() {
- // Object[] children = super.getChildren();
- // try {
- // if (node.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
- // return ResultParentUtils.orderChildren(children);
- // else
- // return children;
- // } catch (RepositoryException re) {
- // throw new SlcException(
- // "Unexpected error while initializing simple node folder : "
- // + getName(), re);
- // }
- // }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-
-/**
- * UI Tree component that wrap a node of type ResultFolder. list either other
- * folders and/or a list of results. keeps a reference to its parent.
- */
-public class ResultFolder extends ParentNodeFolder {
-
- /**
- *
- * @param parent
- * @param node
- * throws an exception if null
- * @param name
- */
- public ResultFolder(ParentNodeFolder parent, Node node, String name) {
- super(parent, node, name);
- try {
- // initialize passed status if possible
- if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
- setPassed(node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
- .getProperty(SlcNames.SLC_SUCCESS).getBoolean());
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while initializing result folder : "
- + getName(), re);
- }
- }
-
- // /**
- // * Overriden to return an ordered list of children
- // */
- // public synchronized Object[] getChildren() {
- // Object[] children = super.getChildren();
- // return ResultParentUtils.orderChildren(children);
- // }
- //
- // public int compareTo(ResultFolder o) {
- // return super.compareTo(o);
- // }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-
-/** Enable specific sorting of the ResultTreeView */
-public class ResultItemsComparator extends ViewerComparator {
-
- @Override
- public int category(Object element) {
- if (element instanceof SingleResultNode) {
- return 10;
-
- }
- // folder always first
- return 5;
- }
-
- @Override
- public int compare(Viewer viewer, Object e1, Object e2) {
- int cat1 = category(e1);
- int cat2 = category(e2);
-
- if (cat1 != cat2) {
- return cat1 - cat2;
- }
-
- int result = 0;
-
- if (e1 instanceof TreeParent && ((TreeParent) e1).getParent() == null) {
- // preserve predefined order on UI root items
- return 0;
- }
-
- if (e1 instanceof SingleResultNode && e2 instanceof SingleResultNode) {
- Node an = ((SingleResultNode) e1).getNode();
- Node bn = ((SingleResultNode) e2).getNode();
- try {
- // Order is different if we are under my Result or )in the
- // rest of the tree structure
- if (an.getParent().isNodeType(
- SlcTypes.SLC_MY_RESULT_ROOT_FOLDER)
- || an.getParent()
- .isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
- result = super.compare(viewer, e1, e2);
- // Specific case of two result with same name
- if (result == 0) {
- result = an
- .getProperty(SlcNames.SLC_COMPLETED)
- .getDate()
- .compareTo(
- bn.getProperty(SlcNames.SLC_COMPLETED)
- .getDate());
- }
- } else {
- result = an
- .getProperty(Property.JCR_CREATED)
- .getDate()
- .compareTo(
- bn.getProperty(Property.JCR_CREATED)
- .getDate());
- result = result * -1; // last are displayed first
- }
- } catch (RepositoryException e) {
- throw new SlcException("Unable to compare date created", e);
- }
- } else if (e1 instanceof ParentNodeFolder
- && e2 instanceof ParentNodeFolder) {
- try {
- Node an = ((ParentNodeFolder) e1).getNode();
- // under my Result
- if (an.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER)
- || an.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
- result = super.compare(viewer, e1, e2);
- } else {
- // only remaining objects for the time being
- // NT_UNSTRUCTURED that display all result tree structures
- // We want the newest folders first
- result = super.compare(viewer, e1, e2) * -1;
- }
- } catch (RepositoryException e) {
- throw new SlcException("Unable to compare date created", e);
- }
- }
- return result;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.eclipse.jface.viewers.IElementComparer;
-
-/**
- * Override default behaviour to insure that 2 distincts results that have the
- * same name will be correctly and distincly returned by corresponding
- * TreeViewer.getSelection() method.
- *
- */
-public class ResultItemsComparer implements IElementComparer {
- // private final static Log log =
- // LogFactory.getLog(ResultItemsComparer.class);
-
- public boolean equals(Object a, Object b) {
- if (b == null)
- return a == null ? true : false;
-
- if (a.hashCode() != b.hashCode() || !a.getClass().equals(b.getClass()))
- return false;
- else if (a instanceof SingleResultNode) {
- try {
- String ida = ((SingleResultNode) a).getNode().getIdentifier();
-
- String idb = ((SingleResultNode) b).getNode().getIdentifier();
-
- if (ida.equals(idb))
- return true;
- else
- return false;
-
- } catch (RepositoryException e) {
- throw new SlcException("Cannot compare single reult nodes", e);
- }
- } else
- return true;
- }
-
- public int hashCode(Object element) {
- return element.hashCode();
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.model;
-
-import org.argeo.eclipse.ui.TreeParent;
-
-/**
- * Common base UI object to build result Tree.
- */
-
-public abstract class ResultParent extends TreeParent {
-
- public ResultParent(String name) {
- super(name);
- }
-
- private boolean isPassed = true;
-
- protected synchronized void setPassed(boolean isPassed) {
- this.isPassed = isPassed;
- }
-
- public boolean isPassed() {
- return isPassed;
- }
-
- @Override
- public synchronized boolean hasChildren() {
- // only initialize when needed : correctly called by the jface framework
- if (!isLoaded())
- initialize();
- return super.hasChildren();
- }
-
- public void forceFullRefresh() {
- // if (isDisposed)
- // return;
- if (hasChildren())
- clearChildren();
- initialize();
- }
-
- protected abstract void initialize();
-}
+++ /dev/null
-package org.argeo.slc.client.ui.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-
-public class ResultParentUtils {
- // private final static Log log =
- // LogFactory.getLog(ResultParentUtils.class);
-
- // public static Object[] orderChildren(Object[] children) {
- // List<ResultFolder> folders = new ArrayList<ResultFolder>();
- // List<SingleResultNode> results = new ArrayList<SingleResultNode>();
- // for (Object child : children) {
- // if (child instanceof ResultFolder)
- // folders.add((ResultFolder) child);
- // else if (child instanceof SingleResultNode)
- // results.add((SingleResultNode) child);
- // }
- //
- // // Comparator first = Collections.reverseOrder();
- // Collections.sort(folders);
- // // Comparator<SingleResultNode> second = Collections.reverseOrder();
- // Collections.sort(results);
- //
- // Object[] orderedChildren = new Object[folders.size() + results.size()];
- // int i = 0;
- // Iterator<ResultFolder> it = folders.iterator();
- // while (it.hasNext()) {
- // orderedChildren[i] = it.next();
- // i++;
- // }
- // Iterator<SingleResultNode> it2 = results.iterator();
- // while (it2.hasNext()) {
- // orderedChildren[i] = it2.next();
- // i++;
- // }
- // return orderedChildren;
- // }
-
- public static List<Node> getResultsForDates(Session session,
- List<String> dateRelPathes) {
- if (dateRelPathes == null || dateRelPathes.size() == 0)
- throw new SlcException("Specify at least one correct date as Path");
-
- try {
- String basePath = SlcJcrResultUtils.getSlcResultsBasePath(session);
- Iterator<String> it = dateRelPathes.iterator();
- StringBuffer clause = new StringBuffer();
- clause.append("SELECT * FROM [");
- clause.append(SlcTypes.SLC_TEST_RESULT);
- clause.append("] as results");
- clause.append(" WHERE ");
- while (it.hasNext()) {
- String absPath = basePath + "/" + it.next();
- clause.append("ISDESCENDANTNODE(results, [");
- clause.append(absPath);
- clause.append("]) ");
- clause.append(" OR ");
- }
- // remove last " OR "
- clause.delete(clause.length() - 4, clause.length());
- clause.append(" ORDER BY results.[" + Property.JCR_CREATED
- + "] DESC");
-
- // log.debug("request : " + clause.toString());
- QueryManager qm = session.getWorkspace().getQueryManager();
- Query q = qm.createQuery(clause.toString(), Query.JCR_SQL2);
- QueryResult result = q.execute();
-
- NodeIterator ni = result.getNodes();
- List<Node> nodes = new ArrayList<Node>();
- while (ni.hasNext()) {
- nodes.add(ni.nextNode());
- }
- return nodes;
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while getting Results for given date", re);
- }
- }
-
- /**
- * recursively update passed status of the current ResultFolder and its
- * parent if needed
- *
- * @param node
- * cannot be null
- *
- */
- public static void updatePassedStatus(Node node, boolean passed) {
- try {
- if (!node.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
- // we have reached the root of the tree. stop the
- // recursivity
- return;
- boolean pStatus = node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
- .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
- if (pStatus == passed)
- // nothing to update
- return;
- else if (!passed) {
- // New status is 'failed' : we only update status of the result
- // folder and its
- // parent if needed
- node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
- SlcNames.SLC_SUCCESS, passed);
- updatePassedStatus(node.getParent(), passed);
- } else {
- // New status is 'passed': we must first check if all siblings
- // have also
- // successfully completed
- boolean success = true;
- NodeIterator ni = node.getNodes();
- children: while (ni.hasNext()) {
- Node currNode = ni.nextNode();
- if ((currNode.isNodeType(SlcTypes.SLC_DIFF_RESULT) || currNode
- .isNodeType(SlcTypes.SLC_RESULT_FOLDER))
- && !currNode
- .getNode(SlcNames.SLC_AGGREGATED_STATUS)
- .getProperty(SlcNames.SLC_SUCCESS)
- .getBoolean()) {
- success = false;
- break children;
- }
- }
- if (success) {
- node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
- SlcNames.SLC_SUCCESS, passed);
- updatePassedStatus(node.getParent(), passed);
- } else
- // one of the siblings had also the failed status so
- // above tree remains unchanged.
- return;
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot update result passed status", e);
- }
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.model;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Workspace;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-
-/**
- * UI Tree component. Wraps a result node of a JCR {@link Workspace}. It also
- * keeps a reference to its parent node that can either be a
- * {@link ResultFolder}, a {@link SingleResultNode} or a {@link VirtualFolder}.
- * It has no child.
- */
-
-public class SingleResultNode extends ResultParent implements
- Comparable<SingleResultNode> {
-
- private final Node node;
- private boolean passed;
-
- // keeps a local reference to the node's name to avoid exception when the
- // session is lost
-
- /** Creates a new UiNode in the UI Tree */
- public SingleResultNode(TreeParent parent, Node node, String name) {
- super(name);
- setParent(parent);
- this.node = node;
- setPassed(refreshPassedStatus());
- }
-
- public boolean refreshPassedStatus() {
- try {
- Node check;
- if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS)) {
- check = node.getNode(SlcNames.SLC_AGGREGATED_STATUS);
- passed = check.getProperty(SlcNames.SLC_SUCCESS).getBoolean();
- return passed;
- } else
- // Happens only if the UI triggers a refresh while the execution
- // is in progress and the corresponding node is being built
- return false;
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while checking result status", re);
- }
- }
-
- /** returns the node wrapped by the current UI object */
- public Node getNode() {
- return node;
- }
-
- /**
- * Override normal behavior : Results have no children for this view
- */
- @Override
- public synchronized Object[] getChildren() {
- return null;
- }
-
- @Override
- public boolean hasChildren() {
- return false;
- }
-
- public boolean isPassed() {
- return passed;
- }
-
- @Override
- protected void initialize() {
- // Do nothing this object is fully initialized at instantiation time.
- }
-
- public int compareTo(SingleResultNode o) {
- return super.compareTo(o);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.client.ui.model;
-
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-
-/**
- * UI Tree component. Virtual folder to list a list of results. Keeps a
- * reference to its parent that might be null. It also keeps a reference to all
- * nodes that must be displayed as children of the current virtual folder.
- */
-public class VirtualFolder extends ResultParent {
- List<Node> displayedNodes;
-
- public VirtualFolder(VirtualFolder parent, List<Node> displayedNodes,
- String name) {
- super(name);
- setParent(parent);
- this.displayedNodes = displayedNodes;
- }
-
- @Override
- protected void initialize() {
- try {
- for (Node currNode : displayedNodes) {
- if (currNode.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
- SingleResultNode srn = new SingleResultNode(this, currNode,
- currNode.getProperty(SlcNames.SLC_TEST_CASE)
- .getString());
- addChild(srn);
- }
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while initializing ParentNodeFolder : "
- + getName(), re);
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.providers;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/** Basic content provider for a tree of result */
-public class ResultTreeContentProvider implements ITreeContentProvider {
-
- /**
- * @param parent
- * Pass current user home as parameter
- *
- */
- public Object[] getElements(Object parent) {
- if (parent instanceof Object[])
- return (Object[]) parent;
- else
- return null;
- }
-
- public Object getParent(Object child) {
- return ((TreeParent) child).getParent();
- }
-
- public Object[] getChildren(Object parent) {
- return ((TreeParent) parent).getChildren();
- }
-
- public boolean hasChildren(Object parent) {
- return ((TreeParent) parent).hasChildren();
- }
-
- public void dispose() {
- // FIXME implement if needed
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.providers;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.argeo.eclipse.ui.TreeParent;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.client.ui.SlcUiConstants;
-import org.argeo.slc.client.ui.model.ParentNodeFolder;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/** Basic label provider for a tree of result */
-public class ResultTreeLabelProvider extends LabelProvider {
- // private final static Log log = LogFactory
- // .getLog(ResultTreeLabelProvider.class);
-
- @Override
- public String getText(Object element) {
- try {
-
- if (element instanceof SingleResultNode) {
- Node node = ((SingleResultNode) element).getNode();
- if (node.isNodeType(NodeType.MIX_TITLE))
- return node.getProperty(Property.JCR_TITLE).getString();
-
- } else if (element instanceof ParentNodeFolder) {
- Node node = ((ParentNodeFolder) element).getNode();
- if (node.hasProperty(Property.JCR_TITLE))
- return node.getProperty(Property.JCR_TITLE).getString();
- }
- } catch (RepositoryException e) {
- throw new SlcException("Unexpected error while getting "
- + "custom result label", e);
- }
- return ((TreeParent) element).getName();
- }
-
- public Image getImage(Object obj) {
- if (obj instanceof SingleResultNode) {
- // FIXME add realtime modification of process icon (SCHEDULED,
- // RUNNING, COMPLETED...)
- // Node resultNode = ((SingleResultNode) obj).getNode();
- // int status = SlcJcrUtils.aggregateTestStatus(resultNode);
- return SlcImages.PROCESS_COMPLETED;
- } else if (obj instanceof ResultParent) {
- ResultParent rParent = (ResultParent) obj;
- if (SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL.equals(rParent
- .getName()))
- return SlcImages.MY_RESULTS_FOLDER;
- else
- return SlcImages.FOLDER;
- } else
- return null;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.views;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.observation.Event;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.eclipse.ui.jcr.DefaultNodeLabelProvider;
-import org.argeo.eclipse.ui.jcr.NodeElementComparer;
-import org.argeo.eclipse.ui.jcr.SimpleNodeContentProvider;
-import org.argeo.eclipse.ui.specific.EclipseUiSpecificUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.client.ui.editors.ProcessEditor;
-import org.argeo.slc.client.ui.editors.ProcessEditorInput;
-import org.argeo.slc.execution.ExecutionModulesManager;
-import org.argeo.slc.jcr.SlcJcrConstants;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.rap.rwt.service.ServerPushSession;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceAdapter;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPage;
-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 static final String ID = ClientUiPlugin.ID + ".jcrExecutionModulesView";
-
- private TreeViewer viewer;
-
- private ServerPushSession pushSession;
-
- /* DEPENDENCY INJECTION */
- private Repository repository;
- private Session session;
- private ExecutionModulesManager modulesManager;
-
- public void createPartControl(Composite parent) {
- pushSession = new ServerPushSession();
- pushSession.start();
-
- 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.setContentProvider(contentProvider);
- viewer.setComparer(new NodeElementComparer());
- final ViewLabelProvider viewLabelProvider = new ViewLabelProvider();
- viewer.setLabelProvider(viewLabelProvider);
- viewer.setInput(getViewSite());
- viewer.addDoubleClickListener(new ViewDoubleClickListener());
- // context menu
- // addContextMenu(viewer);
-
- getViewSite().setSelectionProvider(viewer);
-
- Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
- // Transfer[] tt = new Transfer[] { EditorInputTransfer.getInstance() };
- int operations = DND.DROP_COPY | DND.DROP_MOVE;
- 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);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot add observer", e);
- }
- }
-
- public void setFocus() {
- viewer.getControl().setFocus();
- }
-
- public TreeViewer getViewer() {
- return viewer;
- }
-
- public void refreshView() {
- viewer.setInput(getViewSite());
- }
-
- // Controllers
- class ViewContentProvider extends SimpleNodeContentProvider {
- private static final long serialVersionUID = 5117887833174813672L;
-
- public ViewContentProvider(Session session) {
- super(session, new String[] { SlcJcrConstants.VM_AGENT_FACTORY_PATH });
- }
-
- @Override
- protected Object[] sort(Object parent, Object[] children) {
- Object[] sorted = new Object[children.length];
- System.arraycopy(children, 0, sorted, 0, children.length);
- Arrays.sort(sorted, new ViewComparator());
- return sorted;
- }
-
- @Override
- 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))
- it.remove();
- }
- return super.filterChildren(children);
- }
-
- @Override
- public boolean hasChildren(Object element) {
- if (element instanceof Node) {
- Node node = (Node) element;
- try {
- if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
- return false;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot check has children", e);
- }
- }
- return super.hasChildren(element);
- }
- }
-
- static class ViewComparator implements Comparator<Object> {
-
- public int compare(Object o1, Object o2) {
- try {
- if (o1 instanceof Node && o2 instanceof Node) {
- Node node1 = (Node) o1;
- Node node2 = (Node) o2;
-
- if (node1.getName().equals(SLC_EXECUTION_SPECS))
- return -100;
- if (node2.getName().equals(SLC_EXECUTION_SPECS))
- return 100;
-
- 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)) {
- return 1;
- } else if (!node1.isNodeType(SLC_EXECUTION_FLOW) && node2.isNodeType(SLC_EXECUTION_FLOW)) {
- return -1;
- } else {
- // TODO: check title
- return node1.getName().compareTo(node2.getName());
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot compare " + o1 + " and " + o2, e);
- }
- return 0;
- }
-
- }
-
- // private void addContextMenu(TreeViewer flowsViewer) {
- //
- // final MenuManager menuMgr = new MenuManager();
- // menuMgr.setRemoveAllWhenShown(true);
- // menuMgr.addMenuListener(new IMenuListener() {
- //
- // public void menuAboutToShow(IMenuManager manager) {
- // menuMgr.add(new Action("Test") {
- // public void run() {
- // log.debug("do something");
- // }
- // });
- // }
- // });
- // Menu menu = menuMgr.createContextMenu(flowsViewer.getControl());
- // flowsViewer.getTree().setMenu(menu);
- // getSite().registerContextMenu(menuMgr, flowsViewer);
- // }
-
- class VmAgentObserver extends AsyncUiEventListener {
-
- public VmAgentObserver(Display display) {
- super(display);
- }
-
- protected void onEventInUiThread(List<Event> events) {
- for (Event event : events) {
- try {
- String path = event.getPath();
-
- if (session.itemExists(path)) {
- Node parentNode = session.getNode(path);// .getParent();
- if (log.isTraceEnabled())
- log.trace("Refresh " + parentNode + " after event " + event);
- viewer.refresh(parentNode);
- }
- } catch (RepositoryException e) {
- log.warn("Cannot process event " + event + ": " + e);
- }
- }
-
- // TODO: optimize based on event
- viewer.refresh();
- }
- }
-
- 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))
- 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))
- 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))
- return SlcImages.CHOICES;
- else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
- return SlcImages.EXECUTION_SPEC_ATTRIBUTE;
- else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC))
- return SlcImages.EXECUTION_SPEC;
- else if (node.getName().equals(SLC_EXECUTION_SPECS))
- return SlcImages.EXECUTION_SPECS;
- else if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
- return SlcImages.FLOW;
- else if (node.isNodeType(SlcTypes.SLC_MODULE)) {
- if (node.getProperty(SLC_STARTED).getBoolean())
- return SlcImages.MODULE;
- else
- return SlcImages.MODULE_STOPPED;
- } else if (node.isNodeType(SlcTypes.SLC_AGENT))
- return SlcImages.AGENT;
- else if (node.isNodeType(SlcTypes.SLC_AGENT_FACTORY))
- return SlcImages.AGENT_FACTORY;
- else
- return SlcImages.FOLDER;
- }
-
- public String getToolTipText(Node node) throws RepositoryException {
- if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_DESCRIPTION))
- return node.getProperty(Property.JCR_DESCRIPTION).getString();
- return super.getToolTipText(node);
- }
-
- public String getColumnText(Object obj, int index) {
- return getText(obj);
- }
-
- public Image getColumnImage(Object obj, int index) {
- return getImage(obj);
- }
-
- }
-
- class ViewDoubleClickListener implements IDoubleClickListener {
- public void doubleClick(DoubleClickEvent evt) {
- 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);
- } 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 + "'])";
- // 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();) {
- paths.add(nit.nextNode().getPath());
- }
-
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage();
- activePage.openEditor(new ProcessEditorInput(new ArrayList<String>(paths), true),
- ProcessEditor.ID);
- }
- }
- } catch (Exception e) {
- throw new SlcException("Cannot open " + obj, e);
- }
- }
-
- }
-
- /** 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();
- @SuppressWarnings("rawtypes")
- Iterator it = selection.iterator();
- try {
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof Node) {
- Node node = (Node) obj;
- if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW)
- || node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) {
- doIt = true;
- }
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot read node to set drag data", e);
- }
- event.doit = doIt;
- }
-
- public void dragSetData(DragSourceEvent event) {
- IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
- StringBuilder buf = new StringBuilder();
- @SuppressWarnings("rawtypes")
- Iterator it = selection.iterator();
- try {
-
- while (it.hasNext()) {
- Object obj = it.next();
-
- 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)) {
- buf.append(node.getPath()).append('\n');
- }
- }
- }
- } catch (RepositoryException e) {
- throw new SlcException("Cannot read node to set drag data", e);
- }
-
- if (buf.length() > 0) {
- if (buf.charAt(buf.length() - 1) == '\n')
- buf.deleteCharAt(buf.length() - 1);
- event.data = buf.toString();
- log.debug("data set to : " + buf.toString());
- }
- }
- }
-
- public void dispose() {
- JcrUtils.logoutQuietly(session);
- if (pushSession != null)
- pushSession.stop();
- super.dispose();
- }
-
- // DEPENDENCY INJECTION
-
- public void setModulesManager(ExecutionModulesManager modulesManager) {
- this.modulesManager = modulesManager;
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.views;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-import javax.jcr.query.Query;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcImages;
-import org.argeo.slc.client.ui.editors.ProcessEditor;
-import org.argeo.slc.client.ui.editors.ProcessEditorInput;
-import org.argeo.slc.execution.ExecutionProcess;
-import org.argeo.slc.jcr.SlcJcrUtils;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.rap.rwt.service.ServerPushSession;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-/** Displays processes. */
-public class JcrProcessListView extends ViewPart {
- public static final String ID = ClientUiPlugin.ID + ".jcrProcessListView";
-
- private TableViewer viewer;
- private ServerPushSession pushSession;
-
- private Repository repository;
- private Session session;
-
- private EventListener processesObserver;
-
- private DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
- private Integer queryLimit = 2000;
-
- public void createPartControl(Composite parent) {
- pushSession = new ServerPushSession();
- pushSession.start();
- try {
- session = repository.login(NodeConstants.HOME_WORKSPACE);
- } catch (RepositoryException re) {
- throw new SlcException("Unable to log in Repository " + repository, re);
- }
- Table table = createTable(parent);
- viewer = new TableViewer(table);
- viewer.setLabelProvider(new LabelProvider());
- viewer.setContentProvider(new ContentProvider());
- viewer.setInput(getViewSite());
- viewer.addDoubleClickListener(new ViewDoubleClickListener());
-
- processesObserver = new AsyncUiEventListener(viewer.getTable().getDisplay()) {
- protected void onEventInUiThread(List<Event> events) {
- // TODO optimize by updating only the changed process
- viewer.refresh();
- }
- };
- try {
- ObservationManager observationManager = session.getWorkspace().getObservationManager();
- observationManager.addEventListener(processesObserver,
- Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_CHANGED,
- SlcJcrUtils.getSlcProcessesBasePath(session), true, null, null, false);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot register listeners", e);
- }
-
- }
-
- protected Table createTable(Composite parent) {
- int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
- // does not function with RAP, commented for the time being
- // | SWT.HIDE_SELECTION;
-
- Table table = new Table(parent, style);
-
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
-
- TableColumn column = new TableColumn(table, SWT.LEFT, 0);
- column.setText("Date");
- column.setWidth(200);
-
- column = new TableColumn(table, SWT.LEFT, 1);
- column.setText("Host");
- column.setWidth(100);
-
- column = new TableColumn(table, SWT.LEFT, 2);
- column.setText("Id");
- column.setWidth(300);
-
- column = new TableColumn(table, SWT.LEFT, 3);
- column.setText("Status");
- column.setWidth(100);
-
- return table;
- }
-
- public void setFocus() {
- viewer.getControl().setFocus();
- }
-
- class ContentProvider implements IStructuredContentProvider {
-
- public Object[] getElements(Object inputElement) {
- try {
- // TODO filter, optimize with virtual table, ...
- String sql = "SELECT * from [slc:process] 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();) {
- nodes.add(nit.nextNode());
- }
- return nodes.toArray();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot retrieve processes", e);
- }
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- }
-
- class LabelProvider extends ColumnLabelProvider implements ITableLabelProvider {
-
- public Image getColumnImage(Object obj, int columnIndex) {
- if (columnIndex != 0)
- return null;
- try {
- Node node = (Node) obj;
- String status = node.getProperty(SlcNames.SLC_STATUS).getString();
- if (status.equals(ExecutionProcess.NEW) || status.equals(ExecutionProcess.INITIALIZED)
- || status.equals(ExecutionProcess.SCHEDULED))
- return SlcImages.PROCESS_SCHEDULED;
- else if (status.equals(ExecutionProcess.ERROR) || status.equals(ExecutionProcess.UNKOWN))
- return SlcImages.PROCESS_ERROR;
- else if (status.equals(ExecutionProcess.COMPLETED))
- return SlcImages.PROCESS_COMPLETED;
- else if (status.equals(ExecutionProcess.RUNNING))
- return SlcImages.PROCESS_RUNNING;
- else if (status.equals(ExecutionProcess.KILLED))
- return SlcImages.PROCESS_ERROR;
- else
- throw new SlcException("Unkown status " + status);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get column text", e);
- }
- }
-
- public String getColumnText(Object obj, int index) {
- try {
- Node node = (Node) obj;
- switch (index) {
-
- case 0:
- return dateFormat.format(node.getProperty(Property.JCR_LAST_MODIFIED).getDate().getTime());
- case 1:
- return "local";
- case 2:
- return node.getProperty(SlcNames.SLC_UUID).getString();
- case 3:
- return node.getProperty(SlcNames.SLC_STATUS).getString();
- }
- return getText(obj);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get column text", e);
- }
- }
-
- }
-
- class ViewDoubleClickListener implements IDoubleClickListener {
- public void doubleClick(DoubleClickEvent evt) {
- Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement();
- try {
- if (obj instanceof Node) {
- Node node = (Node) obj;
- if (node.isNodeType(SlcTypes.SLC_PROCESS)) {
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage();
- activePage.openEditor(new ProcessEditorInput(node.getPath()), ProcessEditor.ID);
- }
- }
- } catch (Exception e) {
- throw new SlcException("Cannot open " + obj, e);
- }
- }
-
- }
-
- public void dispose() {
- JcrUtils.unregisterQuietly(session.getWorkspace(), processesObserver);
- JcrUtils.logoutQuietly(session);
- if (pushSession != null)
- pushSession.stop();
- super.dispose();
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.views;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-import javax.jcr.query.Query;
-
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.eclipse.ui.jcr.NodeElementComparer;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.editors.ProcessEditor;
-import org.argeo.slc.client.ui.editors.ProcessEditorInput;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-/** Displays results. */
-public class JcrResultListView extends ViewPart implements SlcNames {
- public static final String ID = ClientUiPlugin.ID + ".jcrResultListView";
-
- 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 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);
- viewer.setLabelProvider(createLabelProvider());
- viewer.setContentProvider(new ViewContentProvider());
- viewer.setInput(getViewSite());
- viewer.addDoubleClickListener(new ViewDoubleClickListener());
- viewer.setComparer(new NodeElementComparer());
-
- getViewSite().setSelectionProvider(viewer);
-
- resultsObserver = new ResultObserver(viewer.getTable().getDisplay());
- try {
- 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);
- } 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;
- // does not work with RAP, commented for the time being
- // | SWT.HIDE_SELECTION;
-
- Table table = new Table(parent, style);
-
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
-
- TableColumn column = new TableColumn(table, SWT.LEFT, 0);
- column.setText("Date");
- column.setWidth(200);
-
- column = new TableColumn(table, SWT.LEFT, 1);
- column.setText("Id");
- column.setWidth(300);
-
- return table;
- }
-
- // public void refresh() {
- // viewer.refresh();
- // }
-
- /*
- * METHODS TO BE OVERRIDDEN
- */
- protected IBaseLabelProvider createLabelProvider() {
- return new ViewLabelProvider();
- }
-
- protected void processDoubleClick(DoubleClickEvent evt) {
- 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);
- }
- }
- } catch (Exception e) {
- throw new SlcException("Cannot open " + obj, e);
- }
- }
-
- public void setFocus() {
- viewer.getControl().setFocus();
- }
-
- 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);
- // TODO paging
- query.setLimit(queryLimit);
- List<Node> nodes = new ArrayList<Node>();
- for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
- nodes.add(nit.nextNode());
- }
- return nodes.toArray();
- } catch (RepositoryException e) {
- throw new SlcException("Cannot retrieve processes", e);
- }
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- }
-
- class ViewLabelProvider extends ColumnLabelProvider implements ITableLabelProvider {
- private static final long serialVersionUID = -6323202576386795247L;
-
- public Image getColumnImage(Object obj, int columnIndex) {
- if (columnIndex != 0)
- return null;
- try {
- Node node = (Node) obj;
- if (node.hasProperty(SLC_COMPLETED)) {
- // TODO
- }
- return null;
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get column text", e);
- }
- }
-
- public String getColumnText(Object obj, int index) {
- try {
- Node node = (Node) obj;
- switch (index) {
-
- case 0:
- if (node.hasProperty(SLC_COMPLETED)) {
- return dateFormat.format(node.getProperty(SLC_COMPLETED).getDate().getTime());
- } else {
- return "OPEN";
- }
- case 1:
- return node.getProperty(SlcNames.SLC_UUID).getString();
- }
- return getText(obj);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get column text", e);
- }
- }
-
- }
-
- class ViewDoubleClickListener implements IDoubleClickListener {
- public void doubleClick(DoubleClickEvent evt) {
- processDoubleClick(evt);
- }
-
- }
-
- class ResultObserver extends AsyncUiEventListener {
-
- public ResultObserver(Display display) {
- super(display);
- }
-
- @Override
- protected Boolean willProcessInUiThread(List<Event> events) throws RepositoryException {
- for (Event event : events) {
- // getLog().debug("Received event " + event);
- int eventType = event.getType();
- if (eventType == Event.NODE_REMOVED)
- return true;
- String path = event.getPath();
- int index = path.lastIndexOf('/');
- String propertyName = path.substring(index + 1);
- if (propertyName.equals(SLC_COMPLETED) || propertyName.equals(SLC_UUID)) {
- return true;
- }
- }
- return false;
- }
-
- protected void onEventInUiThread(List<Event> events) throws RepositoryException {
- if (getLog().isTraceEnabled())
- getLog().trace("Refresh result list");
- viewer.refresh();
- }
- }
-
- public void dispose() {
- JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver);
- JcrUtils.logoutQuietly(session);
- super.dispose();
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.views;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcUiConstants;
-import org.argeo.slc.client.ui.commands.AddResultFolder;
-import org.argeo.slc.client.ui.commands.DeleteItems;
-import org.argeo.slc.client.ui.commands.RefreshJcrResultTreeView;
-import org.argeo.slc.client.ui.commands.RenameResultFolder;
-import org.argeo.slc.client.ui.commands.RenameResultNode;
-import org.argeo.slc.client.ui.editors.ProcessEditor;
-import org.argeo.slc.client.ui.editors.ProcessEditorInput;
-import org.argeo.slc.client.ui.model.ParentNodeFolder;
-import org.argeo.slc.client.ui.model.ResultFolder;
-import org.argeo.slc.client.ui.model.ResultItemsComparator;
-import org.argeo.slc.client.ui.model.ResultItemsComparer;
-import org.argeo.slc.client.ui.model.ResultParent;
-import org.argeo.slc.client.ui.model.ResultParentUtils;
-import org.argeo.slc.client.ui.model.SingleResultNode;
-import org.argeo.slc.client.ui.model.VirtualFolder;
-import org.argeo.slc.client.ui.providers.ResultTreeContentProvider;
-import org.argeo.slc.client.ui.providers.ResultTreeLabelProvider;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-
-/** SLC generic JCR Result tree view. */
-public class JcrResultTreeView extends ViewPart {
- public final static String ID = ClientUiPlugin.ID + ".jcrResultTreeView";
-
- private final static DateFormat dateFormat = new SimpleDateFormat(
- SlcUiConstants.DEFAULT_DISPLAY_DATE_TIME_FORMAT);
-
- // private final static Log log =
- // LogFactory.getLog(JcrResultTreeView.class);
-
- /* DEPENDENCY INJECTION */
- private Repository repository;
- private Session session;
-
- // This page widgets
- private TreeViewer resultTreeViewer;
- private TableViewer propertiesViewer;
-
- private EventListener myResultsObserver = null;
- private EventListener allResultsObserver = null;
-
- // under My Results
- private final static String[] observedNodeTypesUnderMyResult = {
- SlcTypes.SLC_TEST_RESULT, SlcTypes.SLC_RESULT_FOLDER,
- SlcTypes.SLC_MY_RESULT_ROOT_FOLDER };
-
- private final static String[] observedNodeTypesUnderAllResults = {
- SlcTypes.SLC_TEST_RESULT, NodeType.NT_UNSTRUCTURED };
-
- private boolean isResultFolder = false;
-
- /**
- * To be overridden to adapt size of form and result frames.
- */
- protected int[] getWeights() {
- return new int[] { 70, 30 };
- }
-
- @Override
- public void createPartControl(Composite parent) {
- try {
- session = repository.login(NodeConstants.HOME_WORKSPACE);
- } catch (RepositoryException e1) {
- throw new SlcException("Cannot log in to repository");
- }
-
- parent.setLayout(new FillLayout());
- // Main layout
- SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
- sashForm.setSashWidth(4);
- sashForm.setLayout(new FillLayout());
-
- // Create the tree on top of the view
- Composite top = new Composite(sashForm, SWT.NONE);
- GridLayout gl = new GridLayout(1, false);
- top.setLayout(gl);
- resultTreeViewer = createResultsTreeViewer(top);
-
- // Create the property viewer on the bottom
- Composite bottom = new Composite(sashForm, SWT.NONE);
- bottom.setLayout(new GridLayout(1, false));
- propertiesViewer = createPropertiesViewer(bottom);
-
- sashForm.setWeights(getWeights());
-
- setOrderedInput(resultTreeViewer);
-
- // Initialize observer
- try {
- ObservationManager observationManager = session.getWorkspace()
- .getObservationManager();
- myResultsObserver = new MyResultsObserver(resultTreeViewer
- .getTree().getDisplay());
- allResultsObserver = new AllResultsObserver(resultTreeViewer
- .getTree().getDisplay());
-
- // observe tree changes under MyResults
- observationManager.addEventListener(myResultsObserver,
- Event.NODE_ADDED | Event.NODE_REMOVED,
- SlcJcrResultUtils.getMyResultsBasePath(session), true,
- null, observedNodeTypesUnderMyResult, false);
- // observe tree changes under All results
- observationManager.addEventListener(allResultsObserver,
- Event.NODE_ADDED | Event.NODE_REMOVED,
- SlcJcrResultUtils.getSlcResultsBasePath(session), true,
- null, observedNodeTypesUnderAllResults, false);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot register listeners", e);
- }
- }
-
- /**
- * Override default behaviour so that default defined order remains
- * unchanged on first level of the tree
- */
- private void setOrderedInput(TreeViewer viewer) {
- // Add specific ordering
- viewer.setInput(null);
- viewer.setComparator(null);
- viewer.setInput(initializeResultTree());
- viewer.setComparator(new ResultItemsComparator());
- }
-
- // The main tree viewer
- protected TreeViewer createResultsTreeViewer(Composite parent) {
- int style = SWT.BORDER | SWT.MULTI;
-
- TreeViewer viewer = new TreeViewer(parent, style);
- viewer.getTree().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, true));
-
- viewer.setContentProvider(new ResultTreeContentProvider());
-
- // Add label provider with label decorator
- ResultTreeLabelProvider rtLblProvider = new ResultTreeLabelProvider();
- ILabelDecorator decorator = ClientUiPlugin.getDefault().getWorkbench()
- .getDecoratorManager().getLabelDecorator();
- viewer.setLabelProvider(new DecoratingLabelProvider(rtLblProvider,
- decorator));
- viewer.addDoubleClickListener(new ViewDoubleClickListener());
-
- // Override default behaviour to insure that 2 distincts results that
- // have the same name will be correctly and distincly returned by
- // corresponding TreeViewer.getSelection() method.
- viewer.setComparer(new ResultItemsComparer());
-
- // viewer.setLabelProvider(rtLblProvider);
- getSite().setSelectionProvider(viewer);
-
- // add drag & drop support
- int operations = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
- viewer.addDragSupport(operations, tt, new ViewDragListener());
- viewer.addDropSupport(operations, tt, new ViewDropListener(viewer));
-
- // add context menu
- MenuManager menuManager = new MenuManager();
- Menu menu = menuManager.createContextMenu(viewer.getTree());
- menuManager.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- contextMenuAboutToShow(manager);
- }
- });
- viewer.getTree().setMenu(menu);
- menuManager.setRemoveAllWhenShown(true);
-
- getSite().registerContextMenu(menuManager, viewer);
-
- // add change listener to display TestResult information in the property
- // viewer
- viewer.addSelectionChangedListener(new MySelectionChangedListener());
- return viewer;
- }
-
- // Detailed property viewer
- protected TableViewer createPropertiesViewer(Composite parent) {
- propertiesViewer = new TableViewer(parent);
- propertiesViewer.getTable().setLayoutData(
- new GridData(SWT.FILL, SWT.FILL, true, true));
- propertiesViewer.getTable().setHeaderVisible(true);
- propertiesViewer.setContentProvider(new PropertiesContentProvider());
- TableViewerColumn col = new TableViewerColumn(propertiesViewer,
- SWT.NONE);
- col.getColumn().setText("Name");
- col.getColumn().setWidth(100);
- col.setLabelProvider(new ColumnLabelProvider() {
- public String getText(Object element) {
- try {
- String name = ((Property) element).getName();
- String value = null;
- if (SlcNames.SLC_TEST_CASE.equals(name))
- value = "Test case";
- else if (SlcNames.SLC_COMPLETED.equals(name))
- value = "Completed on";
- else if (SlcNames.SLC_SUCCESS.equals(name))
- value = "Status";
- else if (SlcNames.SLC_MESSAGE.equals(name))
- value = "Message";
- else if (SlcNames.SLC_ERROR_MESSAGE.equals(name))
- value = "Error";
- return value;
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected exception in label provider", e);
- }
- }
- });
- col = new TableViewerColumn(propertiesViewer, SWT.NONE);
- col.getColumn().setText("Value");
- col.getColumn().setWidth(200);
- col.setLabelProvider(new ColumnLabelProvider() {
- public String getText(Object element) {
- try {
- Property property = (Property) element;
- String name = property.getName();
- String value = null;
-
- if (SlcNames.SLC_TEST_CASE.equals(name)
- || SlcNames.SLC_ERROR_MESSAGE.equals(name)
- || SlcNames.SLC_MESSAGE.equals(name))
- value = property.getValue().getString();
- else if (SlcNames.SLC_COMPLETED.equals(name)) {
- Calendar date = property.getValue().getDate();
- value = dateFormat.format(date.getTime());
- } else if (SlcNames.SLC_SUCCESS.equals(name)) {
- if (property.getValue().getBoolean())
- value = "PASSED";
- else {
- if (property.getParent().hasProperty(
- SlcNames.SLC_ERROR_MESSAGE))
- value = "ERROR";
- else
- value = "FAILED";
- }
- }
- return value;
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unexpected exception in label provider", e);
- }
- }
- });
- propertiesViewer.setInput(getViewSite());
- return propertiesViewer;
- }
-
- /**
- * Override to provide specific behaviour. Typically to enable the display
- * of a result file.
- *
- * @param evt
- */
- protected void processDoubleClick(DoubleClickEvent evt) {
- Object obj = ((IStructuredSelection) evt.getSelection())
- .getFirstElement();
- try {
- if (obj instanceof SingleResultNode) {
- SingleResultNode srNode = (SingleResultNode) obj;
- Node node = srNode.getNode();
- // 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);
- }
- }
- } catch (Exception e) {
- throw new SlcException("Cannot open " + obj, e);
- }
- }
-
- @Override
- public void setFocus() {
- }
-
- /**
- * refreshes the passed resultParent and its corresponding subtree. It
- * refreshes the whole viewer if null is passed.
- *
- * @param ResultParent
- *
- */
- public void refresh(ResultParent resultParent) {
- if (resultParent == null) {
- if (!resultTreeViewer.getTree().isDisposed()) {
- TreePath[] tps = resultTreeViewer.getExpandedTreePaths();
- setOrderedInput(resultTreeViewer);
- resultTreeViewer.setExpandedTreePaths(tps);
- } else
- setOrderedInput(resultTreeViewer);
- } else {
- if (resultParent instanceof ParentNodeFolder) {
- ParentNodeFolder currFolder = (ParentNodeFolder) resultParent;
- jcrRefresh(currFolder.getNode());
- currFolder.forceFullRefresh();
- }
- // FIXME: specific refresh does not work
- // resultTreeViewer.refresh(resultParent, true);
- refresh(null);
- }
- }
-
- /**
- * refreshes the passed node and its corresponding subtree.
- *
- * @param node
- * cannot be null
- *
- */
- public boolean jcrRefresh(Node node) {
- // if (log.isDebugEnabled())
- // log.debug(" JCR refreshing " + node + "...");
- // Thread.dumpStack();
- boolean isPassed = true;
- try {
- if (node.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
- isPassed = node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
- .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
- } else if (node.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
- NodeIterator ni = node.getNodes();
- while (ni.hasNext()) {
- Node currChild = ni.nextNode();
- isPassed = isPassed & jcrRefresh(currChild);
- }
- if (isPassed != node.getNode(SlcNames.SLC_AGGREGATED_STATUS)
- .getProperty(SlcNames.SLC_SUCCESS).getBoolean()) {
- node.getNode(SlcNames.SLC_AGGREGATED_STATUS).setProperty(
- SlcNames.SLC_SUCCESS, isPassed);
- node.getSession().save();
- return isPassed;
- }
- } else
- ; // do nothing
- } catch (RepositoryException e) {
- throw new SlcException("Cannot register listeners", e);
- }
- return isPassed;
- }
-
- private ResultParent[] initializeResultTree() {
- try {
- // Force initialization of the tree structure if needed
- SlcJcrResultUtils.getSlcResultsParentNode(session);
- SlcJcrResultUtils.getMyResultParentNode(session);
- // Remove yesterday and last 7 days virtual folders
- // ResultParent[] roots = new ResultParent[5];
- ResultParent[] roots = new ResultParent[3];
-
- // My results
- roots[0] = new ParentNodeFolder(null,
- SlcJcrResultUtils.getMyResultParentNode(session),
- SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL);
-
- // today
- Calendar cal = Calendar.getInstance();
- String relPath = JcrUtils.dateAsPath(cal);
- List<String> datePathes = new ArrayList<String>();
- datePathes.add(relPath);
- roots[1] = new VirtualFolder(null,
- ResultParentUtils.getResultsForDates(session, datePathes),
- "Today");
-
- // // Yesterday
- // cal = Calendar.getInstance();
- // cal.add(Calendar.DAY_OF_YEAR, -1);
- // relPath = JcrUtils.dateAsPath(cal);
- // datePathes = new ArrayList<String>();
- // datePathes.add(relPath);
- // roots[2] = new VirtualFolder(null,
- // ResultParentUtils.getResultsForDates(session, datePathes),
- // "Yesterday");
- // // Last 7 days
- //
- // cal = Calendar.getInstance();
- // datePathes = new ArrayList<String>();
- //
- // for (int i = 0; i < 7; i++) {
- // cal.add(Calendar.DAY_OF_YEAR, -i);
- // relPath = JcrUtils.dateAsPath(cal);
- // datePathes.add(relPath);
- // }
- // roots[3] = new VirtualFolder(null,
- // ResultParentUtils.getResultsForDates(session, datePathes),
- // "Last 7 days");
-
- // All results
- Node otherResultsPar = session.getNode(SlcJcrResultUtils
- .getSlcResultsBasePath(session));
- // roots[4] = new ParentNodeFolder(null, otherResultsPar,
- // "All results");
- roots[2] = new ParentNodeFolder(null, otherResultsPar,
- "All results");
- return roots;
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unexpected error while initializing ResultTree.", re);
- }
- }
-
- // Manage context menu
- /**
- * Defines the commands that will pop up in the context menu.
- **/
- protected void contextMenuAboutToShow(IMenuManager menuManager) {
- IWorkbenchWindow window = ClientUiPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow();
-
- IStructuredSelection selection = (IStructuredSelection) resultTreeViewer
- .getSelection();
- boolean canAddSubfolder = false;
- boolean canRenamefolder = false;
- boolean isSingleResultNode = false;
- boolean isUnderMyResult = false;
- boolean validMultipleDelete = false;
- try {
-
- // Building conditions
- if (selection.size() == 1) {
- Object obj = selection.getFirstElement();
- if (obj instanceof SingleResultNode)
- isSingleResultNode = true;
- else if (obj instanceof ParentNodeFolder) {
- Node cNode = ((ParentNodeFolder) obj).getNode();
- if (cNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER)) {
- canAddSubfolder = true;
- canRenamefolder = true;
- isUnderMyResult = true;
- } else if (cNode
- .isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER)) {
- canAddSubfolder = true;
- }
- }
- } else {
- @SuppressWarnings("rawtypes")
- Iterator it = selection.iterator();
- multicheck: while (it.hasNext()) {
- validMultipleDelete = true;
- Object obj = it.next();
- if (obj instanceof SingleResultNode)
- continue multicheck;
- else if (obj instanceof ParentNodeFolder) {
- Node cNode = ((ParentNodeFolder) obj).getNode();
- if (cNode.isNodeType(SlcTypes.SLC_RESULT_FOLDER))
- continue multicheck;
- else {
- validMultipleDelete = false;
- break multicheck;
- }
- } else {
- validMultipleDelete = false;
- break multicheck;
- }
- }
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "unexpected error while building condition for context menu",
- re);
- }
-
- // Effective Refresh
- CommandUtils.refreshCommand(menuManager, window,
- RefreshJcrResultTreeView.ID,
- RefreshJcrResultTreeView.DEFAULT_LABEL,
- RefreshJcrResultTreeView.DEFAULT_IMG_DESCRIPTOR, true);
-
- CommandUtils.refreshCommand(menuManager, window, DeleteItems.ID,
- DeleteItems.DEFAULT_LABEL, DeleteItems.DEFAULT_IMG_DESCRIPTOR,
- isUnderMyResult || isSingleResultNode || validMultipleDelete);
-
- CommandUtils.refreshCommand(menuManager, window, AddResultFolder.ID,
- AddResultFolder.DEFAULT_LABEL,
- ClientUiPlugin.getDefault().getWorkbench().getSharedImages()
- .getImageDescriptor(ISharedImages.IMG_OBJ_ADD),
- canAddSubfolder);
-
- CommandUtils.refreshCommand(menuManager, window, RenameResultFolder.ID,
- RenameResultFolder.DEFAULT_LABEL,
- RenameResultFolder.DEFAULT_IMG_DESCRIPTOR, canRenamefolder);
-
- // Command removed for the time being.
- CommandUtils.refreshCommand(menuManager, window, RenameResultNode.ID,
- RenameResultNode.DEFAULT_LABEL,
- RenameResultNode.DEFAULT_IMG_DESCRIPTOR, false);
-
- // Test to be removed
- // If you use this pattern, do not forget to call
- // menuManager.setRemoveAllWhenShown(true);
- // when creating the menuManager
-
- // menuManager.add(new Action("Test") {
- // public void run() {
- // log.debug("do something");
- // }
- // });
- }
-
- /* INNER CLASSES */
- class ViewDragListener implements DragSourceListener {
-
- public void dragStart(DragSourceEvent event) {
- // Check if the drag action should start.
- IStructuredSelection selection = (IStructuredSelection) resultTreeViewer
- .getSelection();
- boolean doIt = false;
-
- // FIXME clean this code.
- try {
- if (selection.size() == 1) {
- Object obj = selection.getFirstElement();
- if (obj instanceof ResultFolder) {
- Node tNode = ((ResultFolder) obj).getNode();
- if (tNode.getPrimaryNodeType().isNodeType(
- SlcTypes.SLC_RESULT_FOLDER)) {
- doIt = true;
- isResultFolder = true;
- }
- } else
- isResultFolder = false;
- } else
- isResultFolder = false;
-
- if (!isResultFolder) {
- @SuppressWarnings("rawtypes")
- Iterator it = selection.iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof SingleResultNode) {
- Node tNode = ((SingleResultNode) obj).getNode();
- if (tNode.getPrimaryNodeType().isNodeType(
- SlcTypes.SLC_TEST_RESULT)) {
- doIt = true;
- }
- }
- }
- }
-
- } catch (RepositoryException re) {
- throw new SlcException(
- "unexpected error while validating drag source", re);
- }
- event.doit = doIt;
- }
-
- public void dragSetData(DragSourceEvent event) {
- IStructuredSelection selection = (IStructuredSelection) resultTreeViewer
- .getSelection();
-
- try {
- // specific case of a result folder
- if (isResultFolder) {
- Object obj = selection.getFirstElement();
- event.data = ((ResultFolder) obj).getNode().getIdentifier();
- } else {
- @SuppressWarnings("rawtypes")
- Iterator it = selection.iterator();
- StringBuilder nodes = new StringBuilder();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof SingleResultNode) {
- Node tNode = ((SingleResultNode) obj).getNode();
- if (tNode.getPrimaryNodeType().isNodeType(
- SlcTypes.SLC_TEST_RESULT)) {
- nodes.append(tNode.getIdentifier()).append(";");
- }
- }
- }
- event.data = nodes.toString();
- }
- } catch (RepositoryException re) {
- throw new SlcException("unexpected error while setting data",
- re);
- }
- }
-
- public void dragFinished(DragSourceEvent event) {
- // refresh is done via observer
- }
- }
-
- // Implementation of the Drop Listener
- protected class ViewDropListener extends ViewerDropAdapter {
- private Node targetParentNode = null;
-
- public ViewDropListener(Viewer viewer) {
- super(viewer);
- }
-
- @Override
- public boolean validateDrop(Object target, int operation,
- TransferData transferType) {
- boolean validDrop = false;
- try {
- // We can only drop under myResults
- Node tpNode = null;
- if (target instanceof SingleResultNode) {
- Node currNode = ((SingleResultNode) target).getNode();
- String pPath = currNode.getParent().getPath();
- if (pPath.startsWith(SlcJcrResultUtils
- .getMyResultsBasePath(session)))
- tpNode = currNode.getParent();
- } else if (target instanceof ResultFolder) {
- tpNode = ((ResultFolder) target).getNode();
- } else if (target instanceof ParentNodeFolder) {
- Node node = ((ParentNodeFolder) target).getNode();
- if (node.isNodeType(SlcTypes.SLC_MY_RESULT_ROOT_FOLDER))
- tpNode = ((ParentNodeFolder) target).getNode();
- }
-
- if (tpNode != null) {
- targetParentNode = tpNode;
- validDrop = true;
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "unexpected error while validating drop target", re);
- }
- return validDrop;
- }
-
- @Override
- public boolean performDrop(Object data) {
- // clear selection to prevent unwanted scrolling of the UI
- resultTreeViewer.setSelection(null);
- try {
- if (isResultFolder) {
- // Sanity check : we cannot move a folder to one of its sub
- // folder or neither move an object in the same parent
- // folder
- Node source = session.getNodeByIdentifier((String) data);
- if (targetParentNode.getPath().startsWith(source.getPath())
- || source.getParent().getPath()
- .equals(targetParentNode.getPath()))
- return false;
-
- // Move
- String sourcePath = source.getPath();
- String destPath = targetParentNode.getPath() + "/"
- + source.getName();
- session.move(sourcePath, destPath);
- // Update passed status of the parent source Node
- ResultParentUtils.updatePassedStatus(
- session.getNode(JcrUtils.parentPath(sourcePath)),
- true);
- // Node target = session.getNode(destPath);
- session.save();
- return true;
- }
-
- String[] datas = ((String) data).split(";");
- nodesToCopy: for (String id : datas) {
-
- Node source = session.getNodeByIdentifier(id);
- String name;
- if (source.hasProperty(Property.JCR_TITLE))
- name = source.getProperty(Property.JCR_TITLE)
- .getString();
- else if (source.hasProperty(SlcNames.SLC_TEST_CASE))
- name = source.getProperty(SlcNames.SLC_TEST_CASE)
- .getString();
- else
- name = source.getName();
-
- // Check if another copy of the same test instance already
- // exists at target
- NodeIterator ni = targetParentNode.getNodes();
- String slcUid = source.getProperty(SlcNames.SLC_UUID)
- .getString();
- while (ni.hasNext()) {
- Node curr = ni.nextNode();
- if (curr.hasProperty(SlcNames.SLC_UUID)
- && slcUid.equals(curr.getProperty(
- SlcNames.SLC_UUID).getString())) {
- MessageDialog
- .openWarning(
- PlatformUI.getWorkbench()
- .getDisplay()
- .getActiveShell(),
- "Duplicated instance.",
- "An instance of the same test case ("
- + name
- + ") exists at destination.\n "
- + "This item will not be neither copied nor moved.");
- continue nodesToCopy;
-
- }
- }
-
- Node target;
- boolean passedStatus = false;
- if (source.hasNode(SlcNames.SLC_AGGREGATED_STATUS))
- passedStatus = source
- .getNode(SlcNames.SLC_AGGREGATED_STATUS)
- .getProperty(SlcNames.SLC_SUCCESS).getBoolean();
-
- boolean isActionUnderMyResult = source.getPath()
- .startsWith(
- SlcJcrResultUtils
- .getMyResultsBasePath(session));
-
- if (!isActionUnderMyResult) {// Copy
- target = targetParentNode.addNode(source.getName(),
- source.getPrimaryNodeType().getName());
- JcrUtils.copy(source, target);
- } else {// move
- String sourcePath = source.getPath();
- String destPath = targetParentNode.getPath() + "/"
- + name;
- session.move(sourcePath, destPath);
- // Update passed status of the parent source Node
- ResultParentUtils
- .updatePassedStatus(session.getNode(JcrUtils
- .parentPath(sourcePath)), true);
- target = session.getNode(destPath);
-
- }
- if (!target.isNodeType(NodeType.MIX_TITLE))
- target.addMixin(NodeType.MIX_TITLE);
- target.setProperty(Property.JCR_TITLE, name);
- ResultParentUtils.updatePassedStatus(target.getParent(),
- passedStatus);
- session.save();
- }
- } catch (RepositoryException re) {
- throw new SlcException(
- "unexpected error while copying dropped node", re);
-
- }
- return true;
- }
- }
-
- class MyResultsObserver extends AsyncUiEventListener {
-
- public MyResultsObserver(Display display) {
- super(display);
- }
-
- @Override
- protected Boolean willProcessInUiThread(List<Event> events)
- throws RepositoryException {
- // unfiltered for the time being
- return true;
- }
-
- protected void onEventInUiThread(List<Event> events)
- throws RepositoryException {
- List<Node> nodesToRefresh = new ArrayList<Node>();
-
- for (Event event : events) {
- String parPath = JcrUtils.parentPath(event.getPath());
- if (session.nodeExists(parPath)) {
- Node node = session.getNode(parPath);
- if (!nodesToRefresh.contains(node)) {
- nodesToRefresh.add(node);
- }
- }
- }
-
- // Update check nodes
- for (Node node : nodesToRefresh)
- jcrRefresh(node);
- refresh(null);
- }
- }
-
- class AllResultsObserver extends AsyncUiEventListener {
-
- public AllResultsObserver(Display display) {
- super(display);
- }
-
- @Override
- protected Boolean willProcessInUiThread(List<Event> events)
- throws RepositoryException {
- // unfiltered for the time being
- return true;
- }
-
- protected void onEventInUiThread(List<Event> events)
- throws RepositoryException {
- refresh(null);
- // if (lastSelectedSourceElementParent != null)
- // refresh(lastSelectedSourceElementParent);
- }
- }
-
- class PropertiesContentProvider implements IStructuredContentProvider {
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public Object[] getElements(Object inputElement) {
- try {
- if (inputElement instanceof Node) {
- Node node = (Node) inputElement;
- if (node.isNodeType(SlcTypes.SLC_TEST_RESULT)) {
- List<Property> props = new ArrayList<Property>();
- if (node.hasProperty(SlcNames.SLC_TEST_CASE))
- props.add(node.getProperty(SlcNames.SLC_TEST_CASE));
- if (node.hasProperty(SlcNames.SLC_COMPLETED))
- props.add(node.getProperty(SlcNames.SLC_COMPLETED));
- if (node.hasNode(SlcNames.SLC_AGGREGATED_STATUS)) {
- Node status = node
- .getNode(SlcNames.SLC_AGGREGATED_STATUS);
- props.add(status.getProperty(SlcNames.SLC_SUCCESS));
- if (status.hasProperty(SlcNames.SLC_MESSAGE))
- props.add(status
- .getProperty(SlcNames.SLC_MESSAGE));
- if (status.hasProperty(SlcNames.SLC_ERROR_MESSAGE))
- props.add(status
- .getProperty(SlcNames.SLC_ERROR_MESSAGE));
- }
- return props.toArray();
- }
- }
- return new Object[] {};
-
- } catch (RepositoryException e) {
- throw new SlcException("Cannot get element for "
- + inputElement, e);
- }
- }
- }
-
- class MySelectionChangedListener implements ISelectionChangedListener {
-
- public void selectionChanged(SelectionChangedEvent event) {
- if (!event.getSelection().isEmpty()) {
- IStructuredSelection sel = (IStructuredSelection) event
- .getSelection();
- ResultParent firstItem = (ResultParent) sel.getFirstElement();
- if (firstItem instanceof SingleResultNode)
- propertiesViewer.setInput(((SingleResultNode) firstItem)
- .getNode());
- else
- propertiesViewer.setInput(null);
- // update cache for Drag & drop
- // lastSelectedTargetElement = firstItem;
- // lastSelectedSourceElement = firstItem;
- // lastSelectedSourceElementParent = (ResultParent) firstItem
- // .getParent();
- // String pPath = "";
- // try {
- //
- // if (firstItem instanceof ParentNodeFolder)
- // pPath = ((ParentNodeFolder) firstItem).getNode()
- // .getPath();
- // else if (firstItem instanceof SingleResultNode)
- // pPath = ((SingleResultNode) firstItem).getNode()
- // .getPath();
- // } catch (RepositoryException e) {
- // throw new SlcException(
- // "Unexpected error while checking parent UI tree", e);
- // }
- // if ((pPath.startsWith(SlcJcrResultUtils
- // .getMyResultsBasePath(session))))
- // isActionUnderMyResult = true;
- // else
- // isActionUnderMyResult = false;
- }
- }
- }
-
- class ViewDoubleClickListener implements IDoubleClickListener {
- public void doubleClick(DoubleClickEvent evt) {
- processDoubleClick(evt);
- }
-
- }
-
- /* DEPENDENCY INJECTION */
- public void dispose() {
- // JcrUtils.unregisterQuietly(session.getWorkspace(), resultsObserver);
- JcrUtils.logoutQuietly(session);
- super.dispose();
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-}
+++ /dev/null
-package org.argeo.slc.client.ui.wizards;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.client.ui.ClientUiPlugin;
-import org.argeo.slc.client.ui.SlcUiConstants;
-import org.argeo.slc.jcr.SlcJcrResultUtils;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.ISharedImages;
-
-public class ConfirmOverwriteWizard extends Wizard {
-
- // Define widget here to simplify getters
- private Button overwriteBtn, renameBtn;
- private Text newNameTxt;
- private Label newNameLbl;
-
- // business object
- private String sourceNodeName;
- private Node targetParentNode;
-
- private String newName;
- private String parentRelPath;
- private boolean overwrite;
-
- public ConfirmOverwriteWizard(String sourceNodeName, Node targetParentNode) {
- setWindowTitle("Confirm overwrite or define a new name");
- this.sourceNodeName = sourceNodeName;
- this.targetParentNode = targetParentNode;
- }
-
- @Override
- public void addPages() {
- try {
- addPage(new MyPage());
- } catch (Exception e) {
- throw new SlcException("Cannot add page to wizard ", e);
- }
- getShell().setImage(
- ClientUiPlugin.getDefault().getWorkbench().getSharedImages()
- .getImageDescriptor(ISharedImages.IMG_LCL_LINKTO_HELP)
- .createImage());
- }
-
- // Expose info to the calling view
- public boolean overwrite() {
- return overwrite;
- }
-
- public String newName() {
- return newName;
- }
-
- @Override
- public boolean performFinish() {
- boolean doFinish = false;
-
- if (canFinish()) {
- if (overwriteBtn.getSelection())
- doFinish = MessageDialog.openConfirm(Display.getDefault()
- .getActiveShell(), "CAUTION", "All data contained in ["
- + (parentRelPath != null ? parentRelPath : "")
- + "/"+ sourceNodeName
- + "] are about to be definitively destroyed. \n "
- + "Are you sure you want to proceed ?");
- else
- doFinish = true;
- // cache values
- }
- if (doFinish) {
- overwrite = overwriteBtn.getSelection();
- newName = newNameTxt.getText();
- }
- return doFinish;
- }
-
- class MyPage extends WizardPage implements ModifyListener {
-
- public MyPage() {
- super("");
- String msg = "An object with same name (" + sourceNodeName
- + ") already exists at chosen target path";
-
- // Add target rel path to the message
- Session session;
- String relPath;
- try {
- session = targetParentNode.getSession();
- relPath = targetParentNode.getPath();
- String basePath = SlcJcrResultUtils
- .getMyResultsBasePath(session);
- if (relPath.startsWith(basePath))
- relPath = relPath.substring(basePath.length());
- // FIXME currently add the default base label
- parentRelPath = SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL
- + relPath;
- } catch (RepositoryException e) {
- throw new SlcException("Unexpected error while defining "
- + "target parent node rel path", e);
- }
- msg = msg + (parentRelPath == null ? "." : ": \n" + parentRelPath);
-
- // Set Title
- setTitle(msg);
- }
-
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
-
- // choose between overwrite and rename
- overwriteBtn = new Button(composite, SWT.RADIO);
- overwriteBtn.setText("Overwrite");
- GridData gd = new GridData();
- gd.horizontalIndent = 30;
- gd.horizontalSpan = 2;
- overwriteBtn.setLayoutData(gd);
- overwriteBtn.setSelection(true);
-
- renameBtn = new Button(composite, SWT.RADIO);
- renameBtn.setText("Rename");
- renameBtn.setSelection(false);
- renameBtn.setText("Rename");
- gd = new GridData();
- gd.horizontalIndent = 30;
- gd.horizontalSpan = 2;
- renameBtn.setLayoutData(gd);
-
- newNameLbl = new Label(composite, SWT.LEAD);
- newNameLbl.setText("New name");
- newNameLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
- false));
- newNameLbl.setEnabled(false);
-
- newNameTxt = new Text(composite, SWT.LEAD | SWT.BORDER);
- newNameTxt.setText(sourceNodeName);
- newNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
- false));
- if (newNameTxt != null)
- newNameTxt.addModifyListener(this);
- newNameTxt.setEnabled(false);
-
- SelectionAdapter sa = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- updateSelection(overwriteBtn.getSelection());
- }
- };
- overwriteBtn.addSelectionListener(sa);
- renameBtn.addSelectionListener(sa);
-
- // Compulsory
- setControl(composite);
- }
-
- private void updateSelection(boolean overwrite) {
- newNameLbl.setEnabled(!overwrite);
- newNameTxt.setEnabled(!overwrite);
- if (overwrite)
- setPageComplete(true);
- else
- checkComplete();
- }
-
- protected String getTechName() {
- return newNameTxt.getText();
- }
-
- public void modifyText(ModifyEvent event) {
- checkComplete();
- }
-
- private void checkComplete() {
- try {
-
- String newName = newNameTxt.getText();
- if (newName == null || "".equals(newName.trim())) {
- setMessage("Name cannot be blank or empty",
- WizardPage.ERROR);
- setPageComplete(false);
- } else if (targetParentNode.hasNode(newName)) {
- setMessage("An object with the same name already exists.",
- WizardPage.ERROR);
- setPageComplete(false);
- } else {
- setMessage("Complete", WizardPage.INFORMATION);
- setPageComplete(true);
- }
- } catch (RepositoryException e) {
- throw new SlcException("Unexpected error while checking "
- + "children node with same name", e);
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.demo.ant</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Wed Jan 06 20:27:20 CET 2010
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <bean id="main" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
- <property name="executables">\r
- <list>\r
- <bean class="org.argeo.slc.ant.AntRun">\r
- <property name="buildFile" value="osgibundle:/ant/hello/build.xml" />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <bean class="org.argeo.slc.ant.AntFlowGenerator">\r
- <property name="antFiles">\r
- <list>\r
- <value>osgibundle:/ant/hello/build.xml\r
- </value>\r
- </list>\r
- </property>\r
- </bean>\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- 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">
-
- <import resource="classpath:org/argeo/slc/core/execution/simple.xml" />
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-<project default="hello">
- <target name="hello">
- <echo message="Hello World!" />
- </target>
-</project>
\ No newline at end of file
+++ /dev/null
-bin.includes = META-INF/
+++ /dev/null
-<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.slc</groupId>
- <artifactId>lib</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>lib</relativePath>
- </parent>
- <artifactId>org.argeo.slc.demo.ant</artifactId>
- <name>SLC Demo Ant</name>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.demo.basic</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Fri Mar 13 13:44:23 CET 2009
-eclipse.preferences.version=1
-pluginProject.equinox=false
-pluginProject.extensions=false
-resolve.requirebundle=false
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <bean id="basic.001" parent="basic.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <entry key="testData1" value-ref="basic.001.testData" />\r
- <entry key="testData2">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <aop:scoped-proxy />\r
- <property name="expected" value="tata101" />\r
- <property name="reached" value="tata@{testedComponentId}" />\r
- </bean>\r
- </entry>\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-\r
- <bean id="basic.001.testData" class="org.argeo.slc.runtime.test.BasicTestData"\r
- scope="execution">\r
- <aop:scoped-proxy />\r
- <property name="expected" value="tata100" />\r
- <property name="reached" value="tata@{testedComponentId}" />\r
- </bean>\r
-\r
- <bean id="basic.001.testData2" class="org.argeo.slc.core.test.context.DefaultContextTestData">\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
-\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <bean id="basic.002" parent="basic.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <entry key="testData1">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="toto" />\r
- <property name="reached" value="toto" />\r
- </bean>\r
- </entry>\r
- <entry key="testData2">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="tata" />\r
- <property name="reached" value="toto" />\r
- </bean>\r
- </entry>\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <bean id="basic.spec" parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testedComponentId">\r
- <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
- p:type="integer" />\r
- </entry>\r
- <entry key="testData1">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:isParameter="true" p:isFrozen="true" />\r
- </entry>\r
- <entry key="testData2">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:isParameter="true" p:isFrozen="true" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="basic.flowTemplate" parent="slcTemplate.simpleFlow"\r
- abstract="true">\r
- <constructor-arg ref="basic.spec" />\r
- <property name="path" value="/test/basic" />\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo" scope="execution">\r
- <property name="message" value="From basic @{testedComponentId}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- <bean parent="basic.testRun">\r
- <property name="testDefinition" ref="basic.testDef" />\r
- <property name="testData">\r
- <bean parent="parameterRef">\r
- <constructor-arg value="testData1" />\r
- </bean>\r
- </property>\r
- </bean>\r
- <bean parent="basic.testRun">\r
- <property name="testDefinition" ref="basic.testDef" />\r
- <property name="testData" ref="ref1" />\r
- </bean>\r
-\r
- <bean class="org.argeo.slc.jcr.JcrMetadataWriter">\r
- <property name="metadata">\r
- <map>\r
- <entry key="metadata1" value="value1" />\r
- <entry key="slc:metadata2" value="value2" />\r
- </map>\r
- </property>\r
- <property name="baseNode">\r
- <bean factory-bean="basic.testResult" factory-method="getNode" />\r
- </property>\r
- <flow:variable />\r
- </bean>\r
-\r
- <!-- Attachments -->\r
- <bean parent="task.echo">\r
- <property name="message" value="DATA" />\r
- <property name="writeTo" ref="basic.writeTo" />\r
- </bean>\r
-\r
- <bean parent="task.uploadAttachments">\r
- <property name="attachmentUploader" ref="attachmentUploader" />\r
- <property name="attachment">\r
- <bean parent="taskArg.attachment">\r
- <property name="name" value="myAttachment.txt" />\r
- </bean>\r
- </property>\r
- <property name="resource" ref="basic.writeTo" />\r
- <property name="attachTo">\r
- <list>\r
- <ref bean="basic.testResult" />\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean parent="task.closeTestResult" scope="execution">\r
- <property name="testResult" ref="basic.testResult" />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="ref1" parent="parameterRef" scope="prototype">\r
- <constructor-arg value="testData2" />\r
- </bean>\r
-\r
- <bean id="basic.testData" class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <property name="expected" value="tata" />\r
- <property name="reached" value="tata" />\r
- </bean>\r
-\r
- <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition"\r
- scope="prototype" />\r
-\r
- <bean id="basic.testResult" class="org.argeo.slc.jcr.JcrTestResult"\r
- init-method="init" destroy-method="destroy">\r
- <flow:variable />\r
- <property name="resultType" value="slc:diffResult" />\r
- <property name="attributes">\r
- <map>\r
- <entry key="testCase" value="@{slcVar.flow.name}" />\r
- </map>\r
- </property>\r
- <property name="repository" ref="repository" />\r
- </bean>\r
-\r
- <!-- <bean id="basic.testResult" parent="slcDefault.test.basicTreeTestResult" -->\r
- <!-- scope="execution"> -->\r
- <!-- <property name="listeners" ref="resultListeners" /> -->\r
- <!-- <property name="attributes"> -->\r
- <!-- <map> -->\r
- <!-- <entry key="testedComponentId" value="@{testedComponentId}" /> -->\r
- <!-- </map> -->\r
- <!-- </property> -->\r
- <!-- <aop:scoped-proxy /> -->\r
- <!-- </bean> -->\r
-\r
- <bean id="basic.testRun" class="org.argeo.slc.runtime.test.SimpleTestRun"\r
- abstract="true">\r
- <property name="testResult" ref="basic.testResult" />\r
- </bean>\r
-\r
- <bean id="basic.writeTo" factory-bean="basic.resourcesManager"\r
- factory-method="getWritableResource" scope="execution">\r
- <constructor-arg value="subdir/writeTo" />\r
- <aop:scoped-proxy />\r
- </bean>\r
-\r
- <bean id="basic.resourcesManager" parent="slcTemplate.fileResources">\r
- <property name="executionContext" ref="executionContext" />\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <bean id="canonic.001" parent="canonic.flowTemplate">\r
- <description>Canonic 001</description>\r
- <constructor-arg>\r
- <map>\r
- <entry key="parameterAtInstantiation" value="1" />\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <bean id="canonic.002" parent="canonic.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <entry key="parameterAtInstantiation" value="2" />\r
- <entry key="displayWithoutControl" value="102" />\r
- <entry key="displayWithControl" value="202" />\r
- <entry key="hide" value="202" />\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <bean id="canonic-ns.001" parent="canonic-ns.flowTemplate">\r
- <description>Canonic 001</description>\r
- <constructor-arg>\r
- <map>\r
- <entry key="parameterAtInstantiation" value="1" />\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <flow:flow id="canonic-ns.002" parent="canonic-ns.flowTemplate">\r
- <flow:arg name="parameterAtInstantiation" value="2" />\r
- <flow:arg name="displayWithoutControl" value="102" />\r
- <flow:arg name="displayWithControl" value="202" />\r
- <flow:arg name="hide" value="202" />\r
- </flow:flow>\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <flow:spec id="canonic-ns.spec">\r
- <flow:primitive name="parameterAtInstantiation"\r
- isParameter="true" type="integer" />\r
- <flow:primitive name="displayWithoutControl" value="100"\r
- isParameter="true" type="integer" isFrozen="true" />\r
- <flow:primitive name="displayWithControl" value="200"\r
- isParameter="true" type="integer" />\r
- <flow:primitive name="hide" value="300" isParameter="true"\r
- type="integer" isHidden="true" />\r
- <flow:ref name="refWithValue" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- isParameter="true" ref="testDataNok" />\r
- <flow:ref name="refWithoutValue" targetClass="org.argeo.slc.runtime.test.BasicTestData" />\r
- <flow:ref name="refWithoutValueFrozen" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- isParameter="true" isFrozen="true">\r
- <flow:value>\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <property name="expected" value="tata" />\r
- <property name="reached" value="tata" />\r
- </bean>\r
- </flow:value>\r
- </flow:ref>\r
- </flow:spec>\r
-\r
- <flow:flow id="canonic-ns.flowTemplate" abstract="true"\r
- spec="canonic-ns.spec">\r
- <bean parent="task.echo"\r
- p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
- scope="execution">\r
- <aop:scoped-proxy />\r
- </bean>\r
- </flow:flow>\r
-\r
- <bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <property name="expected" value="tata" />\r
- <property name="reached" value="tata" />\r
- </bean>\r
-\r
- <bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <property name="expected" value="tata" />\r
- <property name="reached" value="toto" />\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <bean id="canonic.spec" parent="slcTemplate.simpleSpec">\r
- <description>Covers various combinations of specs</description>\r
- <property name="attributes">\r
- <map>\r
- <entry key="parameterAtInstantiation">\r
- <bean parent="specAttr.primitive" p:isParameter="true" p:type="integer" />\r
- </entry>\r
- <entry key="displayWithoutControl">\r
- <bean parent="specAttr.primitive" p:value="100" p:isParameter="false"\r
- p:isFrozen="true" p:type="integer" />\r
- </entry>\r
- <entry key="displayWithControl">\r
- <bean parent="specAttr.primitive" p:value="200" p:isParameter="false"\r
- p:isFrozen="false" p:type="integer" />\r
- </entry>\r
- <entry key="hide">\r
- <bean parent="specAttr.primitive" p:value="300" p:isParameter="true"\r
- p:isFrozen="false" p:isHidden="true" p:type="integer" />\r
- </entry>\r
- <entry key="refWithValue">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:value-ref="testDataNok" p:isParameter="true" p:isFrozen="false" />\r
- </entry>\r
- <entry key="refWithoutValue">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:isParameter="false" p:isFrozen="false" />\r
- </entry>\r
- <entry key="refWithoutValueFrozen">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:isParameter="true" p:isFrozen="true">\r
- <property name="value">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <property name="expected" value="tata" />\r
- <property name="reached" value="tata" />\r
- </bean>\r
- </property>\r
- </bean>\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="canonic.flowTemplate" parent="slcTemplate.simpleFlow"\r
- abstract="true">\r
- <constructor-arg ref="canonic.spec" />\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo"\r
- p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
- scope="execution">\r
- <aop:scoped-proxy />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <property name="expected" value="tata" />\r
- <property name="reached" value="tata" />\r
- </bean>\r
-\r
- <bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <property name="expected" value="tata" />\r
- <property name="reached" value="toto" />\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- 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">
-
- <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />
-
- <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />
-
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <bean id="main" parent="slcTemplate.simpleFlow">\r
- <description>The Main Flow</description>\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testKey">\r
- <bean parent="specAttr.primitive" p:value="660" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- <property name="executables">\r
- <list>\r
- <ref local="echo1" />\r
- <ref bean="basic.001" />\r
- <ref bean="basic.001" />\r
- <ref bean="basic.002" />\r
- <ref bean="canonic.001" />\r
- <ref bean="canonic.002" />\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="noArg" parent="slcTemplate.simpleFlow">\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo">\r
- <property name="message" value="No arg!" />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="echo1" parent="task.echo" scope="execution">\r
- <property name="message" value="From main! @{testKey}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <!-- Flow definition is simplified thanks to the 'flow:flow' element -->\r
- <flow:flow name="/namespace/flow" >\r
- <bean p:message="TEST in flow" class="org.argeo.slc.core.execution.tasks.Echo" />\r
- <ref bean="referencedRunnable" />\r
- </flow:flow>\r
-\r
- <bean id="referencedRunnable" p:message="TEST in referenced Runnable"\r
- class="org.argeo.slc.core.execution.tasks.Echo" />\r
-\r
- <!--\r
- Standalone beans implementing Runnable can be exposed as flows via the\r
- 'flow:as-flow' attribute\r
- -->\r
- <bean id="standaloneRunnable" flow:as-flow="implicitFlow"\r
- p:message="TEST in implicit flow" class="org.argeo.slc.core.execution.tasks.Echo" />\r
-\r
- <!-- Specs definition is also simplified -->\r
- <flow:spec id="namespaceSpec">\r
- <flow:primitive name="primitive" value="100"\r
- isParameter="true" type="integer" />\r
- </flow:spec>\r
-\r
- <flow:flow name="/namespace/flowSpec" spec="namespaceSpec">\r
- <bean p:message="TEST in flow @{primitive}" class="org.argeo.slc.core.execution.tasks.Echo"\r
- scope="execution">\r
- <aop:scoped-proxy />\r
- </bean>\r
- <ref bean="referencedRunnable" />\r
- </flow:flow>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
-\r
- <reference id="attachmentUploader"\r
- interface="org.argeo.slc.core.attachment.AttachmentUploader"\r
- cardinality="0..1" />\r
-\r
- <!-- REFERENCES -->\r
- <reference id="repository" interface="javax.jcr.Repository"\r
- filter="(cn=slc)" />\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <!-- Basic echo, should work on all OSs -->\r
- <flow:flow name="os/systemCall">\r
- <bean p:cmd="echo Hello World!" class="org.argeo.slc.core.execution.tasks.SystemCall" />\r
- </flow:flow>\r
-\r
- <!-- Must disable requiretty in sudoers file -->\r
- <flow:flow name="os/sudo">\r
- <bean p:cmd="sudo id" class="org.argeo.slc.core.execution.tasks.SystemCall">\r
- <property name="environmentVariables">\r
- <map>\r
- <entry key="SUDO_ASKPASS" value="/usr/libexec/openssh/gnome-ssh-askpass" />\r
- </map>\r
- </property>\r
- </bean>\r
- </flow:flow>\r
-\r
- <!-- SSH -->\r
- <flow:flow name="os/ssh">\r
- <bean p:cmd="ls /etc" class="org.argeo.slc.core.execution.tasks.SystemCall">\r
- <property name="executor" ref="sshExecutor" />\r
- </bean>\r
- </flow:flow>\r
-\r
- <bean name="sshExecutor" class="org.argeo.slc.jsch.JschExecutor">\r
- <property name="sshTarget">\r
- <bean p:host="localhost" p:port="22" p:user="${user.name}"\r
- p:localPrivateKey="${user.home}/.ssh/id_rsa" class="org.argeo.slc.jsch.SshTarget">\r
- <property name="userInfo">\r
- <bean class="org.argeo.slc.jsch.SwingUserInfo" />\r
- </property>\r
- </bean>\r
- </property>\r
- </bean>\r
-\r
-\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-bin.includes = .settings/,\
- .project,\
- META-INF/,\
- conf/,\
- pom.xml,\
- .svn/
+++ /dev/null
-<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.slc</groupId>
- <artifactId>lib</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>lib</relativePath>
- </parent>
- <artifactId>org.argeo.slc.demo.basic</artifactId>
- <name>SLC Demo Basic</name>
-<!-- <build> -->
-<!-- <plugins> -->
-<!-- <plugin> -->
-<!-- <groupId>org.apache.felix</groupId> -->
-<!-- <artifactId>maven-bundle-plugin</artifactId> -->
-<!-- <configuration> -->
-<!-- <instructions> -->
-<!-- <SLC-ExecutionModule>default</SLC-ExecutionModule> -->
-<!-- <Import-Package> -->
-<!-- *, -->
-<!-- org.argeo.slc.core.structure.tree, -->
-
-<!-- net.sf.cglib.core, -->
-<!-- net.sf.cglib.proxy, -->
-<!-- net.sf.cglib.reflect, -->
-<!-- org.aopalliance.aop, -->
-<!-- org.argeo.slc.core.execution, -->
-<!-- org.argeo.slc.core.execution.tasks, -->
-<!-- org.argeo.slc.execution, -->
-<!-- org.argeo.slc.osgi, -->
-<!-- org.springframework.aop, -->
-<!-- org.springframework.aop.framework, -->
-<!-- org.springframework.aop.scope, -->
-<!-- org.springframework.beans.factory.config, -->
-<!-- org.springframework.core.io, -->
-<!-- </Import-Package> -->
-<!-- </instructions> -->
-<!-- </configuration> -->
-<!-- </plugin> -->
-<!-- </plugins> -->
-<!-- </build> -->
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.demo.minimal</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Wed Jan 06 20:27:49 CET 2010
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
- <import resource="classpath:org/argeo/slc/core/execution/simple.xml" />
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"\r
- >\r
-\r
- <!-- Hello world without namespace (for reference, do not use) -->\r
- <bean name="HelloWorld/Raw" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
- <description>Print Hello World!</description>\r
- <property name="executables">\r
- <list>\r
- <bean p:message="Hello World!" class="org.argeo.slc.core.execution.tasks.Echo" />\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean name="HelloWorld/RawWithVar" class="org.argeo.slc.core.execution.DefaultExecutionFlow">\r
- <description>Print Hello World! with variable</description>\r
- <constructor-arg>\r
- <bean class="org.argeo.slc.core.execution.DefaultExecutionSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testKey">\r
- <bean p:value="777"\r
- class="org.argeo.slc.primitive.PrimitiveSpecAttribute" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- <property name="executables">\r
- <list>\r
- <bean p:message="Hello World! @{testKey}" class="org.argeo.slc.core.execution.tasks.Echo"\r
- scope="execution">\r
- <aop:scoped-proxy proxy-target-class="false" />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-1.2.xsd">\r
-\r
- <!-- Hello world -->\r
- <flow:flow name="hello">\r
- <description>Print Hello World!</description>\r
- <bean p:message="Hello World!" class="org.argeo.slc.core.execution.tasks.Echo" />\r
- </flow:flow>\r
-\r
-\r
- <flow:flow name="HelloWorld/WithVar">\r
- <description>Print Hello World! with variable</description>\r
- <flow:spec>\r
- <flow:primitive name="testKey" value="777" />\r
- </flow:spec>\r
- <bean p:message="Hello World! @{testKey}" class="org.argeo.slc.core.execution.tasks.Echo">\r
- <flow:variable proxy-target-class="false" />\r
- </bean>\r
- </flow:flow>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <beans:import resource="classpath:org/argeo/slc/osgi/execution.xml" />\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-#Import-Package: org.argeo.slc.runtime,\
-#*
\ No newline at end of file
+++ /dev/null
-bin.includes = META-INF/
+++ /dev/null
-<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.slc</groupId>
- <artifactId>lib</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>lib</relativePath>
- </parent>
- <artifactId>org.argeo.slc.demo.minimal</artifactId>
- <name>SLC Demo Minimal</name>
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+++ /dev/null
-/target/
-/.slc/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.launcher</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-Main-Class: org.argeo.slc.cli.SlcMain
\ No newline at end of file
+++ /dev/null
-source.. = src/main/java/,\
- src/main/resources/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.launcher</artifactId>
- <packaging>jar</packaging>
- <name>SLC Launcher</name>
- <build>
- <plugins>
-<!-- <plugin> -->
-<!-- <groupId>org.apache.maven.plugins</groupId> -->
-<!-- <artifactId>maven-assembly-plugin</artifactId> -->
-<!-- <configuration> -->
-<!-- <descriptors> -->
-<!-- <descriptor>assembly/base.xml</descriptor> -->
-<!-- </descriptors> -->
-<!-- </configuration> -->
-<!-- <executions> -->
-<!-- <execution> -->
-<!-- <id>assembly-base</id> -->
-<!-- <phase>package</phase> -->
-<!-- <goals> -->
-<!-- <goal>single</goal> -->
-<!-- </goals> -->
-<!-- </execution> -->
-<!-- </executions> -->
-<!-- </plugin> -->
-<!-- <plugin> -->
-<!-- <groupId>org.apache.felix</groupId> -->
-<!-- <artifactId>maven-bundle-plugin</artifactId> -->
-<!-- <configuration> -->
-<!-- <instructions> -->
-<!-- <Main-Class>org.argeo.slc.cli.SlcMain</Main-Class> -->
-<!-- </instructions> -->
-<!-- </configuration> -->
-<!-- </plugin> -->
-<!-- <plugin> -->
-<!-- <artifactId>maven-resources-plugin</artifactId> -->
-<!-- <executions> -->
-<!-- <execution> -->
-<!-- <phase>validate</phase> -->
-<!-- <goals> -->
-<!-- <goal>copy-resources</goal> -->
-<!-- </goals> -->
-<!-- <configuration> -->
-<!-- <outputDirectory>${basedir}/target/base</outputDirectory> -->
-<!-- <resources> -->
-<!-- <resource> -->
-<!-- <directory>base</directory> -->
-<!-- <filtering>true</filtering> -->
-<!-- </resource> -->
-<!-- </resources> -->
-<!-- </configuration> -->
-<!-- </execution> -->
-<!-- </executions> -->
-<!-- </plugin> -->
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.osgi.boot</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.cli;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceLoader;
-import java.util.UUID;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-
-import org.argeo.osgi.boot.OsgiBoot;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
-
-/** Configures an SLC runtime and runs a process. */
-public class SlcMain implements PrivilegedAction<String> {
- public final static String NIX = "NIX";
- public final static String WINDOWS = "WINDOWS";
- public final static String SOLARIS = "SOLARIS";
-
- public final static String os;
- public final static String slcDirName = ".slc";
- final static File homeDir = new File(System.getProperty("user.home"));
-
- static {
- String osName = System.getProperty("os.name");
- if (osName.startsWith("Win"))
- os = WINDOWS;
- else if (osName.startsWith("Solaris"))
- os = SOLARIS;
- else
- os = NIX;
- }
-
- private Long timeout = 30 * 1000l;
- private final String[] args;
- private final File confDir;
- private final File dataDir;
- private final File modulesDir;
-
- private final List<String> bundlesToStart = new ArrayList<String>();
-
- public SlcMain(String[] args, File confDir, File dataDir, File modulesDir) {
- this.args = args;
- this.confDir = confDir;
- this.dataDir = dataDir;
- this.modulesDir = modulesDir;
-
- bundlesToStart.add("org.eclipse.equinox.cm");
- bundlesToStart.add("org.argeo.cms");
- bundlesToStart.add("org.eclipse.gemini.blueprint.extender");
- bundlesToStart.add("org.argeo.slc.agent");
- bundlesToStart.add("org.argeo.slc.agent.jcr");
-
- // bundlesToStart.add("org.springframework.osgi.extender");
- // bundlesToStart.add("org.argeo.node.repo.jackrabbit");
- // bundlesToStart.add("org.argeo.security.dao.os");
- // bundlesToStart.add("org.argeo.slc.node.jackrabbit");
- // bundlesToStart.add("org.argeo.slc.agent");
- // bundlesToStart.add("org.argeo.slc.agent.jcr");
- // if (args.length == 0)
- // bundlesToStart.add("org.argeo.slc.support.equinox");
- // bundlesToStart.add("org.argeo.slc.agent.cli");
- }
-
- public String run() {
- long begin = System.currentTimeMillis();
-
- Framework framework = null;
- try {
- info("## Date : " + new Date());
- info("## Data : " + dataDir.getCanonicalPath());
-
- // Start Equinox
- ServiceLoader<FrameworkFactory> ff = ServiceLoader.load(FrameworkFactory.class);
- FrameworkFactory frameworkFactory = ff.iterator().next();
- Map<String, String> configuration = new HashMap<String, String>();
- configuration.put("osgi.configuration.area", confDir.getCanonicalPath());
- configuration.put("osgi.instance.area", dataDir.getCanonicalPath());
- // Do clean
- configuration.put("osgi.clean", "true");
- if (args.length == 0) {
- configuration.put("osgi.console", "");
- }
-
- // Spring configs currently require System properties
- System.getProperties().putAll(configuration);
-
- framework = frameworkFactory.newFramework(configuration);
- framework.start();
- BundleContext bundleContext = framework.getBundleContext();
-
- // OSGi bootstrap
- OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
-
- // working copy modules
- if (modulesDir.exists())
- osgiBoot.installUrls(osgiBoot.getBundlesUrls(modulesDir.getCanonicalPath() + ";in=*;ex=.gitignore"));
-
- // system modules
- if (System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES) != null)
- osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES)));
- else
- osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty("user.home") + "/.slc/modules/;in=**"));
-
- // Start runtime
- osgiBoot.startBundles(bundlesToStart);
-
- // Find SLC Agent
- ServiceReference sr = null;
- while (sr == null) {
- sr = bundleContext.getServiceReference("org.argeo.slc.execution.SlcAgentCli");
- if (System.currentTimeMillis() - begin > timeout)
- throw new RuntimeException("Cannot find SLC agent CLI");
- Thread.sleep(100);
- }
- Object agentCli = bundleContext.getService(sr);
-
- // Initialization completed
- long duration = System.currentTimeMillis() - begin;
- info("[[ Initialized in " + (duration / 1000) + "s " + (duration % 1000) + "ms ]]");
-
- if (args.length == 0)
- return null;// console mode
-
- // Subject.doAs(Subject.getSubject(AccessController.getContext()),
- // new AgentCliCall(agentCli));
- Class<?>[] parameterTypes = { String[].class };
- Method method = agentCli.getClass().getMethod("process", parameterTypes);
- Object[] methodArgs = { args };
- Object ret = method.invoke(agentCli, methodArgs);
-
- // Shutdown OSGi runtime
- framework.stop();
- framework.waitForStop(60 * 1000);
-
- return ret.toString();
- } catch (Exception e) {
- // Shutdown OSGi runtime
- if (framework != null)
- try {
- framework.stop();
- framework.waitForStop(15 * 1000);
- } catch (Exception silent) {
- }
- throw new RuntimeException("Cannot run SLC command line", e);
- } finally {
-
- }
- }
-
- public static void main(String[] args) {
- try {
- // Prepare directories
- File executionDir = new File(System.getProperty("user.dir"));
- File slcDir;
- Boolean isTransient = false;
- if (isTransient) {
- File tempDir = new File(System.getProperty("java.io.tmpdir") + "/" + System.getProperty("user.name"));
- slcDir = new File(tempDir, "slc-" + UUID.randomUUID().toString());
- slcDir.mkdirs();
- System.setProperty("argeo.node.repo.configuration", "osgibundle:repository-memory.xml");
- } else {
- slcDir = findSlcDir(executionDir);
- if (slcDir == null) {
- slcDir = new File(executionDir, slcDirName);
- slcDir.mkdirs();
- info("## Creating an SLC node at " + slcDir + " ...");
- }
- }
-
- File dataDir = new File(slcDir, "data");
- if (!dataDir.exists())
- dataDir.mkdirs();
-
- File confDir = new File(slcDir, "conf");
- if (!confDir.exists())
- confDir.mkdirs();
-
- File modulesDir = new File(slcDir, "modules");
-
- // JAAS
- // File jaasFile = new File(confDir, "jaas.config");
- // if (!jaasFile.exists())
- // copyResource("/org/argeo/slc/cli/jaas.config", jaasFile);
- // System.setProperty("java.security.auth.login.config",
- // jaasFile.getCanonicalPath());
-
- // log4j
- File log4jFile = new File(confDir, "log4j.properties");
- if (!log4jFile.exists())
- copyResource("/org/argeo/slc/cli/log4j.properties", log4jFile);
- System.setProperty("log4j.configuration", "file://" + log4jFile.getCanonicalPath());
- // Run as a privileged action
- // LoginContext lc = new LoginContext(os);
- // lc.login();
- //
- // Subject subject =
- // Subject.getSubject(AccessController.getContext());
- // Subject.doAs(subject, new SlcMain(args, confDir, dataDir,
- // modulesDir));
- SlcMain slcMain = new SlcMain(args, confDir, dataDir, modulesDir);
- slcMain.run();
- if (args.length != 0)
- System.exit(0);
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- /**
- * Recursively look in parent directories for a directory named
- * {@link #slcDirName}
- */
- protected static File findSlcDir(File currentDir) {
- File slcDir = new File(currentDir, slcDirName);
- // covers the use case of running from the home directory
- if (slcDir.exists() && slcDir.isDirectory())
- return slcDir;
- File parentDir = currentDir.getParentFile();
- if (parentDir == null)
- return null;
- try {
- // ~/.slc reserved for agent
- if (parentDir.getCanonicalPath().equals(homeDir.getCanonicalPath()))
- return null;
- } catch (IOException e) {
- throw new RuntimeException("Cannot check home directory", e);
- }
- return findSlcDir(parentDir);
- }
-
- protected static void copyResource(String resource, File targetFile) {
- InputStream input = null;
- FileOutputStream output = null;
- try {
- input = SlcMain.class.getResourceAsStream(resource);
- output = new FileOutputStream(targetFile);
- byte[] buf = new byte[8192];
- while (true) {
- int length = input.read(buf);
- if (length < 0)
- break;
- output.write(buf, 0, length);
- }
- } catch (Exception e) {
- throw new RuntimeException("Cannot write " + resource + " file to " + targetFile, e);
- } finally {
- try {
- input.close();
- } catch (Exception ignore) {
- }
- try {
- output.close();
- } catch (Exception ignore) {
- }
- }
-
- }
-
- protected static void info(Object msg) {
- System.out.println(msg);
- }
-
- protected static void err(Object msg) {
- System.err.println(msg);
- }
-
- protected static void debug(Object msg) {
- System.out.println(msg);
- }
-
-}
-
-// private String bundlesToInstall = System.getProperty("user.home")
-// +
-// "/dev/src/slc/dep/org.argeo.slc.dep.minimal/target/dependency;in=*.jar,"
-// + System.getProperty("user.home")
-// + "/dev/src/slc/demo/modules;in=*;ex=pom.xml;ex=.svn";
-
-// ServiceTracker agentTracker = new ServiceTracker(bundleContext,
-// "org.argeo.slc.execution.SlcAgentCli", null);
-// agentTracker.open();
-// final Object agentCli = agentTracker.waitForService(30 * 1000);
-// if (agentCli == null)
-// throw new RuntimeException("Cannot find SLC agent CLI");
-
-// protected class AgentCliCall implements PrivilegedAction<String> {
-// private final Object agentCli;
-//
-// public AgentCliCall(Object agentCli) {
-// super();
-// this.agentCli = agentCli;
-// }
-//
-// public String run() {
-// try {
-// Class<?>[] parameterTypes = { String[].class };
-// Method method = agentCli.getClass().getMethod("process",
-// parameterTypes);
-// Object[] methodArgs = { args };
-// Object ret = method.invoke(agentCli, methodArgs);
-// return ret.toString();
-// } catch (Exception e) {
-// throw new RuntimeException("Cannot run "
-// + Arrays.toString(args) + " on " + agentCli, e);
-// }
-// }
-//
-// }
+++ /dev/null
-NIX {
- com.sun.security.auth.module.UnixLoginModule required;
-};
-
-WINDOWS {
- com.sun.security.auth.module.NTLoginModule required;
-};
+++ /dev/null
-log4j.rootLogger=WARN, console
-#log4j.rootLogger=DEBUG, development
-
-## Levels
-log4j.logger.org.argeo=INFO
-
-log4j.logger.org.apache.jackrabbit.core.query.lucene=ERROR
-log4j.logger.org.apache.jackrabbit.core.config.ConfigurationErrorHandler=ERROR
-log4j.logger.org.apache.jackrabbit.core.util.db.DbUtility=FATAL
-
-## Appenders
-# default appender
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %m%n
-
-# development appender
-log4j.appender.development=org.apache.log4j.ConsoleAppender
-log4j.appender.development.layout=org.apache.log4j.PatternLayout
-log4j.appender.development.layout.ConversionPattern=%d{HH:mm:ss,SSS} %5p %m [%16.16t] %c%n
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.server.repo</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Sun Feb 06 14:17:19 CET 2011
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- 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
- /> -->\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
- <property name="repository" ref="javaRepository" />\r
- </bean>\r
- <bean parent="template.jcrAuthorizations">\r
- <property name="repository" ref="distRepository" />\r
- </bean>\r
- <bean parent="template.jcrAuthorizations">\r
- <property name="repository" ref="rpmRepository" />\r
- </bean>\r
- <bean parent="template.jcrAuthorizations">\r
- <property name="repository" ref="docsRepository" />\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
- /> -->\r
- <!-- </bean> -->\r
-\r
- <bean id="template.jcrAuthorizations" abstract="true"\r
- class="org.argeo.jcr.JcrAuthorizations" init-method="run">\r
- <property name="principalPrivileges">\r
- <map>\r
- <entry key="jcr:all" value="cn=org.argeo.slc.user,ou=roles,ou=node" />\r
- </map>\r
- </property>\r
- <property name="workspace" value="*" />\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:security="http://www.springframework.org/schema/security"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd">\r
-\r
- <!-- REFERENCES -->\r
- <reference id="userAdmin" interface="org.osgi.service.useradmin.UserAdmin" />\r
- <reference id="userTransaction" interface="javax.transaction.UserTransaction" />\r
-\r
- <set id="defaultRpmRepositories" cardinality="0..N"\r
- interface="org.argeo.slc.rpmfactory.RpmRepository" />\r
-\r
- <reference id="javaRepository" interface="javax.jcr.Repository"\r
- filter="(cn=java)" />\r
- <reference id="distRepository" interface="javax.jcr.Repository"\r
- filter="(cn=dist)" />\r
- <reference id="rpmRepository" interface="javax.jcr.Repository"\r
- filter="(cn=rpm)" />\r
- <reference id="docsRepository" interface="javax.jcr.Repository"\r
- filter="(cn=docs)" />\r
-\r
- <!-- SERVICES -->\r
- <service ref="slcRepoManager" interface="org.argeo.slc.repo.SlcRepoManager" />\r
-\r
-<!-- <service ref="mavenProxyService" interface="org.argeo.slc.repo.MavenProxyService" /> -->\r
-<!-- <service ref="rpmProxyService" interface="org.argeo.slc.rpmfactory.RpmProxyService" /> -->\r
-\r
- <!-- LABEL -->\r
- <beans:bean class="org.argeo.cms.spring.osgi.OsgiModuleLabel">\r
- <beans:property name="bundleContext" ref="bundleContext" />\r
- </beans:bean>\r
-\r
- <!-- ROLES -->\r
- <beans:bean id="ROLE_SLC"\r
- class="org.argeo.cms.spring.SimpleRoleRegistration" init-method="run">\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:bean>\r
-\r
- <beans:bean\r
- class="org.argeo.cms.spring.AuthenticatedApplicationContextInitialization">\r
- </beans:bean>\r
-</beans:beans>\r
-\r
-<!-- <reference id="mavenRepositorySystem" interface="org.sonatype.aether.RepositorySystem" -->\r
-<!-- filter="(aether.repositorySystemType=maven)" /> -->\r
-<!-- <reference id="mavenRepositorySystemSession" interface="org.sonatype.aether.RepositorySystemSession" -->\r
-<!-- filter="(aether.repositorySystemType=maven)" /> -->\r
-\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
- ">
-
- <bean
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
- <property name="locations">
- <value>osgibundle:repo.properties</value>
- </property>
- </bean>
-
- <bean id="slcRepoManager" class="org.argeo.slc.repo.core.SlcRepoManagerImpl"
- init-method="init" destroy-method="destroy">
- <property name="javaRepoManager" ref="javaRepoManager" />
- </bean>
-
- <!-- Java -->
- <bean id="javaRepoManager" class="org.argeo.slc.repo.core.JavaRepoManagerImpl"
- init-method="init" destroy-method="destroy" depends-on="ROLE_SLC">
- <property name="nodeIndexers">
- <list>
- <bean class="org.argeo.slc.repo.ModularDistributionIndexer" />
- <bean class="org.argeo.slc.repo.JarFileIndexer" />
- <bean class="org.argeo.slc.repo.ArtifactIndexer" />
- <bean class="org.argeo.slc.repo.PdeSourcesIndexer" />
- </list>
- </property>
- <property name="jcrRepository" ref="javaRepository" />
- </bean>
-
- <!-- <bean id="mavenProxyService" class="org.argeo.slc.repo.maven.MavenProxyServiceImpl" -->
- <!-- init-method="init" destroy-method="destroy" depends-on="ROLE_SLC"> -->
- <!-- <property name="jcrRepository" ref="javaRepository" /> -->
- <!-- <property name="proxyWorkspace" value="${slc.repo.jcr.proxyWorkspace}"
- /> -->
- <!-- <property name="defaultRepositories" ref="defaultMavenRepositories"
- /> -->
- <!-- </bean> -->
-
- <!-- RPM -->
- <bean id="rpmRepoManager" class="org.argeo.slc.repo.core.RpmRepoManagerImpl"
- init-method="init" destroy-method="destroy" depends-on="ROLE_SLC">
- <property name="nodeIndexers">
- <list>
- <bean class="org.argeo.slc.repo.RpmIndexer" />
- </list>
- </property>
- <property name="jcrRepository" ref="rpmRepository" />
- </bean>
-
- <!-- <bean id="rpmProxyService" class="org.argeo.slc.rpmfactory.core.RpmProxyServiceImpl" -->
- <!-- init-method="init" destroy-method="destroy" depends-on="ROLE_SLC"> -->
- <!-- <property name="jcrRepository" ref="rpmRepository" /> -->
- <!-- <property name="proxyWorkspace" value="${slc.repo.jcr.proxyWorkspace}"
- /> -->
- <!-- <property name="defaultRepositories" ref="defaultRpmRepositories" /> -->
- <!-- </bean> -->
-
-</beans>
\ No newline at end of file
+++ /dev/null
-Import-Package: org.argeo.jcr,\
-org.argeo.security.jackrabbit,\
-org.argeo.slc.jcr,\
-org.argeo.slc.repo,\
-org.h2;resolution:=optional,\
-org.postgresql;resolution:=optional,\
-org.osgi.*;version=0.0.0,\
-*
+++ /dev/null
-bin.includes = META-INF/,\
- repo.properties,\
- repository-h2.xml
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.server.repo</artifactId>
- <name>SLC Repo</name>
-</project>
\ No newline at end of file
+++ /dev/null
-slc.repo.jcr.reposBase=${osgi.instance.area}/repos
-slc.repo.jcr.forceCndImport=true
-slc.repo.jcr.proxyWorkspace=proxy
-
-slc.repo.jcr.configuration.java=osgibundle:repository-localfs.xml
-slc.repo.jcr.configuration.dist=osgibundle:repository-localfs.xml
-slc.repo.jcr.configuration.rpm=osgibundle:repository-localfs.xml
-slc.repo.jcr.configuration.docs=osgibundle:repository-localfs.xml
-argeo.node.repo.defaultWorkspace=main
-argeo.node.repo.bundleCacheMB=8
-argeo.node.repo.extractorPoolSize=0
-argeo.node.repo.searchCacheSize=1000
-argeo.node.repo.maxVolatileIndexSize=1048576
-
-slc.repo.jcr.dbuser=sa
-slc.repo.jcr.dbpassword=
-slc.repo.jcr.maxPoolSize=10
-
-# Postgres
-slc.repo.jcr.dburl.java=jdbc:postgresql://localhost/slc_repo_java
-slc.repo.jcr.dburl.dist=jdbc:postgresql://localhost/slc_repo_dist
-slc.repo.jcr.dburl.rpm=jdbc:postgresql://localhost/slc_repo_rpm
-slc.repo.jcr.dburl.docs=jdbc:postgresql://localhost/slc_repo_docs
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src"/>
- <classpathentry kind="src" path="ext/test"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+++ /dev/null
-/bin/
-/target/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.spring</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-http\://www.argeo.org/schema/slc-flow=org.argeo.slc.core.execution.xml.FlowNamespaceHandler
\ No newline at end of file
+++ /dev/null
-http\://www.argeo.org/schema/slc-flow.xsd=org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd
-http\://www.argeo.org/schema/slc-flow-1.2.xsd=org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd
-http\://www.argeo.org/schema/slc-flow-0.12.xsd=org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd
+++ /dev/null
-Import-Package: javax.jcr.nodetype,\
-javax.jcr.security,\
-org.argeo.api,\
-aQute.bnd.osgi,\
-org.apache.tools.ant.*;resolution:="optional",\
-junit.framework;resolution:="optional",\
-org.osgi.*;version=0.0.0,\
-*
-
-Export-Package: org.argeo.slc.core.test,\
-*
\ No newline at end of file
+++ /dev/null
-additional.bundles = org.springframework.context,\
- org.slf4j.api,\
- org.slf4j.commons.logging,\
- org.slf4j.log4j12,\
- org.apache.log4j,\
- org.springframework.aop,\
- org.springframework.aspects,\
- org.springframework.beans,\
- org.springframework.context.support,\
- org.springframework.core,\
- org.springframework.expression,\
- org.springframework.instrument,\
- org.aopalliance
-bin.includes = META-INF/,.
-source.. = src/,\
- ext/test/
+++ /dev/null
-# Set root logger level to DEBUG and its only appender to A1.\r
-log4j.rootLogger=WARN, console\r
-\r
-## Levels\r
-# Slc\r
-log4j.logger.org.argeo=DEBUG\r
-\r
-# Castor\r
-log4j.logger.org.exolab.castor=WARN\r
-\r
-# Spring\r
-log4j.logger.org.springframework=WARN\r
-\r
-\r
-## Appenders\r
-# A1 is set to be a ConsoleAppender.\r
-log4j.appender.console=org.apache.log4j.ConsoleAppender\r
-\r
-# A1 uses PatternLayout.\r
-log4j.appender.console.layout=org.apache.log4j.PatternLayout\r
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n\r
-\r
+++ /dev/null
-package org.argeo.slc.core.deploy;
-
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.core.test.context.AbstractInternalSpringTestCase;
-import org.springframework.core.io.Resource;
-
-public class DefaultResourceSetTest extends AbstractInternalSpringTestCase {
- private final static Log log = LogFactory
- .getLog(DefaultResourceSetTest.class);
-
- public void testListResources() {
- DefaultResourceSet rrs = getBean("relativeResourceSet");
- Map<String, Resource> res = rrs.listResources();
- for (String relativePath : res.keySet())
- log.debug(relativePath + "=" + res.get(relativePath));
- assertEquals(2, res.size());
- }
-
- @Override
- protected String getApplicationContextLocation() {
- return inPackage("relativeResourceSet.xml");
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <bean id="relativeResourceSet" class="org.argeo.slc.core.deploy.DefaultResourceSet">\r
- <property name="base" value="classpath:/org/argeo/slc/core/deploy/data" />\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.argeo.slc.test.TestResultPart;
-import org.argeo.slc.test.TestStatus;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public abstract class AbstractExecutionFlowTestCase extends TestCase {
-
- protected final Log log = LogFactory.getLog(getClass());
-
- protected void logException(Throwable ex) {
- log.info("Got Exception of class " + ex.getClass().toString()
- + " with message '" + ex.getMessage() + "'.");
- }
-
- protected void validateTestResult(SimpleTestResult testResult) {
- validateTestResult(testResult, TestStatus.PASSED);
- }
-
- protected void validateTestResult(SimpleTestResult testResult,
- int expectedStatus) {
- for (TestResultPart part : testResult.getParts()) {
- if (part.getStatus() != expectedStatus) {
- fail("Error found in TestResult: " + part.getMessage());
- }
- }
- }
-
- protected ConfigurableApplicationContext createApplicationContext(
- String applicationContextSuffix) {
- ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext(
- inPackage(applicationContextSuffix));
- // applicationContext.start();
- return applicationContext;
- }
-
- protected void configureAndExecuteSlcFlow(String applicationContextSuffix,
- String beanName) {
- ConfigurableApplicationContext applicationContext = createApplicationContext(applicationContextSuffix);
- ExecutionContext executionContext = (ExecutionContext) applicationContext
- .getBean("executionContext");
- ExecutionFlow executionFlow = (ExecutionFlow) applicationContext
- .getBean(beanName);
- if (executionFlow instanceof DefaultExecutionFlow)
- ((DefaultExecutionFlow) executionFlow)
- .setExecutionContext(executionContext);
- try {
- executionContext.beforeFlow(executionFlow);
- executionFlow.run();
- } finally {
- executionContext.afterFlow(executionFlow);
- }
- applicationContext.close();
- }
-
- protected String inPackage(String suffix) {
- String prefix = getClass().getPackage().getName().replace('.', '/');
- return prefix + '/' + suffix;
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.argeo.slc.test.TestStatus;
-import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.context.ConfigurableApplicationContext;
-
-public class BasicExecutionFlowTest extends AbstractExecutionFlowTestCase {
- // TO TEST
- // - post-processing for @{} replacement in beans with complex properties
- // - bean of scope other than execution are not resolved at execution
-
- // public void testMyTest() throws Exception {
- // ConfigurableApplicationContext applicationContext =
- // createApplicationContext("test.xml");
- // log.info("Start Execution");
- // ((ExecutionFlow) applicationContext.getBean("flow1")).execute();
- // applicationContext.close();
- // }
-
- public void XXXtestSpecOverriding() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("specOverriding.xml");
- ((ExecutionFlow) applicationContext.getBean("flow2")).run();
- SimpleTestResult res = (SimpleTestResult) applicationContext
- .getBean("myTestResult");
- validateTestResult(res);
- }
-
- public void testMultipleFlows() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("multipleFlow.xml");
- ((ExecutionFlow) applicationContext.getBean("flow1")).run();
- SimpleTestResult res = (SimpleTestResult) applicationContext
- .getBean("myTestResult");
- validateTestResult(res);
- res.getParts().clear();
- ((ExecutionFlow) applicationContext.getBean("flow2")).run();
- validateTestResult(res, TestStatus.FAILED);
- applicationContext.close();
- }
-
- /**
- * Test placeholder resolution in a context without scope execution or proxy
- * and with cascading flows (the flow A contains the flow B)
- *
- * @throws Exception
- */
- public void testPlaceHolders() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.xml");
- ((ExecutionFlow) applicationContext.getBean("flowA")).run();
- validateTestResult((SimpleTestResult) applicationContext
- .getBean("myTestResult"));
- applicationContext.close();
- }
-
- /**
- * Test placeholder resolution in a context without scope execution or proxy
- * and with cascading flows (the flow A contains the flow B) setting
- * execution values (should have no effect)
- *
- * @throws Exception
- */
- public void testPlaceHoldersWithExecutionValues() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.xml");
-
- ExecutionContext executionContext = (ExecutionContext) applicationContext
- .getBean("executionContext");
- Map<String, String> executionParameters = new HashMap<String, String>();
- executionParameters.put("p1", "e1");
- executionParameters.put("p2", "e2");
- executionParameters.put("p3", "e3");
- executionParameters.put("p4", "e4");
- executionParameters.put("p5", "e5");
- executionParameters.put("p6", "e6");
- executionParameters.put("p7", "e7");
- executionParameters.put("p8", "e8");
- addVariables(executionContext, executionParameters);
-
- ((ExecutionFlow) applicationContext.getBean("flowA")).run();
- validateTestResult((SimpleTestResult) applicationContext
- .getBean("myTestResult"));
- applicationContext.close();
- }
-
- public void XXXtestPlaceHoldersExec() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("placeHolders.cascading.exec.xml");
-
- ExecutionContext executionContext = (ExecutionContext) applicationContext
- .getBean("executionContext");
- Map<String, String> executionParameters = new HashMap<String, String>();
- executionParameters.put("p1", "e1");
- executionParameters.put("p2", "e2");
- executionParameters.put("p3", "e3");
- executionParameters.put("p4", "e4");
- executionParameters.put("p5", "e5");
- executionParameters.put("p6", "e6");
- addVariables(executionContext, executionParameters);
-
- ((ExecutionFlow) applicationContext.getBean("flowA")).run();
- validateTestResult((SimpleTestResult) applicationContext
- .getBean("myTestResult"));
- applicationContext.close();
- }
-
- public void testCanonicFlowParameters() throws Exception {
- configureAndExecuteSlcFlow("canonic-001.xml", "canonic.001");
- }
-
- public void testCanonicDefaultValues() throws Exception {
- configureAndExecuteSlcFlow("canonic-002.xml", "canonic.002");
- }
-
- public void testCanonicMissingValues() throws Exception {
- try {
- configureAndExecuteSlcFlow("canonic-003.error.xml", "canonic.003");
- fail("Parameter not set - should be rejected.");
- } catch (BeanCreationException e) {
- // exception expected
- logException(e);
- }
- }
-
- public void testCanonicUnknownParameter() throws Exception {
- try {
- configureAndExecuteSlcFlow("canonic-004.error.xml", "canonic.004");
- fail("Unknown parameter set - should be rejected.");
- } catch (BeanCreationException e) {
- // exception expected
- logException(e);
- }
- }
-
- public void testListSetMap() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("listSetMap.xml");
- ExecutionFlow executionFlow = (ExecutionFlow) applicationContext
- .getBean("myFlow");
- executionFlow.run();
-
- validateTestResult((SimpleTestResult) applicationContext
- .getBean("myTestResult"));
-
- // BasicTestData res = (BasicTestData)
- // applicationContext.getBean("cascadingComplex.testData");
- // log.info("res=" + res.getReached().toString());
-
- applicationContext.close();
- }
-
- public void testListSetMapMultipleFlows() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("listSetMapMultipleFlow.xml");
- ((ExecutionFlow) applicationContext.getBean("flow1")).run();
- SimpleTestResult res = (SimpleTestResult) applicationContext
- .getBean("myTestResult");
- validateTestResult(res);
- res.getParts().clear();
- ((ExecutionFlow) applicationContext.getBean("flow2")).run();
- validateTestResult(res, TestStatus.FAILED);
- applicationContext.close();
- }
-
- protected void addVariables(ExecutionContext executionContext,
- Map<String, String> vars) {
- for (String key : vars.keySet())
- executionContext.setVariable(key, vars.get(key));
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.net.URI;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class DefaultAgentCliTest extends TestCase {
- public void testArgsToUris() {
- String[] args = { "org.argeo.slc.demo.minimal", "HelloWorld/WithVar",
- "--testKey", "555" };
- List<URI> uris = DefaultAgentCli.asURIs(args);
- assertEquals(1, uris.size());
- assertEquals(
- "flow:/org.argeo.slc.demo.minimal/HelloWorld/WithVar?testKey=555",
- uris.get(0).toString());
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.InitializingBean;
-
-public class ExceptionIfInitCalledTwice implements Runnable, InitializingBean {
- private final static Log log = LogFactory
- .getLog(ExceptionIfInitCalledTwice.class);
-
- private Boolean calledOnce = false;
-
- public void run() {
- log.info(getClass().getSimpleName() + " ran properly");
- }
-
- public void afterPropertiesSet() throws Exception {
- log.info(getClass().getSimpleName() + " init method called");
-
- if (calledOnce)
- throw new SlcException(getClass().getSimpleName()
- + "init method called twice.");
- else
- calledOnce = true;
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-
-public class FileExecutionResourcesSpringTest extends
- AbstractExecutionFlowTestCase {
- private String basePath = FileExecutionResources.DEFAULT_EXECUTION_RESOURCES_TMP_PATH;
-
- public void testSimple() throws Exception {
- File file = getFile("subdir/writeTo");
- try {
- assertFalse(file.exists());
- configureAndExecuteSlcFlow("executionResources.xml",
- "executionResources.simple");
- assertTrue(file.exists());
- } finally {
- file.deleteOnExit();
- }
- }
-
- public void testPlaceholderPass() throws Exception {
- File file = getFile("subdir/60");
- try {
- assertFalse(file.exists());
- configureAndExecuteSlcFlow("executionResources.xml",
- "executionResources.placeholderPass");
- assertTrue(file.exists());
- } finally {
- file.deleteOnExit();
- }
- }
-
- /**
- * Test that it generate the wrong file because of issue when using
- * execution placeholder in contructor-arg
- */
- public void testPlaceholderFail() throws Exception {
- File file = getFile("subdir/@{var}");
- try {
- assertFalse(file.exists());
- configureAndExecuteSlcFlow("executionResources.xml",
- "executionResources.placeholderFail");
- assertTrue(file.exists());
- } finally {
- file.deleteOnExit();
- }
- }
-
- protected File getFile(String relativePath) {
- return new File(basePath + File.separator
- + relativePath.replace('/', File.separatorChar));
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.io.FileUtils;
-import org.argeo.slc.execution.ExecutionContext;
-import org.springframework.core.io.Resource;
-
-public class FileExecutionResourcesTest extends TestCase {
- public void testGetWritableFile() throws Exception {
- FileExecutionResources executionResources = new FileExecutionResources();
- ExecutionContext executionContext = new MapExecutionContext();
- executionResources.setExecutionContext(executionContext);
-
- String expected = "TEST";
- String reached = "";
- try {
- // Resource
- Resource resource = executionResources
- .getWritableResource("subdir1/textRes.txt");
- assertTrue(resource.getFile().getParentFile().exists());
- assertFalse(resource.getFile().exists());
- FileUtils.writeStringToFile(resource.getFile(), expected);
- reached = FileUtils.readFileToString(resource.getFile());
- assertEquals(expected, reached);
-
- // File
- File file = executionResources.getFile("subdir2/textFile.txt");
- assertFalse(file.getParentFile().exists());
- assertFalse(file.exists());
- FileUtils.writeStringToFile(file, expected);
- reached = FileUtils.readFileToString(file);
- assertEquals(expected, reached);
- } finally {
- if (executionResources.getBaseDir() != null
- && executionResources.getBaseDir().exists())
- FileUtils.deleteDirectory(executionResources.getBaseDir());
- }
-
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.argeo.slc.test.TestStatus;
-import org.springframework.context.ConfigurableApplicationContext;
-
-public class ParameterRefTest extends AbstractExecutionFlowTestCase {
- public void test001() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("parameterRef.xml");
- ((ExecutionFlow) applicationContext.getBean("parameterRef.001")).run();
-
- SimpleTestResult res = (SimpleTestResult) applicationContext
- .getBean("parameterRef.testResult");
- assertEquals(res.getParts().get(0).getStatus(), TestStatus.PASSED);
- assertEquals(res.getParts().get(1).getStatus(), TestStatus.FAILED);
-
- applicationContext.close();
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" /> \r
-\r
- <bean id="executionModule_1" class="org.argeo.slc.core.execution.SimpleSpringExecutionModule" >\r
- <property name="executionContext">\r
- <ref bean="executionContext" />\r
- </property> \r
- <property name="name" value="dummyname" />\r
- <property name="version" value="dummyversion" />\r
- </bean>\r
- \r
- <bean id="main" parent="slcTemplate.simpleFlow">\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testKey">\r
- <bean parent="specAttr.primitive" p:value="660" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- <property name="executables">\r
- <list>\r
- <ref local="echo1" />\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="echo1" parent="task.echo" scope="execution">\r
- <property name="message"\r
- value="From main! @{testKey}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="canonic.xml" />\r
-\r
- <bean id="canonic.001" parent="canonic.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <entry key="parameterAtInstantiation" value="1" />\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="canonic.xml" />\r
-\r
- <bean id="canonic.002" parent="canonic.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <entry key="parameterAtInstantiation" value="2" />\r
- <entry key="displayWithoutControl" value="102" />\r
- <entry key="displayWithControl" value="202" />\r
- <entry key="hide" value="202" />\r
- <entry key="notParameterAtInstantiation" value="202" />\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="canonic.xml" />\r
-\r
- <bean id="canonic.003" parent="canonic.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <!-- missing parameter -->\r
- <entry key="displayWithoutControl" value="102" />\r
- <entry key="displayWithControl" value="202" />\r
- <entry key="hide" value="202" />\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="canonic.xml" />\r
-\r
- <bean id="canonic.004" parent="canonic.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <entry key="parameterAtInstantiation" value="2" />\r
- <entry key="displayWithoutControl" value="102" />\r
- <entry key="displayWithControl" value="202" />\r
- <entry key="hide" value="202" />\r
- <entry key="unknownParameter" value="1" />\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" />\r
-\r
- <bean id="canonic.spec" parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="parameterAtInstantiation">\r
- <bean parent="specAttr.primitive" p:isParameter="true" p:type="integer" />\r
- </entry>\r
- <entry key="displayWithoutControl">\r
- <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
- p:isFrozen="true" p:type="integer" />\r
- </entry>\r
- <entry key="displayWithControl">\r
- <bean parent="specAttr.primitive" p:value="200" p:isParameter="true"\r
- p:isFrozen="false" p:type="integer" />\r
- </entry>\r
- <entry key="hide">\r
- <bean parent="specAttr.primitive" p:value="300" p:isParameter="true"\r
- p:isFrozen="false" p:isHidden="true" p:type="integer" />\r
- </entry> \r
- <entry key="notParameterAtInstantiation">\r
- <bean parent="specAttr.primitive" p:value="400" p:isParameter="false"\r
- p:isFrozen="false" p:isHidden="false" p:type="integer" />\r
- </entry> \r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="canonic.flowTemplate" parent="slcTemplate.simpleFlow"\r
- abstract="true">\r
- <constructor-arg ref="canonic.spec" />\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo"\r
- p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}">\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" />\r
-\r
- <bean id="executionResources.spec" parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="var">\r
- <bean parent="specAttr.primitive" p:isParameter="false"\r
- p:type="integer" p:value="60" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="executionResources.placeholderPass" parent="slcTemplate.simpleFlow">\r
- <constructor-arg ref="executionResources.spec" />\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo">\r
- <property name="message" value="DATA" />\r
- <property name="writeTo">\r
- <bean parent="slcTemplate.resourcesFactoryBean" scope="execution">\r
- <property name="executionResources" ref="executionResources" />\r
- <property name="relativePath" value="subdir/@{var}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property>\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="executionResources.placeholderFail" parent="slcTemplate.simpleFlow">\r
- <constructor-arg ref="executionResources.spec" />\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo">\r
- <property name="message" value="DATA" />\r
- <property name="writeTo">\r
- <bean factory-bean="executionResources" factory-method="getWritableResource"\r
- scope="execution">\r
- <constructor-arg value="subdir/@{var}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property>\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="executionResources.simple" parent="slcTemplate.simpleFlow">\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo">\r
- <property name="message" value="DATA" />\r
- <property name="writeTo">\r
- <bean factory-bean="executionResources" factory-method="getWritableResource"\r
- scope="execution">\r
- <constructor-arg value="subdir/writeTo" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property>\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="executionResources" parent="slcTemplate.fileResources">\r
- <property name="executionContext" ref="executionContext" />\r
- <property name="withExecutionSubdirectory" value="false" />\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<!-- Copyright (C) 2007-2012 Mathieu Baudier Licensed under the Apache License,
- Version 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the License. -->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
- <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />
- <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />
-
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" /> \r
-\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
- <property name="testDefinition" ref="basic.testDef" />\r
- <property name="testResult" ref="myTestResult"/>\r
- </bean> \r
-\r
- <bean id="myFlow" parent="slcTemplate.simpleFlow">\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testKey">\r
- <bean parent="specAttr.primitive" p:value="myValue" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- <property name="executables">\r
- <list>\r
- <ref local="echo1" />\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="simpleMap.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingMap.testData" />\r
- </bean> \r
- \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="simpleList.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingList.testData" />\r
- </bean> \r
- \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="simpleSet.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingSet.testData" />\r
- </bean> \r
- \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingListMap.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingSetMap.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingComplex.testData" />\r
- </bean> \r
- \r
- </list>\r
- </property>\r
- </bean>\r
-\r
-\r
- <bean id="simpleMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <map>\r
- <entry key="key1" value="myValue_myValue" />\r
- </map>\r
- </property>\r
- <property name="reached">\r
- <map>\r
- <entry key="key1" value="@{testKey}_@{testKey}" />\r
- </map>\r
- </property>\r
- </bean>\r
- \r
- <bean id="cascadingMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <map>\r
- <entry key="key3">\r
- <map>\r
- <entry key="key2">\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map>\r
- </entry>\r
- <entry key="key2bis" value="myValue" />\r
- </map>\r
- </entry>\r
- </map>\r
- </property>\r
- <property name="reached">\r
- <map>\r
- <entry key="key3">\r
- <map>\r
- <entry key="key2">\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map>\r
- </entry>\r
- <entry key="key2bis" value="@{testKey}" />\r
- </map>\r
- </entry>\r
- </map>\r
- </property>\r
- </bean> \r
- \r
- <bean id="simpleList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <list>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </list>\r
- </property>\r
- <property name="reached">\r
- <list>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value> \r
- </list>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <list>\r
- <list>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </list>\r
- <value>myValue</value>\r
- </list>\r
- </property>\r
- <property name="reached">\r
- <list>\r
- <list>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value>\r
- </list>\r
- <value>@{testKey}</value>\r
- </list>\r
- </property>\r
- </bean> \r
- \r
- <bean id="simpleSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <set>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </set>\r
- </property>\r
- <property name="reached">\r
- <set>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value> \r
- </set>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <set>\r
- <set>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </set>\r
- <value>myValue</value>\r
- </set>\r
- </property>\r
- <property name="reached">\r
- <set>\r
- <set>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value>\r
- </set>\r
- <value>@{testKey}</value>\r
- </set>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingListMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <list>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- </list>\r
- </property>\r
- <property name="reached">\r
- <list>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- </list>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingSetMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <set>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- </set>\r
- </property>\r
- <property name="reached">\r
- <set>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- </set>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingComplex.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <set>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- <list>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- <set>\r
- <set>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- <list>\r
- <list>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </list>\r
- <value>myValue</value>\r
- </list> \r
- </set>\r
- <value>myValue</value>\r
- </set> \r
- </list> \r
- <set>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- </set> \r
- </set>\r
- </property>\r
- <property name="reached">\r
- <set>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- <list>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- <set>\r
- <set>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value>\r
- <list>\r
- <list>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value>\r
- </list>\r
- <value>@{testKey}</value>\r
- </list> \r
- </set>\r
- <value>@{testKey}</value>\r
- </set> \r
- </list> \r
- <set>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- </set> \r
- </set>\r
- </property>\r
- </bean> \r
- \r
- <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition">\r
- </bean> \r
-\r
-\r
- <bean id="echo1" parent="task.echo" scope="prototype">\r
- <property name="message"\r
- value="testKey=@{testKey}" />\r
- </bean>\r
- \r
- <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" /> \r
-\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
- <property name="testDefinition" ref="basic.testDef" />\r
- <property name="testResult" ref="myTestResult"/>\r
- </bean> \r
-\r
- <bean id="abstractFlow" parent="slcTemplate.simpleFlow" abstract="true">\r
- <property name="executables">\r
- <list>\r
- <ref local="echo1" />\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="simpleMap.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingMap.testData" />\r
- </bean> \r
- \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="simpleList.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingList.testData" />\r
- </bean> \r
- \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="simpleSet.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingSet.testData" />\r
- </bean> \r
- \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingListMap.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingSetMap.testData" />\r
- </bean> \r
- <bean parent="myTestRunTemplate">\r
- <property name="testData" ref="cascadingComplex.testData" />\r
- </bean> \r
- \r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="flow1" parent="abstractFlow" scope="prototype">\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testKey">\r
- <bean parent="specAttr.primitive" p:value="myValue" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- </bean> \r
-\r
- <bean id="flow2" parent="abstractFlow" scope="prototype">\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testKey">\r
- <bean parent="specAttr.primitive" p:value="myValue2" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- </bean> \r
-\r
-\r
- <bean id="simpleMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <map>\r
- <entry key="key1" value="myValue_myValue" />\r
- </map>\r
- </property>\r
- <property name="reached">\r
- <map>\r
- <entry key="key1" value="@{testKey}_@{testKey}" />\r
- </map>\r
- </property>\r
- </bean>\r
- \r
- <bean id="cascadingMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <map>\r
- <entry key="key3">\r
- <map>\r
- <entry key="key2">\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map>\r
- </entry>\r
- <entry key="key2bis" value="myValue" />\r
- </map>\r
- </entry>\r
- </map>\r
- </property>\r
- <property name="reached">\r
- <map>\r
- <entry key="key3">\r
- <map>\r
- <entry key="key2">\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map>\r
- </entry>\r
- <entry key="key2bis" value="@{testKey}" />\r
- </map>\r
- </entry>\r
- </map>\r
- </property>\r
- </bean> \r
- \r
- <bean id="simpleList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <list>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </list>\r
- </property>\r
- <property name="reached">\r
- <list>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value> \r
- </list>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <list>\r
- <list>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </list>\r
- <value>myValue</value>\r
- </list>\r
- </property>\r
- <property name="reached">\r
- <list>\r
- <list>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value>\r
- </list>\r
- <value>@{testKey}</value>\r
- </list>\r
- </property>\r
- </bean> \r
- \r
- <bean id="simpleSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <set>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </set>\r
- </property>\r
- <property name="reached">\r
- <set>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value> \r
- </set>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <set>\r
- <set>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </set>\r
- <value>myValue</value>\r
- </set>\r
- </property>\r
- <property name="reached">\r
- <set>\r
- <set>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value>\r
- </set>\r
- <value>@{testKey}</value>\r
- </set>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingListMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <list>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- </list>\r
- </property>\r
- <property name="reached">\r
- <list>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- </list>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingSetMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <set>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- </set>\r
- </property>\r
- <property name="reached">\r
- <set>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- </set>\r
- </property>\r
- </bean> \r
- \r
- <bean id="cascadingComplex.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
- <property name="expected">\r
- <set>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- <list>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- <set>\r
- <set>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- <list>\r
- <list>\r
- <value>myValue</value>\r
- <value>_myValue_</value>\r
- </list>\r
- <value>myValue</value>\r
- </list> \r
- </set>\r
- <value>myValue</value>\r
- </set> \r
- </list> \r
- <set>\r
- <map>\r
- <entry key="key1" value="myValue" />\r
- </map> \r
- </set> \r
- </set>\r
- </property>\r
- <property name="reached">\r
- <set>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- <list>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- <set>\r
- <set>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value>\r
- <list>\r
- <list>\r
- <value>@{testKey}</value>\r
- <value>_@{testKey}_</value>\r
- </list>\r
- <value>@{testKey}</value>\r
- </list> \r
- </set>\r
- <value>@{testKey}</value>\r
- </set> \r
- </list> \r
- <set>\r
- <map>\r
- <entry key="key1" value="@{testKey}" />\r
- </map> \r
- </set> \r
- </set>\r
- </property>\r
- </bean> \r
- \r
- <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition">\r
- </bean> \r
-\r
-\r
- <bean id="echo1" parent="task.echo" scope="prototype">\r
- <property name="message"\r
- value="testKey=@{testKey}" />\r
- </bean>\r
- \r
- <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" /> \r
-\r
- <bean id="minimal" parent="slcTemplate.simpleFlow">\r
- <property name="executionSpec">\r
- <bean parent="slcTemplate.simpleSpec">\r
-<!-- <property name="attributes">\r
- <map>\r
- <entry key="testKey">\r
- <bean parent="specAttr.primitive" p:value="660" />\r
- </entry>\r
- </map>\r
- </property> -->\r
- </bean>\r
- </property>\r
- <property name="executables">\r
- <list>\r
- <ref local="echo1" />\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="echo1" parent="task.echo" scope="execution">\r
- <property name="message"\r
- value="From minimal" />\r
- <aop:scoped-proxy />\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" /> \r
-\r
- <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
- <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
- <property name="testDefinition" ref="myTestDef" />\r
- <property name="testResult" ref="myTestResult"/>\r
- </bean> \r
-\r
- <bean id="fileDiff.spec" parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="fileName">\r
- <bean parent="specAttr.primitive" p:isParameter="true" p:type="string"\r
- p:isFrozen="true" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
-\r
-\r
- <bean id="fileDiff.flowTemplate" parent="slcTemplate.simpleFlow"\r
- abstract="true">\r
- <property name="path" value="/fileDiff/testcases" />\r
- <constructor-arg ref="fileDiff.spec" />\r
- <property name="executables">\r
- <list> \r
- <bean parent="task.echo">\r
- <property name="message" value="fileName=@{fileName}" />\r
- </bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="file1" />\r
- <property name="reached" value="@{fileName}" />\r
- </bean>\r
- </property> \r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
- \r
- <bean id="echo" parent="task.echo" scope="prototype">\r
- <property name="message" value="fileName=@{fileName}" />\r
- </bean> \r
- \r
- <bean id="flow1" parent="fileDiff.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <entry key="fileName" value="file1" />\r
- </map>\r
- </constructor-arg>\r
- </bean> \r
-\r
- <bean id="flow2" parent="fileDiff.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <entry key="fileName" value="file2" />\r
- </map>\r
- </constructor-arg>\r
- </bean> \r
- \r
- \r
- <!-- \r
- <bean id="flow1" parent="slcTemplate.simpleFlow">\r
- <property name="path" value="/fileDiff/testcases" />\r
- <constructor-arg ref="fileDiff.spec" />\r
- <constructor-arg>\r
- <map>\r
- <entry key="fileName" value="file1" />\r
- </map>\r
- </constructor-arg> \r
- <property name="executables">\r
- <list> \r
- <bean parent="task.echo" scope="execution">\r
- <property name="message" value="fileName=@{fileName}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="flow2" parent="slcTemplate.simpleFlow">\r
- <property name="path" value="/fileDiff/testcases" />\r
- <constructor-arg ref="fileDiff.spec" />\r
- <constructor-arg>\r
- <map>\r
- <entry key="fileName" value="file2" />\r
- </map>\r
- </constructor-arg> \r
- <property name="executables">\r
- <list> \r
- <bean parent="task.echo" scope="execution">\r
- <property name="message" value="fileName=@{fileName}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
- -->\r
-<!-- \r
- <bean id="main" parent="slcTemplate.simpleFlow">\r
- <property name="executables">\r
- <list> \r
- <ref bean="flow1"/> \r
- <ref bean="flow2"/> \r
- </list>\r
- </property>\r
- </bean>\r
- -->\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" />\r
-\r
- <!-- DEFINITIONS -->\r
- <bean id="parameterRef.spec" parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="exceptionIfInitCalledTwice">\r
- <bean parent="specAttr.ref"\r
- p:targetClass="org.argeo.slc.core.execution.ExceptionIfInitCalledTwice"\r
- p:isParameter="true" p:isFrozen="true" />\r
- </entry>\r
- <entry key="testData1">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:isParameter="true" p:isFrozen="true" />\r
- </entry>\r
- <entry key="testData2">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:isParameter="true" p:isFrozen="true" />\r
- </entry>\r
- <entry key="testedComponentId">\r
- <bean parent="specAttr.primitive" p:value="100" p:isParameter="true"\r
- p:type="integer" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="parameterRef.flowTemplate" parent="slcTemplate.simpleFlow"\r
- abstract="true">\r
- <constructor-arg ref="parameterRef.spec" />\r
- <property name="executables">\r
- <list>\r
- <!-- Primitive -->\r
- <bean parent="task.echo" scope="execution">\r
- <property name="message" value="testedComponentId=@{testedComponentId}" />\r
- </bean>\r
-\r
- <!-- Exception if init called twice -->\r
- <bean parent="parameterRef">\r
- <constructor-arg value="exceptionIfInitCalledTwice" />\r
- </bean>\r
- <bean parent="parameterRef">\r
- <property name="name" value="exceptionIfInitCalledTwice" />\r
- </bean>\r
-\r
- <!-- Basic tests -->\r
- <bean parent="parameterRef.testRun">\r
- <property name="testData">\r
- <bean parent="parameterRef">\r
- <constructor-arg value="testData1" />\r
- </bean>\r
- </property>\r
- </bean>\r
- <bean parent="parameterRef.testRun">\r
- <property name="testData" ref="ref1" />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <!-- TEST CASES -->\r
- <bean id="parameterRef.001" parent="parameterRef.flowTemplate">\r
- <constructor-arg>\r
- <map>\r
- <entry key="exceptionIfInitCalledTwice">\r
- <bean class="org.argeo.slc.core.execution.ExceptionIfInitCalledTwice" />\r
- </entry>\r
- <entry key="testData1">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="toto" />\r
- <property name="reached" value="toto" />\r
- </bean>\r
- </entry>\r
- <entry key="testData2">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="tata" />\r
- <property name="reached" value="toto" />\r
- </bean>\r
- </entry>\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-\r
- <!-- UTILITIES -->\r
-\r
- <bean id="ref1" parent="parameterRef">\r
- <constructor-arg value="testData2" />\r
- </bean>\r
-\r
- <bean id="parameterRef.testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
- <bean id="parameterRef.testRun" class="org.argeo.slc.runtime.test.SimpleTestRun"\r
- abstract="true">\r
- <property name="testResult" ref="parameterRef.testResult" />\r
- <property name="testDefinition">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
- </property>\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" /> \r
-\r
- <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
- <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
- <bean id="echo1" parent="task.echo">\r
- <property name="message" value="From minimal" />\r
- </bean>\r
-\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
- <property name="testDefinition" ref="myTestDef" />\r
- <property name="testResult" ref="myTestResult"/>\r
- </bean> \r
-\r
- <!-- \r
- The Flow A contains the flow B as executable.\r
- \r
- Parameters\r
- p1: flow A: default - flow B: - \r
- p2: flow A: set - flow B: - \r
- p3: flow A: default - flow B: default \r
- p4: flow A: set - flow B: default\r
- p5: flow A: default - flow B: set \r
- p6: flow A: set - flow B: set\r
- p7: flow A: - - flow B: default\r
- p8: flow A: - - flow B: set\r
- \r
- \r
- -->\r
-\r
- <bean id="flowA" parent="slcTemplate.simpleFlow">\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="p1"><bean parent="specAttr.primitive" p:value="da1" /></entry>\r
- <entry key="p2"><bean parent="specAttr.primitive" p:value="da2" /></entry> \r
- <entry key="p3"><bean parent="specAttr.primitive" p:value="da3" /></entry> \r
- <entry key="p4"><bean parent="specAttr.primitive" p:value="da4" /></entry> \r
- <entry key="p5"><bean parent="specAttr.primitive" p:value="da5" /></entry> \r
- <entry key="p6"><bean parent="specAttr.primitive" p:value="da6" /></entry> \r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- <constructor-arg> \r
- <map>\r
- <entry key="p2" value="va2"/>\r
- <entry key="p4" value="va4"/>\r
- <entry key="p6" value="va6"/>\r
- </map>\r
- </constructor-arg>\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da1" />\r
- <property name="reached" value="@{p1}" />\r
- </bean>\r
- </property> \r
- </bean>\r
- <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va2" />\r
- <property name="reached" value="@{p2}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da3" />\r
- <property name="reached" value="@{p3}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va4" />\r
- <property name="reached" value="@{p4}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da5" />\r
- <property name="reached" value="@{p5}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va6" />\r
- <property name="reached" value="@{p6}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <ref bean="flowB"/> \r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="flowB" parent="slcTemplate.simpleFlow" scope="prototype">\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="p3"><bean parent="specAttr.primitive" p:value="db3" /></entry> \r
- <entry key="p4"><bean parent="specAttr.primitive" p:value="db4" /></entry>\r
- <entry key="p5"><bean parent="specAttr.primitive" p:value="db5" /></entry> \r
- <entry key="p6"><bean parent="specAttr.primitive" p:value="db6" /></entry>\r
- <entry key="p7"><bean parent="specAttr.primitive" p:value="db7" /></entry> \r
- <entry key="p8"><bean parent="specAttr.primitive" p:value="db8" /></entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- <constructor-arg> \r
- <map>\r
- <entry key="p3" value="vb3"/>\r
- <entry key="p4" value="vb4"/>\r
- <entry key="p7" value="vb7"/>\r
- </map>\r
- </constructor-arg> \r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da1" />\r
- <property name="reached" value="@{p1}" />\r
- </bean>\r
- </property> \r
- </bean>\r
- <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va2" />\r
- <property name="reached" value="@{p2}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da3" />\r
- <property name="reached" value="@{p3}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va4" />\r
- <property name="reached" value="@{p4}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da5" />\r
- <property name="reached" value="@{p5}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va6" />\r
- <property name="reached" value="@{p6}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p7=@{p7}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="vb7" />\r
- <property name="reached" value="@{p7}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p8=@{p8}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="db8" />\r
- <property name="reached" value="@{p8}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- \r
- <!-- test in scope execution -->\r
- <bean parent="task.echo" scope="execution"><property name="message" value="p1=@{p1}" /><aop:scoped-proxy /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <property name="expected" value="e1" />\r
- <property name="reached" value="@{p1}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property> \r
- </bean>\r
- <bean parent="task.echo" scope="execution"><property name="message" value="p2=@{p2}" /><aop:scoped-proxy /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <property name="expected" value="e2" />\r
- <property name="reached" value="@{p2}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo" scope="execution"><property name="message" value="p3=@{p3}" /><aop:scoped-proxy /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <property name="expected" value="e3" />\r
- <property name="reached" value="@{p3}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo" scope="execution"><property name="message" value="p4=@{p4}" /><aop:scoped-proxy /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <property name="expected" value="e4" />\r
- <property name="reached" value="@{p4}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo" scope="execution"><property name="message" value="p5=@{p5}" /><aop:scoped-proxy /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <property name="expected" value="e5" />\r
- <property name="reached" value="@{p5}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo" scope="execution"><property name="message" value="p6=@{p6}" /><aop:scoped-proxy /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <property name="expected" value="e6" />\r
- <property name="reached" value="@{p6}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property> \r
- </bean>\r
- \r
- <!-- \r
- p7 and p8 are not in the spec of FlowA and therefore can not be overridden\r
- at the execution\r
- -->\r
- <bean parent="task.echo" scope="execution"><property name="message" value="p7=@{p7}" /><aop:scoped-proxy /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <property name="expected" value="vb7" />\r
- <property name="reached" value="@{p7}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo" scope="execution"><property name="message" value="p8=@{p8}" /><aop:scoped-proxy /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <property name="expected" value="db8" />\r
- <property name="reached" value="@{p8}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property> \r
- </bean> \r
- \r
- </list>\r
- </property>\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" /> \r
-\r
- <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
- <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
- <bean id="echo1" parent="task.echo">\r
- <property name="message" value="From minimal" />\r
- </bean>\r
-\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
- <property name="testDefinition" ref="myTestDef" />\r
- <property name="testResult" ref="myTestResult"/>\r
- </bean> \r
-\r
- <!-- \r
- The Flow A contains the flow B as executable.\r
- \r
- Parameters\r
- p1: flow A: default - flow B: - \r
- p2: flow A: set - flow B: - \r
- p3: flow A: default - flow B: default \r
- p4: flow A: set - flow B: default\r
- p5: flow A: default - flow B: set \r
- p6: flow A: set - flow B: set\r
- p7: flow A: - - flow B: default\r
- p8: flow A: - - flow B: set\r
- \r
- \r
- -->\r
-\r
- <bean id="flowA" parent="slcTemplate.simpleFlow">\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="p1"><bean parent="specAttr.primitive" p:value="da1" /></entry>\r
- <entry key="p2"><bean parent="specAttr.primitive" p:value="da2" /></entry> \r
- <entry key="p3"><bean parent="specAttr.primitive" p:value="da3" /></entry> \r
- <entry key="p4"><bean parent="specAttr.primitive" p:value="da4" /></entry> \r
- <entry key="p5"><bean parent="specAttr.primitive" p:value="da5" /></entry> \r
- <entry key="p6"><bean parent="specAttr.primitive" p:value="da6" /></entry> \r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- <constructor-arg> \r
- <map>\r
- <entry key="p2" value="va2"/>\r
- <entry key="p4" value="va4"/>\r
- <entry key="p6" value="va6"/>\r
- </map>\r
- </constructor-arg>\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da1" />\r
- <property name="reached" value="@{p1}" />\r
- </bean>\r
- </property> \r
- </bean>\r
- <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va2" />\r
- <property name="reached" value="@{p2}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da3" />\r
- <property name="reached" value="@{p3}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va4" />\r
- <property name="reached" value="@{p4}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da5" />\r
- <property name="reached" value="@{p5}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va6" />\r
- <property name="reached" value="@{p6}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <ref bean="flowB"/> \r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="flowB" parent="slcTemplate.simpleFlow" scope="prototype">\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="p3"><bean parent="specAttr.primitive" p:value="db3" /></entry> \r
- <entry key="p4"><bean parent="specAttr.primitive" p:value="db4" /></entry>\r
- <entry key="p5"><bean parent="specAttr.primitive" p:value="db5" /></entry> \r
- <entry key="p6"><bean parent="specAttr.primitive" p:value="db6" /></entry>\r
- <entry key="p7"><bean parent="specAttr.primitive" p:value="db7" /></entry> \r
- <entry key="p8"><bean parent="specAttr.primitive" p:value="db8" /></entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- <constructor-arg> \r
- <map>\r
- <entry key="p3" value="vb3"/>\r
- <entry key="p4" value="vb4"/>\r
- <entry key="p7" value="vb7"/>\r
- </map>\r
- </constructor-arg> \r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da1" />\r
- <property name="reached" value="@{p1}" />\r
- </bean>\r
- </property> \r
- </bean>\r
- <bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va2" />\r
- <property name="reached" value="@{p2}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da3" />\r
- <property name="reached" value="@{p3}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va4" />\r
- <property name="reached" value="@{p4}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="da5" />\r
- <property name="reached" value="@{p5}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="va6" />\r
- <property name="reached" value="@{p6}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p7=@{p7}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="vb7" />\r
- <property name="reached" value="@{p7}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- <bean parent="task.echo"><property name="message" value="p8=@{p8}" /></bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="db8" />\r
- <property name="reached" value="@{p8}" />\r
- </bean>\r
- </property> \r
- </bean> \r
- </list>\r
- </property>\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" /> \r
- \r
- <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
- <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
- <property name="testDefinition" ref="myTestDef" />\r
- <property name="testResult" ref="myTestResult"/>\r
- </bean> \r
- \r
- <bean id="spec1" parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testedComponentId">\r
- <bean parent="specAttr.primitive" p:isParameter="true"\r
- p:type="integer" />\r
- </entry>\r
- <entry key="testData1">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:isParameter="true" p:isFrozen="true" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="flowTemplate1" parent="slcTemplate.simpleFlow"\r
- abstract="true">\r
- <constructor-arg ref="spec1" />\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo" scope="execution">\r
- <property name="message" value="From basic @{testedComponentId}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean parent="parameterRef">\r
- <constructor-arg value="testData1" />\r
- </bean>\r
- </property>\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="flow1" parent="flowTemplate1" scope="prototype">\r
- <constructor-arg>\r
- <map>\r
- <entry key="testedComponentId" value="200" />\r
- <entry key="testData1">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <aop:scoped-proxy/>\r
- <property name="expected" value="tata101" />\r
- <property name="reached" value="tata@{testedComponentId}" />\r
- </bean>\r
- </entry>\r
- </map> \r
- </constructor-arg>\r
- </bean>\r
-\r
- <bean id="spec2" parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testData1">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:isParameter="true" p:isFrozen="true" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="flowTemplate2" parent="slcTemplate.simpleFlow" abstract="true">\r
- <constructor-arg ref="spec2" />\r
- <property name="executables">\r
- <list>\r
- <ref bean="flow1"/>\r
- </list>\r
- </property>\r
- </bean>\r
- \r
- <bean id="flow2" parent="flowTemplate2">\r
- <constructor-arg>\r
- <map>\r
- <entry key="testData1">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected" value="tata100" />\r
- <property name="reached" value="tata100" />\r
- </bean>\r
- </entry>\r
- </map> \r
- </constructor-arg>\r
- </bean> \r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.core.execution.AbstractExecutionFlowTestCase;
-
-public class SystemCallTest extends AbstractExecutionFlowTestCase {
- private final static Log log = LogFactory.getLog(SystemCallTest.class);
-
- private final String defFile = "systemCall.xml";
-
- public void testSystemCallSimple() throws Exception {
- if (isOsSupported())
- configureAndExecuteSlcFlow(defFile, "systemCallSimple");
- }
-
- public void testSystemCallList() throws Exception {
- if (isOsSupported())
- configureAndExecuteSlcFlow(defFile, "systemCallList");
- }
-
- public void testSystemCallOsSpecific() throws Exception {
- if (isOsSupported())
- configureAndExecuteSlcFlow(defFile, "systemCallOsSpecific");
- }
-
- public void testSystemCallWithVar() throws Exception {
- if (isOsSupported())
- configureAndExecuteSlcFlow(defFile, "systemCallWithVar");
- }
-
- protected boolean isOsSupported() {
- String osName = System.getProperty("os.name");
- final Boolean ret;
- if (osName.contains("Windows"))
- ret = false;
- else
- ret = true;
-
- if (ret == false)
- log.warn("Skip test because OS '" + osName + "' is not supported.");
- return ret;
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="../imports.xml" />\r
-\r
- <bean id="systemCallSimple" parent="slcTemplate.simpleFlow">\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo">\r
- <property name="message" value="os.name=${os.name}" />\r
- </bean>\r
- <bean parent="task.systemCall">\r
- <property name="cmd" value="echo Hello World" />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="systemCallList" parent="slcTemplate.simpleFlow">\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.systemCall">\r
- <property name="command">\r
- <list>\r
- <value>echo</value>\r
- <value>Hello</value>\r
- <value>World</value>\r
- </list>\r
- </property>\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="systemCallOsSpecific" parent="slcTemplate.simpleFlow">\r
- <!-- Direct call to dir under Windows isnot working -->\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.systemCall">\r
- <property name="cmd" value="dir" />\r
- <property name="execDir" value="../.." />\r
- <property name="osCmds">\r
- <map>\r
- <entry key="Linux" value="ls" />\r
- <entry key="Mac OS X" value="ls" />\r
- </map>\r
- </property>\r
- </bean>\r
- <bean parent="task.systemCall">\r
- <property name="command">\r
- <list>\r
- <value>dir</value>\r
- </list>\r
- </property>\r
- <property name="osCommands">\r
- <map>\r
- <entry key="Linux">\r
- <list>\r
- <value>ls</value>\r
- </list>\r
- </entry>\r
- <entry key="Mac OS X">\r
- <list>\r
- <value>ls</value>\r
- </list>\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="systemCallWithVar" parent="slcTemplate.simpleFlow">\r
- <constructor-arg>\r
- <bean parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="var">\r
- <bean parent="specAttr.primitive" p:value="660" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
- </constructor-arg>\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.systemCall" scope="execution">\r
- <property name="cmd" value="echo var=@{var}" />\r
- <aop:scoped-proxy />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">\r
-\r
- <import resource="imports.xml" /> \r
-\r
- <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
- <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
- <property name="testDefinition" ref="myTestDef" />\r
- <property name="testResult" ref="myTestResult"/>\r
- </bean> \r
- \r
- <bean id="spec1" parent="slcTemplate.simpleSpec">\r
- <property name="attributes">\r
- <map>\r
- <entry key="testedComponentId">\r
- <bean parent="specAttr.primitive" p:isParameter="true"\r
- p:type="integer" />\r
- </entry>\r
- <entry key="testData1">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- p:isParameter="true" p:isFrozen="true" />\r
- </entry>\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="flowTemplate1" parent="slcTemplate.simpleFlow"\r
- abstract="true">\r
- <constructor-arg ref="spec1" />\r
- <property name="executables">\r
- <list>\r
- <bean parent="task.echo">\r
- <property name="message" value="From basic @{testedComponentId}" />\r
- </bean>\r
- <bean parent="myTestRunTemplate">\r
- <property name="testData">\r
- <bean parent="parameterRef">\r
- <constructor-arg value="testData1" />\r
- </bean>\r
- </property>\r
- </bean>\r
- <bean parent="task.echo">\r
- <property name="message"><value>From basic @{testedComponentId}</value></property>\r
- </bean> \r
- <bean parent="task.echo">\r
- <property name="message"><value>testData1='@{testData1}'</value></property>\r
- </bean> \r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="flow1" parent="flowTemplate1" scope="prototype">\r
- <constructor-arg>\r
- <map>\r
- <entry key="testedComponentId" value="200" />\r
- <entry key="testData1">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
- <aop:scoped-proxy/>\r
- <property name="expected" value="tata101" />\r
- <property name="reached" value="tata@{testedComponentId}" />\r
- </bean>\r
- </entry>\r
- </map> \r
- </constructor-arg>\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.execution.xml;
-
-import org.argeo.slc.core.execution.AbstractExecutionFlowTestCase;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.springframework.context.ConfigurableApplicationContext;
-
-public abstract class FlowNamespaceTest extends AbstractExecutionFlowTestCase {
- public void XXXtestCanonical() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("canonic-ns.xml");
- ((ExecutionFlow) applicationContext.getBean("canonic-ns.001")).run();
- ((ExecutionFlow) applicationContext.getBean("canonic-ns.002")).run();
- }
-
- public void XXXtestAdvanced() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("advanced.xml");
- ((ExecutionFlow) applicationContext.getBean("flow1")).run();
- ((ExecutionFlow) applicationContext.getBean("flow2")).run();
- ((ExecutionFlow) applicationContext.getBean("flow3")).run();
-
- validateTestResult((SimpleTestResult) applicationContext
- .getBean("testResult"));
- }
-
- public void XXXtestAdvancedExecution() throws Exception {
- ConfigurableApplicationContext applicationContext = createApplicationContext("advanced.xml");
-
- ExecutionContext executionContext = (ExecutionContext) applicationContext
- .getBean("executionContext");
- executionContext.setVariable("param2", 4);
-
- ((ExecutionFlow) applicationContext.getBean("flow4")).run();
-
- validateTestResult((SimpleTestResult) applicationContext
- .getBean("testResult"));
- }
-
- // These tests causes pb when using Spring 3
-
- // public void testContainers() throws Exception {
- // ConfigurableApplicationContext applicationContext =
- // createApplicationContext("containers.xml");
- // ((ExecutionFlow) applicationContext.getBean("test.list.flow1")).run();
- // ((ExecutionFlow) applicationContext.getBean("test.list.flow2")).run();
- //
- // validateTestResult((SimpleTestResult) applicationContext
- // .getBean("testResult"));
- // }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
- <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
-\r
- <bean id="testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
- <bean id="testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
- <bean id="testRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
- <property name="testDefinition" ref="testDef" />\r
- <property name="testResult" ref="testResult"/>\r
- </bean> \r
-\r
- <flow:spec id="advanced.spec">\r
- <description>spec description</description>\r
- <flow:primitive name="param1" isParameter="true"\r
- type="integer" />\r
- <flow:primitive name="param2" isParameter="true"\r
- type="integer" /> \r
- </flow:spec>\r
-\r
-\r
- <flow:flow id="advanced.flowTemplate" abstract="true" spec="advanced.spec"\r
- path="/path">\r
- <description>flow description</description>\r
- <bean parent="task.echo">\r
- <property name="message" value="Advanced: param1=@{param1}, param2=@{param2}" />\r
- <flow:variable/>\r
- </bean> \r
- <flow:flow>\r
- <bean parent="task.echo" p:message="Flow in Flow - param1=@{param1}, param2=@{param2} [Not variable]" />\r
- </flow:flow>\r
- \r
- <bean parent="testRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <flow:variable/>\r
- <property name="expected" value="@{param1}" />\r
- <property name="reached" value="@{param2}" />\r
- </bean>\r
- </property> \r
- </bean>\r
- \r
- </flow:flow>\r
-\r
- <flow:flow id="advanced.flowTemplate2" abstract="true" spec="advanced.spec"\r
- path="/path">\r
- <bean parent="task.echo" p:message="Advanced2: param1=@{param1}, param2=@{param2}">\r
- <flow:variable/>\r
- </bean>\r
- <flow:flow parent="advanced.flowTemplate">\r
- <flow:arg name="param1" value="@{param1}"/>\r
- <flow:arg name="param2">\r
- <!-- flow:param in flow:arg -->\r
- <flow:param name="param2" />\r
- </flow:arg>\r
- </flow:flow>\r
- </flow:flow>\r
-\r
- \r
- <flow:flow id="flow1" parent="advanced.flowTemplate">\r
- <flow:arg name="param1" value="1" />\r
- <flow:arg name="param2" value="1" />\r
- </flow:flow>\r
- \r
- <flow:flow id="flow2">\r
- <flow:flow parent="advanced.flowTemplate">\r
- <flow:arg name="param1" value="2" />\r
- <flow:arg name="param2" value="2" />\r
- </flow:flow>\r
- </flow:flow>\r
-\r
- <flow:flow id="flow3" parent="advanced.flowTemplate2">\r
- <flow:arg name="param1" value="3" />\r
- <flow:arg name="param2" value="3" />\r
- </flow:flow>\r
- \r
- <flow:flow id="flow4" parent="advanced.flowTemplate">\r
- <description>Would fail if param 2 is not changed at execution</description>\r
- <flow:arg name="param1" value="4" />\r
- <flow:arg name="param2" value="3" />\r
- </flow:flow> \r
-\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <bean id="canonic-ns.001" parent="canonic-ns.flowTemplate">\r
- <description>Canonic 001</description>\r
- <constructor-arg>\r
- <map>\r
- <entry key="parameterAtInstantiation" value="1" />\r
- </map>\r
- </constructor-arg>\r
- </bean>\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans:beans xmlns="http://www.argeo.org/schema/slc-flow"\r
- xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:p="http://www.springframework.org/schema/p"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <flow id="canonic-ns.002" parent="canonic-ns.flowTemplate">\r
- <arg name="parameterAtInstantiation" value="2" />\r
- <arg name="displayWithoutControl" value="102" />\r
- <arg name="displayWithControl" value="202" />\r
- <arg name="hide" value="202" />\r
- <arg name="refWithoutValue">\r
- <beans:bean id="testDataOk" p:expected="tata" p:reached="tata"\r
- class="org.argeo.slc.runtime.test.BasicTestData" />\r
- </arg>\r
- </flow>\r
-</beans:beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans:beans xmlns="http://www.argeo.org/schema/slc-flow"\r
- xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <beans:import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
- <beans:import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
-\r
- <beans:import resource="canonic-ns-001.xml" />\r
- <beans:import resource="canonic-ns-002.xml" />\r
- <beans:import resource="tests.xml" />\r
-\r
- <!--\r
- Specifications definition is greatly simplified by the flow namespace\r
- -->\r
- <spec id="canonic-ns.spec">\r
- <primitive name="parameterAtInstantiation" isParameter="true"\r
- type="integer" />\r
- <primitive name="displayWithoutControl" value="100"\r
- isParameter="true" type="integer" isFrozen="true" />\r
- <primitive name="displayWithControl" value="200"\r
- isParameter="true" type="integer" />\r
- <primitive name="hide" value="300" isParameter="true" type="integer"\r
- isHidden="true" />\r
- <ref name="refWithValue" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- isParameter="true" ref="testDataNok" />\r
- <ref name="refWithoutValue" targetClass="org.argeo.slc.runtime.test.BasicTestData" />\r
- <ref name="refWithoutValueFrozen" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
- isParameter="true" isFrozen="true">\r
- <value>\r
- <beans:bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <beans:property name="expected" value="tata" />\r
- <beans:property name="reached" value="tata" />\r
- </beans:bean>\r
- </value>\r
- </ref>\r
- </spec>\r
-\r
- <flow id="canonic-ns.flowTemplate" abstract="true" spec="canonic-ns.spec"\r
- path="/path">\r
- <beans:bean parent="task.echo"\r
- p:message="Canonical: displayWithControl=@{displayWithControl}, displayWithoutControl=@{displayWithoutControl}, hide=@{hide}"\r
- scope="execution">\r
- <aop:scoped-proxy />\r
- </beans:bean>\r
- <beans:ref bean="testRun" />\r
- </flow>\r
-\r
- <beans:bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <beans:property name="expected" value="tata" />\r
- <beans:property name="reached" value="tata" />\r
- </beans:bean>\r
-\r
- <beans:bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
- <aop:scoped-proxy />\r
- <beans:property name="expected" value="tata" />\r
- <beans:property name="reached" value="toto" />\r
- </beans:bean>\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
- <import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
-\r
- <bean id="testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
-\r
- <bean id="testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
-\r
- <bean id="testRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
- <property name="testDefinition" ref="testDef" />\r
- <property name="testResult" ref="testResult"/>\r
- </bean> \r
-\r
- <flow:spec id="test.list.spec">\r
- <flow:ref name="list1" targetClass="java.util.List">\r
- <flow:value>\r
- <!-- a list element can be used directly as default value-->\r
- <list>\r
- <value>val1</value>\r
- </list>\r
- </flow:value>\r
- </flow:ref>\r
- <flow:ref name="list2" targetClass="java.util.List" />\r
- <!-- following parameters are not used in flow -->\r
- <flow:ref name="dummyMap" targetClass="java.util.Map">\r
- <flow:value>\r
- <map></map>\r
- </flow:value>\r
- </flow:ref>\r
- <flow:ref name="dummySet" targetClass="java.util.Set">\r
- <flow:value>\r
- <set></set>\r
- </flow:value>\r
- </flow:ref>\r
- <flow:ref name="dummyProperties" targetClass="java.util.Properties">\r
- <flow:value>\r
- <props></props>\r
- </flow:value>\r
- </flow:ref>\r
- \r
- </flow:spec>\r
-\r
-\r
- <flow:flow id="test.list.flowTemplate" abstract="true" spec="test.list.spec"\r
- path="/path">\r
- <bean parent="task.echo">\r
- <property name="message" value="list1=@{list1}, list2=@{list2}" />\r
- <flow:variable/>\r
- </bean> \r
-\r
- <bean parent="testRunTemplate">\r
- <property name="testData">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
- <property name="expected">\r
- <flow:param name="list1"/>\r
- </property>\r
- <property name="reached">\r
- <flow:param name="list2"/>\r
- </property>\r
- </bean>\r
- </property> \r
- </bean>\r
- \r
- </flow:flow>\r
-\r
- <flow:flow id="test.list.flow1" parent="test.list.flowTemplate">\r
- <flow:arg name="list1">\r
- <list>\r
- <value>val1</value>\r
- <value>val2</value> \r
- </list>\r
- </flow:arg>\r
- <flow:arg name="list2">\r
- <list>\r
- <value>val1</value>\r
- <value>val2</value> \r
- </list>\r
- </flow:arg>\r
- \r
- <!-- not used in flow (just to test that the syntax is accepted): -->\r
- <flow:arg name="dummyMap">\r
- <map></map>\r
- </flow:arg>\r
- <flow:arg name="dummySet">\r
- <set></set>\r
- </flow:arg>\r
- <flow:arg name="dummyProperties">\r
- <props></props>\r
- </flow:arg> \r
- \r
- </flow:flow>\r
- \r
- <flow:flow id="test.list.flow2" parent="test.list.flowTemplate">\r
- <description>use default value for parameter "list1"</description>\r
- <flow:arg name="list2">\r
- <list>\r
- <value>val1</value>\r
- </list>\r
- </flow:arg>\r
- </flow:flow>\r
-\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
- xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
-\r
- <bean id="testRun" class="org.argeo.slc.runtime.test.SimpleTestRun">\r
- <property name="testDefinition">\r
- <bean class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
- </property>\r
- <property name="testData">\r
- <flow:param name="refWithValue" />\r
- </property>\r
- <!-- <property name="testData">-->\r
- <!-- <bean parent="parameterRef">-->\r
- <!-- <constructor-arg value="refWithValue" />-->\r
- <!-- </bean>-->\r
- <!-- </property>-->\r
- <property name="testResult">\r
- <bean parent="slcDefault.test.basicSimpleTestResult" scope="execution">\r
- <property name="attributes">\r
- <map>\r
- <entry key="displayWithControl" value="@{displayWithControl}" />\r
- </map>\r
- </property>\r
- <aop:scoped-proxy />\r
- </bean>\r
- </property>\r
- </bean>\r
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.test.context;
-
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.BeanFactoryUtils;
-import org.springframework.beans.factory.ListableBeanFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-/** Helper for tests using a Spring application context. */
-public abstract class AbstractInternalSpringTestCase extends TestCase {
- protected final Log log = LogFactory.getLog(getClass());
- private ConfigurableApplicationContext context;
-
- /**
- * Gets (and create if necessary) the application context to use. Default
- * implementation uses a class path xml application context and calls
- * {@link #getApplicationContextLocation()}.
- */
- protected ConfigurableApplicationContext getContext() {
- if (context == null) {
- context = new ClassPathXmlApplicationContext(
- getApplicationContextLocation());
- }
- return context;
- }
-
- /** Returns a bean from the underlying context */
- @SuppressWarnings(value = { "unchecked" })
- protected <T> T getBean(String beanId) {
- return (T) getContext().getBean(beanId);
- }
-
- protected <T> T getBean(Class<? extends T> clss) {
- T bean = loadSingleFromContext(getContext(), clss);
- if (bean == null) {
- throw new SlcException("Cannot retrieve a unique bean of type "
- + clss);
- } else {
- return bean;
- }
- }
-
- /**
- * Th location of the application to load. The default implementation
- * returns <i>applicationContext.xml</i> found in the same package as the
- * test.
- */
- protected String getApplicationContextLocation() {
- return inPackage("applicationContext.xml");
- }
-
- /**
- * Prefixes the package of the class after converting the '.' to '/' in
- * order to have a resource path.
- */
- protected String inPackage(String suffix) {
- String prefix = getClass().getPackage().getName().replace('.', '/');
- return prefix + '/' + suffix;
- }
-
- @SuppressWarnings(value = { "unchecked" })
- protected <T> T loadSingleFromContext(ListableBeanFactory context,
- Class<T> clss) {
- Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
- context, clss, false, false);
- if (beans.size() == 1) {
- return beans.values().iterator().next();
- } else if (beans.size() > 1) {
- if (log.isDebugEnabled()) {
- log
- .debug(("Found more that on bean for type " + clss
- + ": " + beans.keySet()));
- }
- return null;
- } else {
- return null;
- }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.test.context;
-
-import java.util.List;
-
-import org.argeo.slc.runtime.test.ContextUtils;
-import org.argeo.slc.runtime.test.SimpleTestResult;
-import org.argeo.slc.test.TestResultPart;
-import org.argeo.slc.test.TestStatus;
-import org.argeo.slc.test.context.ContextAware;
-
-public class ContextTest extends AbstractInternalSpringTestCase {
-
- public void testComplexContext() {
- SimpleTestResult testResult = new SimpleTestResult();
- ContextUtils.compareReachedExpected(
- (ContextAware) getBean("context.c1"), testResult);
- ContextUtils.compareReachedExpected(
- (ContextAware) getBean("context.c2"), testResult);
- ContextUtils.compareReachedExpected(
- (ContextAware) getBean("context.c3"), testResult);
-
- List<TestResultPart> parts = testResult.getParts();
- assertEquals(6, parts.size());
- assertEquals(TestStatus.PASSED, parts.get(0).getStatus());
- assertEquals(TestStatus.PASSED, parts.get(1).getStatus());
- assertEquals(TestStatus.PASSED, parts.get(2).getStatus());
- assertEquals(TestStatus.FAILED, parts.get(3).getStatus());
- assertEquals(TestStatus.PASSED, parts.get(4).getStatus());
- assertEquals(TestStatus.PASSED, parts.get(5).getStatus());
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <bean id="parentContext.pc1" parent="parentContext.template">\r
- <property name="values">\r
- <map>\r
- <entry key="rootvar" value="text" />\r
- </map>\r
- </property>\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="reference" value="20" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="context.c1" parent="context.template">\r
- <property name="parentContext" ref="parentContext.pc1" />\r
- <property name="values">\r
- <map>\r
- <entry key="reference" value="20" />\r
- <entry key="any" value="999" />\r
- <entry key="skipped" value="999" />\r
- </map>\r
- </property>\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="reference" value="21" />\r
- <entry key="any" value="*" />\r
- <entry key="skipped" value="!" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="context.c2" parent="context.template">\r
- <property name="parentContext" ref="parentContext.pc1" />\r
- <property name="values">\r
- <map>\r
- <entry key="var" value="37" />\r
- <entry key="bad" value="56" />\r
- </map>\r
- </property>\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="var" value="37" />\r
- <entry key="bad" value="57" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="parentContext.pc2" parent="parentContext.template">\r
- <property name="parentContext" ref="parentContext.pc1" />\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="reference" value="40" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="context.c3" parent="context.template">\r
- <property name="parentContext" ref="parentContext.pc2" />\r
- <property name="values">\r
- <map>\r
- <entry key="reference" value="41" />\r
- <entry key="rootvar" value="textX" />\r
- </map>\r
- </property>\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="reference" value="40" />\r
- <entry key="rootvar" value="text" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
-\r
- <bean id="parentContext.template"\r
- class="org.argeo.slc.core.test.context.SimpleParentContextAware"\r
- abstract="true">\r
- </bean>\r
-\r
- <bean id="context.template"\r
- class="org.argeo.slc.core.test.context.SimpleContextAware"\r
- abstract="true">\r
- </bean>\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.spring</artifactId>
- <name>SLC Spring Runtime</name>
- <dependencies>
- <!-- Commons -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.enterprise</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.api</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.cms</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.jcr</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <!-- Commons -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.osgi.boot</artifactId>
- <version>${version.argeo-commons}</version>
- <scope>provided</scope>
- </dependency>
-
- <!-- SLC -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.api</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.jcr</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.repo</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- Spring -->
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.beans</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.context</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.expression</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.spring</groupId>
- <artifactId>org.springframework.aop</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.gemini</groupId>
- <artifactId>org.eclipse.gemini.blueprint.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.gemini</groupId>
- <artifactId>org.eclipse.gemini.blueprint.io</artifactId>
- </dependency>
-
- <!-- Ant -->
- <dependency>
- <groupId>org.argeo.tp.apache.ant</groupId>
- <artifactId>org.apache.ant</artifactId>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.ant;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.argeo.slc.core.execution.AbstractExecutionFlowGenerator;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.core.io.Resource;
-
-public class AntFlowGenerator extends AbstractExecutionFlowGenerator {
- private List<Resource> antFiles = new ArrayList<Resource>();
-
- protected Map<String, BeanDefinition> createExecutionFlowDefinitions(
- ConfigurableListableBeanFactory beanFactory) {
- Map<String, BeanDefinition> definitions = new HashMap<String, BeanDefinition>();
-
- for (Resource antFile : antFiles) {
- AntRun antRun = new AntRun();
- antRun.setBuildFile(antFile);
-
- List<Runnable> executables = new ArrayList<Runnable>();
- executables.add(antRun);
- definitions.put("ant." + antFile.getFilename(),
- createDefaultFlowDefinition(executables));
- }
- return definitions;
- }
-
- public void setAntFiles(List<Resource> antFiles) {
- this.antFiles = antFiles;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.ant;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
-import org.apache.tools.ant.helper.ProjectHelper2;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-public class AntRun implements Runnable {
- private final static Log log = LogFactory.getLog(AntRun.class);
-
- private Resource buildFile;
- private File baseDir;
-
- private List<String> targets = new ArrayList<String>();
- private Map<Object, Object> properties = new HashMap<Object, Object>();
-
- public void run() {
- Project project = new Project();
-
- try {
- String path = buildFile.getURL().getPath();
- project.setUserProperty("ant.file", path);
- project.setBaseDir(extractBaseDir(path));
-
- project.init();
- ProjectHelper projectHelper = new ProjectHelper2();
- project.addReference(ProjectHelper.PROJECTHELPER_REFERENCE,
- projectHelper);
- projectHelper.parse(project, buildFile.getURL());
- } catch (Exception e) {
- throw new SlcException("Could not parse " + buildFile, e);
- }
-
- if (properties != null) {
- for (Map.Entry<Object, Object> entry : properties.entrySet()) {
- project.setUserProperty(entry.getKey().toString(), entry
- .getValue().toString());
- }
- }
-
- project.fireBuildStarted();
- Throwable exception = null;
- try {
- project.addBuildListener(new LoggingListener());
- if (targets.size() == 0) {
- project.executeTarget(project.getDefaultTarget());
- } else {
- project.executeTargets(new Vector<String>(targets));
- }
- } catch (Throwable e) {
- exception = e;
- throw new SlcException("Could not run Ant script " + buildFile, e);
- } finally {
- project.fireBuildFinished(exception);
- }
- }
-
- private File extractBaseDir(String path) {
- if(this.baseDir!=null)
- return this.baseDir;
-
- String baseDir = null;
- if (path.length() > 1) {
- int indx = path.lastIndexOf('/', path.length() - 1);
- if (indx == -1 || indx == 0) {
- baseDir = "/";
- } else {
- baseDir = path.substring(0, indx) + "/";
- }
- } else {
- baseDir = "/";
- }
- File file = new File(baseDir);
- if (file.exists()) {
- return file;
- } else {
- return new File(System.getProperty("user.dir"));
- }
- }
-
- public void setBuildFile(Resource buildFile) {
- this.buildFile = buildFile;
- }
-
- public void setTargets(List<String> targets) {
- this.targets = targets;
- }
-
- public void setProperties(Map<Object, Object> properties) {
- this.properties = properties;
- }
-
- public void setBaseDir(File baseDir) {
- this.baseDir = baseDir;
- }
-
- protected static class LoggingListener implements BuildListener {
-
- public void buildFinished(BuildEvent event) {
- if (log.isDebugEnabled())
- log.debug("Ant build finished: " + event);
- }
-
- public void buildStarted(BuildEvent event) {
- if (log.isDebugEnabled())
- log.debug("Ant build started: " + event);
- }
-
- public void messageLogged(BuildEvent event) {
- if (event.getPriority() == Project.MSG_DEBUG) {
- if (log.isTraceEnabled())
- log.trace(event.getMessage());
- } else if (event.getPriority() == Project.MSG_VERBOSE) {
- if (log.isDebugEnabled())
- log.debug(event.getMessage());
- } else if (event.getPriority() == Project.MSG_INFO) {
- log.info(event.getMessage());
-
- } else if (event.getPriority() == Project.MSG_WARN) {
- log.warn(event.getMessage());
-
- } else if (event.getPriority() == Project.MSG_ERR) {
- log.error(event.getMessage());
- } else {
- log.error(event.getMessage());
- }
- }
-
- public void targetFinished(BuildEvent event) {
- if (log.isTraceEnabled())
- log.debug("Target finished: " + event.getTarget());
- }
-
- public void targetStarted(BuildEvent event) {
- if (log.isTraceEnabled())
- log.debug("Target started: " + event.getTarget());
- }
-
- public void taskFinished(BuildEvent event) {
- }
-
- public void taskStarted(BuildEvent event) {
- }
- }
-}
+++ /dev/null
-package org.argeo.slc.core.attachment;
-
-import org.argeo.slc.attachment.Attachment;
-import org.springframework.core.io.Resource;
-
-public interface AttachmentUploader {
- public void upload(Attachment attachment, Resource resource);
-}
+++ /dev/null
-package org.argeo.slc.core.attachment;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.attachment.Attachment;
-import org.argeo.slc.attachment.AttachmentsStorage;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-public class FileAttachmentsStorage implements AttachmentsStorage,
- AttachmentUploader, InitializingBean {
- private final static Log log = LogFactory
- .getLog(FileAttachmentsStorage.class);
-
- private File attachmentsDirectory;
-
- private String attachmentsTocFileName = "attachmentsToc.csv";
-
- private DateFormat dateFormatDay = new SimpleDateFormat("yyyy-MM-dd");
- private DateFormat dateFormatTime = new SimpleDateFormat("HH:mm:ss");
-
- public void afterPropertiesSet() {
- if (attachmentsDirectory == null) {
-
- String osgiInstanceArea = System.getProperty("osgi.instance.area");
- if (osgiInstanceArea != null) {
- if (osgiInstanceArea.startsWith("file:"))
- osgiInstanceArea = osgiInstanceArea.substring("file:"
- .length());
- attachmentsDirectory = new File(osgiInstanceArea
- + File.separator + "slcAttachments");
- }
-
- if (attachmentsDirectory == null) {
- String tempDir = System.getProperty("java.io.tmpdir");
- attachmentsDirectory = new File(tempDir + File.separator
- + "slcAttachments");
- }
- }
- if (!attachmentsDirectory.exists())
- attachmentsDirectory.mkdirs();
- if (log.isDebugEnabled())
- log.debug("File attachment storage initialized in directory "
- + attachmentsDirectory);
- }
-
- public void retrieveAttachment(Attachment attachment,
- OutputStream outputStream) {
- File file = getFile(attachment);
- InputStream in = null;
- try {
- byte[] buffer = new byte[1024 * 1024];
- in = new FileInputStream(file);
- int read = -1;
- while ((read = in.read(buffer)) >= 0) {
- outputStream.write(buffer, 0, read);
- }
- if (log.isTraceEnabled())
- log.trace("Read " + attachment + " from " + file);
- } catch (IOException e) {
- throw new SlcException("Cannot write attachment " + attachment
- + " to " + file, e);
- } finally {
- IOUtils.closeQuietly(in);
- }
- }
-
- public void storeAttachment(Attachment attachment, InputStream inputStream) {
- File file = getFile(attachment);
- FileOutputStream out = null;
- try {
- byte[] buffer = new byte[1024 * 1024];
- out = new FileOutputStream(file);
- int read = -1;
- while ((read = inputStream.read(buffer)) >= 0) {
- out.write(buffer, 0, read);
- }
- if (log.isTraceEnabled())
- log.trace("Wrote " + attachment + " to " + file);
- updateAttachmentToc(attachment, file);
- } catch (IOException e) {
- throw new SlcException("Cannot write attachment " + attachment
- + " to " + file, e);
- } finally {
- IOUtils.closeQuietly(out);
- }
-
- }
-
- public void upload(Attachment attachment, Resource resource) {
- try {
- storeAttachment(attachment, resource.getInputStream());
- } catch (IOException e) {
- throw new SlcException("Cannot upload attachment " + attachment, e);
- }
- }
-
- /** For monitoring purposes only */
- protected void updateAttachmentToc(Attachment attachment, File file) {
- Date date = new Date(file.lastModified());
- FileWriter writer = null;
- try {
- writer = new FileWriter(attachmentsDirectory + File.separator
- + attachmentsTocFileName, true);
- writer.append(dateFormatDay.format(date));
- writer.append(',');
- writer.append(dateFormatTime.format(date));
- writer.append(',');
- writer.append(attachment.getUuid());
- writer.append(',');
- writer.append(attachment.getName());
- writer.append(',');
- writer.append(attachment.getContentType());
- writer.append(',');
- writer.append(Long.toString(file.length()));
- writer.append(',');
- writer.append(file.getCanonicalPath());
- writer.append('\n');
- } catch (IOException e) {
- log.warn("Could not update attachments TOC for " + attachment
- + " and file " + file, e);
- } finally {
- IOUtils.closeQuietly(writer);
- }
-
- }
-
- protected File getFile(Attachment attachment) {
- File file = new File(attachmentsDirectory + File.separator
- + attachment.getUuid());
- return file;
- }
-
- public void setAttachmentsDirectory(File attachmentsDirectory) {
- this.attachmentsDirectory = attachmentsDirectory;
- }
-
- public void setAttachmentsTocFileName(String attachmentsTocFileName) {
- this.attachmentsTocFileName = attachmentsTocFileName;
- }
-
- public void setDateFormatDay(DateFormat dateFormatDay) {
- this.dateFormatDay = dateFormatDay;
- }
-
- public void setDateFormatTime(DateFormat dateFormatTime) {
- this.dateFormatTime = dateFormatTime;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.attachment;
-
-import java.io.Serializable;
-import java.util.UUID;
-
-import org.argeo.slc.attachment.Attachment;
-
-public class SimpleAttachment implements Attachment, Serializable {
- private static final long serialVersionUID = 6615155908800610606L;
- private String uuid = UUID.randomUUID().toString();
- private String name;
- private String contentType = "";
-
- public SimpleAttachment() {
- }
-
- public SimpleAttachment(String uuid, String name, String contentType) {
- super();
- this.uuid = uuid;
- this.name = name;
- this.contentType = contentType;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- public String toString() {
- return "Attachment #" + uuid + "(" + name + ", " + contentType + ")";
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof Attachment) {
- Attachment attachment = (Attachment) obj;
- if (uuid != null && attachment.getUuid() != null)
- return uuid.equals(attachment.getUuid());
-
- if (name != null && attachment.getName() != null)
- return name.equals(attachment.getName());
-
- return hashCode() == attachment.hashCode();
- }
- return false;
- }
-}
+++ /dev/null
-package org.argeo.slc.core.build;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.StreamReadable;
-import org.argeo.slc.build.Distribution;
-import org.springframework.core.io.Resource;
-
-/** A software distribution archive accessible via a {@link Resource}. */
-public class ResourceDistribution implements Distribution, StreamReadable {
- private Resource resource;
-
- public ResourceDistribution() {
- }
-
- public ResourceDistribution(Resource location) {
- this.resource = location;
- }
-
- public String getDistributionId() {
- return resource.toString();
- }
-
- public Resource getResource() {
- return resource;
- }
-
- public void setResource(Resource resource) {
- this.resource = resource;
- }
-
- public InputStream getInputStream() {
- try {
- return resource.getInputStream();
- } catch (IOException e) {
- throw new SlcException("Cannot get input stream", e);
- }
- }
-
- @Override
- public String toString() {
- return resource.toString();
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.build;
-
-import java.util.StringTokenizer;
-
-/**
- * <p>
- * An implementation of the distribution id using the standard
- * Major.Minor.Release notation. And additional arbitrary string can also be
- * added.
- * </p>
- *
- * <p>
- * <b>Examples:</b><br>
- * 0.2.6<br>
- * 2.4.12.RC1
- * </p>
- */
-public class VersionDistributionId {
-
- private Integer major;
- private Integer minor;
- private Integer release;
- private String additional;
-
- /** Parse the provided string in order to set the various components. */
- public void setVersionString(String str) {
- StringTokenizer st = new StringTokenizer(str, ".");
- if (st.hasMoreTokens())
- major = Integer.parseInt(st.nextToken());
- if (st.hasMoreTokens())
- minor = Integer.parseInt(st.nextToken());
- if (st.hasMoreTokens())
- release = Integer.parseInt(st.nextToken());
- if (st.hasMoreTokens())
- additional = st.nextToken();
- }
-
- public Integer getMajor() {
- return major;
- }
-
- public void setMajor(Integer major) {
- this.major = major;
- }
-
- public Integer getMinor() {
- return minor;
- }
-
- public void setMinor(Integer minor) {
- this.minor = minor;
- }
-
- public Integer getRelease() {
- return release;
- }
-
- public void setRelease(Integer release) {
- this.release = release;
- }
-
- public String getAdditional() {
- return additional;
- }
-
- public void setAdditional(String additional) {
- this.additional = additional;
- }
-
- @Override
- public boolean equals(Object obj) {
- // TODO Auto-generated method stub
- return super.equals(obj);
- }
-
- @Override
- public String toString() {
- return major + "." + minor + "." + release
- + (additional != null ? "." + additional : "");
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.build;
-
-import org.argeo.slc.NameVersion;
-import org.springframework.core.io.Resource;
-
-/**
- * The distribution of a software package (jar, zip, RPM, etc.) which is
- * versioned. The archive itself is accessible via a {@link Resource}.
- */
-public class VersionedResourceDistribution extends ResourceDistribution
- implements NameVersion {
- private String name;
- private String version;
-
- public VersionedResourceDistribution() {
- super();
- }
-
- public VersionedResourceDistribution(NameVersion nameVersion,
- Resource resource) {
- this(nameVersion.getName(), nameVersion.getVersion(), resource);
- }
-
- public VersionedResourceDistribution(String name, String version,
- Resource resource) {
- super(resource);
- this.name = name;
- this.version = version;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
-}
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-SLC Build: building of software systems.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.deploy;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.util.AntPathMatcher;
-import org.springframework.util.PathMatcher;
-
-public class DefaultResourceSet implements ResourceLoaderAware,
- InitializingBean, ResourceSet {
- private final static Log log = LogFactory.getLog(DefaultResourceSet.class);
- public final static String DEFAULT_EXCLUDES = "**/.svn/**";
-
- private String base;
- private String include;
- private List<String> includes = new ArrayList<String>();
- private String exclude;
- private List<String> excludes = new ArrayList<String>();
- private Boolean useDefaultExcludes = true;
- private ResourcePatternResolver resourcePatternResolver;
- private PathMatcher excludePathMatcher = new AntPathMatcher();
-
- private ResourceLoader resourceLoader;
-
- /** List the resources, identified by their relative path. */
- public Map<String, Resource> listResources() {
- try {
- Map<String, Resource> res = new TreeMap<String, Resource>();
- if (base == null)
- return res;
- String baseResUrl = getResourceLoaderToUse().getResource(base)
- .getURL().toString();
- for (String includePattern : includes)
- processInclude(res, includePattern, baseResUrl);
- return res;
- } catch (IOException e) {
- throw new SlcException("Cannot list resource from " + base, e);
- }
- }
-
- protected void processInclude(Map<String, Resource> res, String include,
- String baseResUrl) throws IOException {
- String pattern = base + "/" + include;
- if (log.isTraceEnabled())
- log.trace("Look for resources with pattern '" + pattern
- + "' in base url " + baseResUrl);
- Resource[] resources = resourcePatternResolver.getResources(pattern);
- resources: for (Resource resource : resources) {
- String url = resource.getURL().toString();
- String relPath = url.substring(baseResUrl.length());
-
- // skip dir
- if (relPath.charAt(relPath.length() - 1) == '/') {
- if (log.isTraceEnabled())
- log.trace("Skip directory " + relPath + "=" + resource);
- continue resources;
- }
-
- // make sure there is not starting '/'
- if (relPath.charAt(0) == '/')
- relPath = relPath.substring(1);
-
- // skip excludes
- for (String exclude : excludes)
- if (excludePathMatcher.match(exclude, relPath)) {
- if (log.isTraceEnabled())
- log.trace("Exclude " + relPath + "=" + resource);
- continue resources;
- }
-
- // check if already exists
- if (res.containsKey(relPath))
- log.warn(relPath + " already matched by " + res.get(relPath)
- + ", " + resource + " will override it.");
-
- // store the marched resource
- res.put(relPath, resource);
- if (log.isTraceEnabled())
- log.trace(relPath + "=" + resource);
- }
-
- }
-
- public void afterPropertiesSet() throws Exception {
- if (resourcePatternResolver == null)
- resourcePatternResolver = new PathMatchingResourcePatternResolver(
- getResourceLoaderToUse());
- if (include != null)
- addCommaSeparatedToList(include, includes);
- if (exclude != null)
- addCommaSeparatedToList(exclude, excludes);
-
- if (includes.size() == 0)
- includes.add("**");
-
- if (useDefaultExcludes)
- addCommaSeparatedToList(DEFAULT_EXCLUDES, excludes);
- }
-
- private void addCommaSeparatedToList(String str, List<String> lst) {
- StringTokenizer st = new StringTokenizer(str, ",");
- while (st.hasMoreTokens()) {
- String token = st.nextToken();
- if (!lst.contains(token))
- lst.add(token);
- }
- }
-
- public void setResourceLoader(ResourceLoader resourceLoader) {
- this.resourceLoader = resourceLoader;
- }
-
- /**
- * Can be overridden in order to provide the proper resource loader used to
- * resolve resources.
- */
- public ResourceLoader getResourceLoaderToUse() {
- return resourceLoader;
- }
-
- public void setBase(String base) {
- this.base = base;
- }
-
- public void setInclude(String include) {
- this.include = include;
- }
-
- public void setIncludes(List<String> includes) {
- this.includes = includes;
- }
-
- public void setExclude(String exclude) {
- this.exclude = exclude;
- }
-
- public void setExcludes(List<String> excludes) {
- this.excludes = excludes;
- }
-
- public void setUseDefaultExcludes(Boolean useDefaultExcludes) {
- this.useDefaultExcludes = useDefaultExcludes;
- }
-
- public void setExcludePathMatcher(PathMatcher excludePathMatcher) {
- this.excludePathMatcher = excludePathMatcher;
- }
-
- public void setResourcePatternResolver(
- ResourcePatternResolver resourcePatternResolver) {
- this.resourcePatternResolver = resourcePatternResolver;
- }
-
- public ResourcePatternResolver getResourcePatternResolver() {
- return resourcePatternResolver;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.deploy;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-import org.springframework.util.DigestUtils;
-
-/** Add Spring capabilities to {@link DigestUtils} */
-public class DigestCheck extends DigestUtils {
- public static String digest(String algorithm, Resource resource) {
- try {
- File file = resource.getFile();
- return org.argeo.util.DigestUtils.digest(algorithm, file);
- } catch (IOException e) {
- try {
- return org.argeo.util.DigestUtils.digest(algorithm,
- resource.getInputStream());
- } catch (IOException e1) {
- throw new SlcException("Cannot digest " + resource
- + " with algorithm " + algorithm, e);
- }
- }
- }
-}
+++ /dev/null
-package org.argeo.slc.core.deploy;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-public class LocalFilesDeployment implements Runnable {
- private String targetBase = "";
- private ResourceSet resourceSet;
-
- public LocalFilesDeployment() {
- }
-
- public LocalFilesDeployment(ResourceSet resourceSet) {
- this.resourceSet = resourceSet;
- }
-
- public void run() {
- Map<String, Resource> resources = resourceSet.listResources();
- for (String relPath : resources.keySet()) {
- File targetFile = new File(targetBase + File.separator + relPath);
- File parentDir = targetFile.getParentFile();
- if (!parentDir.exists())
- parentDir.mkdirs();
-
- Resource resource = resources.get(relPath);
-
- InputStream in = null;
- OutputStream out = null;
- try {
- in = resource.getInputStream();
- out = FileUtils.openOutputStream(targetFile);
- IOUtils.copy(in, out);
- } catch (IOException e) {
- throw new SlcException("Cannot extract " + resource + " to "
- + targetFile, e);
- } finally {
- IOUtils.closeQuietly(in);
- IOUtils.closeQuietly(out);
- }
- }
- }
-
- public void setTargetBase(String targetBase) {
- this.targetBase = targetBase;
- }
-
- public void setResourceSet(ResourceSet resourceSet) {
- this.resourceSet = resourceSet;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.deploy;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.springframework.core.io.Resource;
-
-public class MultiResourceSet implements ResourceSet {
- private List<ResourceSet> resourceSets = new ArrayList<ResourceSet>();
-
- public Map<String, Resource> listResources() {
- Map<String, Resource> res = new HashMap<String, Resource>();
- for (ResourceSet resourceSet : resourceSets) {
- res.putAll(resourceSet.listResources());
- }
- return res;
- }
-
- /** Last listed override previous for the same relative paths. */
- public void setResourceSets(List<ResourceSet> resourceSets) {
- this.resourceSets = resourceSets;
- }
-
- public List<ResourceSet> getResourceSets() {
- return resourceSets;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.deploy;
-
-import java.util.Map;
-
-import org.springframework.core.io.Resource;
-
-public interface ResourceSet {
- /**
- * List the resources, identified by their relative path. Relative paths
- * must NOT start with a '/'.
- */
- public Map<String, Resource> listResources();
-}
+++ /dev/null
-package org.argeo.slc.core.deploy;
-
-import java.io.File;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.InstalledExecutables;
-import org.argeo.slc.deploy.TargetData;
-
-public class SimpleExecutables implements InstalledExecutables {
- private final static Log log = LogFactory.getLog(SimpleExecutables.class);
-
- private String baseDir;
- private Map<String, String> paths = new TreeMap<String, String>();
-
- private Distribution distribution;
-
- public String getExecutablePath(String key) {
- String path = paths.get(key);
- if (path == null) {
- if (log.isDebugEnabled())
- log.debug("No executable path found for key " + key
- + ", using the key as executable name.");
- path = key;
- }
-
- if (baseDir != null)
- path = baseDir + File.separator + path;
- return path;
- }
-
- public String getDeployedSystemId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public DeploymentData getDeploymentData() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Distribution getDistribution() {
- return distribution;
- }
-
- public TargetData getTargetData() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getBaseDir() {
- return baseDir;
- }
-
- public void setBaseDir(String baseDir) {
- this.baseDir = baseDir;
- }
-
- public Map<String, String> getPaths() {
- return paths;
- }
-
- public void setPaths(Map<String, String> paths) {
- this.paths = paths;
- }
-
- public void setDistribution(Distribution distribution) {
- this.distribution = distribution;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.deploy;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.deploy.VersioningDriver;
-
-/**
- * Synchronizes an URL to a local directory, taking into account versioning
- * information if possible.
- */
-public class VersionedDirSync implements Runnable {
- private final static Log log = LogFactory.getLog(VersionedDirSync.class);
-
- private VersioningDriver versioningDriver;
- private File dir;
- private String url;
- private Boolean clean = false;
-
- private Boolean changed = null;
-
- public void run() {
- changed = null;
- if (clean) {
- try {
- log.info("Clean " + dir);
- FileUtils.deleteDirectory(dir);
- } catch (IOException e) {
- throw new SlcException("Cannot delete checkout directory "
- + dir, e);
- }
- dir.mkdirs();
- }
- log.info("Checkout " + url + " to " + dir);
- changed = versioningDriver.checkout(url, dir, true);
- if (log.isDebugEnabled())
- log.debug("Synchronized " + url + " to " + dir);
- }
-
- public void setVersioningDriver(VersioningDriver versioningDriver) {
- this.versioningDriver = versioningDriver;
- }
-
- public void setDir(File dir) {
- this.dir = dir;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- /** Delete before checkout */
- public void setClean(Boolean clean) {
- this.clean = clean;
- }
-
- /** Whether last call has changed the directory */
- public Boolean getChanged() {
- if (changed == null)
- throw new SlcException("Sync has not run");
- return changed;
- }
-
-}
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-SLC Deploy: deployment of software systems.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.GenericBeanDefinition;
-import org.springframework.core.Ordered;
-import org.springframework.core.PriorityOrdered;
-
-public abstract class AbstractExecutionFlowGenerator implements
- BeanFactoryPostProcessor, PriorityOrdered {
- private final Log log = LogFactory.getLog(getClass());
-
- protected abstract Map<String, BeanDefinition> createExecutionFlowDefinitions(
- ConfigurableListableBeanFactory beanFactory);
-
- public void postProcessBeanFactory(
- ConfigurableListableBeanFactory beanFactory) throws BeansException {
- if (!(beanFactory instanceof BeanDefinitionRegistry)) {
- throw new SlcException("Can only work on "
- + BeanDefinitionRegistry.class);
- }
-
- Map<String, BeanDefinition> definitions = createExecutionFlowDefinitions(beanFactory);
-
- for (String beanName : definitions.keySet()) {
- if (log.isTraceEnabled())
- log.debug("Registering execution flow " + beanName);
- ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(
- beanName, definitions.get(beanName));
- }
- }
-
- protected GenericBeanDefinition createDefaultFlowDefinition(
- List<Runnable> executables) {
- GenericBeanDefinition bd = new GenericBeanDefinition();
- bd.setBeanClass(DefaultExecutionFlow.class);
-
- MutablePropertyValues mpv = new MutablePropertyValues();
- mpv.addPropertyValue("executables", executables);
-
- bd.setPropertyValues(mpv);
- return bd;
- }
-
- public int getOrder() {
- return Ordered.HIGHEST_PRECEDENCE;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import org.argeo.slc.execution.ExecutionModule;
-
-@Deprecated
-public abstract class AbstractSpringExecutionModule implements ExecutionModule
- {
-/*
- protected ApplicationContext applicationContext;
-
- protected ExecutionContext executionContext;
-
- protected ExecutionFlowDescriptorConverter descriptorConverter = new DefaultDescriptorConverter();
-
- public ExecutionModuleDescriptor getDescriptor() {
- ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
- md.setName(getName());
- md.setVersion(getVersion());
-
- Map<String, ExecutionFlow> executionFlows = listFlows();
- for (String name : executionFlows.keySet()) {
- ExecutionFlow executionFlow = executionFlows.get(name);
-
- Assert.notNull(executionFlow.getName());
- Assert.state(name.equals(executionFlow.getName()));
-
- ExecutionSpec executionSpec = executionFlow.getExecutionSpec();
- Assert.notNull(executionSpec);
- Assert.notNull(executionSpec.getName());
-
- Map<String, Object> values = new TreeMap<String, Object>();
- for (String key : executionSpec.getAttributes().keySet()) {
- ExecutionSpecAttribute attribute = executionSpec
- .getAttributes().get(key);
-
- if (executionFlow.isSetAsParameter(key)) {
- Object value = executionFlow.getParameter(key);
- if (attribute instanceof PrimitiveSpecAttribute) {
- PrimitiveValue primitiveValue = new PrimitiveValue();
- primitiveValue
- .setType(((PrimitiveSpecAttribute) attribute)
- .getType());
- primitiveValue.setValue(value);
- values.put(key, primitiveValue);
- } else if (attribute instanceof RefSpecAttribute) {
- RefValue refValue = new RefValue();
- if (value instanceof ScopedObject) {
- refValue.setLabel("RUNTIME "
- + value.getClass().getName());
- } else {
- refValue.setLabel("STATIC "
- + value.getClass().getName());
- }
- values.put(key, refValue);
- } else if (attribute instanceof ResourceSpecAttribute) {
- PrimitiveValue primitiveValue = new PrimitiveValue();
- primitiveValue
- .setType(((ResourceSpecAttribute) attribute)
- .getType());
- primitiveValue.setValue(value);
- values.put(key, primitiveValue);
- } else {
- throw new SlcException("Unkown spec attribute type "
- + attribute.getClass());
- }
- }
-
- }
-
- ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name,
- values, executionSpec);
- if (executionFlow.getPath() != null)
- efd.setPath(executionFlow.getPath());
-
- // Add execution spec if necessary
- if (!md.getExecutionSpecs().contains(executionSpec))
- md.getExecutionSpecs().add(executionSpec);
-
- // Add execution flow
- md.getExecutionFlows().add(efd);
- }
-
- return md;
- }
-
- protected Map<String, ExecutionFlow> listFlows() {
- GenericBeanFactoryAccessor accessor = new GenericBeanFactoryAccessor(
- applicationContext);
- Map<String, ExecutionFlow> executionFlows = accessor
- .getBeansOfType(ExecutionFlow.class);
- return executionFlows;
- }
-
- public void execute(ExecutionFlowDescriptor executionFlowDescriptor) {
- if (descriptorConverter != null)
- executionContext.addVariables(descriptorConverter
- .convertValues(executionFlowDescriptor));
- ExecutionFlow flow = (ExecutionFlow) applicationContext.getBean(
- executionFlowDescriptor.getName(), ExecutionFlow.class);
- flow.run();
- }
-
- public void setApplicationContext(ApplicationContext applicationContext)
- throws BeansException {
- this.applicationContext = applicationContext;
- }
-
- public void setExecutionContext(ExecutionContext executionContext) {
- this.executionContext = executionContext;
- }
-
- public void setDescriptorConverter(
- ExecutionFlowDescriptorConverter descriptorConverter) {
- this.descriptorConverter = descriptorConverter;
- }*/
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-/** Implements the base methods of an SLC agent. */
-@Deprecated
-public class DefaultAgent extends org.argeo.slc.runtime.DefaultAgent {
-
- public DefaultAgent() {
- super();
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-/**
- * Authenticates thread and executes synchronously a command line execution.
- * Reference implementation of args to URIs algorithm.
- */
-@Deprecated
-public class DefaultAgentCli extends org.argeo.slc.runtime.DefaultAgentCli {
-
- public DefaultAgentCli() {
- super();
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.util.Map;
-
-import org.argeo.slc.execution.ExecutionSpec;
-import org.springframework.beans.factory.BeanNameAware;
-import org.springframework.beans.factory.InitializingBean;
-
-/** Default implementation of an execution flow. */
-@Deprecated
-public class DefaultExecutionFlow extends org.argeo.slc.runtime.DefaultExecutionFlow
- implements InitializingBean, BeanNameAware {
- public DefaultExecutionFlow() {
- super();
- }
-
- public DefaultExecutionFlow(ExecutionSpec executionSpec, Map<String, Object> parameters) {
- super(executionSpec, parameters);
- }
-
- public DefaultExecutionFlow(ExecutionSpec executionSpec) {
- super(executionSpec);
- }
-
- public void afterPropertiesSet() throws Exception {
- init();
- }
-
- public void setBeanName(String name) {
- setName(name);
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
-import org.argeo.slc.execution.ExecutionModuleDescriptor;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.FlowConfigurationException;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValue;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveUtils;
-import org.argeo.slc.primitive.PrimitiveValue;
-import org.springframework.aop.scope.ScopedObject;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.util.StringUtils;
-
-/**
- * Performs conversion in both direction between data exchanged with the agent
- * and the data in the application context.
- */
-public class DefaultExecutionFlowDescriptorConverter implements
- ExecutionFlowDescriptorConverter, ApplicationContextAware {
- public final static String REF_VALUE_TYPE_BEAN_NAME = "beanName";
-
- /** Workaround for https://www.spartadn.com/bugzilla/show_bug.cgi?id=206 */
- private final static String REF_VALUE_INTERNAL = "[internal]";
-
- private final static Log log = LogFactory
- .getLog(DefaultExecutionFlowDescriptorConverter.class);
-
- private ApplicationContext applicationContext;
-
- @SuppressWarnings("unused")
- public Map<String, Object> convertValues(
- ExecutionFlowDescriptor executionFlowDescriptor) {
- Map<String, Object> values = executionFlowDescriptor.getValues();
- Map<String, Object> convertedValues = new HashMap<String, Object>();
- ExecutionSpec executionSpec = executionFlowDescriptor
- .getExecutionSpec();
-
- if (executionSpec == null && log.isTraceEnabled())
- log.warn("Execution spec is null for " + executionFlowDescriptor);
-
- if (values != null && executionSpec != null) {
- values: for (String key : values.keySet()) {
- ExecutionSpecAttribute attribute = executionSpec
- .getAttributes().get(key);
-
- if (attribute == null)
- throw new FlowConfigurationException(
- "No spec attribute defined for '" + key + "'");
-
- if (attribute.getIsConstant())
- continue values;
-
- Object value = values.get(key);
- if (value instanceof PrimitiveValue) {
- PrimitiveValue primitiveValue = (PrimitiveValue) value;
- // TODO: check class <=> type
- convertedValues.put(key, primitiveValue.getValue());
- } else if (value instanceof RefValue) {
- RefValue refValue = (RefValue) value;
- String type = refValue.getType();
- if (REF_VALUE_TYPE_BEAN_NAME.equals(type)) {
- // FIXME: UI should send all information about spec
- // - targetClass
- // - name
- // String executionSpecName = executionSpec.getName();
- // ExecutionSpec localSpec = (ExecutionSpec)
- // applicationContext
- // .getBean(executionSpecName);
- // RefSpecAttribute localAttr = (RefSpecAttribute)
- // localSpec
- // .getAttributes().get(key);
- // Class<?> targetClass = localAttr.getTargetClass();
- //
- // String primitiveType = PrimitiveUtils
- // .classAsType(targetClass);
- String primitiveType = null;
- if (primitiveType != null) {
- // not active
- String ref = refValue.getRef();
- Object obj = PrimitiveUtils.convert(primitiveType,
- ref);
- convertedValues.put(key, obj);
- } else {
- String ref = refValue.getRef();
- if (ref != null && !ref.equals(REF_VALUE_INTERNAL)) {
- Object obj = null;
- if (applicationContext.containsBean(ref)) {
- obj = applicationContext.getBean(ref);
- } else {
- // FIXME: hack in order to pass primitive
- obj = ref;
- }
- convertedValues.put(key, obj);
- } else {
- log.warn("Cannot interpret " + refValue);
- }
- }
- } else if (PrimitiveUtils.typeAsClass(type) != null) {
- String ref = refValue.getRef();
- Object obj = PrimitiveUtils.convert(type, ref);
- convertedValues.put(key, obj);
- } else {
- throw new FlowConfigurationException(
- "Ref value type not supported: "
- + refValue.getType());
- }
- } else {
- // default is to take the value as is
- convertedValues.put(key, value);
- }
- }
- }
- return convertedValues;
- }
-
- public void addFlowsToDescriptor(ExecutionModuleDescriptor md,
- Map<String, ExecutionFlow> executionFlows) {
- SortedSet<ExecutionFlowDescriptor> set = new TreeSet<ExecutionFlowDescriptor>(
- new ExecutionFlowDescriptorComparator());
- for (String name : executionFlows.keySet()) {
- ExecutionFlow executionFlow = executionFlows.get(name);
-
- ExecutionFlowDescriptor efd = getExecutionFlowDescriptor(executionFlow);
- ExecutionSpec executionSpec = efd.getExecutionSpec();
-
- // Add execution spec if necessary
- if (!md.getExecutionSpecs().contains(executionSpec))
- md.getExecutionSpecs().add(executionSpec);
-
- // Add execution flow
- set.add(efd);
- // md.getExecutionFlows().add(efd);
- }
- md.getExecutionFlows().addAll(set);
- }
-
- public ExecutionFlowDescriptor getExecutionFlowDescriptor(
- ExecutionFlow executionFlow) {
- if (executionFlow.getName() == null)
- throw new FlowConfigurationException("Flow name is null: "
- + executionFlow);
- String name = executionFlow.getName();
-
- ExecutionSpec executionSpec = executionFlow.getExecutionSpec();
- if (executionSpec == null)
- throw new FlowConfigurationException("Execution spec is null: "
- + executionFlow);
- if (executionSpec.getName() == null)
- throw new FlowConfigurationException(
- "Execution spec name is null: " + executionSpec);
-
- Map<String, Object> values = new TreeMap<String, Object>();
- for (String key : executionSpec.getAttributes().keySet()) {
- ExecutionSpecAttribute attribute = executionSpec.getAttributes()
- .get(key);
-
- if (attribute instanceof PrimitiveSpecAttribute) {
- if (executionFlow.isSetAsParameter(key)) {
- Object value = executionFlow.getParameter(key);
- PrimitiveValue primitiveValue = new PrimitiveValue();
- primitiveValue.setType(((PrimitiveSpecAttribute) attribute)
- .getType());
- primitiveValue.setValue(value);
- values.put(key, primitiveValue);
- } else {
- // no need to add a primitive value if it is not set,
- // all necessary information is in the spec
- }
- } else if (attribute instanceof RefSpecAttribute) {
- if (attribute.getIsConstant()) {
- values.put(key, new RefValue(REF_VALUE_INTERNAL));
- } else
- values.put(
- key,
- buildRefValue((RefSpecAttribute) attribute,
- executionFlow, key));
- } else {
- throw new FlowConfigurationException(
- "Unkown spec attribute type " + attribute.getClass());
- }
-
- }
-
- ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(name, null,
- values, executionSpec);
- // Takes description from spring
- BeanFactory bf = getBeanFactory();
- if (bf != null) {
- BeanDefinition bd = getBeanFactory().getBeanDefinition(name);
- efd.setDescription(bd.getDescription());
- }
- return efd;
- }
-
- protected RefValue buildRefValue(RefSpecAttribute rsa,
- ExecutionFlow executionFlow, String key) {
- RefValue refValue = new RefValue();
- // FIXME: UI should be able to deal with other types
- refValue.setType(REF_VALUE_TYPE_BEAN_NAME);
- Class<?> targetClass = rsa.getTargetClass();
- String primitiveType = PrimitiveUtils.classAsType(targetClass);
- if (primitiveType != null) {
- if (executionFlow.isSetAsParameter(key)) {
- Object value = executionFlow.getParameter(key);
- refValue.setRef(value.toString());
- }
- refValue.setType(primitiveType);
- return refValue;
- } else {
-
- if (executionFlow.isSetAsParameter(key)) {
- String ref = null;
- Object value = executionFlow.getParameter(key);
- if (applicationContext == null) {
- log.warn("No application context declared, cannot scan ref value.");
- ref = value.toString();
- } else {
-
- // look for a ref to the value
- Map<String, ?> beans = getBeanFactory()
- .getBeansOfType(targetClass, false, false);
- // TODO: also check scoped beans
- beans: for (String beanName : beans.keySet()) {
- Object obj = beans.get(beanName);
- if (value instanceof ScopedObject) {
- // don't call methods of the target of the scope
- if (obj instanceof ScopedObject)
- if (value == obj) {
- ref = beanName;
- break beans;
- }
- } else {
- if (obj.equals(value)) {
- ref = beanName;
- break beans;
- }
- }
- }
- }
- if (ref == null) {
- if (log.isTraceEnabled())
- log.trace("Cannot define reference for ref spec attribute "
- + key
- + " in "
- + executionFlow
- + " ("
- + rsa
- + ")."
- + " If it is an inner bean consider put it frozen.");
- ref = REF_VALUE_INTERNAL;
- } else {
- if (log.isTraceEnabled())
- log.trace(ref
- + " is the reference for ref spec attribute "
- + key + " in " + executionFlow + " (" + rsa
- + ")");
- }
- refValue.setRef(ref);
- }
- return refValue;
- }
- }
-
- /** @return can be null */
- private ConfigurableListableBeanFactory getBeanFactory() {
- if (applicationContext == null)
- return null;
- return ((ConfigurableApplicationContext) applicationContext)
- .getBeanFactory();
- }
-
- /** Must be use within the execution application context */
- public void setApplicationContext(ApplicationContext applicationContext)
- throws BeansException {
- this.applicationContext = applicationContext;
- }
-
- private static class ExecutionFlowDescriptorComparator implements
- Comparator<ExecutionFlowDescriptor> {
- @SuppressWarnings("deprecation")
- public int compare(ExecutionFlowDescriptor o1,
- ExecutionFlowDescriptor o2) {
- // TODO: write unit tests for this
-
- String name1 = o1.getName();
- String name2 = o2.getName();
-
- String path1 = o1.getPath();
- String path2 = o2.getPath();
-
- // Check whether name include path
- int lastIndex1 = name1.lastIndexOf('/');
- // log.debug(name1+", "+lastIndex1);
- if (!StringUtils.hasText(path1) && lastIndex1 >= 0) {
- path1 = name1.substring(0, lastIndex1);
- name1 = name1.substring(lastIndex1 + 1);
- }
-
- int lastIndex2 = name2.lastIndexOf('/');
- if (!StringUtils.hasText(path2) && lastIndex2 >= 0) {
- path2 = name2.substring(0, lastIndex2);
- name2 = name2.substring(lastIndex2 + 1);
- }
-
- // Perform the actual comparison
- if (StringUtils.hasText(path1) && StringUtils.hasText(path2)) {
- if (path1.equals(path2))
- return name1.compareTo(name2);
- else if (path1.startsWith(path2))
- return -1;
- else if (path2.startsWith(path1))
- return 1;
- else
- return path1.compareTo(path2);
- } else if (!StringUtils.hasText(path1)
- && StringUtils.hasText(path2)) {
- return 1;
- } else if (StringUtils.hasText(path1)
- && !StringUtils.hasText(path2)) {
- return -1;
- } else if (!StringUtils.hasText(path1)
- && !StringUtils.hasText(path2)) {
- return name1.compareTo(name2);
- } else {
- return 0;
- }
- }
-
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValueChoice;
-import org.springframework.beans.factory.BeanNameAware;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ConfigurableApplicationContext;
-
-/** Spring based implementation of execution specifications. */
-@Deprecated
-public class DefaultExecutionSpec extends org.argeo.slc.runtime.DefaultExecutionSpec
- implements BeanNameAware, ApplicationContextAware, InitializingBean {
- private static final long serialVersionUID = 5159882223926926539L;
- private final static Log log = LogFactory.getLog(DefaultExecutionSpec.class);
- private transient ApplicationContext applicationContext;
-
- public DefaultExecutionSpec() {
- super();
- }
-
- public void setBeanName(String name) {
- setName(name);
- }
-
- private ConfigurableListableBeanFactory getBeanFactory() {
- return ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
- }
-
- public void setApplicationContext(ApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
-
- public void afterPropertiesSet() throws Exception {
- if (getDescription() == null) {
- try {
- setDescription(getBeanFactory().getBeanDefinition(getName()).getDescription());
- } catch (NoSuchBeanDefinitionException e) {
- // silent
- }
- }
-
- for (String key : getAttributes().keySet()) {
- ExecutionSpecAttribute attr = getAttributes().get(key);
- if (attr instanceof RefSpecAttribute) {
- RefSpecAttribute rsa = (RefSpecAttribute) attr;
- if (rsa.getChoices() == null) {
- List<RefValueChoice> choices = buildRefValueChoices(rsa);
- rsa.setChoices(choices);
- }
- if (log.isTraceEnabled())
- log.debug("Spec attr " + key + " has " + rsa.getChoices().size() + " choices");
- }
- }
- }
-
- /**
- * Generates a list of ref value choices based on the bean available in the
- * application context.
- */
- protected List<RefValueChoice> buildRefValueChoices(RefSpecAttribute rsa) {
- List<RefValueChoice> choices = new ArrayList<RefValueChoice>();
- if (applicationContext == null) {
- log.warn("No application context declared," + " cannot scan ref value choices.");
- return choices;
- }
-
- beanNames: for (String beanName : getBeanFactory().getBeanNamesForType(rsa.getTargetClass(), true, false)) {
-
- // Since Spring 3, systemProperties is implicitly defined but has no
- // bean definition
- if (beanName.equals("systemProperties"))
- continue beanNames;
-
- BeanDefinition bd = getBeanFactory().getBeanDefinition(beanName);
- RefValueChoice choice = new RefValueChoice();
- choice.setName(beanName);
- choice.setDescription(bd.getDescription());
- if (log.isTraceEnabled())
- log.debug("Found choice " + beanName + " for " + rsa);
-
- choices.add(choice);
-
- }
- return choices;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionStack;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-
-@Aspect
-/** Aspect intercepting calls on execution flows and contexts. */
-public class ExecutionAspect {
- private final static Log log = LogFactory.getLog(ExecutionAspect.class);
-
- private ExecutionStack executionStack;
- private ExecutionContext executionContext;
-
- @Around("flowExecution()")
- public void aroundFlow(ProceedingJoinPoint pjp) throws Throwable {
- // IMPORTANT: Make sure that the execution context is called before the
- // execution stack
- executionContext.getUuid();
-
- ExecutionFlow executionFlow = (ExecutionFlow) pjp.getTarget();
- executionStack.enterFlow(executionFlow);
- executionContext.setVariable(ExecutionContext.VAR_FLOW_ID,
- executionStack.getCurrentStackLevelUuid());
- executionContext.setVariable(ExecutionContext.VAR_FLOW_NAME,
- executionFlow.getName());
-
- logStackEvent("=> ", executionFlow);
- try {
- // Actually execute the flow
- pjp.proceed();
- } finally {
- logStackEvent("<= ", executionFlow);
- executionStack.leaveFlow(executionFlow);
- }
- }
-
- @Around("getVariable()")
- public Object aroundGetVariable(ProceedingJoinPoint pjp) throws Throwable {
- Object obj = pjp.proceed();
- // if the variable was not found, look in the stack starting at the
- // upper flows
- if (obj == null) {
- String key = pjp.getArgs()[0].toString();
- obj = executionStack.findLocalVariable(key);
- }
- return obj;
- }
-
- @Pointcut("execution(void org.argeo.slc.execution.ExecutionFlow.run())")
- public void flowExecution() {
- }
-
- @Pointcut("execution(* org.argeo.slc.execution.ExecutionContext.getVariable(..))")
- public void getVariable() {
- }
-
- public void setExecutionStack(ExecutionStack executionStack) {
- this.executionStack = executionStack;
- }
-
- public void setExecutionContext(ExecutionContext executionContext) {
- this.executionContext = executionContext;
- }
-
- protected void logStackEvent(String symbol, ExecutionFlow executionFlow) {
- Integer stackSize = executionStack.getStackSize();
- if (log.isTraceEnabled())
- log.debug(depthSpaces(stackSize) + symbol + executionFlow + " #"
- + executionStack.getCurrentStackLevelUuid() + ", depth="
- + stackSize);
- if (log.isDebugEnabled())
- log.debug(depthSpaces(stackSize) + symbol + executionFlow);
- }
-
- protected void logRunnableExecution(ExecutionFlow executionFlow,
- Runnable runnable) {
- Integer stackSize = executionStack.getStackSize();
- if (log.isDebugEnabled())
- log.debug(depthSpaces(stackSize + 1)
- + runnable.getClass().getSimpleName() + " in "
- + executionFlow);
- }
-
- private String depthSpaces(int depth) {
- StringBuffer buf = new StringBuffer(depth * 2);
- for (int i = 0; i < depth; i++)
- buf.append(" ");
- return buf.toString();
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.beans.PropertyDescriptor;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.runtime.InstantiationManager;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.PropertyValue;
-import org.springframework.beans.PropertyValues;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
-import org.springframework.beans.factory.config.TypedStringValue;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.ManagedMap;
-import org.springframework.beans.factory.support.ManagedSet;
-import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
-
-/**
- * Spring post processor which ensures that execution parameters are properly
- * set. It is used at two levels: first during instantiation for instantiation
- * parameters which allow to implement templates, then at runtime in order to
- * interpret @{} placeholders when object of scope execution are instantiated.
- */
-public class ExecutionParameterPostProcessor extends
- InstantiationAwareBeanPostProcessorAdapter {
-
- private final static Log log = LogFactory
- .getLog(ExecutionParameterPostProcessor.class);
-
- private ExecutionContext executionContext;
- private InstantiationManager instantiationManager;
-
- private String placeholderPrefix = "@{";
- private String placeholderSuffix = "}";
- private String nullValue;
-
- @Override
- public PropertyValues postProcessPropertyValues(PropertyValues pvs,
- PropertyDescriptor[] pds, Object bean, String beanName)
- throws BeansException {
-
- // TODO: resolve at execution only if scope is execution
- // TODO: deal with placeholders in RuntimeBeanReference and
- // RuntimeBeanNameReference
-
- MutablePropertyValues newPvs = new MutablePropertyValues();
-
- boolean changesOccured = false;
-
- for (PropertyValue pv : pvs.getPropertyValues()) {
- Object convertedValue = resolveValue(beanName, bean, pv.getValue());
- newPvs.addPropertyValue(new PropertyValue(pv, convertedValue));
- if (convertedValue != pv.getValue()) {
- changesOccured = true;
- }
- }
-
- return changesOccured ? newPvs : pvs;
- }
-
- @Override
- public boolean postProcessAfterInstantiation(Object bean, String beanName)
- throws BeansException {
- if (bean instanceof ExecutionFlow)
- instantiationManager.flowInitializationStarted(
- (ExecutionFlow) bean, beanName);
- return true;
- }
-
- @Override
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
- if (bean instanceof ExecutionFlow)
- instantiationManager.flowInitializationFinished(
- (ExecutionFlow) bean, beanName);
- return bean;
- }
-
- protected String resolvePlaceholder(Object bean, String placeholder) {
- if (instantiationManager.isInFlowInitialization())
- return instantiationManager.getInitializingFlowParameter(
- placeholder).toString();
-
- else {// execution
- // next call fail if no execution context available
- Object obj = executionContext.getVariable(placeholder);
- if (obj != null) {
- return obj.toString();
- }
- }
-
- return null;
- }
-
- public Object resolveValue(String beanName, Object bean, Object value) {
- if (value instanceof TypedStringValue) {
- TypedStringValue tsv = (TypedStringValue) value;
- String originalValue = tsv.getValue();
-
- String convertedValue = resolveString(beanName, bean, originalValue);
- if (convertedValue == null)
- return null;
- return convertedValue.equals(originalValue) ? value
- : new TypedStringValue(convertedValue);
- } else if (value instanceof String) {
- String originalValue = value.toString();
- String convertedValue = resolveString(beanName, bean, originalValue);
- if (convertedValue == null)
- return null;
- return convertedValue.equals(originalValue) ? value
- : convertedValue;
- } else if (value instanceof ManagedMap) {
- Map<?, ?> mapVal = (Map<?, ?>) value;
-
- Map<Object, Object> newContent = new ManagedMap<Object, Object>();
- boolean entriesModified = false;
- for (Iterator<?> it = mapVal.entrySet().iterator(); it.hasNext();) {
- Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
- Object key = entry.getKey();
- int keyHash = (key != null ? key.hashCode() : 0);
- Object newKey = resolveValue(beanName, bean, key);
- int newKeyHash = (newKey != null ? newKey.hashCode() : 0);
- Object val = entry.getValue();
- Object newVal = resolveValue(beanName, bean, val);
- newContent.put(newKey, newVal);
- entriesModified = entriesModified
- || (newVal != val || newKey != key || newKeyHash != keyHash);
- }
-
- return entriesModified ? newContent : value;
- } else if (value instanceof ManagedList) {
- List<?> listVal = (List<?>) value;
- List<Object> newContent = new ManagedList<Object>();
- boolean valueModified = false;
-
- for (int i = 0; i < listVal.size(); i++) {
- Object elem = listVal.get(i);
- Object newVal = resolveValue(beanName, bean, elem);
- newContent.add(newVal);
- if (!ObjectUtils.nullSafeEquals(newVal, elem)) {
- valueModified = true;
- }
- }
- return valueModified ? newContent : value;
- } else if (value instanceof ManagedSet) {
- Set<?> setVal = (Set<?>) value;
- Set<Object> newContent = new ManagedSet<Object>();
- boolean entriesModified = false;
- for (Iterator<?> it = setVal.iterator(); it.hasNext();) {
- Object elem = it.next();
- int elemHash = (elem != null ? elem.hashCode() : 0);
- Object newVal = resolveValue(beanName, bean, elem);
- int newValHash = (newVal != null ? newVal.hashCode() : 0);
- newContent.add(newVal);
- entriesModified = entriesModified
- || (newVal != elem || newValHash != elemHash);
- }
- return entriesModified ? newContent : value;
- } else {
- // log.debug(beanName + ": " + value.getClass() + " : " + value);
- return value;
- }
-
- }
-
- private String resolveString(String beanName, Object bean, String strVal) {
- // in case <null/> is passed
- if (strVal == null)
- return null;
-
- String value = parseStringValue(bean, strVal, new HashSet<String>());
-
- if (value == null)
- throw new SlcException("Could not resolve placeholder '" + strVal
- + "' in bean '" + beanName + "'");
-
- return (value.equals(nullValue) ? null : value);
- }
-
- public void setPlaceholderPrefix(String placeholderPrefix) {
- this.placeholderPrefix = placeholderPrefix;
- }
-
- public void setPlaceholderSuffix(String placeholderSuffix) {
- this.placeholderSuffix = placeholderSuffix;
- }
-
- public void setNullValue(String nullValue) {
- this.nullValue = nullValue;
- }
-
- public void setInstantiationManager(
- InstantiationManager instantiationManager) {
- this.instantiationManager = instantiationManager;
- }
-
- public void setExecutionContext(ExecutionContext executionContext) {
- this.executionContext = executionContext;
- }
-
- //
- // Following methods hacked from the internals of
- // PropertyPlaceholderConfigurer
- //
-
- protected String parseStringValue(Object bean, String strVal,
- Set<String> visitedPlaceholders)
- throws BeanDefinitionStoreException {
-
- // in case <null/> is passed
- if (strVal == null)
- return null;
-
- StringBuffer buf = new StringBuffer(strVal);
-
- int startIndex = strVal.indexOf(placeholderPrefix);
- while (startIndex != -1) {
- int endIndex = findPlaceholderEndIndex(buf, startIndex);
- if (endIndex != -1) {
- String placeholder = buf.substring(startIndex
- + placeholderPrefix.length(), endIndex);
- if (!visitedPlaceholders.add(placeholder)) {
- throw new BeanDefinitionStoreException(
- "Circular placeholder reference '" + placeholder
- + "' in property definitions");
- }
- // Recursive invocation, parsing placeholders contained in
- // the placeholder key.
- placeholder = parseStringValue(bean, placeholder,
- visitedPlaceholders);
- // Now obtain the value for the fully resolved key...
- String propVal = resolvePlaceholder(bean, placeholder);
- if (propVal != null) {
- // Recursive invocation, parsing placeholders contained
- // in the
- // previously resolved placeholder value.
- propVal = parseStringValue(bean, propVal,
- visitedPlaceholders);
- buf.replace(startIndex,
- endIndex + placeholderSuffix.length(), propVal);
- if (log.isTraceEnabled()) {
- log.trace("Resolved placeholder '" + placeholder + "'");
- }
- startIndex = buf.indexOf(placeholderPrefix, startIndex
- + propVal.length());
- } else {
- throw new BeanDefinitionStoreException(
- "Could not resolve placeholder '" + placeholder
- + "'");
- }
- visitedPlaceholders.remove(placeholder);
- } else {
- startIndex = -1;
- }
- }
-
- return buf.toString();
- }
-
- private int findPlaceholderEndIndex(CharSequence buf, int startIndex) {
- int index = startIndex + placeholderPrefix.length();
- int withinNestedPlaceholder = 0;
- while (index < buf.length()) {
- if (StringUtils.substringMatch(buf, index, placeholderSuffix)) {
- if (withinNestedPlaceholder > 0) {
- withinNestedPlaceholder--;
- index = index + placeholderSuffix.length();
- } else {
- return index;
- }
- } else if (StringUtils
- .substringMatch(buf, index, placeholderPrefix)) {
- withinNestedPlaceholder++;
- index = index + placeholderPrefix.length();
- } else {
- index++;
- }
- }
- return -1;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-
-import org.springframework.core.io.Resource;
-
-/** Provides write access to resources during execution */
-public interface ExecutionResources {
- /** The base directory where this execution can write */
- public File getWritableBaseDir();
-
- /** Allocates a local file in the writable area and return it as a resource. */
- public Resource getWritableResource(String relativePath);
-
- /**
- * Allocates a local file in the writable area and return it as a fully
- * qualified OS path.
- */
- public String getWritableOsPath(String relativePath);
-
- /**
- * Allocates a local file in the writable area and return it as a
- * {@link File}.
- */
- public File getWritableOsFile(String relativePath);
-
- /**
- * Returns the resource as a file path. If the resource is not writable it
- * is copied as a file in the writable area and the path to this local file
- * is returned.
- */
- public String getAsOsPath(Resource resource, Boolean overwrite);
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.core.io.Resource;
-import org.springframework.util.Assert;
-
-/** Workaround when execution placedholders needs to be passed. */
-public class ExecutionResourcesFactoryBean implements FactoryBean<Resource> {
- private ExecutionResources executionResources;
- private String relativePath;
-
- public Resource getObject() throws Exception {
- Assert.notNull(executionResources, "executionResources is null");
- Assert.notNull(relativePath, "relativePath is null");
- return executionResources.getWritableResource(relativePath);
- }
-
- public Class<? extends Object> getObjectType() {
- return Resource.class;
- }
-
- public boolean isSingleton() {
- return true;
- }
-
- public void setExecutionResources(ExecutionResources executionResources) {
- this.executionResources = executionResources;
- }
-
- public void setRelativePath(String relativePath) {
- this.relativePath = relativePath;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.argeo.slc.execution.ExecutionStack;
-import org.argeo.slc.runtime.ExecutionThread;
-import org.springframework.beans.factory.ObjectFactory;
-import org.springframework.beans.factory.config.Scope;
-
-/**
- * When Spring beans are instantiated with this scope, the same instance is
- * reused across an execution.
- */
-public class ExecutionScope implements Scope {
- private final static Log log = LogFactory.getLog(ExecutionScope.class);
-
- private final ThreadLocal<ExecutionStack> executionStack = new ThreadLocal<ExecutionStack>();
- public final ThreadLocal<String> executionStackBeanName = new ThreadLocal<String>();
-
- private final ThreadLocal<ExecutionContext> executionContext = new ThreadLocal<ExecutionContext>();
- private final ThreadLocal<String> executionContextBeanName = new ThreadLocal<String>();
-
- public Object get(String name, ObjectFactory<?> objectFactory) {
- if (log.isTraceEnabled())
- log.debug("Get execution scoped bean " + name);
-
- // shortcuts
- if (executionStackBeanName.get() != null
- && name.equals(executionStackBeanName.get())) {
- return executionStack.get();
- }
-
- if (executionContextBeanName.get() != null
- && name.equals(executionContextBeanName.get())) {
- return executionContext.get();
- }
-
- // execution context must be defined first
- if (executionContext.get() == null) {
- Object obj = objectFactory.getObject();
- if (obj instanceof ExecutionContext) {
- return dealWithSpecialScopedObject(name, executionContext,
- executionContextBeanName, (ExecutionContext) obj);
- } else {
- // TODO: use execution context wrapper
- throw new SlcException("No execution context has been defined.");
- }
- }
-
- // for other scoped objects, an executions stack must be available
- if (executionStack.get() == null) {
- Object obj = objectFactory.getObject();
- if (obj instanceof ExecutionStack) {
- return dealWithSpecialScopedObject(name, executionStack,
- executionStackBeanName, (ExecutionStack) obj);
- } else {
- throw new SlcException("No execution stack has been defined.");
- }
- }
-
- // see if the execution stack already knows the object
- Object obj = executionStack.get().findScopedObject(name);
- if (obj == null) {
- obj = objectFactory.getObject();
- if (obj instanceof ExecutionContext)
- throw new SlcException(
- "Only one execution context can be defined per thread");
- if (obj instanceof ExecutionStack)
- throw new SlcException(
- "Only one execution stack can be defined per thread");
-
- checkForbiddenClasses(obj);
-
- executionStack.get().addScopedObject(name, obj);
- }
- return obj;
-
- }
-
- protected <T> T dealWithSpecialScopedObject(String name,
- ThreadLocal<T> threadLocal,
- ThreadLocal<String> threadLocalBeanName, T newObj) {
-
- T obj = threadLocal.get();
- if (obj == null) {
- obj = newObj;
- threadLocal.set(obj);
- threadLocalBeanName.set(name);
- if (log.isTraceEnabled()) {
- log.debug(obj.getClass() + " instantiated. (beanName=" + name
- + ")");
- }
- return obj;
- } else {
- throw new SlcException("Only one scoped " + obj.getClass()
- + " can be defined per thread");
- }
-
- }
-
- protected void checkForbiddenClasses(Object obj) {
- Class<?> clss = obj.getClass();
- if (ExecutionFlow.class.isAssignableFrom(clss)
- || ExecutionSpec.class.isAssignableFrom(clss)) {
- throw new UnsupportedException("Execution scoped object", clss);
- }
- }
-
- public String getConversationId() {
- // TODO: is it the most relevant?
- return executionContext.get().getUuid();
- }
-
- public void registerDestructionCallback(String name, Runnable callback) {
- if (Thread.currentThread() instanceof ExecutionThread) {
- ExecutionThread executionThread = (ExecutionThread) Thread
- .currentThread();
- executionThread.registerDestructionCallback(name, callback);
- }
- }
-
- public Object remove(String name) {
- if (log.isDebugEnabled())
- log.debug("Remove object " + name);
- throw new UnsupportedOperationException();
- }
-
- public Object resolveContextualObject(String key) {
- return executionContext.get().getVariable(key);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionContext;
-import org.springframework.core.io.FileSystemResource;
-import org.springframework.core.io.Resource;
-import org.springframework.util.Assert;
-
-/** Implements write access to resources based on standard Java {@link File} */
-public class FileExecutionResources implements ExecutionResources {
- private final static Log log = LogFactory
- .getLog(FileExecutionResources.class);
- protected final static String DEFAULT_EXECUTION_RESOURCES_DIRNAME = "executionResources";
- public final static String DEFAULT_EXECUTION_RESOURCES_TMP_PATH = System
- .getProperty("java.io.tmpdir")
- + File.separator
- + System.getProperty("user.name")
- + File.separator
- + "slc"
- + File.separator + DEFAULT_EXECUTION_RESOURCES_DIRNAME;
-
- private File baseDir;
- private ExecutionContext executionContext;
- private String prefixDatePattern = "yyMMdd_HHmmss_SSS";
- private SimpleDateFormat sdf = null;
-
- private Boolean withExecutionSubdirectory = true;
-
- public FileExecutionResources() {
- // Default base directory
- String osgiInstanceArea = System.getProperty("osgi.instance.area");
- String osgiInstanceAreaDefault = System
- .getProperty("osgi.instance.area.default");
-
- if (osgiInstanceArea != null) {
- // within OSGi with -data specified
- osgiInstanceArea = removeFilePrefix(osgiInstanceArea);
- baseDir = new File(osgiInstanceArea + File.separator
- + DEFAULT_EXECUTION_RESOURCES_DIRNAME);
- } else if (osgiInstanceAreaDefault != null) {
- // within OSGi without -data specified
- osgiInstanceAreaDefault = removeFilePrefix(osgiInstanceAreaDefault);
- baseDir = new File(osgiInstanceAreaDefault + File.separator
- + DEFAULT_EXECUTION_RESOURCES_DIRNAME);
- } else {// outside OSGi
- baseDir = new File(DEFAULT_EXECUTION_RESOURCES_TMP_PATH);
- }
- }
-
- protected SimpleDateFormat sdf() {
- // Lazy init in case prefix has been externally set
- if (sdf == null)
- sdf = new SimpleDateFormat(prefixDatePattern);
- return sdf;
- }
-
- public Resource getWritableResource(String relativePath) {
- File file = getFile(relativePath);
- File parentDir = file.getParentFile();
-
- if (!parentDir.exists()) {
- // Creates if necessary
- if (log.isTraceEnabled())
- log.trace("Creating parent directory " + parentDir);
- parentDir.mkdirs();
- }
- Resource resource = new FileSystemResource(file);
-
- if (log.isTraceEnabled())
- log.trace("Returns writable resource " + resource);
- return resource;
- }
-
- public String getWritableOsPath(String relativePath) {
- try {
- return getFile(relativePath).getCanonicalPath();
- } catch (IOException e) {
- throw new SlcException("Cannot find canonical path", e);
- }
- }
-
- public File getWritableOsFile(String relativePath) {
- return getFile(relativePath);
- }
-
- public String getAsOsPath(Resource resource, Boolean overwrite) {
- File file = fileFromResource(resource);
- if (file != null)
- try {
- if (log.isTraceEnabled())
- log.debug("Directly interpret " + resource + " as OS file "
- + file);
- return file.getCanonicalPath();
- } catch (IOException e1) {
- // silent
- }
-
- if (log.isTraceEnabled())
- log.trace("Resource " + resource
- + " is not available on the file system. Retrieving it...");
-
- InputStream in = null;
- OutputStream out = null;
- try {
- String path = resource.getURL().getPath();
- file = getFile(path);
- if (file.exists() && !overwrite)
- return file.getCanonicalPath();
-
- file.getParentFile().mkdirs();
- in = resource.getInputStream();
- out = new FileOutputStream(file);
- IOUtils.copy(in, out);
- if (log.isDebugEnabled())
- log.debug("Retrieved " + resource + " to OS file " + file);
- return file.getCanonicalPath();
- } catch (IOException e) {
- throw new SlcException("Could not make resource " + resource
- + " an OS file.", e);
- } finally {
- IOUtils.closeQuietly(in);
- IOUtils.closeQuietly(out);
- }
- }
-
- /**
- * Extract the underlying file from the resource.
- *
- * @return the file or null if no files support this resource.
- */
- protected File fileFromResource(Resource resource) {
- try {
- return resource.getFile();
- } catch (IOException e) {
- return null;
- }
-
- }
-
- protected File getFile(String relativePath) {
- File writableBaseDir = getWritableBaseDir();
- return new File(writableBaseDir.getPath() + File.separator
- + relativePath.replace('/', File.separatorChar));
- }
-
- public File getWritableBaseDir() {
- if (withExecutionSubdirectory) {
- Date executionContextCreationDate = (Date) executionContext
- .getVariable(ExecutionContext.VAR_EXECUTION_CONTEXT_CREATION_DATE);
- Assert.notNull(executionContext, "execution context is null");
- String path = baseDir.getPath() + File.separator
- + sdf().format(executionContextCreationDate);
- // TODO write execution id somewhere? like in a txt file
- return new File(path);
- } else {
- return baseDir;
- }
- }
-
- protected String removeFilePrefix(String url) {
- if (url.startsWith("file:"))
- return url.substring("file:".length());
- else if (url.startsWith("reference:file:"))
- return url.substring("reference:file:".length());
- else
- return url;
- }
-
- public void setBaseDir(File baseDir) {
- this.baseDir = baseDir;
- }
-
- public void setExecutionContext(ExecutionContext executionContext) {
- this.executionContext = executionContext;
- }
-
- public void setPrefixDatePattern(String prefixDatePattern) {
- this.prefixDatePattern = prefixDatePattern;
- }
-
- public File getBaseDir() {
- return baseDir;
- }
-
- public ExecutionContext getExecutionContext() {
- return executionContext;
- }
-
- public String getPrefixDatePattern() {
- return prefixDatePattern;
- }
-
- /** Default is true. */
- public void setWithExecutionSubdirectory(Boolean withExecutionSubdirectory) {
- this.withExecutionSubdirectory = withExecutionSubdirectory;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionStack;
-import org.springframework.beans.BeanWrapper;
-import org.springframework.beans.BeanWrapperImpl;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-public class MapExecutionContext implements ExecutionContext,
- ApplicationContextAware {
- private final Map<String, Object> variables = Collections
- .synchronizedMap(new HashMap<String, Object>());
-
- private final String uuid;
-
- private ApplicationContext applicationContext;
- private ExecutionStack executionStack;
-
- public MapExecutionContext() {
- uuid = UUID.randomUUID().toString();
- variables.put(VAR_EXECUTION_CONTEXT_ID, uuid);
- variables.put(VAR_EXECUTION_CONTEXT_CREATION_DATE, new Date());
- }
-
- public void setVariable(String key, Object value) {
- // check if we do not refer to a bean
- int lastInd = key.lastIndexOf('.');
- if (applicationContext != null && lastInd > 0) {
- String beanName = key.substring(0, lastInd);
- String propertyName = key.substring(lastInd + 1);
- if (applicationContext.containsBean(beanName)) {
- BeanWrapper beanWrapper = new BeanWrapperImpl(
- applicationContext.getBean(beanName));
- if (!beanWrapper.isWritableProperty(propertyName))
- throw new SlcException("No writable property "
- + propertyName + " in bean " + beanName);
- beanWrapper.setPropertyValue(propertyName, value);
- }
- }
-
- variables.put(key, value);
- }
-
- public Object getVariable(String key) {
- // check if we do not refer to a bean
- int lastInd = key.lastIndexOf('.');
- if (applicationContext != null && lastInd > 0) {
- String beanName = key.substring(0, lastInd);
- String propertyName = key.substring(lastInd + 1);
- if (applicationContext.containsBean(beanName)) {
- BeanWrapper beanWrapper = new BeanWrapperImpl(
- applicationContext.getBean(beanName));
- if (!beanWrapper.isReadableProperty(propertyName))
- throw new SlcException("No readable property "
- + propertyName + " in bean " + beanName);
- Object obj = beanWrapper.getPropertyValue(propertyName);
- return obj;
- }
- }
-
- Object value = variables.get(key);
- // try system property in last resort
- if (value == null)
- value = System.getProperty(key);
-
- // if the variable was not found, look in the stack starting at the
- // upper flows
- if (value == null) {
- value = executionStack.findLocalVariable(key);
- }
- return value;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- @Override
- public void beforeFlow(ExecutionFlow executionFlow) {
- // getUuid();
- executionStack.enterFlow(executionFlow);
- setVariable(ExecutionContext.VAR_FLOW_ID,
- executionStack.getCurrentStackLevelUuid());
- setVariable(ExecutionContext.VAR_FLOW_NAME, executionFlow.getName());
- }
-
- @Override
- public void afterFlow(ExecutionFlow executionFlow) {
- executionStack.leaveFlow(executionFlow);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ExecutionContext)
- return uuid.equals(((ExecutionContext) obj).getUuid());
- return false;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + "#" + uuid;
- }
-
- public void setApplicationContext(ApplicationContext applicationContext)
- throws BeansException {
- this.applicationContext = applicationContext;
- }
-
- public void setExecutionStack(ExecutionStack executionStack) {
- this.executionStack = executionStack;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.core.io.Resource;
-import org.springframework.util.Assert;
-
-/** Retrieve an OS File from the given resource. */
-public class OsFileFactoryBean implements FactoryBean<String> {
- private ExecutionResources executionResources;
- private Resource resource;
- private Boolean overwrite = false;
-
- /** Return an existing file on the file system. */
- public String getObject() throws Exception {
- Assert.notNull(executionResources, "executionResources is null");
- Assert.notNull(resource, "resource is null");
- return executionResources.getAsOsPath(resource, overwrite);
- }
-
- /** Return {@link Object} because CGLIB is unable to proxy {@link File}. */
- public Class<? extends Object> getObjectType() {
- return CharSequence.class;
- }
-
- public boolean isSingleton() {
- return false;
- }
-
- /** The execution resources object. */
- public void setExecutionResources(ExecutionResources executionResources) {
- this.executionResources = executionResources;
- }
-
- /** The resource to access. */
- public void setResource(Resource resource) {
- this.resource = resource;
- }
-
- /**
- * Whether to overwrite the resource if it already exists. Default is
- * <code>false</code>.
- */
- public void setOverwrite(Boolean overwrite) {
- this.overwrite = overwrite;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.runtime.InstantiationManager;
-import org.springframework.beans.factory.FactoryBean;
-
-public class ParameterRef implements FactoryBean<Object> {
- private final static Log log = LogFactory.getLog(ParameterRef.class);
-
- private InstantiationManager instantiationManager;
- private String name;
-
- /** Cached object. */
- private Object object;
-
- public ParameterRef() {
- }
-
- public ParameterRef(String name) {
- this.name = name;
- }
-
- public Object getObject() throws Exception {
- if (log.isTraceEnabled())
- log.debug("Parameter ref called for " + name);
-
- if (object == null)
- object = instantiationManager.getInitializingFlowParameter(name);
- return object;
- }
-
- public Class<?> getObjectType() {
- if (object == null)
- return instantiationManager.getInitializingFlowParameterClass(name);
- else
- return object.getClass();
- }
-
- public boolean isSingleton() {
- return true;
- }
-
- public void setInstantiationManager(
- InstantiationManager instantiationManager) {
- this.instantiationManager = instantiationManager;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.ByteArrayResource;
-import org.springframework.core.io.Resource;
-
-/** Experimental and suboptimal */
-public class SedFilteredResource implements FactoryBean<Resource>,
- InitializingBean {
- private Resource source;
-
- private List<String> filters = new ArrayList<String>();
- private Map<Pattern, String> patterns = new HashMap<Pattern, String>();
-
- private String charset = "UTF-8";
- private Charset cs;
- private CharsetDecoder decoder;
-
- // private CharsetEncoder encoder;
-
- public Resource getObject() throws Exception {
- if (filters.size() == 0)
- return source;
-
- // int capacity = 100 * 1024;// 100 KB
- ByteBuffer bb;
- if (source instanceof ByteArrayResource) {
- bb = ByteBuffer.wrap(((ByteArrayResource) source).getByteArray());
- } else {
- FileInputStream fis = null;
- try {
- File file = source.getFile();
- fis = new FileInputStream(file);
- FileChannel fc = fis.getChannel();
-
- // Get the file's size and then map it into memory
- int sz = (int) fc.size();
- bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);
- } catch (IOException e) {
- // ReadableByteChannel channel = Channels.newChannel(source
- // .getInputStream());
- // bb = ByteBuffer.allocateDirect(capacity);
- // int read = 0;
- // do {
- // read = channel.read(bb);
- // } while (read > 0);
- // FIXME : use nio to parse the stream as it goes
- bb = ByteBuffer.wrap(IOUtils.toByteArray(source
- .getInputStream()));
- } finally {
- IOUtils.closeQuietly(fis);
- }
- }
- CharBuffer cb = decoder.decode(bb);
- for (Pattern pattern : patterns.keySet()) {
- Matcher matcher = pattern.matcher(cb);
- String output = matcher.replaceAll(patterns.get(pattern));
- cb = CharBuffer.wrap(output);
- }
- // ByteBuffer bbout = encoder.encode(cb);
- // ByteArrayOutputStream out = new ByteArrayOutputStream(capacity);
- // WritableByteChannel wchannel = Channels.newChannel(out);
- // wchannel.write(bbout);
- ByteArrayResource res = new ByteArrayResource(cb.toString().getBytes());
- return res;
- }
-
- public Class<?> getObjectType() {
- return Resource.class;
- }
-
- public boolean isSingleton() {
- return true;
- }
-
- public void afterPropertiesSet() throws Exception {
- cs = Charset.forName(charset);
- decoder = cs.newDecoder();
- // encoder = cs.newEncoder();
-
- for (String sedStr : filters) {
- sedStr = sedStr.trim();
- if (sedStr.length() < 4)
- throw new SlcException(sedStr + " not properly formatted.");
- if (sedStr.charAt(0) != 's')
- throw new SlcException(sedStr + " not properly formatted.");
- Character sep = sedStr.charAt(1);
- List<String> tokens = new ArrayList<String>(4);
- StringTokenizer st = new StringTokenizer(sedStr, sep.toString());
- while (st.hasMoreTokens())
- tokens.add(st.nextToken());
- if (tokens.size() != 3 && tokens.size() != 4)
- throw new SlcException(sedStr + " not properly formatted.");
- patterns.put(Pattern.compile(tokens.get(1)), tokens.get(2));
- }
- }
-
- public void setSource(Resource source) {
- this.source = source;
- }
-
- public void setFilters(List<String> filters) {
- this.filters = filters;
- }
-
- public void setCharset(String charset) {
- this.charset = charset;
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
- <bean id="slcDefault.executionResources" parent="slcTemplate.fileResources"
- scope="execution" lazy-init="true">
- <aop:scoped-proxy proxy-target-class="false" />
- <property name="executionContext" ref="executionContext" />
- </bean>
-
- <bean id="slcDefault.writableResource" parent="slcTemplate.writableResource"
- abstract="true">
- <property name="executionResources" ref="slcDefault.executionResources" />
- </bean>
-
- <bean id="slcDefault.osFile" parent="slcTemplate.osFile" abstract="true">
- <property name="executionResources" ref="slcDefault.executionResources" />
- </bean>
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.execution.doc;
-
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.PropertyValue;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-
-public class ConsoleContextDescriber implements ContextDescriber {
- public void describeContext(BeanDefinitionRegistry registry) {
- String[] beanNames = registry.getBeanDefinitionNames();
- for (String beanName : beanNames) {
- log("\n## BEAN: " + beanName);
- describeBean(registry.getBeanDefinition(beanName));
- }
- }
-
- public void describeBean(BeanDefinition beanDefinition) {
- log("BeanDefinition class: "+beanDefinition.getClass());
- log("# ATTRIBUTES");
- for(String attr:beanDefinition.attributeNames()){
- log(attr+"="+beanDefinition.getAttribute(attr));
- }
- log("# PROPERTIES");
- MutablePropertyValues pValues = beanDefinition.getPropertyValues();
- for (PropertyValue pv : pValues.getPropertyValues()) {
- log(pv.getName() + "= (" + pv.getValue().getClass() + ") "
- + pv.getValue());
- }
- }
-
- protected void log(Object obj){
- System.out.println(obj);
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution.doc;
-
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-
-public interface ContextDescriber {
- public void describeContext(BeanDefinitionRegistry registry);
- public void describeBean(BeanDefinition bd);
-}
+++ /dev/null
-package org.argeo.slc.core.execution.generator;
-
-import java.util.Map;
-
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-
-/**
- * Composite <code>RunnableFactory</code>, redirecting the Runnable
- * creation to on of the configured <code>RunnableFactory</code> depending
- * on an entry of the data of the <code>RunnableDataNode</code>.
- */
-public class CompositeRunnableFactory implements RunnableFactory {
-
- /**
- * Key used to access factory ID in the data of the <code>RunnableDataNode</code>
- */
- private String factoryKey;
-
- /**
- * Maps a factory ID to an ExecutionFlowFactory
- */
- private Map<String, RunnableFactory> factories;
-
- public void createAndRegisterRunnable(RunnableDataNode node,
- BeanDefinitionRegistry beanDefinitionRegistry) {
- findFactory(node).createAndRegisterRunnable(node, beanDefinitionRegistry);
- }
-
- /**
- * Finds the <code>RunnableFactory</code> to use for a <code>RunnableDataNode</code>
- * @param node
- * @return the <code>RunnableFactory</code> to use for the <code>RunnableDataNode</code>
- */
- private RunnableFactory findFactory(RunnableDataNode node) {
- // get the factory ID from the data of the RunnableDescriptor
- Map<String, Object> data = node.getData();
- if (!data.containsKey(factoryKey)) {
- throw new SlcException("No data value for key '" + factoryKey + "'");
- }
- String factoryId = data.get(factoryKey).toString();
-
- // see if we have a factory for the factory ID
- if ((factories != null) && factories.containsKey(factoryId)) {
- return factories.get(factoryId);
- }
- // if not, look for a bean of name equals to the factory ID
- else {
- throw new SlcException("Not implemented");
- }
- }
-
- public void setFactoryKey(String factoryKey) {
- this.factoryKey = factoryKey;
- }
-
- public void setFactories(Map<String, RunnableFactory> factories) {
- this.factories = factories;
- }
-
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.generator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Default implementation of <code>RunnableDataNode</code>
- *
- */
-public class DefaultRunnableDataNode implements RunnableDataNode {
-
- private List<RunnableDataNode> children = new ArrayList<RunnableDataNode>();
-
- private RunnableDataNode parent;
-
- /**
- * Data of the RunnableDataNode. Does not contain
- * parent data.
- */
- private Map<String, Object> properData = new HashMap<String, Object>();
-
- private String path;
-
- private String beanName;
-
- public boolean isLeaf() {
- return children.size() == 0;
- }
-
- public List<RunnableDataNode> getChildren() {
- return children;
- }
-
- public void addChild(RunnableDataNode child) {
- child.setParent(this);
- children.add(child);
- }
-
- public Map<String, Object> getData() {
- Map<String, Object> data = new HashMap<String, Object>();
- if(parent != null) {
- Map<String, Object> parentData = parent.getData();
- if(parentData != null) {
- data.putAll(parentData);
- }
- }
- // entries defined in parentData can be overridden
- // in properData
- if(properData != null) {
- data.putAll(properData);
- }
- return data;
- }
-
- public Map<String, Object> getProperData() {
- return properData;
- }
-
- public void setProperData(Map<String, Object> properData) {
- this.properData = properData;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public String getBeanName() {
- return beanName;
- }
-
- public void setBeanName(String beanName) {
- this.beanName = beanName;
- }
-
- public void setParent(RunnableDataNode parent) {
- this.parent = parent;
- }
-
- public RunnableDataNode getParent() {
- return parent;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.generator;
-
-import java.util.HashMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.aop.scope.ScopedProxyUtils;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.MutablePropertyValues;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.GenericBeanDefinition;
-import org.springframework.core.Ordered;
-
-/**
- * Generates <code>ExecutionFlows</code> and <code>Runnables</code> as
- * beans in the Spring Application Context.
- * Called by the Application Context as a <code>BeanFactoryPostProcessor</code>.
- * Two kinds of beans are generated:
- * <code>RunnableCallFlow</code>, calling a list of <code>Runnables</code> from the
- * Application Context after configuring the <code>ExecutionContext</code>,
- * and outputs of a <code>RunnableFactory</code>.
- */
-public class ExecutionFlowGenerator implements BeanFactoryPostProcessor,
- Ordered {
-
- private final Log log = LogFactory.getLog(getClass());
-
- /**
- * Source providing a list of <code>RunnableCallFlowDescriptor</code>
- * used to create <code>RunnableCallFlow</code> and a list of
- * <code>RunnableDataNode</code> used to create any kind of flow via a factory
- */
- protected ExecutionFlowGeneratorSource source;
-
- /**
- * Factory used to create Runnables in the Application context from
- * the <code>RunnableDataNode</code> provided from the source.
- */
- protected RunnableFactory runnableFactory;
-
- /**
- * Bean name of the <code>ExecutionContext</code>.
- * Used to provide the created <code>RunnableCallFlow</code> beans
- * with a <code>RuntimeBeanReference</code> to
- * the <code>ExecutionContext</code>
- */
- private String executionContextBeanName = "executionContext";
-
- /**
- * Bean name of the context values Map.
- * A bean of class HashMap is created with this name, and a
- * <code>RuntimeBeanReference</code> is provided to the created
- * <code>RunnableCallFlow</code> beans.
- */
- private String contextValuesBeanName = "executionFlowGenerator.contextValues";
-
- /**
- * Prefix added to the bean names defined in each
- * <code>RunnableCallFlowDescriptor</code>
- */
- private String flowBeanNamesPrefix = "";
-
- private int order = Ordered.HIGHEST_PRECEDENCE;
-
- public void postProcessBeanFactory(
- ConfigurableListableBeanFactory beanFactory) throws BeansException {
-
- // assert that the beanFactory is a BeanDefinitionRegistry
- if (!(beanFactory instanceof BeanDefinitionRegistry)) {
- throw new SlcException("Can only work on "
- + BeanDefinitionRegistry.class);
- }
-
- // add bean for the Context Values Map
- createAndRegisterContextValuesBean((BeanDefinitionRegistry) beanFactory);
-
- // add beans for each RunnableDataNode
- for(RunnableDataNode node : source.getRunnableDataNodes()) {
- runnableFactory.createAndRegisterRunnable(node, (BeanDefinitionRegistry) beanFactory);
- }
-
- // add beans for each RunnableCallFlowDescriptor of the source to the application context
- for (RunnableCallFlowDescriptor descriptor : source
- .getRunnableCallFlowDescriptors()) {
- createAndRegisterFlowFor(descriptor, (BeanDefinitionRegistry) beanFactory);
- }
- }
-
- /**
- * Creates a <code>RunnableCallFlow</code> bean
- * for a <code>RunnableCallFlowDescriptor</code> and registers
- * it in the <code>BeanDefinitionRegistry</code>
- * @param flowDescriptor
- * @param registry
- */
- private void createAndRegisterFlowFor(RunnableCallFlowDescriptor flowDescriptor, BeanDefinitionRegistry registry) {
- // create the flow bean
- GenericBeanDefinition flowBean = new GenericBeanDefinition();
- flowBean.setBeanClass(RunnableCallFlow.class);
-
- String beanName = flowBeanNamesPrefix + flowDescriptor.getBeanName();
-
- MutablePropertyValues mpv = new MutablePropertyValues();
- mpv.addPropertyValue("runnableCalls", flowDescriptor.getRunnableCalls());
- mpv.addPropertyValue("sharedContextValuesMap", new RuntimeBeanReference(contextValuesBeanName));
-
- mpv.addPropertyValue("name", beanName);
- mpv.addPropertyValue("path", flowDescriptor.getPath());
-
- mpv.addPropertyValue("executionContext", new RuntimeBeanReference(executionContextBeanName));
-
- flowBean.setPropertyValues(mpv);
-
- // register it
- if(log.isDebugEnabled()) {
- log.debug("Registering bean definition for RunnableCallFlow " + beanName);
- }
- registry.registerBeanDefinition(beanName, flowBean);
- }
-
- /**
- * Creates the Context Values bean and register it in the
- * <code>BeanDefinitionRegistry</code>
- * @param registry
- */
- private void createAndRegisterContextValuesBean(BeanDefinitionRegistry registry) {
- GenericBeanDefinition contextValuesBean = new GenericBeanDefinition();
- contextValuesBean.setBeanClass(HashMap.class);
-
- BeanDefinitionHolder bdh = ScopedProxyUtils.createScopedProxy(new BeanDefinitionHolder(contextValuesBean, contextValuesBeanName), registry, true);
- registry.registerBeanDefinition(contextValuesBeanName, bdh.getBeanDefinition());
- }
-
- public int getOrder() {
- return order;
- }
-
- public void setOrder(int order) {
- this.order = order;
- }
-
- public void setSource(ExecutionFlowGeneratorSource source) {
- this.source = source;
- }
-
- public void setRunnableFactory(RunnableFactory runnableFactory) {
- this.runnableFactory = runnableFactory;
- }
-
- public void setExecutionContextBeanName(String executionContextBeanName) {
- this.executionContextBeanName = executionContextBeanName;
- }
-
- public void setContextValuesBeanName(String contextValuesBeanName) {
- this.contextValuesBeanName = contextValuesBeanName;
- }
-
- public void setFlowBeanNamesPrefix(String flowBeanNamesPrefix) {
- this.flowBeanNamesPrefix = flowBeanNamesPrefix;
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution.generator;
-
-import java.util.List;
-
-/**
- * Provides 2 types of information required by an <code>ExecutionFlowGenerator</code>:
- * a list of <code>RunnableCallFlowDescriptor</code> used to create <code>RunnableCallFlow</code>
- * and a list of <code>RunnableDataNode</code> used to create any kind of flow via a factory.
- */
-public interface ExecutionFlowGeneratorSource {
-
- /**
- * @return a list of <code>RunnableCallFlowDescriptor</code> used
- * by a <code>ExecutionFlowGenerator</code> to create <code>RunnableCallFlow</code>
- */
- public List<RunnableCallFlowDescriptor> getRunnableCallFlowDescriptors();
-
- /**
- * @return a list of <code>RunnableDataNode</code> used
- * by a <code>ExecutionFlowGenerator</code> to create any kind of flow via a factory
- */
- public List<RunnableDataNode> getRunnableDataNodes();
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.generator;
-
-import java.util.Map;
-
-/**
- * Storage class for information required to call a flow
- * of the Spring execution context:
- * bean name of the flow,
- * variables to add to the Execution Context before the call
- * and variables (context values) to add to a Map
- * potentially referenced by the called flow
- */
-public class RunnableCall {
-
- /**
- * Bean name of the flow to call
- */
- private String beanName;
-
- /**
- * Variables to add to the execution context before the call
- */
- private Map<String, Object> executionVariables;
-
- /**
- * Variables to add to the Map potentially referenced by
- * the called flow
- */
- private Map<String, Object> contextValues;
-
- public String getBeanName() {
- return beanName;
- }
-
- public void setBeanName(String beanName) {
- this.beanName = beanName;
- }
-
- public Map<String, Object> getExecutionVariables() {
- return executionVariables;
- }
-
- public void setExecutionVariables(Map<String, Object> executionVariables) {
- this.executionVariables = executionVariables;
- }
-
- public Map<String, Object> getContextValues() {
- return contextValues;
- }
-
- public void setContextValues(Map<String, Object> contextValues) {
- this.contextValues = contextValues;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.generator;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionSpec;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Execution Flow calling a list of <code>Runnable</code> (identified by their
- * bean name in the Spring Application Context) after configuring the Execution
- * context and a Map potentially shared by the called <code>Runnable</code>
- *
- */
-public class RunnableCallFlow implements ExecutionFlow, ApplicationContextAware {
-
- private final static Log log = LogFactory.getLog(RunnableCallFlow.class);
-
- /**
- * Key in the execution context for the index of the call (e.g. 0 for the
- * first runnable called, ...)
- */
- public final static String VAR_CALL_INDEX = "slcVar.runnableCallFlow.callIndex";
-
- /**
- * Name of the flow. Also bean name
- */
- private String name;
-
- /**
- * Path of the flow
- */
- private String path;
-
- /**
- * Whether an exception in a <code>Runnable</code> shall stop the execution
- * of the flow
- */
- private Boolean failOnError = true;
-
- /**
- * List of <code>Runnable</code> to call, with bean name, execution
- * variables and context values
- */
- private List<RunnableCall> runnableCalls;
-
- /**
- * Map potentially referenced by called flows. Updated with the context
- * values of a Runnable before calling it.
- */
- private Map<String, Object> sharedContextValuesMap;
-
- /**
- * ExecutionSpec of the flow. Does not contain any attribute.
- */
- private ExecutionSpec executionSpec = new DefaultExecutionSpec();
-
- /**
- * Reference to the ExecutionContext
- */
- private ExecutionContext executionContext;
-
- /**
- * Reference to the Spring <code>ApplicationContext</code>. Set via
- * <code>setApplicationContext</code>, the class implementing
- * <code>ApplicationContextAware</code>
- */
- private ApplicationContext applicationContext;
-
- /**
- * Runs a <code>Runnable</code> after configuring the Execution Context and
- * <code>sharedContextValuesMap</code>
- *
- * @param runnable
- * the <code>Runnable</code> to call
- * @param executionVariables
- * the variables to add to the <code>ExecutionContext</code>
- * @param contextValues
- * the variables to add to <code>sharedContextValuesMap</code>
- * @param callIndex
- * index of the call (0 for the first called
- * <code>Runnable</code>) set as variable of the
- * <code>ExecutionContext</code>
- */
- private void run(Runnable runnable, Map<String, Object> executionVariables,
- Map<String, Object> contextValues, int callIndex) {
- // add all variables to the Execution Context
- for (Map.Entry<String, Object> entry : executionVariables.entrySet()) {
- executionContext.setVariable(entry.getKey(), entry.getValue());
- }
-
- // add call Index Variable
- executionContext.setVariable(VAR_CALL_INDEX, callIndex);
-
- // clear sharedContextValues and add all values of contextValues
- if (sharedContextValuesMap != null) {
- sharedContextValuesMap.clear();
- sharedContextValuesMap.putAll(contextValues);
- }
-
- // then run the runnable
- doExecuteRunnable(runnable);
- }
-
- public void doExecuteRunnable(Runnable runnable) {
- runnable.run();
- }
-
- /**
- * Executes the flow. For each <code>RunnableCall</code>, the corresponding
- * flow is retrieved from the Spring Application Context, the
- * <code>ExecutionContext</code> and <code>sharedContextValuesMap</code> are
- * configured and the <code>Runnable</code> is called.
- */
- public void run() {
- if (applicationContext == null) {
- throw new SlcException("No ApplicationContext defined");
- }
-
- try {
- for (int callIndex = 0; callIndex < runnableCalls.size(); ++callIndex) {
- RunnableCall runnableCall = runnableCalls.get(callIndex);
- Object bean = applicationContext.getBean(
- runnableCall.getBeanName(), Runnable.class);
- if (log.isDebugEnabled())
- log.debug("Running flow '" + runnableCall.getBeanName()
- + "'");
- run((Runnable) bean, runnableCall.getExecutionVariables(),
- runnableCall.getContextValues(), callIndex);
- }
- } catch (RuntimeException e) {
- if (failOnError)
- throw e;
- else {
- log.error("Execution flow failed,"
- + " but process did not fail"
- + " because failOnError property"
- + " is set to false: " + e);
- if (log.isTraceEnabled())
- e.printStackTrace();
- }
- }
- }
-
- public Iterator<Runnable> runnables() {
- List<Runnable> runnables = new ArrayList<Runnable>();
- for (int callIndex = 0; callIndex < runnableCalls.size(); ++callIndex) {
- RunnableCall runnableCall = runnableCalls.get(callIndex);
- Object bean = applicationContext.getBean(
- runnableCall.getBeanName(), Runnable.class);
- runnables.add((Runnable) bean);
- }
- return runnables.iterator();
- }
-
- public Runnable getRunnable() {
- if (runnableCalls.size() == 1)
- return runnables().next();
- else
- throw new SlcException("There are " + runnableCalls.size()
- + " runnables in flow " + getName());
- }
-
- @Override
- public String toString() {
- return new StringBuffer("RunnableCallFlow ").append(name).toString();
- }
-
- public ExecutionSpec getExecutionSpec() {
- return executionSpec;
- }
-
- public String getName() {
- return name;
- }
-
- public Object getParameter(String key) {
- throw new SlcException("RunnableCallFlow have no parameters");
- }
-
- public String getPath() {
- return path;
- }
-
- public Boolean isSetAsParameter(String key) {
- // The ExecutionSpec having no attribute,
- // always return false
- return false;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public void setExecutionContext(ExecutionContext executionContext) {
- this.executionContext = executionContext;
- }
-
- public void setRunnableCalls(List<RunnableCall> runnableCalls) {
- this.runnableCalls = runnableCalls;
- }
-
- public void setApplicationContext(ApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
-
- public void setSharedContextValuesMap(Map<String, Object> contextValues) {
- this.sharedContextValuesMap = contextValues;
- }
-
- public void setFailOnError(Boolean failOnError) {
- this.failOnError = failOnError;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.generator;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Storage Class for information required to
- * instantiate a <code>RunnableCallFlow</code>:
- * bean name of the flow,
- * path of the flow
- * and list of <code>RunnableCall</code>.
- *
- */
-public class RunnableCallFlowDescriptor {
-
- /**
- * Bean name of the flow to instantiate
- */
- private String beanName;
-
- /**
- * Path of the flow to instantiate
- */
- private String path;
-
- /**
- * List of <code>RunnableCall</code>
- */
- private List<RunnableCall> runnableCalls = new ArrayList<RunnableCall>();
-
- public String getBeanName() {
- return beanName;
- }
-
- public void setBeanName(String beanName) {
- this.beanName = beanName;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public List<RunnableCall> getRunnableCalls() {
- return runnableCalls;
- }
-
- public void setRunnableCalls(List<RunnableCall> runnableCalls) {
- this.runnableCalls = runnableCalls;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.generator;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Stores information relative to a Runnable.
- * Allows to structure the information as a tree, each node
- * storing data as a Map.
- */
-public interface RunnableDataNode {
-
- /**
- * @return a Map containing the data associated with this node.
- * Data associated with parent nodes are expected
- * to be contained in the returned Map
- */
- public Map<String, Object> getData();
-
- /**
- * @return the name of the bean to create.
- * Can be null if no bean shall be created for the
- * <code>RunnableDataNode</code> (e.g. is is a sub-node)
- */
- public String getBeanName();
-
- /**
- * @return the path of the flow bean to create.
- * Can be null if the bean to created is not an
- * <code>ExecutionFlow</code> or if no bean shall be created for the
- * <code>RunnableDataNode</code> (e.g. is is a sub-node)
- */
- public String getPath();
-
- /**
- * @return whether the <code>RunnableDataNode</code> has
- * children or not.
- * Expected to be equivalent to <code>getChildren().empty()</code>
- */
- public boolean isLeaf();
-
- /**
- * @return the list of <code>RunnableDataNode</code> children.
- * Can be empty. Shall not be null.
- */
- public List<RunnableDataNode> getChildren();
-
- /**
- * @return the <code>RunnableDataNode</code> parent.
- * Can be null if no parent is defined (top node).
- */
- public RunnableDataNode getParent();
-
- /**
- * Sets the <code>RunnableDataNode</code> parent
- * @param parent
- */
- public void setParent(RunnableDataNode parent);
-}
+++ /dev/null
-package org.argeo.slc.core.execution.generator;
-
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-
-/**
- * Interprets a <code>RunnableDataNode</code> by creating corresponding
- * beans and registering them in a <code>BeanDefinitionRegistry</code>
- *
- */
-public interface RunnableFactory {
-
- public void createAndRegisterRunnable(RunnableDataNode node,
- BeanDefinitionRegistry beanDefinitionRegistry);
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License,
- Version 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the License. -->
-<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under
- the Apache License, Version 2.0 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of the License
- at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
- law or agreed to in writing, software distributed under the License is distributed
- on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- express or implied. See the License for the specific language governing permissions
- and limitations under the License. -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
- <description>Bare minimal runtime configuration. In general you will
- want to use simple.xml instead.
- </description>
-
- <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
- <property name="scopes">
- <map>
- <entry key="execution">
- <bean class="org.argeo.slc.core.execution.ExecutionScope" />
- </entry>
- </map>
- </property>
- </bean>
-
-
- <bean id="executionStack" class="org.argeo.slc.runtime.DefaultExecutionStack"
- scope="execution">
- <aop:scoped-proxy proxy-target-class="false" />
- </bean>
-
- <bean id="instantiationManager" class="org.argeo.slc.runtime.InstantiationManager" />
-
- <bean class="org.argeo.slc.core.execution.ExecutionParameterPostProcessor">
- <property name="executionContext" ref="executionContext" />
- <property name="instantiationManager" ref="instantiationManager" />
- </bean>
-
- <!-- <bean class="org.argeo.slc.core.execution.ExecutionAspect"> -->
- <!-- <property name="executionStack" ref="executionStack" /> -->
- <!-- <property name="executionContext" ref="executionContext" /> -->
- <!-- </bean> -->
-
- <aop:aspectj-autoproxy />
-
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License,
- Version 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the License. -->
-<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under
- the Apache License, Version 2.0 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of the License
- at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
- law or agreed to in writing, software distributed under the License is distributed
- on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- express or implied. See the License for the specific language governing permissions
- and limitations under the License. -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
- <description>Default Capabilities</description>
-
- <import resource="runtime.xml" />
-
- <bean id="executionContext" class="org.argeo.slc.core.execution.MapExecutionContext"
- scope="execution">
- <aop:scoped-proxy proxy-target-class="false" />
- <property name="executionStack" ref="executionStack" />
- </bean>
-
- <bean id="executionFlowDescriptorConverter"
- class="org.argeo.slc.core.execution.DefaultExecutionFlowDescriptorConverter"></bean>
-
- <bean
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
- <property name="ignoreUnresolvablePlaceholders" value="true" />
- </bean>
-
- <bean id="parameterRef" class="org.argeo.slc.core.execution.ParameterRef"
- abstract="true">
- <property name="instantiationManager" ref="instantiationManager" />
- </bean>
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
- <bean id="specAttr.primitive" class="org.argeo.slc.primitive.PrimitiveSpecAttribute"
- abstract="true" />
- <bean id="specAttr.resource" class="org.argeo.slc.core.execution.ResourceSpecAttribute"
- abstract="true" />
- <bean id="specAttr.ref" class="org.argeo.slc.execution.RefSpecAttribute"
- abstract="true" />
-
- <bean id="slcTemplate.simpleFlow" class="org.argeo.slc.core.execution.DefaultExecutionFlow"
- abstract="true" />
- <bean id="slcTemplate.simpleSpec" class="org.argeo.slc.core.execution.DefaultExecutionSpec"
- abstract="true" />
-
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under
- the Apache License, Version 2.0 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of the License
- at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
- law or agreed to in writing, software distributed under the License is distributed
- on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- express or implied. See the License for the specific language governing permissions
- and limitations under the License. -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
- <description>
- Simple runtime enriched with defaults and templates used
- to simplify XML files. These templates have been deprecated by the
- custom XML namespace and will be removed in SLC 2.x. Use the XML
- namespace instead.
- </description>
-
- <import resource="simple.xml" />
-
- <import resource="specs.xml" />
- <import resource="templates.xml" />
- <import resource="defaults.xml" />
- <import resource="utils.xml" />
- <import resource="tasks/core.xml" />
-
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import org.argeo.slc.test.TestResult;
-
-public class CloseTestResult implements Runnable {
- private TestResult testResult;
-
- public void run() {
- testResult.close();
- }
-
- public void setTestResult(TestResult testResult) {
- this.testResult = testResult;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-public class Echo implements Runnable {
- private final static Log defaultLog = LogFactory.getLog(Echo.class);
- private Resource writeTo = null;
-
- private Log log;
- private Object message;
-
- public void run() {
- log().info(message);
-
- if (writeTo != null) {
- try {
- File file = writeTo.getFile();
- if (log().isDebugEnabled())
- log().debug("Write to " + file);
- if (message != null)
- FileUtils.writeStringToFile(file, message.toString());
- } catch (IOException e) {
- throw new SlcException("Could not write to " + writeTo, e);
- }
- }
- }
-
- private Log log() {
- return log != null ? log : defaultLog;
- }
-
- public void setMessage(Object message) {
- this.message = message;
- }
-
- public void setWriteTo(Resource writeTo) {
- this.writeTo = writeTo;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import org.argeo.slc.SlcException;
-
-/** Conditional execution */
-public class If implements Runnable {
- private Boolean is;
- private Boolean not;
- private Runnable then;
- private Runnable els;
-
- public void run() {
- if (is == null && not == null)
- throw new SlcException("No condition set");
- if (is != null && not != null)
- throw new SlcException("Both is and not cannot be set");
-
- boolean bool = (is != null ? is : !not);
- if (bool) {
- if (then != null)
- then.run();
- } else {
- if (els != null)
- els.run();
- }
-
- }
-
- public void setIs(Boolean bool) {
- this.is = bool;
- }
-
- public void setThen(Runnable then) {
- this.then = then;
- }
-
- public void setEls(Runnable els) {
- this.els = els;
- }
-
- public Boolean getNot() {
- return not;
- }
-
- public void setNot(Boolean not) {
- this.not = not;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-/** A Java Virtual Machine process. */
-public class JvmProcess extends SystemCall implements InitializingBean {
- private Properties systemProperties = new Properties();
- private List<Resource> classpath = new ArrayList<Resource>();
- private List<Resource> pBootClasspath = new ArrayList<Resource>();
- private Resource jvm = null;
- private String mainClass;
- private String mainJar;
- private List<String> jvmArgs = new ArrayList<String>();
- private List<String> args = new ArrayList<String>();
-
- private String systemPropertiesFileProperty = null;
- private String systemPropertiesFileDir = null;
- private String systemPropertiesFileName = null;
-
- public void afterPropertiesSet() throws Exception {
- List<Object> command = new ArrayList<Object>();
- if (jvm != null)
- command.add(asFile(jvm).getPath());
- else
- command.add("java");
-
- if (pBootClasspath.size() > 0) {
- StringBuffer buf = new StringBuffer("-Xbootclasspath/p:");
- Boolean first = true;
- for (Resource res : pBootClasspath) {
- if (first)
- first = false;
- else
- buf.append(File.pathSeparatorChar);
-
- buf.append(asFile(res));
- }
- command.add(buf.toString());
- }
-
- for (String jvmArg : jvmArgs) {
- command.add(jvmArg);
- }
-
- if (classpath.size() > 0) {
- command.add("-cp");
- StringBuffer buf = new StringBuffer("");
- for (Resource res : classpath) {
- if (buf.length() != 0)
- buf.append(File.pathSeparatorChar);
- buf.append(asFile(res));
- }
- command.add(buf.toString());
- }
-
- if (systemPropertiesFileProperty == null) {
- // pass system properties as argument
- for (Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
- command.add("-D" + entry.getKey() + "=" + entry.getValue());
- }
- } else {
- // write system properties in a file to work around OS limitations
- // with command line (e.g. Win XP)
- String dir = systemPropertiesFileDir;
- if (dir == null)
- dir = getExecDirToUse();
- String fileName = systemPropertiesFileName;
- if (fileName == null)
- fileName = systemPropertiesFileProperty + ".properties";
-
- // Write file
- FileOutputStream fos = null;
- File file = new File(dir + File.separator + fileName);
- try {
-
- if (!file.getParentFile().exists())
- file.getParentFile().mkdirs();
- fos = new FileOutputStream(file);
- systemProperties.store(fos, "Automatically generated by "
- + getClass());
- command.add("-D" + systemPropertiesFileProperty + "="
- + file.getCanonicalPath());
- } catch (IOException e) {
- throw new SlcException("Cannot write to system properties to "
- + file, e);
- } finally {
- IOUtils.closeQuietly(fos);
- }
- }
-
- // Program
- if (mainClass != null) {
- command.add(mainClass);
- } else if (mainJar != null) {
- command.add("-jar");
- command.add(mainJar);
- } else {
- throw new SlcException("No main class or jar defined");
- }
-
- for (String arg : args) {
- command.add(arg);
- }
-
- setCommand(command);
- }
-
- protected File asFile(Resource res) {
- try {
- return res.getFile();
- } catch (FileNotFoundException e) {
- return copyToTempFile(res);
- } catch (IOException e) {
- throw new SlcException("Cannot convert resource to file", e);
- }
-
- }
-
- protected File copyToTempFile(Resource res) {
- File tempFile;
- FileOutputStream fos;
- try {
- tempFile = File.createTempFile("slcJvmProcess-", res.getFilename());
- tempFile.deleteOnExit();
- fos = new FileOutputStream(tempFile);
- IOUtils.copy(res.getInputStream(), fos);
- } catch (IOException e) {
- throw new SlcException("Cannot copy " + res + " to temp file.", e);
- }
- IOUtils.closeQuietly(fos);
- return tempFile;
- }
-
- /** Append the argument (for chaining) */
- @Override
- public SystemCall arg(String arg) {
- args.add(arg);
- return this;
- }
-
- /** Append the argument (for chaining) */
- @Override
- public SystemCall arg(String arg, String value) {
- args.add(arg);
- args.add(value);
- return this;
- }
-
- public Properties getSystemProperties() {
- return systemProperties;
- }
-
- public void setSystemProperties(Properties systemProperties) {
- this.systemProperties = systemProperties;
- }
-
- public List<Resource> getClasspath() {
- return classpath;
- }
-
- public void setClasspath(List<Resource> classpath) {
- this.classpath = classpath;
- }
-
- public List<Resource> getPBootClasspath() {
- return pBootClasspath;
- }
-
- public void setPBootClasspath(List<Resource> bootClasspath) {
- pBootClasspath = bootClasspath;
- }
-
- public Resource getJvm() {
- return jvm;
- }
-
- public void setJvm(Resource jvm) {
- this.jvm = jvm;
- }
-
- public String getMainClass() {
- return mainClass;
- }
-
- public void setMainClass(String mainClass) {
- this.mainClass = mainClass;
- }
-
- public String getMainJar() {
- return mainJar;
- }
-
- public void setMainJar(String mainJar) {
- this.mainJar = mainJar;
- }
-
- public List<String> getJvmArgs() {
- return jvmArgs;
- }
-
- public void setJvmArgs(List<String> jvmArgs) {
- this.jvmArgs = jvmArgs;
- }
-
- public List<String> getArgs() {
- return args;
- }
-
- public void setArgs(List<String> args) {
- this.args = args;
- }
-
- public void setSystemPropertiesFileProperty(
- String systemPropertiesFilePropertyName) {
- this.systemPropertiesFileProperty = systemPropertiesFilePropertyName;
- }
-
- public void setSystemPropertiesFileDir(String systemPropertiesFileDir) {
- this.systemPropertiesFileDir = systemPropertiesFileDir;
- }
-
- public void setSystemPropertiesFileName(String systemPropertiesFileName) {
- this.systemPropertiesFileName = systemPropertiesFileName;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.beans.factory.FactoryBean;
-
-/** Merge the provided lists in one single list, in the order provided. */
-public class MergedLists implements FactoryBean<List<Object>> {
- private List<List<Object>> lists = new ArrayList<List<Object>>();
-
- public void setLists(List<List<Object>> lists) {
- this.lists = lists;
- }
-
- public List<Object> getObject() throws Exception {
- List<Object> merged = new ArrayList<Object>();
- for (List<Object> lst : lists) {
- merged.addAll(lst);
- }
- return merged;
- }
-
- public Class<?> getObjectType() {
- return List.class;
- }
-
- public boolean isSingleton() {
- return false;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.springframework.util.Assert;
-import org.springframework.util.ReflectionUtils;
-
-public class MethodCall implements Runnable {
- private Object target;
- private String method;
- private List<Object> args = new ArrayList<Object>();
-
- public void run() {
- Assert.notNull(target, "target");
- Assert.notNull(method, "method");
- Method methodRef = ReflectionUtils
- .findMethod(target.getClass(), method);
- if (args.size() == 0)
- ReflectionUtils.invokeMethod(methodRef, target);
- else
- ReflectionUtils.invokeMethod(methodRef, methodRef, args.toArray());
- }
-
- public void setTarget(Object target) {
- this.target = target;
- }
-
- public void setMethod(String method) {
- this.method = method;
- }
-
- public void setArgs(List<Object> args) {
- this.args = args;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.test.context.SimpleContextAware;
-import org.argeo.slc.test.context.ContextAware;
-
-/**
- * Overrides Values and Expected values of a target
- * <code>SimpleContextAware</code> with the corresponding
- * values and expected values of a source <code>ContextAware</code>
- *
- */
-public class OverrideContextAware implements Runnable {
-
- private ContextAware source;
-
- private SimpleContextAware target;
-
- /**
- * Whether an exception shall be thrown if a value
- * or expected value of the source is not defined
- * in the target
- */
- private Boolean failIfUndefinedInSource = true;
-
- public void run() {
- // override values
- if(source.getValues() != null)
- for(String key : source.getValues().keySet()) {
- if(failIfUndefinedInSource && !target.getValues().containsKey(key)) {
- throw new SlcException("No entry in target values for key '" + key + "'");
- }
- target.getValues().put(key, source.getValues().get(key));
- }
-
- // override expected values
- if(source.getExpectedValues() != null)
- for(String key : source.getExpectedValues().keySet()) {
- if(failIfUndefinedInSource && !target.getExpectedValues().containsKey(key)) {
- throw new SlcException("No entry in target expected values for key '" + key + "'");
- }
- target.getExpectedValues().put(key, source.getExpectedValues().get(key));
- }
- }
-
- public void setSource(ContextAware source) {
- this.source = source;
- }
-
- public void setTarget(SimpleContextAware target) {
- this.target = target;
- }
-
- public void setFailIfUndefinedInSource(Boolean failIfUndefinedInSource) {
- this.failIfUndefinedInSource = failIfUndefinedInSource;
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.security.auth.callback.CallbackHandler;
-
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.DefaultExecutor;
-import org.apache.commons.exec.ExecuteException;
-import org.apache.commons.exec.ExecuteResultHandler;
-import org.apache.commons.exec.ExecuteStreamHandler;
-import org.apache.commons.exec.ExecuteWatchdog;
-import org.apache.commons.exec.Executor;
-import org.apache.commons.exec.LogOutputStream;
-import org.apache.commons.exec.PumpStreamHandler;
-import org.apache.commons.exec.ShutdownHookProcessDestroyer;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.core.execution.ExecutionResources;
-import org.argeo.slc.runtime.test.SimpleResultPart;
-import org.argeo.slc.test.TestResult;
-import org.argeo.slc.test.TestStatus;
-import org.springframework.core.io.Resource;
-
-/** Execute an OS specific system call. */
-public class SystemCall implements Runnable {
- public final static String LOG_STDOUT = "System.out";
-
- private final Log log = LogFactory.getLog(getClass());
-
- private String execDir;
-
- private String cmd = null;
- private List<Object> command = null;
-
- private Executor executor = new DefaultExecutor();
- private Boolean synchronous = true;
-
- private String stdErrLogLevel = "ERROR";
- private String stdOutLogLevel = "INFO";
-
- private Resource stdOutFile = null;
- private Resource stdErrFile = null;
-
- private Resource stdInFile = null;
- /**
- * If no {@link #stdInFile} provided, writing to this stream will write to
- * the stdin of the process.
- */
- private OutputStream stdInSink = null;
-
- private Boolean redirectStdOut = false;
-
- private List<SystemCallOutputListener> outputListeners = Collections
- .synchronizedList(new ArrayList<SystemCallOutputListener>());
-
- private Map<String, List<Object>> osCommands = new HashMap<String, List<Object>>();
- private Map<String, String> osCmds = new HashMap<String, String>();
- private Map<String, String> environmentVariables = new HashMap<String, String>();
-
- private Boolean logCommand = false;
- private Boolean redirectStreams = true;
- private Boolean exceptionOnFailed = true;
- private Boolean mergeEnvironmentVariables = true;
-
-// private Authentication authentication;
-
- private String osConsole = null;
- private String generateScript = null;
-
- /** 24 hours */
- private Long watchdogTimeout = 24 * 60 * 60 * 1000l;
-
- private TestResult testResult;
-
- private ExecutionResources executionResources;
-
- /** Sudo the command, as root if empty or as user if not. */
- private String sudo = null;
- // TODO make it more secure and robust, test only once
- private final String sudoPrompt = UUID.randomUUID().toString();
- private String askPassProgram = "/usr/libexec/openssh/ssh-askpass";
- @SuppressWarnings("unused")
- private boolean firstLine = true;
- @SuppressWarnings("unused")
- private CallbackHandler callbackHandler;
- /** Chroot to the this path (must not be empty) */
- private String chroot = null;
-
- // Current
- /** Current watchdog, null if process is completed */
- ExecuteWatchdog currentWatchdog = null;
-
- /** Empty constructor */
- public SystemCall() {
-
- }
-
- /**
- * Constructor based on the provided command list.
- *
- * @param command
- * the command list
- */
- public SystemCall(List<Object> command) {
- this.command = command;
- }
-
- /**
- * Constructor based on the provided command.
- *
- * @param cmd
- * the command. If the provided string contains no space a
- * command list is initialized with the argument as first
- * component (useful for chained construction)
- */
- public SystemCall(String cmd) {
- if (cmd.indexOf(' ') < 0) {
- command = new ArrayList<Object>();
- command.add(cmd);
- } else {
- this.cmd = cmd;
- }
- }
-
- /** Executes the system call. */
- public void run() {
-// authentication = SecurityContextHolder.getContext().getAuthentication();
-
- // Manage streams
- Writer stdOutWriter = null;
- OutputStream stdOutputStream = null;
- Writer stdErrWriter = null;
- InputStream stdInStream = null;
- if (stdOutFile != null)
- if (redirectStdOut)
- stdOutputStream = createOutputStream(stdOutFile);
- else
- stdOutWriter = createWriter(stdOutFile, true);
-
- if (stdErrFile != null) {
- stdErrWriter = createWriter(stdErrFile, true);
- } else {
- if (stdOutFile != null && !redirectStdOut)
- stdErrWriter = createWriter(stdOutFile, true);
- }
-
- try {
- if (stdInFile != null)
- stdInStream = stdInFile.getInputStream();
- else {
- stdInStream = new PipedInputStream();
- stdInSink = new PipedOutputStream(
- (PipedInputStream) stdInStream);
- }
- } catch (IOException e2) {
- throw new SlcException("Cannot open a stream for " + stdInFile, e2);
- }
-
- if (log.isTraceEnabled()) {
- log.debug("os.name=" + System.getProperty("os.name"));
- log.debug("os.arch=" + System.getProperty("os.arch"));
- log.debug("os.version=" + System.getProperty("os.version"));
- }
-
- // Execution directory
- File dir = new File(getExecDirToUse());
- // if (!dir.exists())
- // dir.mkdirs();
-
- // Watchdog to check for lost processes
- Executor executorToUse;
- if (executor != null)
- executorToUse = executor;
- else
- executorToUse = new DefaultExecutor();
- executorToUse.setWatchdog(createWatchdog());
-
- if (redirectStreams) {
- // Redirect standard streams
- executorToUse.setStreamHandler(createExecuteStreamHandler(
- stdOutWriter, stdOutputStream, stdErrWriter, stdInStream));
- } else {
- // Dummy stream handler (otherwise pump is used)
- executorToUse.setStreamHandler(new DummyexecuteStreamHandler());
- }
-
- executorToUse.setProcessDestroyer(new ShutdownHookProcessDestroyer());
- executorToUse.setWorkingDirectory(dir);
-
- // Command line to use
- final CommandLine commandLine = createCommandLine();
- if (logCommand)
- log.info("Execute command:\n" + commandLine
- + "\n in working directory: \n" + dir + "\n");
-
- // Env variables
- Map<String, String> environmentVariablesToUse = null;
- environmentVariablesToUse = new HashMap<String, String>();
- if (mergeEnvironmentVariables)
- environmentVariablesToUse.putAll(System.getenv());
- if (environmentVariables.size() > 0)
- environmentVariablesToUse.putAll(environmentVariables);
-
- // Execute
- ExecuteResultHandler executeResultHandler = createExecuteResultHandler(commandLine);
-
- //
- // THE EXECUTION PROPER
- //
- try {
- if (synchronous)
- try {
- int exitValue = executorToUse.execute(commandLine,
- environmentVariablesToUse);
- executeResultHandler.onProcessComplete(exitValue);
- } catch (ExecuteException e1) {
- if (e1.getExitValue() == Executor.INVALID_EXITVALUE) {
- Thread.currentThread().interrupt();
- return;
- }
- // Sleep 1s in order to make sure error logs are flushed
- Thread.sleep(1000);
- executeResultHandler.onProcessFailed(e1);
- }
- else
- executorToUse.execute(commandLine, environmentVariablesToUse,
- executeResultHandler);
- } catch (SlcException e) {
- throw e;
- } catch (Exception e) {
- throw new SlcException("Could not execute command " + commandLine,
- e);
- } finally {
- IOUtils.closeQuietly(stdOutWriter);
- IOUtils.closeQuietly(stdErrWriter);
- IOUtils.closeQuietly(stdInStream);
- IOUtils.closeQuietly(stdInSink);
- }
-
- }
-
- public synchronized String function() {
- final StringBuffer buf = new StringBuffer("");
- SystemCallOutputListener tempOutputListener = new SystemCallOutputListener() {
- private Long lineCount = 0l;
-
- public void newLine(SystemCall systemCall, String line,
- Boolean isError) {
- if (!isError) {
- if (lineCount != 0l)
- buf.append('\n');
- buf.append(line);
- lineCount++;
- }
- }
- };
- addOutputListener(tempOutputListener);
- run();
- removeOutputListener(tempOutputListener);
- return buf.toString();
- }
-
- public String asCommand() {
- return createCommandLine().toString();
- }
-
- @Override
- public String toString() {
- return asCommand();
- }
-
- /**
- * Build a command line based on the properties. Can be overridden by
- * specific command wrappers.
- */
- protected CommandLine createCommandLine() {
- // Check if an OS specific command overrides
- String osName = System.getProperty("os.name");
- List<Object> commandToUse = null;
- if (osCommands.containsKey(osName))
- commandToUse = osCommands.get(osName);
- else
- commandToUse = command;
- String cmdToUse = null;
- if (osCmds.containsKey(osName))
- cmdToUse = osCmds.get(osName);
- else
- cmdToUse = cmd;
-
- CommandLine commandLine = null;
-
- // Which command definition to use
- if (commandToUse == null && cmdToUse == null)
- throw new SlcException("Please specify a command.");
- else if (commandToUse != null && cmdToUse != null)
- throw new SlcException(
- "Specify the command either as a line or as a list.");
- else if (cmdToUse != null) {
- if (chroot != null && !chroot.trim().equals(""))
- cmdToUse = "chroot \"" + chroot + "\" " + cmdToUse;
- if (sudo != null) {
- environmentVariables.put("SUDO_ASKPASS", askPassProgram);
- if (!sudo.trim().equals(""))
- cmdToUse = "sudo -p " + sudoPrompt + " -u " + sudo + " "
- + cmdToUse;
- else
- cmdToUse = "sudo -p " + sudoPrompt + " " + cmdToUse;
- }
-
- // GENERATE COMMAND LINE
- commandLine = CommandLine.parse(cmdToUse);
- } else if (commandToUse != null) {
- if (commandToUse.size() == 0)
- throw new SlcException("Command line is empty.");
-
- if (chroot != null && sudo != null) {
- commandToUse.add(0, "chroot");
- commandToUse.add(1, chroot);
- }
-
- if (sudo != null) {
- environmentVariables.put("SUDO_ASKPASS", askPassProgram);
- commandToUse.add(0, "sudo");
- commandToUse.add(1, "-p");
- commandToUse.add(2, sudoPrompt);
- if (!sudo.trim().equals("")) {
- commandToUse.add(3, "-u");
- commandToUse.add(4, sudo);
- }
- }
-
- // GENERATE COMMAND LINE
- commandLine = new CommandLine(commandToUse.get(0).toString());
-
- for (int i = 1; i < commandToUse.size(); i++) {
- if (log.isTraceEnabled())
- log.debug(commandToUse.get(i));
- commandLine.addArgument(commandToUse.get(i).toString());
- }
- } else {
- // all cases covered previously
- throw new UnsupportedException();
- }
-
- if (generateScript != null) {
- File scriptFile = new File(getExecDirToUse() + File.separator
- + generateScript);
- try {
- FileUtils.writeStringToFile(scriptFile,
- (osConsole != null ? osConsole + " " : "")
- + commandLine.toString());
- } catch (IOException e) {
- throw new SlcException("Could not generate script "
- + scriptFile, e);
- }
- commandLine = new CommandLine(scriptFile);
- } else {
- if (osConsole != null)
- commandLine = CommandLine.parse(osConsole + " "
- + commandLine.toString());
- }
-
- return commandLine;
- }
-
- /**
- * Creates a {@link PumpStreamHandler} which redirects streams to the custom
- * logging mechanism.
- */
- protected ExecuteStreamHandler createExecuteStreamHandler(
- final Writer stdOutWriter, final OutputStream stdOutputStream,
- final Writer stdErrWriter, final InputStream stdInStream) {
-
- // Log writers
- OutputStream stdout = stdOutputStream != null ? stdOutputStream
- : new LogOutputStream() {
- protected void processLine(String line, int level) {
- // if (firstLine) {
- // if (sudo != null && callbackHandler != null
- // && line.startsWith(sudoPrompt)) {
- // try {
- // PasswordCallback pc = new PasswordCallback(
- // "sudo password", false);
- // Callback[] cbs = { pc };
- // callbackHandler.handle(cbs);
- // char[] pwd = pc.getPassword();
- // char[] arr = Arrays.copyOf(pwd,
- // pwd.length + 1);
- // arr[arr.length - 1] = '\n';
- // IOUtils.write(arr, stdInSink);
- // stdInSink.flush();
- // } catch (Exception e) {
- // throw new SlcException(
- // "Cannot retrieve sudo password", e);
- // }
- // }
- // firstLine = false;
- // }
-
- if (line != null && !line.trim().equals(""))
- logStdOut(line);
-
- if (stdOutWriter != null)
- appendLineToFile(stdOutWriter, line);
- }
- };
-
- OutputStream stderr = new LogOutputStream() {
- protected void processLine(String line, int level) {
- if (line != null && !line.trim().equals(""))
- logStdErr(line);
- if (stdErrWriter != null)
- appendLineToFile(stdErrWriter, line);
- }
- };
-
- PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(stdout,
- stderr, stdInStream) {
-
- @Override
- public void stop() throws IOException {
- // prevents the method to block when joining stdin
- if (stdInSink != null)
- IOUtils.closeQuietly(stdInSink);
-
- super.stop();
- }
- };
- return pumpStreamHandler;
- }
-
- /** Creates the default {@link ExecuteResultHandler}. */
- protected ExecuteResultHandler createExecuteResultHandler(
- final CommandLine commandLine) {
- return new ExecuteResultHandler() {
-
- public void onProcessComplete(int exitValue) {
- String msg = "System call '" + commandLine
- + "' properly completed.";
- if (log.isTraceEnabled())
- log.trace(msg);
- if (testResult != null) {
- forwardPath(testResult);
- testResult.addResultPart(new SimpleResultPart(
- TestStatus.PASSED, msg));
- }
- releaseWatchdog();
- }
-
- public void onProcessFailed(ExecuteException e) {
-
- String msg = "System call '" + commandLine + "' failed.";
- if (testResult != null) {
- forwardPath(testResult);
- testResult.addResultPart(new SimpleResultPart(
- TestStatus.ERROR, msg, e));
- } else {
- if (exceptionOnFailed)
- throw new SlcException(msg, e);
- else
- log.error(msg, e);
- }
- releaseWatchdog();
- }
- };
- }
-
- @Deprecated
- protected void forwardPath(TestResult testResult) {
- // TODO: allocate a TreeSPath
- }
-
- /**
- * Shortcut method getting the execDir to use
- */
- protected String getExecDirToUse() {
- try {
- if (execDir != null) {
- return execDir;
- }
- return System.getProperty("user.dir");
- } catch (Exception e) {
- throw new SlcException("Cannot find exec dir", e);
- }
- }
-
- protected void logStdOut(String line) {
- for (SystemCallOutputListener outputListener : outputListeners)
- outputListener.newLine(this, line, false);
- log(stdOutLogLevel, line);
- }
-
- protected void logStdErr(String line) {
- for (SystemCallOutputListener outputListener : outputListeners)
- outputListener.newLine(this, line, true);
- log(stdErrLogLevel, line);
- }
-
- /** Log from the underlying streams. */
- protected void log(String logLevel, String line) {
- // TODO optimize
-// if (SecurityContextHolder.getContext().getAuthentication() == null) {
-// SecurityContextHolder.getContext()
-// .setAuthentication(authentication);
-// }
-
- if ("ERROR".equals(logLevel))
- log.error(line);
- else if ("WARN".equals(logLevel))
- log.warn(line);
- else if ("INFO".equals(logLevel))
- log.info(line);
- else if ("DEBUG".equals(logLevel))
- log.debug(line);
- else if ("TRACE".equals(logLevel))
- log.trace(line);
- else if (LOG_STDOUT.equals(logLevel))
- System.out.println(line);
- else if ("System.err".equals(logLevel))
- System.err.println(line);
- else
- throw new SlcException("Unknown log level " + logLevel);
- }
-
- /** Append line to a log file. */
- protected void appendLineToFile(Writer writer, String line) {
- try {
- writer.append(line).append('\n');
- } catch (IOException e) {
- log.error("Cannot write to log file", e);
- }
- }
-
- /** Creates the writer for the output/err files. */
- protected Writer createWriter(Resource target, Boolean append) {
- FileWriter writer = null;
- try {
-
- final File file;
- if (executionResources != null)
- file = new File(executionResources.getAsOsPath(target, true));
- else
- file = target.getFile();
- writer = new FileWriter(file, append);
- } catch (IOException e) {
- log.error("Cannot get file for " + target, e);
- IOUtils.closeQuietly(writer);
- }
- return writer;
- }
-
- /** Creates an outputstream for the output/err files. */
- protected OutputStream createOutputStream(Resource target) {
- FileOutputStream out = null;
- try {
-
- final File file;
- if (executionResources != null)
- file = new File(executionResources.getAsOsPath(target, true));
- else
- file = target.getFile();
- out = new FileOutputStream(file, false);
- } catch (IOException e) {
- log.error("Cannot get file for " + target, e);
- IOUtils.closeQuietly(out);
- }
- return out;
- }
-
- /** Append the argument (for chaining) */
- public SystemCall arg(String arg) {
- if (command == null)
- command = new ArrayList<Object>();
- command.add(arg);
- return this;
- }
-
- /** Append the argument (for chaining) */
- public SystemCall arg(String arg, String value) {
- if (command == null)
- command = new ArrayList<Object>();
- command.add(arg);
- command.add(value);
- return this;
- }
-
- // CONTROL
- public synchronized Boolean isRunning() {
- return currentWatchdog != null;
- }
-
- private synchronized ExecuteWatchdog createWatchdog() {
-// if (currentWatchdog != null)
-// throw new SlcException("A process is already being monitored");
- currentWatchdog = new ExecuteWatchdog(watchdogTimeout);
- return currentWatchdog;
- }
-
- private synchronized void releaseWatchdog() {
- currentWatchdog = null;
- }
-
- public synchronized void kill() {
- if (currentWatchdog != null)
- currentWatchdog.destroyProcess();
- }
-
- /** */
- public void setCmd(String command) {
- this.cmd = command;
- }
-
- public void setCommand(List<Object> command) {
- this.command = command;
- }
-
- public void setExecDir(String execdir) {
- this.execDir = execdir;
- }
-
- public void setStdErrLogLevel(String stdErrLogLevel) {
- this.stdErrLogLevel = stdErrLogLevel;
- }
-
- public void setStdOutLogLevel(String stdOutLogLevel) {
- this.stdOutLogLevel = stdOutLogLevel;
- }
-
- public void setSynchronous(Boolean synchronous) {
- this.synchronous = synchronous;
- }
-
- public void setOsCommands(Map<String, List<Object>> osCommands) {
- this.osCommands = osCommands;
- }
-
- public void setOsCmds(Map<String, String> osCmds) {
- this.osCmds = osCmds;
- }
-
- public void setEnvironmentVariables(Map<String, String> environmentVariables) {
- this.environmentVariables = environmentVariables;
- }
-
- public Map<String, String> getEnvironmentVariables() {
- return environmentVariables;
- }
-
- public void setWatchdogTimeout(Long watchdogTimeout) {
- this.watchdogTimeout = watchdogTimeout;
- }
-
- public void setStdOutFile(Resource stdOutFile) {
- this.stdOutFile = stdOutFile;
- }
-
- public void setStdErrFile(Resource stdErrFile) {
- this.stdErrFile = stdErrFile;
- }
-
- public void setStdInFile(Resource stdInFile) {
- this.stdInFile = stdInFile;
- }
-
- public void setTestResult(TestResult testResult) {
- this.testResult = testResult;
- }
-
- public void setLogCommand(Boolean logCommand) {
- this.logCommand = logCommand;
- }
-
- public void setRedirectStreams(Boolean redirectStreams) {
- this.redirectStreams = redirectStreams;
- }
-
- public void setExceptionOnFailed(Boolean exceptionOnFailed) {
- this.exceptionOnFailed = exceptionOnFailed;
- }
-
- public void setMergeEnvironmentVariables(Boolean mergeEnvironmentVariables) {
- this.mergeEnvironmentVariables = mergeEnvironmentVariables;
- }
-
- public void setOsConsole(String osConsole) {
- this.osConsole = osConsole;
- }
-
- public void setGenerateScript(String generateScript) {
- this.generateScript = generateScript;
- }
-
- public void setExecutionResources(ExecutionResources executionResources) {
- this.executionResources = executionResources;
- }
-
- public void setRedirectStdOut(Boolean redirectStdOut) {
- this.redirectStdOut = redirectStdOut;
- }
-
- public void addOutputListener(SystemCallOutputListener outputListener) {
- outputListeners.add(outputListener);
- }
-
- public void removeOutputListener(SystemCallOutputListener outputListener) {
- outputListeners.remove(outputListener);
- }
-
- public void setOutputListeners(
- List<SystemCallOutputListener> outputListeners) {
- this.outputListeners = outputListeners;
- }
-
- public void setExecutor(Executor executor) {
- this.executor = executor;
- }
-
- public void setSudo(String sudo) {
- this.sudo = sudo;
- }
-
- public void setCallbackHandler(CallbackHandler callbackHandler) {
- this.callbackHandler = callbackHandler;
- }
-
- public void setChroot(String chroot) {
- this.chroot = chroot;
- }
-
- private class DummyexecuteStreamHandler implements ExecuteStreamHandler {
-
- public void setProcessErrorStream(InputStream is) throws IOException {
- }
-
- public void setProcessInputStream(OutputStream os) throws IOException {
- }
-
- public void setProcessOutputStream(InputStream is) throws IOException {
- }
-
- public void start() throws IOException {
- }
-
- public void stop() {
- }
-
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-public interface SystemCallOutputListener {
- public void newLine(SystemCall systemCall, String line, Boolean isError);
-}
+++ /dev/null
-package org.argeo.slc.core.execution.tasks;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.attachment.Attachment;
-import org.argeo.slc.attachment.AttachmentsEnabled;
-import org.argeo.slc.core.attachment.AttachmentUploader;
-import org.springframework.core.io.Resource;
-
-public class UploadAttachments implements Runnable {
- private AttachmentUploader attachmentUploader;
- private Attachment attachment = null;
- private Resource resource = null;
- private Map<Attachment, Resource> attachments = new HashMap<Attachment, Resource>();
- private List<AttachmentsEnabled> attachTo = new ArrayList<AttachmentsEnabled>();
- private Boolean newUuidPerExecution = true;
-
- public void run() {
- if (attachment != null) {
- if (resource == null)
- throw new SlcException("A resource must be specified.");
- uploadAndAdd(attachment, resource);
- }
-
- for (Attachment attachmentT : attachments.keySet()) {
- Resource resourceT = attachments.get(attachmentT);
- uploadAndAdd(attachmentT, resourceT);
- }
-
- }
-
- protected void uploadAndAdd(Attachment attachment, Resource resource) {
- if (newUuidPerExecution)
- attachment.setUuid(UUID.randomUUID().toString());
- attachmentUploader.upload(attachment, resource);
- for (AttachmentsEnabled attachmentsEnabled : attachTo) {
- attachmentsEnabled.addAttachment(attachment);
- }
- }
-
- public void setAttachmentUploader(AttachmentUploader attachmentUploader) {
- this.attachmentUploader = attachmentUploader;
- }
-
- public void setAttachments(Map<Attachment, Resource> attachments) {
- this.attachments = attachments;
- }
-
- public void setAttachTo(List<AttachmentsEnabled> attachTo) {
- this.attachTo = attachTo;
- }
-
- public void setAttachment(Attachment attachment) {
- this.attachment = attachment;
- }
-
- public void setResource(Resource resource) {
- this.resource = resource;
- }
-
- public void setNewUuidPerExecution(Boolean newUuidPerExecution) {
- this.newUuidPerExecution = newUuidPerExecution;
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
- <bean id="task.echo" class="org.argeo.slc.core.execution.tasks.Echo"
- abstract="true" />
- <bean id="task.systemCall" class="org.argeo.slc.core.execution.tasks.SystemCall"
- abstract="true" />
- <bean id="task.closeTestResult" class="org.argeo.slc.core.execution.tasks.CloseTestResult"
- abstract="true" />
- <bean id="task.slcManager" class="org.argeo.slc.core.execution.tasks.SlcManager"
- abstract="true" />
- <bean id="task.overrideContextAware" class="org.argeo.slc.core.execution.tasks.OverrideContextAware"
- abstract="true" />
- <bean id="task.uploadAttachments" class="org.argeo.slc.core.execution.tasks.UploadAttachments"
- abstract="true" />
-
- <bean id="taskArg.attachment" class="org.argeo.slc.core.attachment.SimpleAttachment"
- abstract="true" />
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
- <bean id="slcTemplate.fileResources" class="org.argeo.slc.core.execution.FileExecutionResources"
- abstract="true" />
-
- <bean id="slcTemplate.resourcesFactoryBean" parent="slcTemplate.writableResource"
- abstract="true" />
-
- <bean id="slcTemplate.writableResource"
- class="org.argeo.slc.core.execution.ExecutionResourcesFactoryBean"
- abstract="true" />
-
- <bean id="slcTemplate.osFile" class="org.argeo.slc.core.execution.OsFileFactoryBean"
- abstract="true" />
-
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
- <bean id="mergedLists" class="org.argeo.slc.core.execution.tasks.MergedLists"
- abstract="true">
- </bean>
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.execution.xml;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.DefaultExecutionFlow;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.springframework.beans.BeanMetadataElement;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/** Publishes a {@link Runnable} as an {@link ExecutionFlow} */
-public class AsFlowDecorator implements BeanDefinitionDecorator {
- private Log log = LogFactory.getLog(AsFlowDecorator.class);
-
- public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder bean,
- ParserContext ctx) {
- String attrValue = ((Attr) node).getValue();
- if (attrValue.charAt(attrValue.length() - 1) == '/')
- throw new SlcException(attrValue + " cannot end with a path");
- final String flowBeanName = attrValue;
-
- if (log.isTraceEnabled())
- log.trace("flowBeanName=" + flowBeanName);
-
- if (ctx.getRegistry().containsBeanDefinition(flowBeanName))
- throw new SlcException("A bean named " + flowBeanName
- + " is already defined.");
- BeanDefinitionBuilder flow = BeanDefinitionBuilder
- .rootBeanDefinition(DefaultExecutionFlow.class);
- ManagedList<BeanMetadataElement> executables = new ManagedList<BeanMetadataElement>(
- 1);
-
- String beanName = bean.getBeanName();
- if (beanName == null)
- executables.add(bean.getBeanDefinition());
- else
- executables.add(new RuntimeBeanReference(beanName));
-
- // if (path != null)
- // flow.addPropertyValue("path", path);
- flow.addPropertyValue("executables", executables);
-
- if (beanName != null)
- ctx.getRegistry().registerBeanDefinition(flowBeanName,
- flow.getBeanDefinition());
- return bean;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.xml;
-
-import org.springframework.aop.scope.ScopedProxyUtils;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.parsing.BeanComponentDefinition;
-import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Inspired by org.springframework.aop.config.ScopedProxyBeanDefinitionDecorator
- */
-public class ExecutionScopeDecorator implements BeanDefinitionDecorator {
- private static final String PROXY_TARGET_CLASS = "proxy-target-class";
-
- public BeanDefinitionHolder decorate(Node node,
- BeanDefinitionHolder definition, ParserContext parserContext) {
-
- definition.getBeanDefinition().setScope("execution");
-
- // Default: CGLib not used
- boolean proxyTargetClass = false;
- if (node instanceof Element) {
- Element ele = (Element) node;
- if (ele.hasAttribute(PROXY_TARGET_CLASS)) {
- proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS)).booleanValue();
- }
- }
-
- // Register the original bean definition as it will be referenced by the scoped proxy and is relevant for tooling (validation, navigation).
- String targetBeanName = ScopedProxyUtils.getTargetBeanName(definition.getBeanName());
- parserContext.getReaderContext().fireComponentRegistered(new BeanComponentDefinition(definition.getBeanDefinition(), targetBeanName));
-
- return ScopedProxyUtils.createScopedProxy(definition, parserContext.getRegistry(), proxyTargetClass);
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution.xml;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.DefaultExecutionFlow;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.ManagedMap;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/** Interprets the <flow:flow> tag */
-public class FlowBeanDefinitionParser extends
- AbstractSingleBeanDefinitionParser {
- private Log log = LogFactory.getLog(FlowBeanDefinitionParser.class);
-
- /** Whether the user has already be warned on path attribute usage. */
- private Boolean warnedAboutPathAttribute = false;
-
- @Override
- protected void doParse(Element element, ParserContext parserContext,
- BeanDefinitionBuilder builder) {
- String path = element.getAttribute("path");
- if (StringUtils.hasText(path)) {
- builder.addPropertyValue("path", path);
-
- // warns user only once
- if (!warnedAboutPathAttribute)
- log.warn("The path=\"\" attribute is deprecated"
- + " and will be removed in a later release."
- + " Use <flow:flow name=\"/my/path/flowName\">.");
- warnedAboutPathAttribute = true;
- }
-
- String spec = element.getAttribute("spec");
- if (StringUtils.hasText(spec))
- builder.getBeanDefinition().getConstructorArgumentValues()
- .addGenericArgumentValue(new RuntimeBeanReference(spec));
-
- String abstrac = element.getAttribute("abstract");
- if (StringUtils.hasText(abstrac))
- builder.setAbstract(Boolean.parseBoolean(abstrac));
-
- String parent = element.getAttribute("parent");
- if (StringUtils.hasText(parent))
- builder.setParentName(parent);
-
- builder.getBeanDefinition().setDescription(
- DomUtils.getChildElementValueByTagName(element, "description"));
-
- List<Element> argsElems = new ArrayList<Element>();
- List<Element> execElems = new ArrayList<Element>();
- List<Element> specElems = new ArrayList<Element>();
- NodeList nodeList = element.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node node = nodeList.item(i);
- if (node instanceof Element) {
- if (DomUtils.nodeNameEquals(node, "arg"))
- argsElems.add((Element) node);
- else if (DomUtils.nodeNameEquals(node, "spec"))
- specElems.add((Element) node);
- else if (!DomUtils.nodeNameEquals(node, "description"))
- execElems.add((Element) node);
- }
- }
-
- // Arguments
- if (argsElems.size() != 0) {
- ManagedMap<String, Object> args = new ManagedMap<String, Object>(
- argsElems.size());
- for (Element argElem : argsElems) {
- Object value = NamespaceUtils.parseValue(argElem,
- parserContext, builder.getBeanDefinition(), null);
- if (value != null)
- args.put(argElem.getAttribute("name"), value);
- else
- throw new SlcException("No value defined.");
- }
- builder.getBeanDefinition().getConstructorArgumentValues()
- .addGenericArgumentValue(args);
- }
-
- // Execution specs
- if (StringUtils.hasText(spec) && specElems.size() != 0)
- throw new SlcException("A flow cannot have multiple specs");
- if (specElems.size() == 1) {
- Object specObj = NamespaceUtils.parseBeanOrReference(
- specElems.get(0), parserContext,
- builder.getBeanDefinition());
- builder.getBeanDefinition().getConstructorArgumentValues()
- .addGenericArgumentValue(specObj);
- } else if (specElems.size() > 1)
- throw new SlcException("A flow cannot have multiple specs");
-
- // Executables
- if (execElems.size() != 0) {
- ManagedList<Object> executables = new ManagedList<Object>(
- execElems.size());
- for (Element child : execElems) {
- // child validity check is performed in xsd
- executables.add(NamespaceUtils.parseBeanOrReference(child,
- parserContext, builder.getBeanDefinition()));
- }
- if (executables.size() > 0)
- builder.addPropertyValue("executables", executables);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected Class<? extends ExecutionFlow> getBeanClass(Element element) {
- String clss = element.getAttribute("class");
- if (StringUtils.hasText(clss))
- // TODO: check that it actually works
- try {
- return (Class<? extends ExecutionFlow>) getClass()
- .getClassLoader().loadClass(clss);
- } catch (ClassNotFoundException e) {
- try {
- return (Class<? extends ExecutionFlow>) Thread
- .currentThread().getContextClassLoader()
- .loadClass(clss);
- } catch (ClassNotFoundException e1) {
- throw new SlcException("Cannot load class " + clss, e);
- }
- }
- else
- return DefaultExecutionFlow.class;
- }
-
- // parse nested bean definition
- // private Object parseBeanReference(Element element,
- // ParserContext parserContext, BeanDefinitionBuilder builder) {
- // return parserContext.getDelegate().parsePropertySubElement(element,
- // builder.getBeanDefinition());
- // }
-
- @Override
- protected String resolveId(Element element,
- AbstractBeanDefinition definition, ParserContext parserContext)
- throws BeanDefinitionStoreException {
- String name = element.getAttribute("name");
- if (StringUtils.hasText(name)) {
- return name;
- } else {
- return super.resolveId(element, definition, parserContext);
- }
- }
-
- protected boolean shouldGenerateIdAsFallback() {
- return true;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.xml;
-
-import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
-public class FlowNamespaceHandler extends NamespaceHandlerSupport {
-
- public void init() {
- registerBeanDefinitionParser("flow", new FlowBeanDefinitionParser());
- registerBeanDefinitionParser("spec", new SpecBeanDefinitionParser());
- registerBeanDefinitionDecoratorForAttribute("as-flow",
- new AsFlowDecorator());
- registerBeanDefinitionParser("param", new ParamDecorator());
-
- // The objective was to replace
- // - attribute scope="execution"
- // - and element "aop:scoped-proxy"
- // by a single attribute, using an attribute decorator
- // this does not work correctly with other attribute decorators (e.g.
- // p namespace) since this decorator needs to be called after all
- // properties have been set on target bean.
- // It works properly with element decorators (called after all attribute
- // decorators
- registerBeanDefinitionDecorator("variable", new ExecutionScopeDecorator());
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.execution.xml;
-
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Utilities to simplify common tasks when interpreting a custom namespace and
- * converting it into bean definitions.
- */
-public class NamespaceUtils {
- // private final static Log log = LogFactory.getLog(NamespaceUtils.class);
-
- /**
- * Returns the value defined either: directly by the the 'value' attribute,
- * as reference by the 'ref' attribute or as a nested bean.
- */
- public static Object parseValue(Element element,
- ParserContext parserContext,
- BeanDefinition containingBeanDefintion, String valueTagName) {
- Object value = null;
- if (element.hasAttribute("value")) {
- value = element.getAttribute("value");
- }
-
- if (element.hasAttribute("ref")) {
- if (value != null)
- throw new SlcException("Multiple value definition for "
- + element);
- value = new RuntimeBeanReference(element.getAttribute("ref"));
- }
-
- Element uniqueSubElem = null;
- if (valueTagName != null) {
- Element valueElem = DomUtils.getChildElementByTagName(element,
- valueTagName);
- if (valueElem != null) {
- uniqueSubElem = findUniqueSubElement(valueElem);
- if (uniqueSubElem == null)
- throw new SlcException("No subelement found under "
- + valueElem);
- }
- } else {// no intermediary tag
- uniqueSubElem = findUniqueSubElement(element);
- }
-
- if (uniqueSubElem != null) {
- if (value != null)
- throw new SlcException("Multiple value definition for "
- + element);
- value = parseBeanOrReference(uniqueSubElem, parserContext,
- containingBeanDefintion);
- }
- return value;
- }
-
- public static Element findUniqueSubElement(Element element) {
- NodeList childNodes = element.getChildNodes();
-
- Element uniqueSubElem = null;
- for (int i = 0; i < childNodes.getLength(); i++) {
- Node node = childNodes.item(i);
- if (node != null && node instanceof Element) {
- if (uniqueSubElem == null)
- uniqueSubElem = (Element) node;
- else
- throw new SlcException(
- "There are more than one sub element under "
- + element);
- }
- }
- return uniqueSubElem;
- }
-
- public static Object parseBeanOrReference(Element element,
- ParserContext parserContext, BeanDefinition beanDefinition) {
- // return parserContext.getDelegate().parsePropertySubElement(element,
- // beanDefinition);
-
- BeanDefinitionParserDelegate deleg = parserContext.getDelegate();
- // if ("bean".equals(element.getNodeName()))
- // return deleg.parseBeanDefinitionElement(element, beanDefinition);
- // else
- return deleg.parsePropertySubElement(element, beanDefinition);
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution.xml;
-
-import org.argeo.slc.core.execution.ParameterRef;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-import org.w3c.dom.Element;
-
-public class ParamDecorator extends AbstractSingleBeanDefinitionParser {
-
- // public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder
- // bean,
- // ParserContext ctx) {
- // String paramName = ((Element) node).getAttribute("name");
- // String propertyName = ((Element) node.getParentNode())
- // .getAttribute("name");
- // BeanDefinitionBuilder parameterRef = BeanDefinitionBuilder
- // .genericBeanDefinition(ParameterRef.class);
- // parameterRef.addPropertyReference("instantiationManager",
- // "instantiationManager");
- // parameterRef.addConstructorArgValue(paramName);
- // bean.getBeanDefinition().getPropertyValues().addPropertyValue(
- // propertyName, parameterRef.getBeanDefinition());
- // return bean;
- // }
-
- @Override
- protected void doParse(Element element, ParserContext parserContext,
- BeanDefinitionBuilder builder) {
- String paramName = element.getAttribute("name");
-
- String instantationManagerRef = element
- .getAttribute("instantiationManager");
- if (!StringUtils.hasText(instantationManagerRef))
- instantationManagerRef = "instantiationManager";
- builder.addPropertyReference("instantiationManager",
- instantationManagerRef);
- builder.addConstructorArgValue(paramName);
- }
-
- @Override
- protected Class<ParameterRef> getBeanClass(Element element) {
- return ParameterRef.class;
- }
-}
+++ /dev/null
-package org.argeo.slc.core.execution.xml;
-
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValueChoice;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.support.ManagedMap;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-import org.springframework.util.xml.DomUtils;
-import org.w3c.dom.Element;
-
-/** Interprets the <flow:spec> tag */
-public class SpecBeanDefinitionParser extends
- AbstractSingleBeanDefinitionParser {
- private Log log = LogFactory.getLog(SpecBeanDefinitionParser.class);
-
- @Override
- protected void doParse(Element element, ParserContext parserContext,
- BeanDefinitionBuilder builder) {
- builder.getBeanDefinition().setDescription(
- DomUtils.getChildElementValueByTagName(element, "description"));
-
- ManagedMap<String, BeanDefinition> attributes = new ManagedMap<String, BeanDefinition>();
-
- // Primitives
- for (Element child : (List<Element>) DomUtils
- .getChildElementsByTagName(element, "primitive")) {
- BeanDefinitionBuilder childBuilder = BeanDefinitionBuilder
- .genericBeanDefinition(PrimitiveSpecAttribute.class);
- addCommonProperties(child, parserContext, childBuilder);
-
- String type = child.getAttribute("type");
- if (StringUtils.hasText(type))
- childBuilder.addPropertyValue("type", type);
-
- putInAttributes(attributes, child,
- childBuilder.getBeanDefinition(), "primitive");
- }
-
- // Refs
- for (Element refAttrElem : (List<Element>) DomUtils
- .getChildElementsByTagName(element, "ref")) {
- BeanDefinitionBuilder refAttrBuilder = BeanDefinitionBuilder
- .genericBeanDefinition(RefSpecAttribute.class);
- addCommonProperties(refAttrElem, parserContext, refAttrBuilder);
-
- String targetClassName = refAttrElem.getAttribute("targetClass");
- if (StringUtils.hasText(targetClassName))
- refAttrBuilder.addPropertyValue("targetClass", targetClassName);
-
- // Choices
- Element choicesElem = DomUtils.getChildElementByTagName(
- refAttrElem, "choices");
- if (choicesElem != null) {
- List<Element> choices = DomUtils.getChildElementsByTagName(
- choicesElem, "choice");
- ManagedList<BeanDefinition> choiceBeans = new ManagedList<BeanDefinition>(
- choices.size());
- for (Element choiceElem : choices) {
- BeanDefinitionBuilder choiceBuilder = BeanDefinitionBuilder
- .genericBeanDefinition(RefValueChoice.class);
- choiceBuilder.addPropertyValue("name",
- choiceElem.getAttribute("name"));
- String desc = choiceElem.getAttribute("description");
- if (StringUtils.hasText(desc))
- choiceBuilder.addPropertyValue("description", desc);
-
- choiceBeans.add(choiceBuilder.getBeanDefinition());
- }
- refAttrBuilder.addPropertyValue("choices", choiceBeans);
- }
-
- putInAttributes(attributes, refAttrElem,
- refAttrBuilder.getBeanDefinition(), "ref");
- }
-
- builder.addPropertyValue("attributes", attributes);
- }
-
- protected void addCommonProperties(Element element,
- ParserContext parserContext, BeanDefinitionBuilder specAttr) {
- addBooleanProperty("isImmutable", specAttr, element);
- addBooleanProperty("isConstant", specAttr, element);
- addBooleanProperty("isHidden", specAttr, element);
- addBooleanProperty("isParameter", specAttr, element);
- addBooleanProperty("isFrozen", specAttr, element);
-
- Object value = NamespaceUtils.parseValue(element, parserContext,
- specAttr.getBeanDefinition(), "value");
- if (value != null)
- specAttr.addPropertyValue("value", value);
-
- }
-
- protected void putInAttributes(
- ManagedMap<String, BeanDefinition> attributes, Element child,
- BeanDefinition beanDefinition, String nature) {
- String name = child.getAttribute("name");
- attributes.put(name, beanDefinition);
- if (log.isTraceEnabled())
- log.debug("Added " + nature + " attribute " + name);
-
- }
-
- private void addBooleanProperty(String name,
- BeanDefinitionBuilder specAttr, Element element) {
- String bool = element.getAttribute(name);
- if (StringUtils.hasText(bool))
- specAttr.addPropertyValue(name, Boolean.parseBoolean(bool));
-
- }
-
- @Override
- protected Class<DefaultExecutionSpec> getBeanClass(Element element) {
- return DefaultExecutionSpec.class;
- }
-
- protected boolean shouldGenerateIdAsFallback() {
- return false;
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns:beans="http://www.springframework.org/schema/beans"
- targetNamespace="http://www.argeo.org/schema/slc-flow"
- elementFormDefault="qualified" attributeFormDefault="unqualified">
-
- <xsd:import namespace="http://www.springframework.org/schema/beans"
- schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" />
-
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- SLC Flow Schema, version 0.12
- Authors: Mathieu Baudier
-
- This simplifies the definition of SLC flows and their integration with
- regular Spring beans.
- ]]></xsd:documentation>
- </xsd:annotation>
-
- <xsd:element name="flow">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Adds an SLC execution flow, using the default implementation.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:complexContent>
- <xsd:extension base="beans:identifiedType">
- <xsd:sequence>
- <xsd:element ref="beans:description" minOccurs="0" />
- <xsd:sequence>
- <xsd:element name="arg" minOccurs="0" maxOccurs="unbounded"
- type="flow:argType">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Parameter for an execution flow which will override at instantiation the
- value of the parameter already defined as default value or in a parent bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:sequence>
- <xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element ref="beans:bean" />
- <xsd:element ref="beans:ref" />
- <xsd:element ref="flow:flow" />
- </xsd:choice>
- <!--
- <xsd:any namespace="##other" processContents="strict"
- minOccurs="0" maxOccurs="unbounded" />
- -->
- </xsd:sequence>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Name of the flow (alternative to ID).
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Another implementation of execution flow.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The hierarchical path under which to register this flow.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="spec" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A reference to the related specification bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="parent" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The parent bean definition (in Spring sense).
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="abstract" type="xsd:boolean"
- default="false">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether this flow is abstract (in Spring sense).
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="spec">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- SLC flow specifications, defining the parameters and variables
- which can be used in related flows, along with their default values and
- various constraints.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:complexContent>
- <xsd:extension base="beans:identifiedType">
- <xsd:sequence>
- <xsd:element ref="beans:description" minOccurs="0" />
- <xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element name="primitive" type="flow:primitiveSpecAttributeType"
- minOccurs="0" maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A primitive specification attribute, that is, a plain standard value
- and not a reference to an object.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="ref" type="flow:refSpecAttributeType"
- minOccurs="0" maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A reference specification attribute, that is, a reference to another object.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:choice>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:complexType name="specAttributeType">
- <xsd:choice>
- <xsd:element name="value" minOccurs="0" maxOccurs="1">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The default value of the attribute as an inner bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:choice minOccurs="1" maxOccurs="1">
- <xsd:element ref="beans:bean" />
- <xsd:element ref="beans:ref" />
- <xsd:element ref="beans:list" />
- <xsd:element ref="beans:set" />
- <xsd:element ref="beans:map" />
- <xsd:element ref="beans:props" />
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:attribute name="name" use="required" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The name of the attribute, under which in can then be referenced.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="value" use="optional" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The default value of the attribute.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="ref" use="optional" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The default value of the attribute as a reference to another bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="isParameter" use="optional" type="xsd:boolean"
- default="false">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether the attribute is a parameter, that is, it has to be set at
- instantiation but can be modified afterwards for objects of scope execution.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="isFrozen" use="optional" type="xsd:boolean"
- default="false">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether the attribute is frozen, that is, it cannot be modified at runtime.
- A frozen attribute has to be a parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="isHidden" use="optional" type="xsd:boolean"
- default="false">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether the attribute is hidden, that is, it should not be displayed in UIs.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
-
- <xsd:complexType name="primitiveSpecAttributeType">
- <xsd:complexContent>
- <xsd:extension base="flow:specAttributeType">
- <xsd:attribute name="type" default="string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The type of the primitive specification attribute.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="string" />
- <xsd:enumeration value="integer" />
- <xsd:enumeration value="long" />
- <xsd:enumeration value="float" />
- <xsd:enumeration value="double" />
- <xsd:enumeration value="boolean" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:attribute>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="refSpecAttributeType">
- <xsd:complexContent>
- <xsd:extension base="flow:specAttributeType">
- <xsd:choice>
- <xsd:element name="choices" minOccurs="0" maxOccurs="1">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Possible values to chose from, if ommitted, all the beans in the
- application context which implement the provided targetClass will
- be considered.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:choice>
- <xsd:element name="choice" minOccurs="0" maxOccurs="unbounded"
- type="flow:refChoiceType">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A choice for a reference specification attribute.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:attribute name="targetClass" use="required" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The class that has to be implemented by the underlying object.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="refChoiceType">
- <xsd:attribute name="name" use="required" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The name of the related bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="description" use="optional" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A human readable description of this choice.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
-
- <xsd:complexType name="argType">
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element ref="beans:bean" />
- <xsd:element ref="beans:ref" />
- <xsd:element ref="flow:param" />
- <xsd:element ref="beans:list" />
- <xsd:element ref="beans:set" />
- <xsd:element ref="beans:map" />
- <xsd:element ref="beans:props" />
- </xsd:choice>
- <xsd:attribute name="name" use="required" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The name of the related parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="value" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The plain value of the related parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="ref" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The value of the related parameter as a reference to a bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
-
- <xsd:attribute name="as-flow" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- If decorating an executable bean, it will generate an implicit SLC
- execution flow with the provided value as name.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <!--
- <xsd:attribute name="var" type="xsd:boolean"> <xsd:annotation>
- <xsd:documentation><![CDATA[ If true, the decorated bean is set to
- scope execution and proxied. ]]></xsd:documentation> </xsd:annotation>
- </xsd:attribute>
- -->
-
- <xsd:element name="variable">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Marks a bean definition as being variable, i.e. a scoped proxy of scope execution
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="proxy-target-class" type="xsd:boolean"
- default="true">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Are class-based (CGLIB) proxies to be created?
- This is the default;
- in order to switch to standard Java
- interface-based proxies, turn this flag to
- "false".
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="param">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- If within a property tag of a bean, it will set the value of this property
- with a reference to a parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string" use="required">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The name of the related parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="instantiationManager" type="xsd:string"
- use="optional" default="instantiationManager">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A reference to the instantiation manager to use instead of the default one
- (expert usage).
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- </xsd:element>
-
-</xsd:schema>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:flow="http://www.argeo.org/schema/slc-flow" xmlns:beans="http://www.springframework.org/schema/beans"
- targetNamespace="http://www.argeo.org/schema/slc-flow"
- elementFormDefault="qualified" attributeFormDefault="unqualified">
-
- <xsd:import namespace="http://www.springframework.org/schema/beans"
- schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" />
-
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- SLC Flow Schema, version 1.2
- Authors: Mathieu Baudier
-
- This simplifies the definition of SLC flows and their integration with
- regular Spring beans.
- ]]></xsd:documentation>
- </xsd:annotation>
-
- <xsd:element name="flow">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Adds an SLC execution flow, using the default implementation.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:complexContent>
- <xsd:extension base="beans:identifiedType">
- <xsd:sequence>
- <xsd:element ref="beans:description" minOccurs="0" />
- <xsd:sequence>
- <xsd:element name="arg" minOccurs="0" maxOccurs="unbounded"
- type="flow:argType">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Parameter for an execution flow which will override at instantiation the
- value of the parameter already defined as default value or in a parent bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:sequence>
- <xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element ref="beans:bean" />
- <xsd:element ref="beans:ref" />
- <xsd:element ref="flow:flow" />
- <xsd:element ref="flow:spec" />
- </xsd:choice>
- <!-- <xsd:any namespace="##other" processContents="strict" minOccurs="0"
- maxOccurs="unbounded" /> -->
- </xsd:sequence>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Name of the flow (alternative to ID).
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Another implementation of execution flow.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="path" type="xsd:string">
- <!-- DEPRECATED: not used anymore -->
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The hierarchical path under which to register this flow.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="spec" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A reference to the related specification bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="parent" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The parent bean definition (in Spring sense).
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="abstract" type="xsd:boolean"
- default="false">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether this flow is abstract (in Spring sense).
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="spec">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- SLC flow specifications, defining the parameters and variables
- which can be used in related flows, along with their default values and
- various constraints.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:complexContent>
- <xsd:extension base="beans:identifiedType">
- <xsd:sequence>
- <xsd:element ref="beans:description" minOccurs="0" />
- <xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element name="primitive" type="flow:primitiveSpecAttributeType"
- minOccurs="0" maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A primitive specification attribute, that is, a plain standard value
- and not a reference to an object.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="ref" type="flow:refSpecAttributeType"
- minOccurs="0" maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A reference specification attribute, that is, a reference to another object.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:choice>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:complexType name="specAttributeType">
- <xsd:choice>
- <xsd:element name="value" minOccurs="0" maxOccurs="1">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The default value of the attribute as an inner bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:choice minOccurs="1" maxOccurs="1">
- <xsd:element ref="beans:bean" />
- <xsd:element ref="beans:ref" />
- <xsd:element ref="beans:list" />
- <xsd:element ref="beans:set" />
- <xsd:element ref="beans:map" />
- <xsd:element ref="beans:props" />
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:attribute name="name" use="required" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The name of the attribute, under which in can then be referenced.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="value" use="optional" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The default value of the attribute.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="ref" use="optional" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The default value of the attribute as a reference to another bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="isImmutable" use="optional" type="xsd:boolean"
- default="false">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether the attribute is a parameter, that is, it has to be set at
- instantiation but can be modified afterwards for objects of scope execution.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="isParameter" use="optional" type="xsd:boolean"
- default="false">
- <!-- DEPRECATED: old name of isImmutable -->
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether the attribute is a parameter, that is, it has to be set at
- instantiation but can be modified afterwards for objects of scope execution.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="isConstant" use="optional" type="xsd:boolean"
- default="false">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether the attribute is frozen, that is, it cannot be modified at runtime.
- A frozen attribute has to be a parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="isFrozen" use="optional" type="xsd:boolean"
- default="false">
- <!-- DEPRECATED: old name of isConstant -->
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether the attribute is frozen, that is, it cannot be modified at runtime.
- A frozen attribute has to be a parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="isHidden" use="optional" type="xsd:boolean"
- default="false">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Whether the attribute is hidden, that is, it should not be displayed in UIs.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
-
- <xsd:complexType name="primitiveSpecAttributeType">
- <xsd:complexContent>
- <xsd:extension base="flow:specAttributeType">
- <xsd:attribute name="type" default="string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The type of the primitive specification attribute.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="string" />
- <xsd:enumeration value="password" />
- <xsd:enumeration value="integer" />
- <xsd:enumeration value="long" />
- <xsd:enumeration value="float" />
- <xsd:enumeration value="double" />
- <xsd:enumeration value="boolean" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:attribute>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="refSpecAttributeType">
- <xsd:complexContent>
- <xsd:extension base="flow:specAttributeType">
- <xsd:choice>
- <xsd:element name="choices" minOccurs="0" maxOccurs="1">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Possible values to chose from, if ommitted, all the beans in the
- application context which implement the provided targetClass will
- be considered.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:choice>
- <xsd:element name="choice" minOccurs="0" maxOccurs="unbounded"
- type="flow:refChoiceType">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A choice for a reference specification attribute.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:attribute name="targetClass" use="required" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The class that has to be implemented by the underlying object.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="refChoiceType">
- <xsd:attribute name="name" use="required" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The name of the related bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="description" use="optional" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A human readable description of this choice.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
-
- <xsd:complexType name="argType">
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element ref="beans:bean" />
- <xsd:element ref="beans:ref" />
- <xsd:element ref="flow:param" />
- <xsd:element ref="beans:list" />
- <xsd:element ref="beans:set" />
- <xsd:element ref="beans:map" />
- <xsd:element ref="beans:props" />
- </xsd:choice>
- <xsd:attribute name="name" use="required" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The name of the related parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="value" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The plain value of the related parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="ref" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The value of the related parameter as a reference to a bean.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
-
- <xsd:attribute name="as-flow" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- If decorating an executable bean, it will generate an implicit SLC
- execution flow with the provided value as name.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <!-- <xsd:attribute name="var" type="xsd:boolean"> <xsd:annotation> <xsd:documentation><![CDATA[
- If true, the decorated bean is set to scope execution and proxied. ]]></xsd:documentation>
- </xsd:annotation> </xsd:attribute> -->
-
- <xsd:element name="variable">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Marks a bean definition as being variable, i.e. a scoped proxy of scope execution
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="proxy-target-class" type="xsd:boolean"
- default="true">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- Are class-based (CGLIB) proxies to be created?
- This is the default;
- in order to switch to standard Java
- interface-based proxies, turn this flag to
- "false".
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="param">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- If within a property tag of a bean, it will set the value of this property
- with a reference to a parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string" use="required">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- The name of the related parameter.
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="instantiationManager" type="xsd:string"
- use="optional" default="instantiationManager">
- <xsd:annotation>
- <xsd:documentation><![CDATA[
- A reference to the instantiation manager to use instead of the default one
- (expert usage).
- ]]></xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- </xsd:element>
-
-</xsd:schema>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.core.test.context;
-
-import org.argeo.slc.runtime.test.TestDataUtils;
-import org.argeo.slc.test.TestData;
-import org.argeo.slc.test.TestDataProvider;
-
-public class DefaultContextTestData extends SimpleContextAware implements
- TestData, TestDataProvider {
-
- public <T extends TestData> T getTestData(Class<T> clss, String key) {
- return TestDataUtils.getItSelf(clss, this);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.test.context;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.runtime.test.ContextUtils;
-import org.argeo.slc.test.context.ContextAware;
-import org.argeo.slc.test.context.ParentContextAware;
-import org.springframework.beans.factory.InitializingBean;
-
-public class SimpleContextAware implements ContextAware, InitializingBean {
- private ParentContextAware parentContext;
-
- private Map<String, Object> values = new TreeMap<String, Object>();
- private Map<String, Object> expectedValues = new TreeMap<String, Object>();
-
- private String contextSkipFlag = DEFAULT_SKIP_FLAG;
- private String contextAnyFlag = DEFAULT_ANY_FLAG;
-
- public Map<String, Object> getValues() {
- return values;
- }
-
- public void setValues(Map<String, Object> values) {
- this.values = values;
- }
-
- public Map<String, Object> getExpectedValues() {
- return expectedValues;
- }
-
- public void setExpectedValues(Map<String, Object> expectedValues) {
- this.expectedValues = expectedValues;
- }
-
- /** Used to add this context as a child by setting a property. */
- public void setParentContext(ParentContextAware parentContextAware) {
- if (parentContext != null)
- throw new SlcException("Parent context already set");
- this.parentContext = parentContextAware;
- this.parentContext.addChildContext(this);
- }
-
- protected ParentContextAware getParentContext() {
- return parentContext;
- }
-
- public void afterPropertiesSet() throws Exception {
- if (parentContext != null) {
- ContextUtils.synchronize(parentContext);
- }
- }
-
- public String getContextSkipFlag() {
- return contextSkipFlag;
- }
-
- public void setContextSkipFlag(String contextSkipFlag) {
- this.contextSkipFlag = contextSkipFlag;
- }
-
- public String getContextAnyFlag() {
- return contextAnyFlag;
- }
-
- public void setContextAnyFlag(String contextAnyFlag) {
- this.contextAnyFlag = contextAnyFlag;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.test.context;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Vector;
-
-import org.argeo.slc.runtime.test.ContextUtils;
-import org.argeo.slc.test.context.ContextAware;
-import org.argeo.slc.test.context.ParentContextAware;
-import org.springframework.beans.factory.InitializingBean;
-
-public class SimpleParentContextAware extends SimpleContextAware implements
- ParentContextAware, InitializingBean {
- private List<ContextAware> children = new Vector<ContextAware>();
-
- public Collection<ContextAware> getChildContexts() {
- return children;
- }
-
- public void addChildContext(ContextAware contextAware) {
- children.add(contextAware);
- }
-
- @Override
- public void afterPropertiesSet() throws Exception {
- if (getParentContext() != null) {
- // If has a parent, sync it.
- super.afterPropertiesSet();
- } else {
- if (children.size() > 0) {
- // No need to synchronize if no children
- ContextUtils.synchronize(this);
- }
- }
- }
-}
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Context variables to be passed between parts of tests.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-SLC Test: test of software systems.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright (C) 2007-2012 Argeo GmbH
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- 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"
- default-lazy-init="true">
-
- <bean name="slcDefault.test.testRun"
- class="org.argeo.slc.runtime.test.SimpleTestRun"
- scope="prototype">
- </bean>
-
- <bean name="slcDefault.test.uuid" class="java.util.UUID"
- factory-method="randomUUID" scope="prototype">
- </bean>
-
- <bean id="slcDefault.test.basicSimpleTestResult"
- class="org.argeo.slc.runtime.test.SimpleTestResult"
- abstract="true">
- <property name="uuid">
- <bean factory-bean="slcDefault.test.uuid"
- factory-method="toString">
- </bean>
- </property>
- </bean>
-
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.osgi;
-
-/** <b>Experimental</b> A structured set of OSGi bundles. */
-public interface BundleRegister {
- /**
- * @param pkg
- * the Java package
- * @param version
- * the version, can be only major.minor or null
- * @return the bundle providing this package or null if none was found
- */
- public String bundleProvidingPackage(String pkg, String version);
-}
+++ /dev/null
-package org.argeo.slc.osgi;
-
-import java.util.Collection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextEvent;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleApplicationContextListener;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleContextClosedEvent;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleContextFailedEvent;
-import org.eclipse.gemini.blueprint.context.event.OsgiBundleContextRefreshedEvent;
-import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
-import org.eclipse.gemini.blueprint.util.OsgiFilterUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.util.Assert;
-
-/** Wraps low-level access to a {@link BundleContext} */
-@SuppressWarnings("deprecation")
-public class BundlesManager implements BundleContextAware, FrameworkListener,
- InitializingBean, DisposableBean,
- OsgiBundleApplicationContextListener<OsgiBundleApplicationContextEvent> {
- private final static Log log = LogFactory.getLog(BundlesManager.class);
-
- private BundleContext bundleContext;
-
- private Long defaultTimeout = 60 * 1000l;
- private Long pollingPeriod = 200l;
-
- // Refresh sync objects
- private final Object refreshedPackageSem = new Object();
- private Boolean packagesRefreshed = false;
-
- public BundlesManager() {
- }
-
- public BundlesManager(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- /**
- * Stop the module, update it, refresh it and restart it. All synchronously.
- */
- public void upgradeSynchronous(OsgiBundle osgiBundle) {
- try {
- Bundle bundle = findRelatedBundle(osgiBundle);
-
- long begin = System.currentTimeMillis();
-
- long bStop = begin;
- stopSynchronous(bundle);
-
- long bUpdate = System.currentTimeMillis();
- updateSynchronous(bundle);
-
- // Refresh in case there are fragments
- long bRefresh = System.currentTimeMillis();
- refreshSynchronous(bundle);
-
- long bStart = System.currentTimeMillis();
- startSynchronous(bundle);
-
- long aStart = System.currentTimeMillis();
- if (log.isTraceEnabled()) {
- log.debug("OSGi upgrade performed in " + (aStart - begin)
- + "ms for bundle " + osgiBundle);
- log.debug(" stop \t: " + (bUpdate - bStop) + "ms");
- log.debug(" update\t: " + (bRefresh - bUpdate) + "ms");
- log.debug(" refresh\t: " + (bStart - bRefresh) + "ms");
- log.debug(" start\t: " + (aStart - bStart) + "ms");
- log.debug(" TOTAL\t: " + (aStart - begin) + "ms");
- }
-
- long bAppContext = System.currentTimeMillis();
- String filter = "(Bundle-SymbolicName=" + bundle.getSymbolicName()
- + ")";
- // Wait for application context to be ready
- // TODO: use service tracker
- Collection<ServiceReference<ApplicationContext>> srs = getServiceRefSynchronous(
- ApplicationContext.class, filter);
- ServiceReference<ApplicationContext> sr = srs.iterator().next();
- long aAppContext = System.currentTimeMillis();
- long end = aAppContext;
-
- if (log.isTraceEnabled()) {
- log.debug("Application context refresh performed in "
- + (aAppContext - bAppContext) + "ms for bundle "
- + osgiBundle);
- }
-
- if (log.isDebugEnabled())
- log.debug("Bundle '" + bundle.getSymbolicName()
- + "' upgraded and ready " + " (upgrade performed in "
- + (end - begin) + "ms).");
-
- if (log.isTraceEnabled()) {
- ApplicationContext applicationContext = (ApplicationContext) bundleContext
- .getService(sr);
- int beanDefCount = applicationContext.getBeanDefinitionCount();
- log.debug(" " + beanDefCount + " beans in app context of "
- + bundle.getSymbolicName()
- + ", average init time per bean=" + (end - begin)
- / beanDefCount + "ms");
- }
-
- bundleContext.ungetService(sr);
-
- } catch (Exception e) {
- throw new SlcException("Cannot update bundle " + osgiBundle, e);
- }
- }
-
- /** Updates bundle synchronously. */
- protected void updateSynchronous(Bundle bundle) throws BundleException {
- bundle.update();
- boolean waiting = true;
-
- long begin = System.currentTimeMillis();
- do {
- int state = bundle.getState();
- if (state == Bundle.INSTALLED || state == Bundle.ACTIVE
- || state == Bundle.RESOLVED)
- waiting = false;
-
- sleepWhenPolling();
- checkTimeout(begin, "Update of bundle " + bundle.getSymbolicName()
- + " timed out. Bundle state = " + bundle.getState());
- } while (waiting);
-
- if (log.isTraceEnabled())
- log.debug("Bundle " + bundle.getSymbolicName() + " updated.");
- }
-
- /** Starts bundle synchronously. Does nothing if already started. */
- protected void startSynchronous(Bundle bundle) throws BundleException {
- int originalState = bundle.getState();
- if (originalState == Bundle.ACTIVE)
- return;
-
- bundle.start();
- boolean waiting = true;
-
- long begin = System.currentTimeMillis();
- do {
- if (bundle.getState() == Bundle.ACTIVE)
- waiting = false;
-
- sleepWhenPolling();
- checkTimeout(begin, "Start of bundle " + bundle.getSymbolicName()
- + " timed out. Bundle state = " + bundle.getState());
- } while (waiting);
-
- if (log.isTraceEnabled())
- log.debug("Bundle " + bundle.getSymbolicName() + " started.");
- }
-
- /** Stops bundle synchronously. Does nothing if already started. */
- protected void stopSynchronous(Bundle bundle) throws BundleException {
- int originalState = bundle.getState();
- if (originalState != Bundle.ACTIVE)
- return;
-
- bundle.stop();
- boolean waiting = true;
-
- long begin = System.currentTimeMillis();
- do {
- if (bundle.getState() != Bundle.ACTIVE
- && bundle.getState() != Bundle.STOPPING)
- waiting = false;
-
- sleepWhenPolling();
- checkTimeout(begin, "Stop of bundle " + bundle.getSymbolicName()
- + " timed out. Bundle state = " + bundle.getState());
- } while (waiting);
-
- if (log.isTraceEnabled())
- log.debug("Bundle " + bundle.getSymbolicName() + " stopped.");
- }
-
- /** Refresh bundle synchronously. Does nothing if already started. */
- protected void refreshSynchronous(Bundle bundle) throws BundleException {
- ServiceReference<PackageAdmin> packageAdminRef = bundleContext
- .getServiceReference(PackageAdmin.class);
- PackageAdmin packageAdmin = (PackageAdmin) bundleContext
- .getService(packageAdminRef);
- Bundle[] bundles = { bundle };
-
- long begin = System.currentTimeMillis();
- synchronized (refreshedPackageSem) {
- packagesRefreshed = false;
- packageAdmin.refreshPackages(bundles);
- try {
- refreshedPackageSem.wait(defaultTimeout);
- } catch (InterruptedException e) {
- // silent
- }
- if (!packagesRefreshed) {
- long now = System.currentTimeMillis();
- throw new SlcException("Packages not refreshed after "
- + (now - begin) + "ms");
- } else {
- packagesRefreshed = false;
- }
- }
-
- if (log.isTraceEnabled())
- log.debug("Bundle " + bundle.getSymbolicName() + " refreshed.");
- }
-
- public void frameworkEvent(FrameworkEvent event) {
- if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) {
- synchronized (refreshedPackageSem) {
- packagesRefreshed = true;
- refreshedPackageSem.notifyAll();
- }
- }
- }
-
- public <S> Collection<ServiceReference<S>> getServiceRefSynchronous(
- Class<S> clss, String filter) throws InvalidSyntaxException {
- if (log.isTraceEnabled())
- log.debug("Filter: '" + filter + "'");
- Collection<ServiceReference<S>> sfs = null;
- boolean waiting = true;
- long begin = System.currentTimeMillis();
- do {
- sfs = bundleContext.getServiceReferences(clss, filter);
-
- if (sfs != null)
- waiting = false;
-
- sleepWhenPolling();
- checkTimeout(begin, "Search of services " + clss + " with filter "
- + filter + " timed out.");
- } while (waiting);
-
- return sfs;
- }
-
- protected void checkTimeout(long begin, String msg) {
- long now = System.currentTimeMillis();
- if (now - begin > defaultTimeout)
- throw new SlcException(msg + " (timeout after " + (now - begin)
- + "ms)");
-
- }
-
- protected void sleepWhenPolling() {
- try {
- Thread.sleep(pollingPeriod);
- } catch (InterruptedException e) {
- throw new SlcException("Polling interrupted");
- }
- }
-
- /** Creates and open a new service tracker. */
- public <S> ServiceTracker<S, S> newTracker(Class<S> clss) {
- ServiceTracker<S, S> st = new ServiceTracker<S, S>(bundleContext, clss,
- null);
- st.open();
- return st;
- }
-
- public <T> T getSingleService(Class<T> clss, String filter,
- Boolean synchronous) {
- if (filter != null)
- Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
- Collection<ServiceReference<T>> sfs;
- try {
- if (synchronous)
- sfs = getServiceRefSynchronous(clss, filter);
- else
- sfs = bundleContext.getServiceReferences(clss, filter);
- } catch (InvalidSyntaxException e) {
- throw new SlcException("Cannot retrieve service reference for "
- + filter, e);
- }
-
- if (sfs == null || sfs.size() == 0)
- return null;
- else if (sfs.size() > 1)
- throw new SlcException("More than one execution flow found for "
- + filter);
- return (T) bundleContext.getService(sfs.iterator().next());
- }
-
- public <T> T getSingleServiceStrict(Class<T> clss, String filter,
- Boolean synchronous) {
- T service = getSingleService(clss, filter, synchronous);
- if (service == null)
- throw new SlcException("No execution flow found for " + filter);
- else
- return service;
- }
-
- public OsgiBundle findRelatedBundle(String moduleName, String moduleVersion) {
- OsgiBundle osgiBundle = new OsgiBundle(moduleName, moduleVersion);
- if (osgiBundle.getVersion() == null) {
- Bundle bundle = findRelatedBundle(osgiBundle);
- osgiBundle = new OsgiBundle(bundle);
- }
- return osgiBundle;
- }
-
- /**
- * @param osgiBundle
- * cannot be null
- * @return the related bundle or null if not found
- * @throws SlcException
- * if osgiBundle argument is null
- */
- public Bundle findRelatedBundle(OsgiBundle osgiBundle) {
- if (osgiBundle == null)
- throw new SlcException("OSGi bundle cannot be null");
-
- Bundle bundle = null;
- if (osgiBundle.getInternalBundleId() != null) {
- bundle = bundleContext.getBundle(osgiBundle.getInternalBundleId());
- Assert.isTrue(
- osgiBundle.getName().equals(bundle.getSymbolicName()),
- "symbolic name consistent");
- if (osgiBundle.getVersion() != null)
- Assert.isTrue(
- osgiBundle.getVersion().equals(
- bundle.getHeaders().get(
- Constants.BUNDLE_VERSION)),
- "version consistent");
- } else if (osgiBundle.getVersion() == null
- || osgiBundle.getVersion().equals("0.0.0")) {
- bundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
- osgiBundle.getName());
- } else {// scan all bundles
- bundles: for (Bundle b : bundleContext.getBundles()) {
- if (b.getSymbolicName() == null) {
- log.warn("Bundle " + b + " has no symbolic name defined.");
- continue bundles;
- }
-
- if (b.getSymbolicName().equals(osgiBundle.getName())) {
- if (osgiBundle.getVersion() == null) {
- bundle = b;
- break bundles;
- }
-
- if (b.getHeaders().get(Constants.BUNDLE_VERSION)
- .equals(osgiBundle.getVersion())) {
- bundle = b;
- osgiBundle.setInternalBundleId(b.getBundleId());
- break bundles;
- }
- }
- }
- }
- return bundle;
- }
-
- /** Find a single bundle based on a symbolic name pattern. */
- public OsgiBundle findFromPattern(String pattern) {
- OsgiBundle osgiBundle = null;
- for (Bundle b : bundleContext.getBundles()) {
- if (b.getSymbolicName().contains(pattern)) {
- osgiBundle = new OsgiBundle(b);
- break;
- }
- }
- return osgiBundle;
- }
-
- public OsgiBundle getBundle(Long bundleId) {
- Bundle bundle = bundleContext.getBundle(bundleId);
- return new OsgiBundle(bundle);
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void afterPropertiesSet() throws Exception {
- bundleContext.addFrameworkListener(this);
- }
-
- public void destroy() throws Exception {
- bundleContext.removeFrameworkListener(this);
- }
-
- public void setDefaultTimeout(Long defaultTimeout) {
- this.defaultTimeout = defaultTimeout;
- }
-
- /**
- * Use with caution since it may interfer with some cached information
- * within this object
- */
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- public void setPollingPeriod(Long pollingPeriod) {
- this.pollingPeriod = pollingPeriod;
- }
-
- public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {
- if (event instanceof OsgiBundleContextRefreshedEvent) {
- log.debug("App context refreshed: " + event);
- } else if (event instanceof OsgiBundleContextFailedEvent) {
- log.debug("App context failed: " + event);
- }
- if (event instanceof OsgiBundleContextClosedEvent) {
- log.debug("App context closed: " + event);
- }
-
- }
-
-}
+++ /dev/null
-package org.argeo.slc.osgi;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.Constants;
-
-/** <b>Experimental</b> */
-public class FileSystemBundleRegister implements BundleRegister {
- private final static Log log = LogFactory
- .getLog(FileSystemBundleRegister.class);
- private Properties packagesBundles = null;
-
- public String bundleProvidingPackage(String pkg, String version) {
- if (packagesBundles == null)
- return null;
- return packagesBundles.getProperty(pkg);
- }
-
- protected void scan(File baseDirectory) {
- long begin = System.currentTimeMillis();
- int bundleCount = 0;
- int packageCount = 0;
-
- packagesBundles = new Properties();
-
- File[] files = baseDirectory.listFiles();
- for (File file : files) {
- if (file.isDirectory()) {
-
- } else {
- JarFile jarFile = null;
- try {
- jarFile = new JarFile(file);
- Manifest manifest = jarFile.getManifest();
- String symbolicName = manifest.getMainAttributes()
- .getValue(Constants.BUNDLE_SYMBOLICNAME);
- String exportPackage = manifest.getMainAttributes()
- .getValue(Constants.EXPORT_PACKAGE);
-
- // List exported packages
- Set<String> exportedPackages = exportPackageToPackageNames(exportPackage);
-
- for (String exportedPackage : exportedPackages) {
- packagesBundles.put(exportedPackage, symbolicName);
- packageCount++;
- if (log.isTraceEnabled())
- log.trace("Register " + exportedPackage + "="
- + symbolicName);
- }
- bundleCount++;
- } catch (Exception e) {
- log.warn("Cannot scan " + file, e);
- if (log.isTraceEnabled())
- e.printStackTrace();
- } finally {
- IOUtils.closeQuietly(jarFile);
- }
- }
- }
- if (log.isDebugEnabled())
- log.debug("Scanned " + bundleCount + " bundles with "
- + packageCount + " packages in "
- + (System.currentTimeMillis() - begin) + " ms");
- }
-
- protected Set<String> exportPackageToPackageNames(String exportPackage) {
- Set<String> exportedPackages = new HashSet<String>();
- if (exportPackage == null)
- return exportedPackages;
- char[] arr = exportPackage.toCharArray();
-
- StringBuffer currentPkg = new StringBuffer("");
- boolean skip = false;
- boolean inQuote = false;
- for (char c : arr) {
- if (c == ' ' || c == '\n') {
- // ignore
- } else if (c == ';') {
- if (!skip)
- skip = true;
- } else if (c == ',') {
- if (skip && !inQuote) {
- skip = false;
- // add new package
- exportedPackages.add(currentPkg.toString());
- currentPkg = new StringBuffer("");
- }
- } else if (c == '\"') {
- inQuote = inQuote ? false : true;
- } else {
- if (!skip)
- currentPkg.append(c);
- }
- }
-
- return exportedPackages;
- }
-
- public static void main(String[] args) {
- FileSystemBundleRegister fsbr = new FileSystemBundleRegister();
- fsbr.scan(new File(
- "/home/mbaudier/dev/src/slc/dist/org.argeo.slc.sdk/target/lib"));
-
- }
-}
+++ /dev/null
-package org.argeo.slc.osgi;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.event.ContextRefreshedEvent;
-import org.springframework.core.Ordered;
-
-/** Publishes beans of the application context as OSGi services. */
-@SuppressWarnings(value = { "unchecked", "rawtypes" })
-public class MultipleServiceExporterPostProcessor implements
- ApplicationListener, Ordered {
- private final static Log log = LogFactory
- .getLog(MultipleServiceExporterPostProcessor.class);
-
- private List<Class> interfaces = new ArrayList<Class>();
-
- private int order = Ordered.LOWEST_PRECEDENCE;
-
- private BundleContext bundleContext = null;
-
- // private Class osgiServiceFactoryClass = OsgiServiceFactoryBean.class;
- // private Boolean useServiceProviderContextClassLoader = false;
-
- public void onApplicationEvent(ApplicationEvent event) {
- Map<String, Object> beans = new HashMap<String, Object>();
- if (event instanceof ContextRefreshedEvent) {
- if (bundleContext != null) {
- for (Class clss : interfaces) {
- ApplicationContext ac = ((ContextRefreshedEvent) event)
- .getApplicationContext();
- beans.putAll(ac.getBeansOfType(clss, false, false));
- }
-
- int count = 0;
- for (String beanName : beans.keySet()) {
- Object bean = beans.get(beanName);
- List<String> classes = new ArrayList<String>();
- for (Class clss : interfaces) {
- if (clss.isAssignableFrom(bean.getClass())) {
- classes.add(clss.getName());
- }
- }
- Properties props = new Properties();
- Bundle bundle = bundleContext.getBundle();
- props.put(Constants.BUNDLE_SYMBOLICNAME,
- bundle.getSymbolicName());
- props.put(Constants.BUNDLE_VERSION, bundle.getVersion());
- // retrocompatibility with pre-1.0:
- props.put("org.eclipse.gemini.blueprint.bean.name", beanName);
- bundleContext.registerService(
- classes.toArray(new String[classes.size()]), bean,
- new Hashtable(props));
- count++;
- }
- if (log.isTraceEnabled())
- log.trace("Published " + count + " " + interfaces
- + " as OSGi services from bundle "
- + bundleContext.getBundle().getSymbolicName() + " "
- + bundleContext.getBundle().getVersion());
- // note: the services will be automatically unregistered when
- // the bundle will be stopped
- }
- }
- }
-
- // public void postProcessBeanFactory(
- // ConfigurableListableBeanFactory beanFactory) throws BeansException {
- // if (!(beanFactory instanceof BeanDefinitionRegistry)) {
- // throw new SlcException("Can only work on "
- // + BeanDefinitionRegistry.class);
- // }
- //
- // long begin = System.currentTimeMillis();
- //
- // // Merge all beans implementing these interfaces
- // Set<String> beanNames = new HashSet<String>();
- // for (Class clss : interfaces) {
- // String[] strs = beanFactory.getBeanNamesForType(clss, true, false);
- // beanNames.addAll(Arrays.asList(strs));
- // }
- //
- // // Register service factory beans for them
- // for (String beanName : beanNames) {
- // MutablePropertyValues mpv = new MutablePropertyValues();
- // mpv.addPropertyValue("interfaces", interfaces.toArray());
- // mpv.addPropertyValue("targetBeanName", beanName);
- // if (useServiceProviderContextClassLoader)
- // mpv.addPropertyValue("contextClassLoader",
- // ExportContextClassLoader.SERVICE_PROVIDER);
- // RootBeanDefinition bd = new RootBeanDefinition(
- // osgiServiceFactoryClass, mpv);
- //
- // String exporterBeanName = "osgiService." + beanName;
- // if (log.isTraceEnabled())
- // log.debug("Registering OSGi service exporter "
- // + exporterBeanName);
- // ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(
- // exporterBeanName, bd);
- // }
- //
- // long end = System.currentTimeMillis();
- // if (log.isTraceEnabled())
- // log.debug("Multiple services exported in " + (end - begin)
- // + " ms in bundle.");
- //
- // }
-
- public void setInterfaces(List<Class> interfaces) {
- this.interfaces = interfaces;
- }
-
- // public void setOsgiServiceFactoryClass(Class osgiServiceFactoryClass) {
- // this.osgiServiceFactoryClass = osgiServiceFactoryClass;
- // }
-
- public int getOrder() {
- return order;
- }
-
- public void setOrder(int order) {
- this.order = order;
- }
-
- // public void setUseServiceProviderContextClassLoader(
- // Boolean useServiceProviderContextClassLoader) {
- // this.useServiceProviderContextClassLoader =
- // useServiceProviderContextClassLoader;
- // }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-}
+++ /dev/null
-package org.argeo.slc.osgi;
-
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.core.build.ResourceDistribution;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.Module;
-import org.argeo.slc.deploy.ModuleDescriptor;
-import org.argeo.slc.deploy.TargetData;
-import org.argeo.slc.execution.RealizedFlow;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.springframework.core.io.Resource;
-
-/** A deployed OSGi bundle. */
-public class OsgiBundle extends DefaultNameVersion implements Module {
- private ResourceDistribution distribution;
-
- private Long internalBundleId;
-
- private String title;
- private String description;
-
- public OsgiBundle() {
-
- }
-
- public OsgiBundle(String name, String version) {
- super(name, version);
- }
-
- public OsgiBundle(NameVersion nameVersion) {
- super(nameVersion);
- }
-
- public OsgiBundle(Bundle bundle) {
- super(bundle.getSymbolicName(), getVersionSafe(bundle));
- internalBundleId = bundle.getBundleId();
- }
-
- /**
- * Initialize from a {@link RealizedFlow}.
- *
- * @deprecated introduce an unnecessary dependency. TODO: create a separate
- * helper.
- */
- public OsgiBundle(RealizedFlow realizedFlow) {
- super(realizedFlow.getModuleName(), realizedFlow.getModuleVersion());
- }
-
- /** Utility to avoid NPE. */
- private static String getVersionSafe(Bundle bundle) {
- Object versionObj = bundle.getHeaders().get(Constants.BUNDLE_VERSION);
- if (versionObj != null)
- return versionObj.toString();
- else
- return null;
- }
-
- /** Unique deployed system id. TODO: use internal bundle id when available? */
- public String getDeployedSystemId() {
- return getName() + ":" + getVersion();
- }
-
- /**
- * OSGi bundle are self-contained and do not require additional deployment
- * data.
- *
- * @return always null
- */
- public DeploymentData getDeploymentData() {
- return null;
- }
-
- /** The related distribution. */
- public Distribution getDistribution() {
- return distribution;
- }
-
- /**
- * The related distribution, a jar file with OSGi metadata referenced by a
- * {@link Resource}.
- */
- public ResourceDistribution getResourceDistribution() {
- return distribution;
- }
-
- /** TODO: reference the {@link OsgiRuntime} as target data? */
- public TargetData getTargetData() {
- throw new UnsupportedOperationException();
- }
-
- public void setResourceDistribution(ResourceDistribution distribution) {
- this.distribution = distribution;
- }
-
- /**
- * Bundle ID used by the OSGi runtime. To be used for optimization when
- * looking in the bundle context. Can therefore be null.
- */
- public Long getInternalBundleId() {
- return internalBundleId;
- }
-
- /** Only package access for the time being. e.g. from {@link BundlesManager} */
- void setInternalBundleId(Long internalBundleId) {
- this.internalBundleId = internalBundleId;
- }
-
- /** Value of the <code>Bundle-Name</code> directive. */
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String label) {
- this.title = label;
- }
-
- /** Value of the <code>Bundle-Description</code> directive. */
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public ModuleDescriptor getModuleDescriptor() {
- ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
- moduleDescriptor.setName(getName());
- moduleDescriptor.setVersion(getVersion());
- moduleDescriptor.setDescription(description);
- moduleDescriptor.setTitle(title);
- return moduleDescriptor;
- }
-}
+++ /dev/null
-package org.argeo.slc.osgi;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.core.execution.AbstractSpringExecutionModule;
-import org.argeo.slc.execution.ExecutionContext;
-
-@Deprecated
-public class OsgiExecutionModule extends AbstractSpringExecutionModule {
- private final static Log log = LogFactory.getLog(OsgiExecutionModule.class);
-
- public OsgiExecutionModule() {
- log.error("######## ERROR - DEPRECATED APPROACH USED ########");
- log.error(OsgiExecutionModule.class.getName() + " is deprecated. ");
- log
- .error("It will be removed in the next release. Remove its bean definition.");
- log
- .error("And replace: <service interface=\"org.argeo.slc.execution.ExecutionModule\" ref=\"executionModule\" />");
- log
- .error("by: <beans:import resource=\"classpath:org/argeo/slc/osgi/execution/spring.xml\" /> ");
- log.error("in osgi.xml.\n\n");
- }
-
- public void setExecutionContext(ExecutionContext executionContext) {
- // do nothing, just for compatibility
- }
-
- /*
- * private BundleContext bundleContext;
- *
- * @Override public void execute(ExecutionFlowDescriptor
- * executionFlowDescriptor) { if (descriptorConverter != null)
- * executionContext.addVariables(descriptorConverter
- * .convertValues(executionFlowDescriptor));
- *
- * ExecutionFlow flow = findExecutionFlow(getName(), getVersion(),
- * executionFlowDescriptor.getName()); flow.run(); }
- *
- * @Override protected Map<String, ExecutionFlow> listFlows() { String
- * filter = "(org.argeo.slc.execution.module.name=" + getName() + ")";
- * ServiceReference[] sfs; try { sfs =
- * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
- * filter); } catch (InvalidSyntaxException e) { throw new SlcException(
- * "Cannot retrieve service reference for flow " + filter, e); }
- *
- * Map<String, ExecutionFlow> flows = new HashMap<String, ExecutionFlow>();
- * for (ServiceReference sf : sfs) { ExecutionFlow flow = (ExecutionFlow)
- * bundleContext.getService(sf); flows.put(flow.getName(), flow); } return
- * flows; }
- *
- * public String getName() { return
- * bundleContext.getBundle().getSymbolicName(); }
- *
- * public String getVersion() { return
- * bundleContext.getBundle().getHeaders().get("Bundle-Version") .toString();
- * }
- *
- * public void setBundleContext(BundleContext bundleContext) {
- * this.bundleContext = bundleContext; }
- *
- * protected ExecutionFlow findExecutionFlow(String moduleName, String
- * moduleVersion, String flowName) { String filter =
- * "(&(org.argeo.slc.execution.module.name=" + moduleName +
- * ")(org.argeo.slc.execution.flow.name=" + flowName + "))";
- * log.debug("OSGi filter: " + filter);
- *
- * Assert.isTrue(OsgiFilterUtils.isValidFilter(filter), "valid filter");
- * ServiceReference[] sfs; try { sfs =
- * bundleContext.getServiceReferences(ExecutionFlow.class .getName(),
- * filter); } catch (InvalidSyntaxException e) { throw new
- * SlcException("Cannot retrieve service reference for " + filter, e); }
- *
- * if (sfs == null || sfs.length == 0) throw new
- * SlcException("No execution flow found for " + filter); else if
- * (sfs.length > 1) throw new
- * SlcException("More than one execution flow found for " + filter); return
- * (ExecutionFlow) bundleContext.getService(sfs[0]); }
- */
-
-}
+++ /dev/null
-package org.argeo.slc.osgi;
-
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.DefaultExecutionFlowDescriptorConverter;
-import org.argeo.slc.deploy.Module;
-import org.argeo.slc.deploy.ModuleDescriptor;
-import org.argeo.slc.execution.ExecutionContext;
-import org.argeo.slc.execution.ExecutionFlow;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
-import org.argeo.slc.execution.ExecutionModuleDescriptor;
-import org.argeo.slc.execution.ExecutionModulesListener;
-import org.argeo.slc.execution.RealizedFlow;
-import org.argeo.slc.runtime.AbstractExecutionModulesManager;
-import org.eclipse.gemini.blueprint.service.importer.OsgiServiceLifecycleListener;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.Constants;
-import org.osgi.framework.launch.Framework;
-import org.springframework.context.ApplicationContext;
-
-/** Execution modules manager implementation based on an OSGi runtime. */
-public class OsgiExecutionModulesManager extends
- AbstractExecutionModulesManager implements
- OsgiServiceLifecycleListener, BundleListener {
-
- private final static Log log = LogFactory
- .getLog(OsgiExecutionModulesManager.class);
-
- private BundlesManager bundlesManager;
- private Map<OsgiBundle, ExecutionContext> executionContexts = new HashMap<OsgiBundle, ExecutionContext>();
- private Map<OsgiBundle, ExecutionFlowDescriptorConverter> executionFlowDescriptorConverters = new HashMap<OsgiBundle, ExecutionFlowDescriptorConverter>();
- private Map<OsgiBundle, Set<ExecutionFlow>> executionFlows = new HashMap<OsgiBundle, Set<ExecutionFlow>>();
- private ExecutionFlowDescriptorConverter defaultDescriptorConverter = new DefaultExecutionFlowDescriptorConverter();
-
- private List<ExecutionModulesListener> executionModulesListeners = new ArrayList<ExecutionModulesListener>();
-
- private Boolean registerFlowsToJmx = false;
-
- public void init() throws Exception {
- bundlesManager.getBundleContext().addBundleListener(this);
-
- final String module = System.getProperty(UNIQUE_LAUNCH_MODULE_PROPERTY);
- final String flow = System.getProperty(UNIQUE_LAUNCH_FLOW_PROPERTY);
- if (module != null) {
- // launch a flow and stops
- new Thread("Unique Flow") {
- @Override
- public void run() {
- executeFlowAndExit(module, null, flow);
- }
- }.start();
- }
- }
-
- public void destroy() {
- bundlesManager.getBundleContext().removeBundleListener(this);
- }
-
- /** Executes a single flow and <b>stops the JVM</b> */
- protected void executeFlowAndExit(final String module,
- final String version, final String flow) {
- if (log.isDebugEnabled())
- log.debug("Launch unique flow " + flow + " from module " + module);
- try {
- OsgiBundle osgiBundle = bundlesManager.findFromPattern(module);
- if (osgiBundle == null)
- throw new SlcException("No OSGi bundle found for " + module);
- // Bundle moduleBundle =
- // bundlesManager.findRelatedBundle(osgiBundle);
- start(osgiBundle);
-
- RealizedFlow lastLaunch = findRealizedFlow(module, flow);
- if (lastLaunch == null)
- throw new SlcException("Cannot find launch for " + module + " "
- + flow);
- execute(lastLaunch);
- } catch (Exception e) {
- log.error(
- "Error in unique flow " + flow + " from module " + module,
- e);
- } finally {
- if (log.isDebugEnabled())
- log.debug("Shutdown OSGi runtime...");
- Framework framework = (Framework) bundlesManager.getBundleContext()
- .getBundle(0);
- try {
- // shutdown framework
- framework.stop();
- // wait 1 min for shutdown
- framework.waitForStop(60 * 1000);
- // close VM
- System.exit(0);
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
- }
-
- // public void startExectionModule(String moduleName, String moduleVersion)
- // {
- // try {
- // ServiceReference[] sr = bundlesManager.getServiceRefSynchronous(
- // ApplicationContext.class.getName(),
- // "org.springframework.context.service.name=" + moduleName);
- // // bundlesManager.startSynchronous(moduleBundle);
- // if (sr == null || sr.length == 0)
- // throw new SlcException(
- // "Cannot find execution module application context "
- // + moduleName);
- // } catch (InvalidSyntaxException e) {
- // throw new SlcException("Cannot start exeuction module "
- // + moduleName, e);
- // }
- // }
-
- public synchronized ExecutionModuleDescriptor getExecutionModuleDescriptor(
- String moduleName, String version) {
- ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
- OsgiBundle osgiBundle = null;
- DefaultNameVersion nameVersion = new DefaultNameVersion(moduleName,
- version);
- bundles: for (Iterator<OsgiBundle> iterator = executionContexts
- .keySet().iterator(); iterator.hasNext();) {
- OsgiBundle ob = iterator.next();
- if (nameVersion.getVersion() != null) {
- if (ob.equals(nameVersion)) {
- osgiBundle = ob;
- break bundles;
- }
- } else {
- if (ob.getName().equals(nameVersion.getName())) {
- osgiBundle = ob;
- break bundles;
- }
- }
- }
- if (osgiBundle == null)
- throw new SlcException("No execution module registered for "
- + nameVersion);
- md.setName(osgiBundle.getName());
- md.setVersion(osgiBundle.getVersion());
- md.setTitle(osgiBundle.getTitle());
- md.setDescription(osgiBundle.getDescription());
-
- ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = getExecutionFlowDescriptorConverter(
- moduleName, version);
- if (executionFlowDescriptorConverter == null)
- throw new SlcException("No flow converter found.");
- executionFlowDescriptorConverter.addFlowsToDescriptor(md,
- listFlows(moduleName, version));
- return md;
- }
-
- public synchronized List<ExecutionModuleDescriptor> listExecutionModules() {
- List<ExecutionModuleDescriptor> descriptors = new ArrayList<ExecutionModuleDescriptor>();
-
- for (Iterator<OsgiBundle> iterator = executionContexts.keySet()
- .iterator(); iterator.hasNext();) {
- OsgiBundle osgiBundle = iterator.next();
- ExecutionModuleDescriptor md = new ExecutionModuleDescriptor();
- setMetadataFromBundle(md,
- bundlesManager.findRelatedBundle(osgiBundle));
- descriptors.add(md);
- }
- return descriptors;
- }
-
- protected synchronized Map<String, ExecutionFlow> listFlows(
- String moduleName, String moduleVersion) {
-
- Map<String, ExecutionFlow> flows = new HashMap<String, ExecutionFlow>();
- OsgiBundle key = bundlesManager.findRelatedBundle(moduleName,
- moduleVersion);
- if (!executionFlows.containsKey(key))
- return flows;
- Set<ExecutionFlow> flowsT = executionFlows.get(key);
- for (ExecutionFlow flow : flowsT)
- flows.put(flow.getName(), flow);
- return flows;
- }
-
- protected ExecutionFlow findExecutionFlow(String moduleName,
- String moduleVersion, String flowName) {
- String filter = moduleVersion == null || moduleVersion.equals("0.0.0") ? "(&(Bundle-SymbolicName="
- + moduleName
- + ")(org.eclipse.gemini.blueprint.bean.name="
- + flowName + "))"
- : "(&(Bundle-SymbolicName=" + moduleName + ")(Bundle-Version="
- + moduleVersion
- + ")(org.eclipse.gemini.blueprint.bean.name="
- + flowName + "))";
- return bundlesManager.getSingleServiceStrict(ExecutionFlow.class,
- filter, true);
- }
-
- protected ExecutionContext findExecutionContext(String moduleName,
- String moduleVersion) {
- String filter = moduleFilter(moduleName, moduleVersion);
- return bundlesManager.getSingleServiceStrict(ExecutionContext.class,
- filter, true);
- }
-
- protected ExecutionFlowDescriptorConverter findExecutionFlowDescriptorConverter(
- String moduleName, String moduleVersion) {
- String filter = moduleFilter(moduleName, moduleVersion);
- return bundlesManager.getSingleService(
- ExecutionFlowDescriptorConverter.class, filter, false);
- }
-
- /** Only based on symbolic name if version is null or "0.0.0" */
- protected String moduleFilter(String moduleName, String moduleVersion) {
- return moduleVersion == null || moduleVersion.equals("0.0.0") ? "(Bundle-SymbolicName="
- + moduleName + ")"
- : "(&(Bundle-SymbolicName=" + moduleName + ")(Bundle-Version="
- + moduleVersion + "))";
-
- }
-
- /**
- * Builds a minimal realized flow, based on the provided information
- * (typically from the command line).
- *
- * @param module
- * a bundle id, or a pattern contained in a bundle symbolic name
- * @param module
- * the execution flow name
- * @return a minimal realized flow, to be used in an execution
- */
- public RealizedFlow findRealizedFlow(String module, String executionName) {
- // First check whether we have a bundleId
- Long bundleId = null;
- try {
- bundleId = Long.parseLong(module);
- } catch (NumberFormatException e) {
- // silent
- }
-
- // Look for bundle names containing pattern
- OsgiBundle bundle = null;
- if (bundleId != null) {
- bundle = bundlesManager.getBundle(bundleId);
- } else {
- bundle = bundlesManager.findFromPattern(module);
- }
-
- if (bundle != null) {
- RealizedFlow launch = new RealizedFlow();
- launch.setModuleName(bundle.getName());
- launch.setModuleVersion(bundle.getVersion());
- ExecutionFlowDescriptor descriptor = new ExecutionFlowDescriptor();
- descriptor.setName(executionName);
- launch.setFlowDescriptor(descriptor);
- return launch;
- } else {
- log.warn("Could not find any execution module matching these requirements.");
- return null;
- }
- }
-
- public void upgrade(NameVersion nameVersion) {
- OsgiBundle osgiBundle = new OsgiBundle(nameVersion);
- bundlesManager.upgradeSynchronous(osgiBundle);
- }
-
- protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
- String moduleName, String moduleVersion) {
- return findExecutionFlowDescriptorConverter(moduleName, moduleVersion);
- // OsgiBundle osgiBundle = new OsgiBundle(moduleName, moduleVersion);
- // return getExecutionFlowDescriptorConverter(osgiBundle);
- }
-
- protected synchronized ExecutionFlowDescriptorConverter getExecutionFlowDescriptorConverter(
- OsgiBundle osgiBundle) {
- if (executionFlowDescriptorConverters.containsKey(osgiBundle))
- return executionFlowDescriptorConverters.get(osgiBundle);
- else
- return defaultDescriptorConverter;
- }
-
- public ModuleDescriptor getModuleDescriptor(String moduleName,
- String version) {
- return getExecutionModuleDescriptor(moduleName, version);
- }
-
- public List<ModuleDescriptor> listModules() {
- Bundle[] bundles = bundlesManager.getBundleContext().getBundles();
- List<ModuleDescriptor> lst = new ArrayList<ModuleDescriptor>();
- for (Bundle bundle : bundles) {
- ModuleDescriptor moduleDescriptor = new ModuleDescriptor();
- setMetadataFromBundle(moduleDescriptor, bundle);
- lst.add(moduleDescriptor);
- }
- return lst;
- }
-
- public void start(NameVersion nameVersion) {
- try {
- Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
- nameVersion));
- if (bundle == null)
- throw new SlcException("Could not find bundle for "
- + nameVersion);
-
- bundlesManager.startSynchronous(bundle);
- if (isSpringInstrumented(bundle)) {
- // Wait for Spring application context to be ready
- String filter = "(Bundle-SymbolicName="
- + bundle.getSymbolicName() + ")";
- try {
- bundlesManager.getServiceRefSynchronous(
- ApplicationContext.class, filter);
- } catch (Exception e) {
- // stop if application context not found
- bundle.stop();
- throw e;
- }
- }
- } catch (Exception e) {
- throw new SlcException("Cannot start " + nameVersion, e);
- }
- }
-
- /** Do it calmly in order to avoid NPE */
- private Boolean isSpringInstrumented(Bundle bundle) {
- Dictionary<?, ?> headers = bundle.getHeaders();
- if (headers != null && headers.get("Spring-Context") != null)
- return true;
- Enumeration<?> springEntryPaths = bundle
- .getEntryPaths("/META-INF/spring");
- if (springEntryPaths != null && springEntryPaths.hasMoreElements())
- return true;
- return false;
- }
-
- public void stop(NameVersion nameVersion) {
- try {
- Bundle bundle = bundlesManager.findRelatedBundle(new OsgiBundle(
- nameVersion));
- bundlesManager.stopSynchronous(bundle);
- } catch (BundleException e) {
- throw new SlcException("Cannot stop " + nameVersion, e);
- }
- }
-
- protected void setMetadataFromBundle(ModuleDescriptor md, Bundle bundle) {
- Bundle bdl = bundle;
- if (bdl == null) {
- if (md.getName() == null || md.getVersion() == null)
- throw new SlcException("Name and version not available.");
-
- Bundle[] bundles = bundlesManager.getBundleContext().getBundles();
- for (Bundle b : bundles) {
- if (b.getSymbolicName().equals(md.getName())
- && md.getVersion().equals(
- getHeaderSafe(b, Constants.BUNDLE_VERSION))) {
- bdl = b;
- break;
- }
- }
-
- }
-
- if (bdl == null)
- throw new SlcException("Cannot find bundle.");
-
- md.setName(bdl.getSymbolicName());
- md.setVersion(getHeaderSafe(bdl, Constants.BUNDLE_VERSION));
- md.setTitle(getHeaderSafe(bdl, Constants.BUNDLE_NAME));
- md.setDescription(getHeaderSafe(bdl, Constants.BUNDLE_DESCRIPTION));
-
- // copy manifets header to meta data
- Dictionary<?, ?> headers = bundle.getHeaders();
- Enumeration<?> keys = headers.keys();
- while (keys.hasMoreElements()) {
- Object key = keys.nextElement();
- Object value = headers.get(key);
- if (value != null)
- md.getMetadata().put(key.toString(), value.toString());
- }
-
- // check if started
- if (bundle.getState() == Bundle.ACTIVE
- || bundle.getState() == Bundle.STARTING)
- md.setStarted(true);
- else
- md.setStarted(false);
- }
-
- private String getHeaderSafe(Bundle bundle, Object key) {
- Object obj = bundle.getHeaders().get(key);
- if (obj == null)
- return null;
- else
- return obj.toString();
- }
-
- /*
- * REGISTRATION
- */
-
- /** Registers an execution context. */
- public synchronized void register(ExecutionContext executionContext,
- Map<String, String> properties) {
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- Bundle bundle = bundlesManager.findRelatedBundle(osgiBundle);
- osgiBundle.setTitle(getHeaderSafe(bundle, Constants.BUNDLE_NAME));
- osgiBundle.setDescription(getHeaderSafe(bundle,
- Constants.BUNDLE_DESCRIPTION));
- executionContexts.put(osgiBundle, executionContext);
- if (log.isTraceEnabled())
- log.trace("Registered execution context from " + osgiBundle);
- // Notify
- ModuleDescriptor md = osgiBundle.getModuleDescriptor();
- md.setStarted(true);
- for (ExecutionModulesListener listener : executionModulesListeners)
- listener.executionModuleAdded(md);
- }
-
- /** Unregisters an execution context. */
- public synchronized void unregister(ExecutionContext executionContext,
- Map<String, String> properties) {
- // FIXME why are properties null?
- if (properties == null)
- return;
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- if (executionContexts.containsKey(osgiBundle)) {
- executionContexts.remove(osgiBundle);
- if (log.isTraceEnabled())
- log.trace("Removed execution context from " + osgiBundle);
- // Notify
- ModuleDescriptor md = osgiBundle.getModuleDescriptor();
- md.setStarted(false);
- for (ExecutionModulesListener listener : executionModulesListeners)
- listener.executionModuleRemoved(md);
- }
- }
-
- /** Registers an execution flow. */
- public synchronized void register(ExecutionFlow executionFlow,
- Map<String, String> properties) {
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- if (!executionFlows.containsKey(osgiBundle)) {
- executionFlows.put(osgiBundle, new HashSet<ExecutionFlow>());
- }
- executionFlows.get(osgiBundle).add(executionFlow);
- if (log.isTraceEnabled())
- log.trace("Registered " + executionFlow + " from " + osgiBundle);
-
- // notifications
- if (registerFlowsToJmx)
- registerMBean(osgiBundle, executionFlow);
- ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
- for (ExecutionModulesListener listener : executionModulesListeners)
- listener.executionFlowAdded(osgiBundle.getModuleDescriptor(),
- efdc.getExecutionFlowDescriptor(executionFlow));
- }
-
- /** Unregisters an execution flow. */
- public synchronized void unregister(ExecutionFlow executionFlow,
- Map<String, String> properties) {
- // FIXME why are properties null?
- if (properties == null)
- return;
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- if (executionFlows.containsKey(osgiBundle)) {
- Set<ExecutionFlow> flows = executionFlows.get(osgiBundle);
- flows.remove(executionFlow);
- if (log.isTraceEnabled())
- log.trace("Removed " + executionFlow + " from " + osgiBundle);
- if (flows.size() == 0) {
- executionFlows.remove(osgiBundle);
- if (log.isTraceEnabled())
- log.trace("Removed flows set from " + osgiBundle);
- }
-
- // notifications
- if (registerFlowsToJmx)
- unregisterMBean(osgiBundle, executionFlow);
- ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
- for (ExecutionModulesListener listener : executionModulesListeners)
- listener.executionFlowRemoved(osgiBundle.getModuleDescriptor(),
- efdc.getExecutionFlowDescriptor(executionFlow));
- }
- }
-
- /** Registers an execution module listener. */
- public synchronized void register(
- ExecutionModulesListener executionModulesListener,
- Map<String, String> properties) {
- // sync with current state
- for (OsgiBundle osgiBundle : executionContexts.keySet()) {
- executionModulesListener.executionModuleAdded(osgiBundle
- .getModuleDescriptor());
- }
- for (OsgiBundle osgiBundle : executionFlows.keySet()) {
- ExecutionFlowDescriptorConverter efdc = getExecutionFlowDescriptorConverter(osgiBundle);
- for (ExecutionFlow executionFlow : executionFlows.get(osgiBundle))
- executionModulesListener.executionFlowAdded(
- osgiBundle.getModuleDescriptor(),
- efdc.getExecutionFlowDescriptor(executionFlow));
- }
- executionModulesListeners.add(executionModulesListener);
- }
-
- /** Unregisters an execution module listener. */
- public synchronized void unregister(
- ExecutionModulesListener executionModulesListener,
- Map<String, String> properties) {
- executionModulesListeners.remove(executionModulesListener);
- }
-
- /*
- * INTERFACE IMPLEMENTATIONS
- */
-
- public void bundleChanged(BundleEvent evt) {
- Bundle bundle = evt.getBundle();
- if (bundle.getHeaders().get(
- ExecutionModuleDescriptor.SLC_EXECUTION_MODULE) != null) {
- OsgiBundle osgiBundle = new OsgiBundle(bundle);
- if (evt.getType() == BundleEvent.INSTALLED)
- for (ExecutionModulesListener listener : executionModulesListeners)
- listener.executionModuleAdded(osgiBundle
- .getModuleDescriptor());
- else if (evt.getType() == BundleEvent.UNINSTALLED)
- for (ExecutionModulesListener listener : executionModulesListeners)
- listener.executionModuleRemoved(osgiBundle
- .getModuleDescriptor());
- }
-
- }
-
- @SuppressWarnings({ "rawtypes" })
- public synchronized void bind(Object service, Map properties)
- throws Exception {
- if (service instanceof ExecutionFlowDescriptorConverter) {
- ExecutionFlowDescriptorConverter executionFlowDescriptorConverter = (ExecutionFlowDescriptorConverter) service;
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- executionFlowDescriptorConverters.put(osgiBundle,
- executionFlowDescriptorConverter);
- if (log.isTraceEnabled())
- log.debug("Registered execution flow descriptor converter from "
- + osgiBundle);
- } else {
- // ignore
- }
- }
-
- @SuppressWarnings("rawtypes")
- public synchronized void unbind(Object service, Map properties)
- throws Exception {
- if (service instanceof ExecutionFlowDescriptorConverter) {
- OsgiBundle osgiBundle = asOsgiBundle(properties);
- if (executionFlowDescriptorConverters.containsKey(osgiBundle)) {
- executionFlowDescriptorConverters.remove(osgiBundle);
- if (log.isTraceEnabled())
- log.debug("Removed execution flow descriptor converter from "
- + osgiBundle);
- }
- } else {
- // ignore
- }
- }
-
- /*
- * JMX
- */
- protected MBeanServer getMBeanServer() {
- return ManagementFactory.getPlatformMBeanServer();
- }
-
- public void registerMBean(Module module, ExecutionFlow executionFlow) {
- try {
- StandardMBean mbean = new StandardMBean(executionFlow,
- ExecutionFlow.class);
- getMBeanServer().registerMBean(mbean,
- flowMBeanName(module, executionFlow));
- } catch (Exception e) {
- String msg = "Cannot register execution flow " + executionFlow
- + " as mbean";
- throw new SlcException(msg, e);
- }
- }
-
- public void unregisterMBean(Module module, ExecutionFlow executionFlow) {
- try {
- getMBeanServer().unregisterMBean(
- flowMBeanName(module, executionFlow));
- } catch (Exception e) {
- String msg = "Cannot unregister execution flow " + executionFlow
- + " as mbean";
- throw new SlcException(msg, e);
- }
- }
-
- protected ObjectName flowMBeanName(Module module,
- ExecutionFlow executionFlow) {
- String executionModulesPrefix = "SLCExecutionModules";
- // String path = executionFlow.getPath();
- String name = executionFlow.getName();
- // if (path == null && name.indexOf('/') >= 0) {
- // path = name.substring(0, name.lastIndexOf('/'));
- // name = name.substring(name.lastIndexOf('/'));
- // }
-
- StringBuffer buf = new StringBuffer(executionModulesPrefix + ":"
- + "module=" + module.getName() + " [" + module.getVersion()
- + "],");
-
- // if (path != null && !path.equals("")) {
- // int depth = 0;
- // for (String token : path.split("/")) {
- // if (!token.equals("")) {
- // buf.append("path").append(depth).append('=');
- // // in order to have directories first
- // buf.append('/');
- // buf.append(token).append(',');
- // depth++;
- // }
- // }
- // }
- buf.append("name=").append(name);
- try {
- return new ObjectName(buf.toString());
- } catch (Exception e) {
- throw new SlcException("Cannot generate object name based on "
- + buf, e);
- }
- }
-
- /*
- * UTILITIES
- */
- @SuppressWarnings("rawtypes")
- private OsgiBundle asOsgiBundle(Map properties) {
- String bundleSymbolicName = checkAndGet(Constants.BUNDLE_SYMBOLICNAME,
- properties);
- String bundleVersion = checkAndGet(Constants.BUNDLE_VERSION, properties);
- return new OsgiBundle(bundleSymbolicName, bundleVersion);
- }
-
- @SuppressWarnings("rawtypes")
- private String checkAndGet(Object key, Map properties) {
- if (!properties.containsKey(key) || properties.get(key) == null)
- throw new SlcException(key + " not set in " + properties);
- else
- return properties.get(key).toString();
- }
-
- public void setBundlesManager(BundlesManager bundlesManager) {
- this.bundlesManager = bundlesManager;
- }
-
- public void setDefaultDescriptorConverter(
- ExecutionFlowDescriptorConverter defaultDescriptorConverter) {
- this.defaultDescriptorConverter = defaultDescriptorConverter;
- }
-
- public void setRegisterFlowsToJmx(Boolean registerFlowsToJmx) {
- this.registerFlowsToJmx = registerFlowsToJmx;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.osgi;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.FileExecutionResources;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.eclipse.gemini.blueprint.io.OsgiBundleResource;
-import org.osgi.framework.BundleContext;
-import org.springframework.core.io.Resource;
-
-/** Write access to resources in an OSGi context */
-public class OsgiExecutionResources extends FileExecutionResources implements
- BundleContextAware {
- private final static Log log = LogFactory
- .getLog(OsgiExecutionResources.class);
-
- private BundleContext bundleContext;
-
- @Override
- protected File fileFromResource(Resource resource) {
- File file = super.fileFromResource(resource);
- if (file != null)
- return file;
-
- if (!(resource instanceof OsgiBundleResource))
- return null;
-
- OsgiBundleResource osgiBundleResource = (OsgiBundleResource) resource;
- try {
- return osgiBundleResource.getFile();
- } catch (IOException e) {
- if (log.isTraceEnabled())
- log.trace("Resource " + resource
- + " is not available on the file system: " + e);
- }
-
- // TODO: ability to access resources in other bundles
- String location = bundleContext.getBundle().getLocation();
- String base = null;
- if (location.startsWith("reference:file:"))
- base = location.substring("reference:file:".length());
- else if (location.startsWith("initial@reference:file:")) {
- // TODO: Equinox specific?
- String relPath = location.substring("initial@reference:file:"
- .length());
- // if (relPath.startsWith("../"))// relative to the framework jar
- // relPath = relPath.substring("../".length());
- // String framework =
- // System.getProperty("osgi.framework").substring(
- // "file:".length());
- // log.debug(framework);
- String installArea = System.getProperty("osgi.install.area")
- .substring("file:".length());
- // log.debug(installArea);
- base = installArea + '/' + relPath;
- // int sepIndex = framework.lastIndexOf(File.separatorChar);
- // framework = framework.substring(0, sepIndex);
- // base = framework + '/' + relPath;
- } else {
- return null;
- }
-
- String path = base + '/' + osgiBundleResource.getPathWithinContext();
- try {
- file = new File(path).getCanonicalFile();
- } catch (IOException e) {
- throw new SlcException("Cannot determine canonical path for "
- + path, e);
- }
-
- if (!file.exists())
- throw new SlcException(file
- + " was retrieved in bundle located at '" + location
- + "' for resource " + resource + " but it does not exist");
-
- if (log.isTraceEnabled())
- log.debug("OSGi local resource: " + file + " from " + resource);
- return file;
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.osgi;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.StreamReadable;
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.core.build.VersionedResourceDistribution;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.DynamicRuntime;
-import org.argeo.slc.deploy.TargetData;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-
-public class OsgiRuntime implements BundleContextAware, ResourceLoaderAware,
- DynamicRuntime<OsgiBundle> {
- private String uuid = UUID.randomUUID().toString();
- private BundleContext bundleContext;
- private ResourceLoader resourceLoader;
-
- public List<OsgiBundle> listModules() {
- List<OsgiBundle> modules = new ArrayList<OsgiBundle>();
- Bundle[] bundles = bundleContext.getBundles();
- for (Bundle bundle : bundles) {
- OsgiBundle osgiBundle = new OsgiBundle(bundle);
- modules.add(osgiBundle);
- String location = bundle.getLocation();
- if (location != null) {
- Resource resource = resourceLoader.getResource(location);
- osgiBundle
- .setResourceDistribution(new VersionedResourceDistribution(
- osgiBundle.getName(), osgiBundle.getVersion(),
- resource));
- }
- }
- return modules;
- }
-
- public OsgiBundle installModule(Distribution distribution) {
- if (!(distribution instanceof StreamReadable))
- throw new UnsupportedException("distribution", distribution);
-
- StreamReadable sr = (StreamReadable) distribution;
- Bundle bundle;
- try {
- bundle = bundleContext.installBundle(sr.toString(), sr
- .getInputStream());
- } catch (BundleException e) {
- throw new SlcException(
- "Cannot install OSGi bundle " + distribution, e);
- }
- return new OsgiBundle(bundle);
- }
-
- public void updateModule(NameVersion nameVersion) {
- Bundle bundle = findBundle(nameVersion);
- try {
- bundle.update();
- } catch (BundleException e) {
- throw new SlcException("Cannot update " + bundle, e);
- }
- }
-
- public void uninstallModule(NameVersion nameVersion) {
- Bundle bundle = findBundle(nameVersion);
- try {
- bundle.uninstall();
- } catch (BundleException e) {
- throw new SlcException("Cannot uninstall " + bundle, e);
- }
- }
-
- public void startModule(NameVersion nameVersion) {
- Bundle bundle = findBundle(nameVersion);
- try {
- bundle.start();
- // TODO: use bundle manager
- } catch (BundleException e) {
- throw new SlcException("Cannot uninstall " + bundle, e);
- }
- }
-
- protected Bundle findBundle(NameVersion nameVersion) {
- Bundle[] bundles = bundleContext.getBundles();
- for (Bundle bundle : bundles) {
- OsgiBundle osgiBundle = new OsgiBundle(bundle);
- if (osgiBundle.equals(nameVersion)) {
- return bundle;
- }
- }
- throw new SlcException("Could not find bundle " + nameVersion);
- }
-
- public void shutdown() {
- // FIXME use framework
- throw new UnsupportedException();
- }
-
- public String getDeployedSystemId() {
- return uuid;
- }
-
- public DeploymentData getDeploymentData() {
- throw new UnsupportedException();
- }
-
- public Distribution getDistribution() {
- throw new UnsupportedException();
- }
-
- public TargetData getTargetData() {
- throw new UnsupportedException();
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void setResourceLoader(ResourceLoader resourceLoader) {
- this.resourceLoader = resourceLoader;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.osgi.build;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.build.ModularDistribution;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.springframework.beans.factory.InitializingBean;
-
-public abstract class AbstractOsgiModularDistribution implements
- ModularDistribution, BundleContextAware, InitializingBean {
- private final static Log log = LogFactory
- .getLog(AbstractOsgiModularDistribution.class);
-
- private BundleContext bundleContext;
- private EclipseUpdateSite eclipseUpdateSite;
-
- /** Initialized by the object itself. */
- private SortedMap<NameVersion, Distribution> distributions = new TreeMap<NameVersion, Distribution>();
-
- protected abstract void fillDistributions(
- SortedMap<NameVersion, Distribution> distributions)
- throws Exception;
-
- public Distribution getModuleDistribution(String moduleName,
- String moduleVersion) {
- return distributions.get(new DefaultNameVersion(moduleName,
- moduleVersion));
- }
-
- public String getDistributionId() {
- return bundleContext.getBundle().getSymbolicName()
- + "-"
- + bundleContext.getBundle().getHeaders()
- .get(Constants.BUNDLE_VERSION);
- }
-
- public Set<NameVersion> listModulesNameVersions() {
- return distributions.keySet();
- }
-
- public Iterator<NameVersion> nameVersions() {
- return distributions.keySet().iterator();
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void afterPropertiesSet() throws Exception {
- fillDistributions(distributions);
- if (log.isDebugEnabled())
- log.debug("Distribution " + getName() + ":" + getVersion()
- + " loaded (" + distributions.size() + " modules)");
- }
-
- protected String findVersion(String name) {
- Set<String> versions = new HashSet<String>();
- for (NameVersion key : distributions.keySet()) {
- if (key.getName().equals(name))
- versions.add(key.getVersion());
- }
-
- if (versions.size() == 0)
- throw new SlcException("Cannot find version for name " + name);
- else if (versions.size() > 1)
- throw new SlcException("Found more than one version for name "
- + name + ": " + versions);
- else
- return versions.iterator().next();
-
- }
-
- public Object getModulesDescriptor(String descriptorType) {
- if (descriptorType.equals("eclipse"))
- return writeEclipseUpdateSite();
- else
- throw new UnsupportedException("descriptorType", descriptorType);
- }
-
- protected Set<NameVersion> writePlainUrlList() {
- return distributions.keySet();
- }
-
- protected String writeEclipseUpdateSite() {
- if (eclipseUpdateSite == null)
- throw new SlcException("No eclipse update site declared.");
-
- StringBuffer buf = new StringBuffer("");
- buf.append("<site>");
-
- List<EclipseUpdateSiteCategory> usedCategories = new ArrayList<EclipseUpdateSiteCategory>();
- for (EclipseUpdateSiteFeature feature : eclipseUpdateSite.getFeatures()) {
-
- String featureId = feature.getName();
- String featureVersion = findVersion(featureId);
- buf.append("<feature");
- buf.append(" url=\"features/").append(featureId).append('_')
- .append(featureVersion).append(".jar\"");
- buf.append(" id=\"").append(featureId).append("\"");
- buf.append(" version=\"").append(featureVersion).append("\"");
- buf.append(">\n");
-
- for (EclipseUpdateSiteCategory category : feature.getCategories()) {
- usedCategories.add(category);
- buf.append(" <category name=\"").append(category.getName())
- .append("\"/>\n");
- }
- buf.append("</feature>\n\n");
- }
-
- for (EclipseUpdateSiteCategory category : usedCategories) {
- buf.append("<category-def");
- buf.append(" name=\"").append(category.getName()).append("\"");
- buf.append(" label=\"").append(category.getLabel()).append("\"");
- buf.append(">\n");
- buf.append(" <description>").append(category.getDescription())
- .append("</description>\n");
- buf.append("</category-def>\n\n");
- }
-
- buf.append("</site>");
- return buf.toString();
- }
-
- public String getName() {
- return bundleContext.getBundle().getSymbolicName();
- }
-
- public String getVersion() {
- return bundleContext.getBundle().getHeaders()
- .get(Constants.BUNDLE_VERSION).toString();
- }
-
- @Override
- public String toString() {
- return new DefaultNameVersion(this).toString();
- }
-
- public void setEclipseUpdateSite(EclipseUpdateSite eclipseUpdateSite) {
- this.eclipseUpdateSite = eclipseUpdateSite;
- }
-
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.osgi.build;
-
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.SortedMap;
-import java.util.StringTokenizer;
-import java.util.jar.JarInputStream;
-import java.util.jar.Manifest;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.DefaultNameVersion;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.core.build.VersionedResourceDistribution;
-import org.osgi.framework.Constants;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.io.ResourceLoader;
-
-public class BundleModularDistribution extends AbstractOsgiModularDistribution
- implements ResourceLoaderAware {
- private ResourceLoader resourceLoader;
-
- private String libDirectory = "/lib";
-
- protected void fillDistributions(
- SortedMap<NameVersion, Distribution> distributions)
- throws Exception {
- Enumeration<URL> urls = (Enumeration<URL>) getBundleContext()
- .getBundle().findEntries(libDirectory, "*.jar", false);
- while (urls.hasMoreElements()) {
- URL url = urls.nextElement();
- JarInputStream in = null;
- try {
- in = new JarInputStream(url.openStream());
- Manifest mf = in.getManifest();
- String name = mf.getMainAttributes().getValue(
- Constants.BUNDLE_SYMBOLICNAME);
- // Skip additional specs such as
- // ; singleton:=true
- if (name.indexOf(';') > -1) {
- name = new StringTokenizer(name, " ;").nextToken();
- }
-
- String version = mf.getMainAttributes().getValue(
- Constants.BUNDLE_VERSION);
- DefaultNameVersion nameVersion = new DefaultNameVersion(name,
- version);
- distributions.put(nameVersion,
- new VersionedResourceDistribution(name, version,
- resourceLoader.getResource(url.toString())));
- } finally {
- IOUtils.closeQuietly(in);
- }
- }
- }
-
- public void setLibDirectory(String libDirectory) {
- this.libDirectory = libDirectory;
- }
-
- public void setResourceLoader(ResourceLoader resourceLoader) {
- this.resourceLoader = resourceLoader;
- }
-
- /*
- * @SuppressWarnings(value = { "unchecked" }) protected URL
- * findModule(String moduleName, String version) { Enumeration<URL> urls =
- * (Enumeration<URL>) bundleContext.getBundle() .findEntries(libDirectory,
- * moduleName + "*", false);
- *
- * if (!urls.hasMoreElements()) throw new SlcException("Cannot find module "
- * + moduleName);
- *
- * URL url = urls.nextElement();
- *
- * // TODO: check version as well if (urls.hasMoreElements()) throw new
- * SlcException("More than one module with name " + moduleName); return url;
- * }
- */
-
-}
+++ /dev/null
-package org.argeo.slc.osgi.build;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class EclipseUpdateSite {
- private List<EclipseUpdateSiteFeature> features = new ArrayList<EclipseUpdateSiteFeature>();
-
- public List<EclipseUpdateSiteFeature> getFeatures() {
- return features;
- }
-
- public void setFeatures(List<EclipseUpdateSiteFeature> features) {
- this.features = features;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.osgi.build;
-
-public class EclipseUpdateSiteCategory {
- private String name;
- private String label;
- private String description;
-
- public String getLabel() {
- return label;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.osgi.build;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class EclipseUpdateSiteFeature {
- private String name;
- private List<EclipseUpdateSiteCategory> categories = new ArrayList<EclipseUpdateSiteCategory>();
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<EclipseUpdateSiteCategory> getCategories() {
- return categories;
- }
-
- public void setCategories(List<EclipseUpdateSiteCategory> categories) {
- this.categories = categories;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.osgi.build;
-
-import java.net.URL;
-import java.util.SortedMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.NameVersion;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.core.build.VersionedResourceDistribution;
-import org.argeo.slc.osgi.OsgiBundle;
-import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
-import org.osgi.framework.Bundle;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-
-public class OsgiRuntimeModularDistribution extends
- AbstractOsgiModularDistribution implements ResourceLoaderAware {
- private final static Log log = LogFactory
- .getLog(OsgiRuntimeModularDistribution.class);
-
- private ResourceLoader resourceLoader;
-
- protected void fillDistributions(
- SortedMap<NameVersion, Distribution> distributions)
- throws Exception {
-
- String frameworkUrl = System.getProperty("osgi.framework");
- String frameworkBaseUrl = null;
- if (frameworkUrl != null)
- frameworkBaseUrl = frameworkUrl.substring(0, frameworkUrl
- .lastIndexOf('/'));
- bundles: for (Bundle bundle : getBundleContext().getBundles()) {
- OsgiBundle osgiBundle = new OsgiBundle(bundle);
-
- String originalLocation = bundle.getLocation();
-
- if (OsgiBundleUtils.isSystemBundle(bundle)) {
- continue bundles;
- }
-
- String location = originalLocation;
- if (originalLocation.startsWith("reference:file:"))
- location = originalLocation.substring("reference:".length());
-
- if (frameworkBaseUrl != null
- && originalLocation.startsWith("initial@reference:file:")) {
- location = frameworkBaseUrl
- + '/'
- + originalLocation.substring("initial@reference:file:"
- .length());
- }
-
- try {
- URL url = new URL(location);
- Resource res = resourceLoader.getResource(url.toString());
- distributions.put(osgiBundle,
- new VersionedResourceDistribution(osgiBundle, res));
-
- if (log.isTraceEnabled())
- log.debug("Added url " + url + " from original location "
- + originalLocation);
- } catch (Exception e) {
- log.warn("Cannot interpret location " + location
- + " of bundle " + bundle + ": " + e);
- }
- }
- }
-
- public void setResourceLoader(ResourceLoader resourceLoader) {
- this.resourceLoader = resourceLoader;
- }
-}
+++ /dev/null
-package org.argeo.slc.osgi.deploy;
-
-import org.argeo.slc.core.deploy.DefaultResourceSet;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
-import org.eclipse.gemini.blueprint.io.OsgiBundleResourceLoader;
-import org.eclipse.gemini.blueprint.io.OsgiBundleResourcePatternResolver;
-import org.eclipse.gemini.blueprint.util.OsgiBundleUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.springframework.core.io.ResourceLoader;
-
-/**
- * Retrieves ressources from an OSGi bundle either the active one or another one
- * referenced by its symbolic name.
- */
-public class OsgiResourceSet extends DefaultResourceSet implements
- BundleContextAware {
- private BundleContext bundleContext;
- private Bundle bundle = null;
- private String bundleSymbolicName = null;
-
- private OsgiBundleResourceLoader osgiBundleResourceLoader = null;
-
- @Override
- public void afterPropertiesSet() throws Exception {
- osgiBundleResourceLoader = new OsgiBundleResourceLoader(getBundle());
- if (getResourcePatternResolver() == null)
- setResourcePatternResolver(new OsgiBundleResourcePatternResolver(
- osgiBundleResourceLoader));
- super.afterPropertiesSet();
- }
-
- public Bundle getBundle() {
- if (bundle != null)
- return bundle;
- else if (bundleSymbolicName != null)// do not cache
- return OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
- bundleSymbolicName);
- else
- // containing bundle
- return bundleContext.getBundle();
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- @Override
- public ResourceLoader getResourceLoaderToUse() {
- return osgiBundleResourceLoader;
- }
-
- public void setBundle(Bundle bundle) {
- this.bundle = bundle;
- }
-
- public void setBundleSymbolicName(String bundleSymbolicName) {
- this.bundleSymbolicName = bundleSymbolicName;
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2007-2012 Argeo GmbH Licensed under the Apache License,
- Version 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the License. -->
-<!-- Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org> Licensed under
- the Apache License, Version 2.0 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of the License
- at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
- law or agreed to in writing, software distributed under the License is distributed
- on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- express or implied. See the License for the specific language governing permissions
- and limitations under the License. -->
-
-<beans xmlns:osgi="http://www.springframework.org/schema/osgi"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/osgi
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
- <osgi:service interface="org.argeo.slc.execution.ExecutionContext"
- ref="executionContext" />
- <osgi:service
- interface="org.argeo.slc.execution.ExecutionFlowDescriptorConverter"
- ref="executionFlowDescriptorConverter" />
-
- <osgi:reference id="callbackHandler"
- interface="javax.security.auth.callback.CallbackHandler" cardinality="0..1" />
-
- <bean class="org.argeo.slc.osgi.MultipleServiceExporterPostProcessor">
- <property name="interfaces">
- <list>
- <value><![CDATA[org.argeo.slc.execution.ExecutionFlow]]></value>
- </list>
- </property>
- <property name="bundleContext" ref="bundleContext" />
- </bean>
-
- <bean id="osgiExecutionResources" class="org.argeo.slc.osgi.OsgiExecutionResources">
- <property name="executionContext" ref="executionContext" />
- </bean>
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.spring;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.slc.SlcException;
-
-/** Provides base method for executing code with system authorization. */
-abstract class AbstractSystemExecution {
- private final static Log log = LogFactory.getLog(AbstractSystemExecution.class);
- private final Subject subject = new Subject();
-
- /** Authenticate the calling thread */
- protected void authenticateAsSystem() {
- ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- try {
- LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
- lc.login();
- } catch (LoginException e) {
- throw new SlcException("Cannot login as system", e);
- } finally {
- Thread.currentThread().setContextClassLoader(origClassLoader);
- }
- if (log.isTraceEnabled())
- log.trace("System authenticated");
- }
-
- protected void deauthenticateAsSystem() {
- ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- try {
- LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
- lc.logout();
- } catch (LoginException e) {
- throw new SlcException("Cannot logout as system", e);
- } finally {
- Thread.currentThread().setContextClassLoader(origClassLoader);
- }
- }
-
- protected Subject getSubject() {
- return subject;
- }
-}
+++ /dev/null
-package org.argeo.slc.spring;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-
-import org.eclipse.gemini.blueprint.context.DependencyInitializationAwareBeanPostProcessor;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.support.AbstractBeanFactory;
-import org.springframework.beans.factory.support.SecurityContextProvider;
-import org.springframework.beans.factory.support.SimpleSecurityContextProvider;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Executes with a system authentication the instantiation and initialization
- * methods of the application context where it has been defined.
- */
-public class AuthenticatedApplicationContextInitialization extends
- AbstractSystemExecution implements
- DependencyInitializationAwareBeanPostProcessor, ApplicationContextAware {
- /** If non empty, restricts to these beans */
- private List<String> beanNames = new ArrayList<String>();
-
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
- if (beanNames.size() == 0 || beanNames.contains(beanName))
- authenticateAsSystem();
- return bean;
- }
-
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
- if (beanNames.size() == 0 || beanNames.contains(beanName))
- deauthenticateAsSystem();
- return bean;
- }
-
- public void setBeanNames(List<String> beanNames) {
- this.beanNames = beanNames;
- }
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext)
- throws BeansException {
- if (applicationContext.getAutowireCapableBeanFactory() instanceof AbstractBeanFactory) {
- final AbstractBeanFactory beanFactory = ((AbstractBeanFactory) applicationContext
- .getAutowireCapableBeanFactory());
- // retrieve subject's access control context
- // and set it as the bean factory security context
- Subject.doAs(getSubject(), new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- SecurityContextProvider scp = new SimpleSecurityContextProvider(
- AccessController.getContext());
- beanFactory.setSecurityContextProvider(scp);
- return null;
- }
- });
- }
- }
-}
+++ /dev/null
-package org.argeo.slc.spring.auth;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.slc.SlcException;
-
-/** Provides base method for executing code with system authorization. */
-abstract class AbstractSystemExecution {
- private final static Log log = LogFactory.getLog(AbstractSystemExecution.class);
- private final Subject subject = new Subject();
-
- /** Authenticate the calling thread */
- protected void authenticateAsSystem() {
- ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- try {
- LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
- lc.login();
- } catch (LoginException e) {
- throw new SlcException("Cannot login as system", e);
- } finally {
- Thread.currentThread().setContextClassLoader(origClassLoader);
- }
- if (log.isTraceEnabled())
- log.trace("System authenticated");
- }
-
- protected void deauthenticateAsSystem() {
- ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- try {
- LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_DATA_ADMIN, subject);
- lc.logout();
- } catch (LoginException e) {
- throw new SlcException("Cannot logout as system", e);
- } finally {
- Thread.currentThread().setContextClassLoader(origClassLoader);
- }
- }
-
- protected Subject getSubject() {
- return subject;
- }
-}
+++ /dev/null
-package org.argeo.slc.spring.auth;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-
-import org.eclipse.gemini.blueprint.context.DependencyInitializationAwareBeanPostProcessor;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.support.AbstractBeanFactory;
-import org.springframework.beans.factory.support.SecurityContextProvider;
-import org.springframework.beans.factory.support.SimpleSecurityContextProvider;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Executes with a system authentication the instantiation and initialization
- * methods of the application context where it has been defined.
- */
-public class AuthenticatedApplicationContextInitialization extends
- AbstractSystemExecution implements
- DependencyInitializationAwareBeanPostProcessor, ApplicationContextAware {
- /** If non empty, restricts to these beans */
- private List<String> beanNames = new ArrayList<String>();
-
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
- if (beanNames.size() == 0 || beanNames.contains(beanName))
- authenticateAsSystem();
- return bean;
- }
-
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
- if (beanNames.size() == 0 || beanNames.contains(beanName))
- deauthenticateAsSystem();
- return bean;
- }
-
- public void setBeanNames(List<String> beanNames) {
- this.beanNames = beanNames;
- }
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext)
- throws BeansException {
- if (applicationContext.getAutowireCapableBeanFactory() instanceof AbstractBeanFactory) {
- final AbstractBeanFactory beanFactory = ((AbstractBeanFactory) applicationContext
- .getAutowireCapableBeanFactory());
- // retrieve subject's access control context
- // and set it as the bean factory security context
- Subject.doAs(getSubject(), new PrivilegedAction<Void>() {
- @Override
- public Void run() {
- SecurityContextProvider scp = new SimpleSecurityContextProvider(
- AccessController.getContext());
- beanFactory.setSecurityContextProvider(scp);
- return null;
- }
- });
- }
- }
-}
+++ /dev/null
-package org.argeo.slc.spring.auth;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-import javax.transaction.UserTransaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.osgi.service.useradmin.Role;
-import org.osgi.service.useradmin.UserAdmin;
-
-/**
- * Register one or many roles via a user admin service. Does nothing if the role
- * is already registered.
- */
-public class SimpleRoleRegistration implements Runnable {
- private final static Log log = LogFactory
- .getLog(SimpleRoleRegistration.class);
-
- private String role;
- private List<String> roles = new ArrayList<String>();
- private UserAdmin userAdmin;
- private UserTransaction userTransaction;
-
- @Override
- public void run() {
- try {
- userTransaction.begin();
- if (role != null && !roleExists(role))
- newRole(toDn(role));
-
- for (String r : roles)
- if (!roleExists(r))
- newRole(toDn(r));
- userTransaction.commit();
- } catch (Exception e) {
- try {
- userTransaction.rollback();
- } catch (Exception e1) {
- log.error("Cannot rollback", e1);
- }
- throw new SlcException("Cannot add roles", e);
- }
- }
-
- private boolean roleExists(String role) {
- return userAdmin.getRole(toDn(role).toString()) != null;
- }
-
- protected void newRole(LdapName r) {
- userAdmin.createRole(r.toString(), Role.GROUP);
- log.info("Added role " + r + " required by application.");
- }
-
- public void register(UserAdmin userAdminService, Map<?, ?> properties) {
- this.userAdmin = userAdminService;
- run();
- }
-
- protected LdapName toDn(String name) {
- try {
- return new LdapName("cn=" + name + ",ou=roles,ou=node");
- } catch (InvalidNameException e) {
- throw new SlcException("Badly formatted role name " + name, e);
- }
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- public void setRoles(List<String> roles) {
- this.roles = roles;
- }
-
- public void setUserAdmin(UserAdmin userAdminService) {
- this.userAdmin = userAdminService;
- }
-
- public void setUserTransaction(UserTransaction userTransaction) {
- this.userTransaction = userTransaction;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.spring.repo.osgi;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.BeanNameAware;
-
-public class BndWrapper extends org.argeo.slc.repo.osgi.BndWrapper implements BeanNameAware {
- private final static Log log = LogFactory.getLog(BndWrapper.class);
-
- @Override
- public void setBeanName(String name) {
- if (getName() == null) {
- setName(name);
- } else {
- if (!name.contains("#"))
- log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
- }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.spring.repo.osgi;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.BeanNameAware;
-
-public class MavenWrapper extends org.argeo.slc.repo.osgi.MavenWrapper implements BeanNameAware {
- private final static Log log = LogFactory.getLog(MavenWrapper.class);
-
- @Override
- public void setBeanName(String name) {
- if (getName() == null) {
- setName(name);
- } else {
- if (!name.contains("#"))
- log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
- }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.spring.repo.osgi;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.BeanNameAware;
-
-public class UriWrapper extends org.argeo.slc.repo.osgi.UriWrapper implements BeanNameAware {
- private final static Log log = LogFactory.getLog(UriWrapper.class);
-
- @Override
- public void setBeanName(String name) {
- if (getName() == null) {
- setName(name);
- } else {
- if (!name.contains("#"))
- log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
- }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.spring.unit;
-
-import org.argeo.slc.execution.ExecutionFlow;
-
-public abstract class AbstractExecutionFlowTestcase extends AbstractSpringTestCase {
- @SuppressWarnings(value = { "unchecked" })
- protected <T extends ExecutionFlow> T executeFlow(String flowName) {
- ExecutionFlow flow = getBean(flowName);
- flow.run();
- return (T) flow;
- }
-}
+++ /dev/null
-package org.argeo.slc.spring.unit;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.osgi.boot.OsgiBoot;
-import org.argeo.slc.SlcException;
-import org.eclipse.core.runtime.adaptor.EclipseStarter;
-import org.eclipse.gemini.blueprint.util.OsgiStringUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.springframework.context.ApplicationContext;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("restriction")
-public abstract class AbstractOsgiRuntimeTestCase extends TestCase {
- private final static Log log = LogFactory
- .getLog(AbstractOsgiRuntimeTestCase.class);
-
- protected OsgiBoot osgiBoot = null;
-
- protected void installBundles() throws Exception {
-
- }
-
- public void setUp() throws Exception {
- // To avoid xerces from the classpath being detected as the provider
- System
- .setProperty("javax.xml.parsers.DocumentBuilderFactory",
- "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
- System.setProperty("javax.xml.parsers.SAXParserFactory",
- "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
-
- BundleContext bundleContext = startRuntime();
- osgiBoot = new OsgiBoot(bundleContext);
- log.info("OSGi runtime started.");
-
- installBundles();
-
- List<String> bundlesToStart = getBundlesToStart();
- osgiBoot.startBundles(bundlesToStart);
- waitAllBundlesOk(bundlesToStart);
- if (log.isTraceEnabled())
- listInstalledBundles();
- }
-
- public void tearDown() throws Exception {
- osgiBoot = null;
- stopRuntime();
- log.info("OSGi runtime stopped.");
- }
-
- protected BundleContext startRuntime() throws Exception {
- String[] args = { "-console", "-clean" };
- BundleContext bundleContext = EclipseStarter.startup(args, null);
- return bundleContext;
- }
-
- protected void stopRuntime() throws Exception {
- EclipseStarter.shutdown();
- }
-
- protected List<String> getBundlesToStart() {
- return new ArrayList<String>();
- }
-
- protected void listInstalledBundles() {
- BundleContext bundleContext = osgiBoot.getBundleContext();
- Bundle[] bundles = bundleContext.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- System.out.println(OsgiStringUtils.nullSafeSymbolicName(bundles[i])
- + " [" + OsgiStringUtils.bundleStateAsString(bundles[i])
- + "] " + bundles[i].getLocation());
- }
-
- }
-
- protected Map<Bundle, ApplicationContext> getOsgiApplicationContexts()
- throws Exception {
- Map<Bundle, ApplicationContext> map = new HashMap<Bundle, ApplicationContext>();
- BundleContext bundleContext = osgiBoot.getBundleContext();
- ServiceReference[] srs = bundleContext.getServiceReferences(
- ApplicationContext.class.getName(), null);
- for (ServiceReference sr : srs) {
- ApplicationContext context = (ApplicationContext) bundleContext
- .getService(sr);
- map.put(sr.getBundle(), context);
- }
- return map;
- }
-
- /** Wait for all bundles to be either RESOLVED or ACTIVE. */
- protected void waitAllBundlesOk(List<String> bundlesToStart) {
- BundleContext bundleContext = osgiBoot.getBundleContext();
- long begin = System.currentTimeMillis();
- long duration = 0;
- boolean allBundlesOk = true;
- StringBuffer badBundles = null;
- while (duration < getResolvedTimeout()) {
- badBundles = new StringBuffer();
- for (Bundle bundle : bundleContext.getBundles()) {
- if (bundle.getSymbolicName() != null
- && bundle.getSymbolicName().startsWith(
- "org.eclipse.jdt")) {
- // don't check Eclipse SDK bundles
- continue;
- }
-
- if (bundle.getState() == Bundle.INSTALLED) {
- allBundlesOk = false;
- badBundles
- .append(OsgiStringUtils
- .nullSafeSymbolicName(bundle)
- + " ["
- + OsgiStringUtils
- .bundleStateAsString(bundle) + "]");
- }
-
- if (bundlesToStart.contains(bundle.getSymbolicName())
- && bundle.getState() != Bundle.ACTIVE) {
- allBundlesOk = false;
- badBundles.append(OsgiStringUtils
- .nullSafeSymbolicName(bundle)
- + " ["
- + OsgiStringUtils.bundleStateAsString(bundle)
- + "]\n");
- }
- }
-
- if (allBundlesOk)
- break;// while
-
- sleep(1000);
-
- duration = System.currentTimeMillis() - begin;
- }
-
- if (!allBundlesOk) {
- listInstalledBundles();
- throw new SlcException(
- "Some bundles are not at the proper status:\n" + badBundles);
- }
- }
-
- /**
- * Make sure that the application context of the started bundles starting
- * with this prefix are properly initialized
- */
- protected void assertStartedBundlesApplicationContext(
- String bundleSymbolicNamesPrefix) {
- List<String> bundlesToStart = getBundlesToStart();
- for (String bundleSName : bundlesToStart) {
- if (bundleSName.startsWith(bundleSymbolicNamesPrefix))
- assertBundleApplicationContext(bundleSName);
- }
- }
-
- /**
- * Make sure that the application context of this bundle is properly
- * initialized
- */
- protected void assertBundleApplicationContext(String bundleSymbolicName) {
- String filter = "(Bundle-SymbolicName=" + bundleSymbolicName + ")";
- // Wait for application context to be ready
- try {
- ServiceReference[] srs = getServiceRefSynchronous(
- ApplicationContext.class.getName(), filter);
- if (srs == null)
- throw new SlcException("No application context for "
- + bundleSymbolicName);
- } catch (InvalidSyntaxException e) {
- throw new SlcException(
- "Unexpected exception when looking for application context for bundle "
- + bundleSymbolicName, e);
- }
- log.info("Application context of bundle " + bundleSymbolicName
- + " is initalized.");
- }
-
- protected ServiceReference[] getServiceRefSynchronous(String clss,
- String filter) throws InvalidSyntaxException {
- // FIXME: factorize
- if (log.isTraceEnabled())
- log.debug("Filter: '" + filter + "'");
- ServiceReference[] sfs = null;
- boolean waiting = true;
- long begin = System.currentTimeMillis();
- do {
- sfs = getBundleContext().getServiceReferences(clss, filter);
-
- if (sfs != null)
- waiting = false;
-
- sleep(100);
- if (System.currentTimeMillis() - begin > getDefaultTimeout())
- throw new SlcException("Search of services " + clss
- + " with filter " + filter + " timed out.");
- } while (waiting);
-
- return sfs;
- }
-
- protected BundleContext getBundleContext() {
- return osgiBoot.getBundleContext();
- }
-
- /** Default is 30s */
- protected long getResolvedTimeout() {
- return 30 * 1000l;
- }
-
- /** Default is 10s */
- protected long getDefaultTimeout() {
- return 10 * 1000l;
- }
-
- final protected void sleep(long duration) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // silent
- }
- }
-}
+++ /dev/null
-package org.argeo.slc.spring.unit;
-
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.beans.factory.BeanFactoryUtils;
-import org.springframework.beans.factory.ListableBeanFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import junit.framework.TestCase;
-
-/** Helper for tests using a Spring application co,text. */
-public abstract class AbstractSpringTestCase extends TestCase {
- protected final Log log = LogFactory.getLog(getClass());
- private ConfigurableApplicationContext context;
-
- /**
- * Gets (and create if necessary) the application context to use. Default
- * implementation uses a class path xml application context and calls
- * {@link #getApplicationContextLocation()}.
- */
- protected ConfigurableApplicationContext getContext() {
- if (context == null) {
- context = new ClassPathXmlApplicationContext(
- getApplicationContextLocation());
- if (getIsStartContext())
- context.start();
- }
- return context;
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (context != null && context.isActive())
- context.close();
- super.tearDown();
- }
-
- /** Whether the context should be started after being created. */
- protected Boolean getIsStartContext() {
- return false;
- }
-
- /** Returns a bean from the underlying context */
- @SuppressWarnings(value = { "unchecked" })
- protected <T> T getBean(String beanId) {
- return (T) getContext().getBean(beanId);
- }
-
- protected <T> T getBean(Class<? extends T> clss) {
- T bean = loadSingleFromContext(getContext(), clss);
- if (bean == null) {
- throw new SlcException("Cannot retrieve a unique bean of type "
- + clss);
- } else {
- return bean;
- }
- }
-
- /**
- * Th location of the application to load. The default implementation
- * returns <i>applicationContext.xml</i> found in the same package as the
- * test.
- */
- protected String getApplicationContextLocation() {
- return inPackage("applicationContext.xml");
- }
-
- /**
- * Prefixes the package of the class after converting the '.' to '/' in
- * order to have a resource path.
- */
- protected String inPackage(String suffix) {
- String prefix = getClass().getPackage().getName().replace('.', '/');
- return prefix + '/' + suffix;
- }
-
- @SuppressWarnings(value = { "unchecked" })
- protected <T> T loadSingleFromContext(ListableBeanFactory context,
- Class<T> clss) {
- Map<String, T> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(
- context, clss, false, false);
- if (beans.size() == 1) {
- return beans.values().iterator().next();
- } else if (beans.size() > 1) {
- if (log.isDebugEnabled()) {
- log
- .debug(("Found more that on bean for type " + clss
- + ": " + beans.keySet()));
- }
- return null;
- } else {
- return null;
- }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.spring.unit;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.execution.ExecutionFlowDescriptor;
-import org.argeo.slc.execution.ExecutionSpecAttribute;
-import org.argeo.slc.execution.RefSpecAttribute;
-import org.argeo.slc.execution.RefValue;
-import org.argeo.slc.execution.RefValueChoice;
-import org.argeo.slc.primitive.PrimitiveAccessor;
-import org.argeo.slc.primitive.PrimitiveSpecAttribute;
-import org.argeo.slc.primitive.PrimitiveValue;
-import org.argeo.slc.runtime.test.BasicTestData;
-
-public class ExecutionFlowDescriptorTestUtils {
- public static ExecutionFlowDescriptor createSimpleExecutionFlowDescriptor() {
- ExecutionFlowDescriptor flowDescriptor = new ExecutionFlowDescriptor();
- flowDescriptor.setName("simpleFlow");
- flowDescriptor.setDescription("my description");
-
- Map<String, Object> values = new HashMap<String, Object>();
- values.put("primitiveInteger", new PrimitiveValue(
- PrimitiveAccessor.TYPE_INTEGER, 100));
-
- RefValue refValue = new RefValue("002");
- values.put("ref1", refValue);
- flowDescriptor.setValues(values);
-
- flowDescriptor.setExecutionSpec(createRelatedSimpleSpec());
- return flowDescriptor;
- }
-
- protected static DefaultExecutionSpec createRelatedSimpleSpec() {
- DefaultExecutionSpec spec = new DefaultExecutionSpec();
- spec.setBeanName("simpleSpec");
- Map<String, ExecutionSpecAttribute> attributes = new HashMap<String, ExecutionSpecAttribute>();
-
- PrimitiveSpecAttribute primitiveInteger = new PrimitiveSpecAttribute();
- primitiveInteger.setType(PrimitiveAccessor.TYPE_INTEGER);
- primitiveInteger.setValue(50);
- attributes.put("primitiveInteger", primitiveInteger);
-
- RefSpecAttribute ref1 = new RefSpecAttribute();
- ref1.setTargetClass(BasicTestData.class);
- ref1.setChoices(new ArrayList<RefValueChoice>());
- ref1.getChoices().add(new RefValueChoice("001", "desc"));
- ref1.getChoices().add(new RefValueChoice("002", null));
- ref1.getChoices().add(new RefValueChoice("003", null));
- attributes.put("ref1", ref1);
-
- spec.setAttributes(attributes);
-
- return spec;
- }
-}
+++ /dev/null
-package org.argeo.slc.spring.unit;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-public abstract class UnitUtils {
- public static void assertDateSec(Date expected, Date reached) {
- if (expected == null) {
- assertNull(reached);
- return;
- } else {
- assertNotNull(reached);
- }
-
- Calendar expectedCal = new GregorianCalendar();
- expectedCal.setTime(expected);
- Calendar reachedCal = new GregorianCalendar();
- reachedCal.setTime(reached);
- assertEquals(expectedCal.get(Calendar.YEAR), reachedCal
- .get(Calendar.YEAR));
- assertEquals(expectedCal.get(Calendar.MONTH), reachedCal
- .get(Calendar.MONTH));
- assertEquals(expectedCal.get(Calendar.DATE), reachedCal
- .get(Calendar.DATE));
- assertEquals(expectedCal.get(Calendar.HOUR_OF_DAY), reachedCal
- .get(Calendar.HOUR_OF_DAY));
- assertEquals(expectedCal.get(Calendar.MINUTE), reachedCal
- .get(Calendar.MINUTE));
- assertEquals(expectedCal.get(Calendar.SECOND), reachedCal
- .get(Calendar.SECOND));
- }
-
- private UnitUtils() {
-
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src"/>
- <classpathentry kind="src" path="ext/test"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+++ /dev/null
-/bin/
-/target/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.support</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-/MANIFEST.MF
+++ /dev/null
-Import-Package: org.apache.commons.logging,\
-org.dbunit.*;resolution:="optional",\
-junit.framework;resolution:="optional",\
-javax.mail.*;resolution:="optional",\
-org.apache.commons.vfs.*,\
-javax.swing.plaf.metal,\
-org.osgi.*;version=0.0.0,\
-*
\ No newline at end of file
+++ /dev/null
-# Set root logger level to DEBUG and its only appender to A1.\r
-log4j.rootLogger=WARN, console\r
-\r
-## Levels\r
-# Slc\r
-log4j.logger.org.argeo=DEBUG\r
-\r
-# Castor\r
-log4j.logger.org.exolab.castor=WARN\r
-\r
-# Spring\r
-log4j.logger.org.springframework=WARN\r
-\r
-\r
-## Appenders\r
-# A1 is set to be a ConsoleAppender.\r
-log4j.appender.console=org.apache.log4j.ConsoleAppender\r
-\r
-# A1 uses PatternLayout.\r
-log4j.appender.console.layout=org.apache.log4j.PatternLayout\r
-log4j.appender.console.layout.ConversionPattern= %-5p %d{ISO8601} %m - %c%n\r
-\r
+++ /dev/null
-package org.argeo.slc.diff;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class LineTokenizerTest extends TestCase {
- public void testSimple() throws Exception {
- testAndAssert("a,b,c", new String[] { "a", "b", "c" });
- testAndAssert("hello,bonjour,hallo,priviet", new String[] { "hello",
- "bonjour", "hallo", "priviet" });
- }
-
- public void testTricky() throws Exception {
- testAndAssert("alone", new String[] { "alone" });
- testAndAssert("", new String[] { "" });
-
- testAndAssert(",hello,bonjour,hallo,priviet", new String[] { "",
- "hello", "bonjour", "hallo", "priviet" });
- testAndAssert("hello,bonjour,,hallo,priviet", new String[] { "hello",
- "bonjour", "", "hallo", "priviet" });
- testAndAssert("hello,bonjour,hallo,priviet,", new String[] { "hello",
- "bonjour", "hallo", "priviet", "" });
- testAndAssert(",hello,,bonjour,hallo,,,,priviet,", new String[] { "",
- "hello", "", "bonjour", "hallo", "", "", "", "priviet", "" });
-
- testAndAssert(",,,", new String[] { "", "", "", "" });
- }
-
- public void testComplex() throws Exception {
- testAndAssert("a#b#c", '#', "", new String[] { "a", "b", "c" });
- testAndAssert("hello!bonjour!hallo!priviet", '!', "", new String[] {
- "hello", "bonjour", "hallo", "priviet" });
-
- testAndAssert("hello,,bonjour,,hallo,priviet", ',', "<EMPTY>",
- new String[] { "hello", "<EMPTY>", "bonjour", "<EMPTY>",
- "hallo", "priviet" });
- }
-
- private void testAndAssert(String str, String[] expected) {
- testAndAssert(str, ',', "", expected);
- }
-
- private void testAndAssert(String str, Character sep, String noValueStr,
- String[] expected) {
- List<String> res = LineTokenizer.tokenize(str, sep, noValueStr);
- assertEquals("Size", expected.length, res.size());
- for (int i = 0; i < res.size(); i++) {
- String token = res.get(i);
- assertEquals("Value@" + i, expected[i], token);
- }
- }
-}
+++ /dev/null
-<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.slc</groupId>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.support</artifactId>
- <name>SLC Third Party Support</name>
- <dependencies>
- <!-- SLC Runtime -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.runtime</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.spring</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.diff;
-
-/**
- * Converts data into a format better adapted for comparison. It is typically
- * used to convert <code>String</code> into typed format such as
- * <code>BigDecimal</code>
- */
-public interface DataInterpreter {
- /**
- * Converts data
- *
- * @param key
- * any object used to differentiate the type of data (e.g.
- * column, path)
- * @param value
- * the data to convert
- * @return the converted object
- */
- public Object convert(Object key, Object value);
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-import org.springframework.core.io.Resource;
-
-/** A comparator providing structured information about the differences found. */
-public interface Diff {
- /** Performs the comparison. */
- public void compare(Resource expected, Resource reached,
- DiffResult diffResult);
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-/** The root class for issues which happened during a diff. */
-public abstract class DiffIssue implements Comparable<DiffIssue> {
- /** The position of this issue. */
- // Was final and is not anymore in order to persist in hibernate
- protected DiffPosition position;
-
- // hibernate
- private long id;
-
- /** Constructor */
- public DiffIssue(DiffPosition position) {
- super();
- this.position = position;
- }
-
- public int compareTo(DiffIssue o) {
- return position.compareTo(o.position);
- }
-
- /** The position of this issue within the test file */
- public DiffPosition getPosition() {
- return position;
- }
-
- // Hibernate
- @SuppressWarnings("unused")
- private void setId(long id) {
- this.id = id;
- }
-
- @SuppressWarnings("unused")
- private long getId() {
- return id;
- }
-
- @SuppressWarnings("unused")
- private void setPosition(DiffPosition position) {
- this.position = position;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-/** Intermediate class that can hold the key to be displayed. */
-public abstract class DiffIssueKey extends DiffIssue {
- /** The position of this issue. */
- protected DiffKey key;
-
- /** Constructor without key */
- public DiffIssueKey(DiffPosition position) {
- super(position);
- }
-
- /** Constructor with key */
- public DiffIssueKey(DiffPosition position, DiffKey key) {
- super(position);
- this.key = key;
- }
-
- public Object getKey() {
- return key;
- }
-
- @Override
- public String toString() {
- if (key != null) {
- return key.toString();
- } else {
- return "";
- }
- }
-
- // Hibernate
- @SuppressWarnings("unused")
- private void setKey(DiffKey key) {
- this.key = key;
- }
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-/**
- * Object able to uniquely identify an atomic diff part. Used to identify
- * missings and left-overs.
- */
-public interface DiffKey {
- public String toString();
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-/**
- * A value missing in one of the file. If its position is related to expected,
- * this means it is a left over in the reached, if its position is related to
- * the reached it means that it is missing from the reached. If the value is
- * null it means that the entire line is missing.
- */
-public class DiffMissing extends DiffIssueKey {
-
- public DiffMissing(DiffPosition position, DiffKey key) {
- super(position);
- super.key = key;
- }
-
- @Override
- public String toString() {
- if (position.relatedFile == RelatedFile.EXPECTED) {
- return position + ": left over " + super.toString();
- } else if (position.relatedFile == RelatedFile.REACHED) {
- return position + ": missing " + super.toString();
- }
- return super.toString();
- }
-
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-/**
- * <code>DiffMissing</code> using the XPath of the position as
- * <code>DiffKey</code>
- */
-public class DiffMissingXml extends DiffMissing {
-
- public DiffMissingXml(XPathDiffPosition position) {
- super(position, new DiffKeyXml(position.getXPath()));
- }
-
- /** Implementation of <code>DiffKey</code> based on an XPath string. */
- protected static class DiffKeyXml implements DiffKey {
- private final String xPath;
-
- public DiffKeyXml(String xPath) {
- this.xPath = xPath;
- }
-
- public String getXPath() {
- return xPath;
- }
-
- @Override
- public String toString() {
- return xPath;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof DiffKeyXml))
- return false;
- return xPath.equals(((DiffKeyXml) obj).xPath);
- }
-
- @Override
- public int hashCode() {
- return xPath.hashCode();
- }
-
- }
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-import org.argeo.slc.SlcException;
-
-/** Diff issue where reached and expected values are different. */
-public class DiffNotMatched extends DiffIssueKey {
-
- // To enable hibernate persistance, these object cannot be final
- // private final Object expected;
- // private final Object reached;
-
- private Object expected;
- private Object reached;
-
- public DiffNotMatched(DiffPosition position, Object expected, Object reached) {
- super(position);
- this.expected = expected;
- this.reached = reached;
- }
-
- public DiffNotMatched(DiffPosition position, Object expected,
- Object reached, DiffKey key) {
- super(position, key);
- this.expected = expected;
- this.reached = reached;
- }
-
- public Object getExpected() {
- return expected;
- }
-
- public Object getReached() {
- return reached;
- }
-
- @Override
- public String toString() {
- String result = position + ": not matched " + expected + " <> "
- + reached;
- if (super.key != null) {
- result = result + " - Key: " + super.toString();
- }
-
- return result;
- }
-
- @SuppressWarnings("unused")
- private String getExpectedStr() {
- if (expected instanceof String)
- return (String) expected;
- else
- throw new SlcException(
- "Object 'expected' is of wrong type. Must be a String");
- }
-
- @SuppressWarnings("unused")
- private String getReachedStr() {
- if (reached instanceof String)
- return (String) reached;
- else
- throw new SlcException(
- "Object 'reached' is of wrong type. Must be a String");
- }
-
- @SuppressWarnings("unused")
- private void setReachedStr(String reachedStr) {
- this.reached = reachedStr;
- }
-
- @SuppressWarnings("unused")
- private void setExpectedStr(String expectedStr) {
- this.expected = expectedStr;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-/** The position of a diff issue within the test resource. */
-public abstract class DiffPosition implements Comparable<DiffPosition> {
- protected RelatedFile relatedFile;
-
- public DiffPosition(RelatedFile relatedFile) {
- super();
- this.relatedFile = relatedFile;
- }
-
- // For Hibernate
- DiffPosition() {
- }
-
- public RelatedFile getRelatedFile() {
- return relatedFile;
- }
-
- // Added to enable the new data model for persisting TabularDiffTestResult
- @SuppressWarnings("unused")
- private Boolean getIsReached() {
- return relatedFile.equals(RelatedFile.REACHED);
- }
-
- @SuppressWarnings("unused")
- private void setIsReached(Boolean isReached) {
- this.relatedFile = (isReached ? RelatedFile.REACHED
- : RelatedFile.EXPECTED);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-/**
- * The result of a diff, to be subclassed in order to provide richer information
- */
-public interface DiffResult {
- /** Adds a diff issue */
- public void addDiffIssue(DiffIssue diffIssue);
-
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-import java.util.List;
-
-/**
- * Diff which is based on comparison of multiple-key atomic elements (typically
- * columns in a tabular content)
- */
-public interface KeyColumnsDiff extends Diff {
- /** $The list of key columns. */
- List<String> getKeyColumns();
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Parses a string as a vector of strings according to a separator, dealing
- * properly with missing values. This is intended to be used instead of the
- * standard StringTokenizer, which does not deal well with empty values.
- * Contrary to the StringTokenizer the provided String is parsed in the
- * constructor and the values stored as a property. This should therefore not be
- * used to parse long strings. No reference to the argument passed in
- * constructor is kept.
- */
-public class LineTokenizer {
- private final List<String> tokens;
-
- /** Complete constructor. */
- public LineTokenizer(String stringToParse, Character separator,
- String noValueString) {
- this.tokens = parse(stringToParse, separator, noValueString);
- }
-
- /**
- * Parse the string as a vector of strings. Can be overridden in order to
- * provide another implementation.
- */
- protected List<String> parse(final String stringToParse,
- final char separator, final String noValueString) {
- // Init
- final int NULL = -1;
- List<String> res = new ArrayList<String>();
- final char[] array = stringToParse.toCharArray();
- int lastSeparatorIndex = NULL;
-
- // Loop on chars
- for (int currIndex = 0; currIndex < array.length; currIndex++) {
- char c = array[currIndex];
- if (c == separator) {
- if (currIndex == 0) {
- // first char is a separator
- res.add(new String(noValueString));
- lastSeparatorIndex = 0;
- } else if (lastSeparatorIndex == NULL) {
- // first separator found
- res.add(new String(array, 0, currIndex));
- lastSeparatorIndex = currIndex;
- } else if (lastSeparatorIndex != NULL
- && (lastSeparatorIndex == (currIndex - 1))) {
- // consecutive separators
- res.add(new String(noValueString));
- lastSeparatorIndex = currIndex;
- } else {
- // simple case
- res.add(new String(array, lastSeparatorIndex + 1, currIndex
- - lastSeparatorIndex - 1));
- lastSeparatorIndex = currIndex;
- }
- }
- }
-
- // Finalize
- if (lastSeparatorIndex == NULL) {
- // no separator found
- res.add(new String(stringToParse));
- } else if (lastSeparatorIndex == (array.length - 1)) {
- // last char is a separator
- res.add(new String(noValueString));
- } else {
- // last token
- res.add(new String(array, lastSeparatorIndex + 1, array.length
- - lastSeparatorIndex - 1));
- }
- return res;
- }
-
- /** The tokens. */
- public List<String> getTokens() {
- return tokens;
- }
-
- /** Parse */
- public static List<String> tokenize(String stringToParse,
- Character separator, String noValueString) {
- LineTokenizer lt = new LineTokenizer(stringToParse, separator,
- noValueString);
- return lt.getTokens();
- }
-
- /** Parse, using the empty string as no value string. */
- public static List<String> tokenize(String stringToParse,
- Character separator) {
- return tokenize(stringToParse, separator, "");
- }
-
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-/** Enumeration of the types of resource tested. */
-public enum RelatedFile {
- /** The expected resource */
- EXPECTED,
- /** The reached resource */
- REACHED
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-import org.argeo.slc.UnsupportedException;
-
-/**
- * A diff position within a table structure such a CSV file or an SQL result
- * set.
- */
-public class TableDiffPosition extends DiffPosition {
- private Integer line;
- /** Can be null */
- private Integer column;
- /** Can be null */
- private String columnName;
-
- public TableDiffPosition(RelatedFile relatedFile, Integer line,
- Integer column, String columnName) {
- super(relatedFile);
- this.line = line;
- this.column = column;
- this.columnName = columnName;
- }
-
- @SuppressWarnings("unused")
- private TableDiffPosition() {
- }
-
- public Integer getLine() {
- return line;
- }
-
- public Integer getColumn() {
- return column;
- }
-
- public String getColumnName() {
- return columnName;
- }
-
- public int compareTo(DiffPosition dp) {
- if (!(dp instanceof TableDiffPosition))
- throw new UnsupportedException("position", dp);
-
- TableDiffPosition o = (TableDiffPosition) dp;
- if (relatedFile.equals(o.relatedFile)) {
- if (line == o.line) {
- return column.compareTo(o.column);
- } else {
- return line.compareTo(o.line);
- }
- } else {
- return relatedFile.compareTo(o.relatedFile);
- }
- }
-
- @Override
- public String toString() {
- StringBuffer buf = new StringBuffer("");
- buf.append(relatedFile).append('[').append(line);
- if (column != null) {
- buf.append(',').append(column);
- if (columnName != null) {
- buf.append('-').append(columnName);
- }
- }
- buf.append(']');
- return buf.toString();
- }
-
- // Hibernate
- @SuppressWarnings("unused")
- private void setLine(Integer line) {
- this.line = line;
- }
-
- @SuppressWarnings("unused")
- private void setColumn(Integer column) {
- this.column = column;
- }
-
- @SuppressWarnings("unused")
- private void setColumnName(String columnName) {
- this.columnName = columnName;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-/** Compares objects, eventually using tolerance mechanisms. */
-public interface Tolerance {
- /**
- * Compares objects
- *
- * @param key
- * any object used to differentiate the type of data (e.g.
- * column, path)
- * @param expected
- * the expected value
- * @param reached
- * the reached value
- * @return the converted object
- */
- public Boolean compare(Object key, Object expected, Object reached);
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-import java.util.Map;
-
-/** A diff which can manage tolerances. */
-public interface ToleranceDiff extends Diff {
-
- /** Get tolerances, key is the column name. */
- public Map<String, String> getTolerances();
-}
+++ /dev/null
-package org.argeo.slc.diff;
-
-import org.argeo.slc.UnsupportedException;
-
-/** A diff position within an Xml file. <b>NOT YET IMPLEMENTED</b>. */
-public class XPathDiffPosition extends DiffPosition {
-
- private String xPath;
-
- public XPathDiffPosition(RelatedFile relatedFile, String path) {
- super(relatedFile);
- xPath = path;
- }
-
- public int compareTo(DiffPosition dp) {
- if (!(dp instanceof XPathDiffPosition))
- throw new UnsupportedException("position", dp);
-
- XPathDiffPosition o = (XPathDiffPosition) dp;
- if (relatedFile.equals(o.relatedFile)) {
- return xPath.compareTo(o.xPath);
- } else {
- return relatedFile.compareTo(o.relatedFile);
- }
- }
-
- public String getXPath() {
- return xPath;
- }
-
- @Override
- public String toString() {
- return xPath;
- }
-}
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Abstraction of diff comparison with structured results.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.PrivilegedAction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Logger;
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.UserAuthGSSAPIWithMIC;
-
-public abstract class AbstractJschTask implements Runnable {
- private final Log log = LogFactory.getLog(getClass());
-
- private SshTarget sshTarget;
-
- protected Session openSession() {
- if (sshTarget.getSession() != null) {
- Session session = sshTarget.getSession();
- if (session.isConnected()) {
- if (log.isTraceEnabled())
- log.debug("Using cached session to " + getSshTarget() + " via SSH");
- return session;
- }
- }
-
- try {
- JSch jsch = new JSch();
- if (sshTarget.getUsePrivateKey() && sshTarget.getLocalPrivateKey().exists())
- jsch.addIdentity(sshTarget.getLocalPrivateKey().getAbsolutePath());
- Session session = jsch.getSession(getSshTarget().getUser(), getSshTarget().getHost(),
- getSshTarget().getPort());
-
- session.setUserInfo(getSshTarget().getUserInfo());
- session.setConfig("userauth.gssapi-with-mic", UserAuthGSSAPIWithMIC.class.getName());
- session.setServerAliveInterval(1000);
- session.connect();
- if (log.isTraceEnabled())
- log.trace("Connected to " + getSshTarget() + " via SSH");
- if (sshTarget.getSession() != null) {
- if (log.isTraceEnabled())
- log.trace("The cached session to " + getSshTarget() + " was disconnected and was reset.");
- sshTarget.setSession(session);
- }
- return session;
- } catch (JSchException e) {
- if (sshTarget.getUserInfo() instanceof SimpleUserInfo)
- ((SimpleUserInfo) sshTarget.getUserInfo()).reset();
- throw new SlcException("Could not open session to " + getSshTarget(), e);
- }
- }
-
- public void run() {
- Session session = openSession();
- try {
- run(session);
- } finally {
- if (sshTarget != null && sshTarget.getSession() == null) {
- session.disconnect();
- if (log.isTraceEnabled())
- log.trace("Disconnected from " + getSshTarget() + " via SSH");
- }
- }
- }
-
- abstract void run(Session session);
-
- protected int checkAck(InputStream in) throws IOException {
- int b = in.read();
- // b may be 0 for success,
- // 1 for error,
- // 2 for fatal error,
- // -1
- if (b == 0)
- return b;
- else if (b == -1)
- return b;// throw new SlcException("SSH ack returned -1");
- else if (b == 1 || b == 2) {
- StringBuffer sb = new StringBuffer();
- int c;
- do {
- c = in.read();
- sb.append((char) c);
- } while (c != '\n');
- if (b == 1) { // error
- throw new SlcException("SSH ack error: " + sb.toString());
- }
- if (b == 2) { // fatal error
- throw new SlcException("SSH fatal error: " + sb.toString());
- }
- }
- return b;
- }
-
- public SshTarget getSshTarget() {
- if (sshTarget == null)
- throw new SlcException("No SSH target defined.");
- return sshTarget;
- }
-
- public void setSshTarget(SshTarget sshTarget) {
- this.sshTarget = sshTarget;
- }
-
- PrivilegedAction<Void> asPrivilegedAction() {
- return new PrivilegedAction<Void>() {
- public Void run() {
- AbstractJschTask.this.run();
- return null;
- }
- };
- }
-
- static {
- JSch.setLogger(new JschLogger());
- }
-
- private static class JschLogger implements Logger {
- private final Log log = LogFactory.getLog(JschLogger.class);
-
- // TODO better support levels
- @Override
- public boolean isEnabled(int level) {
- if (log.isTraceEnabled())
- return true;
- return false;
- }
-
- @Override
- public void log(int level, String message) {
- log.trace(message);
- }
-
- }
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.PasswordCallback;
-
-import org.argeo.slc.SlcException;
-
-/** Retrieve a password or a passphrase using a standard callback handler. */
-public final class CallbackHandlerUserInfo extends SimpleUserInfo {
- private CallbackHandler callbackHandler;
-
- private Boolean alwaysPrompt = false;
-
- public boolean promptPassphrase(String message) {
- if (passphrase != null)
- return true;
-
- if (!alwaysPrompt && passphraseSafe != null)
- return true;
-
- reset();
- PasswordCallback passwordCb = new PasswordCallback("SSH Passphrase",
- false);
- Callback[] dialogCbs = new Callback[] { passwordCb };
- try {
- callbackHandler.handle(dialogCbs);
- passphraseSafe = passwordCb.getPassword();
- return passphraseSafe != null;
- } catch (Exception e) {
- throw new SlcException("Cannot ask for a password", e);
- }
- }
-
- public boolean promptPassword(String message) {
- if (password != null)
- return true;
-
- if (!alwaysPrompt && passwordSafe != null)
- return true;
-
- reset();
- PasswordCallback passwordCb = new PasswordCallback("SSH Password",
- false);
- Callback[] dialogCbs = new Callback[] { passwordCb };
- try {
- callbackHandler.handle(dialogCbs);
- passwordSafe = passwordCb.getPassword();
- return passwordSafe != null;
- } catch (Exception e) {
- throw new SlcException("Cannot ask for a password", e);
- }
- }
-
- public void setAlwaysPrompt(Boolean alwaysPrompt) {
- this.alwaysPrompt = alwaysPrompt;
- }
-
- public void setCallbackHandler(CallbackHandler defaultCallbackHandler) {
- this.callbackHandler = defaultCallbackHandler;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-import javax.security.auth.login.LoginContext;
-
-class GetMachineId {
-
- public static void main(String[] args) {
- URL url = GetMachineId.class.getResource("jaas.cfg");
- System.setProperty("java.security.auth.login.config", url.toExternalForm());
-
- String hostname = args[0];
- try {
- LoginContext lc = new LoginContext("SINGLE_USER");
- lc.login();
-
- SshTarget sshTarget = new SshTarget();
- sshTarget.setHost(hostname);
- RemoteExec remoteExec = new RemoteExec();
- remoteExec.setCommand("cat /etc/machine-id");
- remoteExec.setSshTarget(sshTarget);
- List<String> lines = new ArrayList<>();
- remoteExec.setStdOutLines(lines);
-
- Subject.doAs(lc.getSubject(), remoteExec.asPrivilegedAction());
-
- String machineId = lines.get(0);
- System.out.println(hostname + ": " + machineId);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-
-import com.jcraft.jsch.Session;
-
-/** Caches a JSCH session in the the ssh target. */
-public class JschContextSession extends AbstractJschTask implements
- InitializingBean, DisposableBean {
- private final static Log log = LogFactory.getLog(JschContextSession.class);
- private Boolean autoconnect = false;
-
- @Override
- void run(Session session) {
- // clear();
- getSshTarget().setSession(session);
- if (log.isDebugEnabled())
- log.debug("Cached SSH context session to " + getSshTarget());
- }
-
- public void afterPropertiesSet() throws Exception {
- // if (log.isDebugEnabled())
- // log.debug(getClass() + ".afterPropertiesSet(), " + beanName + ", "
- // + this);
- if (autoconnect)
- try {
- run();
- } catch (Exception e) {
- log.error("Could not automatically open session", e);
- }
- }
-
- public void destroy() throws Exception {
- clear();
- }
-
- public void clear() {
- SshTarget sshTarget = getSshTarget();
- synchronized (sshTarget) {
- if (sshTarget.getSession() != null) {
- sshTarget.getSession().disconnect();
- sshTarget.setSession(null);
- if (log.isDebugEnabled())
- log.debug("Cleared cached SSH context session to "
- + getSshTarget());
- }
- }
- }
-
- public void setAutoconnect(Boolean autoconnect) {
- this.autoconnect = autoconnect;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.exec.ExecuteException;
-import org.apache.commons.exec.ExecuteResultHandler;
-import org.apache.commons.exec.ExecuteStreamHandler;
-import org.apache.commons.exec.ExecuteWatchdog;
-import org.apache.commons.exec.Executor;
-import org.apache.commons.exec.ProcessDestroyer;
-
-/** A Commons Exec executor executing remotely via SSH */
-public class JschExecutor implements Executor {
- private File workingDirectory;
- private ExecuteStreamHandler streamHandler;
-
- private SshTarget sshTarget;
-
- public void setExitValue(int value) {
- // TODO Auto-generated method stub
-
- }
-
- public void setExitValues(int[] values) {
- // TODO Auto-generated method stub
-
- }
-
- public boolean isFailure(int exitValue) {
- return Executor.INVALID_EXITVALUE == exitValue;
- }
-
- public ExecuteStreamHandler getStreamHandler() {
- return streamHandler;
- }
-
- public void setStreamHandler(ExecuteStreamHandler streamHandler) {
- this.streamHandler = streamHandler;
- }
-
- public ExecuteWatchdog getWatchdog() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setWatchdog(ExecuteWatchdog watchDog) {
- // TODO Auto-generated method stub
-
- }
-
- public ProcessDestroyer getProcessDestroyer() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setProcessDestroyer(ProcessDestroyer processDestroyer) {
- // TODO Auto-generated method stub
-
- }
-
- public File getWorkingDirectory() {
- return workingDirectory;
- }
-
- public void setWorkingDirectory(File workingDirectory) {
- this.workingDirectory = workingDirectory;
- }
-
- public int execute(CommandLine command) throws ExecuteException,
- IOException {
- return execute(command, (Map) null);
- }
-
- public int execute(CommandLine command, Map environment)
- throws ExecuteException, IOException {
- String cmd = command.toString();
- if(workingDirectory!=null)
- cmd = "cd "+workingDirectory.getPath()+" && "+cmd;
- RemoteExec remoteExec = new RemoteExec();
- remoteExec.setSshTarget(sshTarget);
- remoteExec.setStreamHandler(streamHandler);
- remoteExec.setCommand(cmd);
- if (environment != null)
- remoteExec.setEnv(environment);
- remoteExec.run();
- return remoteExec.getLastExitStatus() != null ? remoteExec
- .getLastExitStatus() : Executor.INVALID_EXITVALUE;
- }
-
- public void execute(CommandLine command, ExecuteResultHandler handler)
- throws ExecuteException, IOException {
- // TODO Auto-generated method stub
-
- }
-
- public void execute(CommandLine command, Map environment,
- ExecuteResultHandler handler) throws ExecuteException, IOException {
-
- }
-
- public SshTarget getSshTarget() {
- return sshTarget;
- }
-
- public void setSshTarget(SshTarget sshTarget) {
- this.sshTarget = sshTarget;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.jcraft.jsch.Session;
-
-public class JschMultiTasks extends AbstractJschTask {
- private List<AbstractJschTask> tasks = new ArrayList<AbstractJschTask>();
-
- @Override
- protected void run(Session session) {
- for (AbstractJschTask task : tasks) {
- task.setSshTarget(getSshTarget());
- task.run(session);
- }
- }
-
- public void setTasks(List<AbstractJschTask> tasks) {
- this.tasks = tasks;
- }
-
- public List<AbstractJschTask> getTasks() {
- return tasks;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.commons.exec.ExecuteStreamHandler;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.ExecutionResources;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.core.io.Resource;
-import org.springframework.util.StringUtils;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.ChannelShell;
-import com.jcraft.jsch.Session;
-
-public class RemoteExec extends AbstractJschTask {
- private final static Log log = LogFactory.getLog(RemoteExec.class);
-
- private Boolean failOnBadExitStatus = true;
-
- private List<String> commands = new ArrayList<String>();
- private String command;
- private SystemCall systemCall;
- private List<SystemCall> systemCalls = new ArrayList<SystemCall>();
- private Resource script;
- private Boolean xForwarding = false;
- private Boolean agentForwarding = false;
- private Boolean forceShell = false;
- private Map<String, String> env = new HashMap<String, String>();
- private Resource stdIn = null;
- private Resource stdOut = null;
- private ExecutionResources executionResources;
-
- private String user;
-
- private ExecuteStreamHandler streamHandler = null;
-
- private Integer lastExitStatus = null;
- /**
- * If set, stdout is written to it as a list of lines. Cleared before each
- * run.
- */
- private List<String> stdOutLines = null;
- private Boolean logEvenIfStdOutLines = false;
- private Boolean quiet = false;
-
- public RemoteExec() {
- }
-
- public RemoteExec(SshTarget sshTarget, String cmd) {
- setSshTarget(sshTarget);
- setCommand(cmd);
- }
-
- public void run(Session session) {
- List<String> commandsToUse = new ArrayList<String>(commands);
- String commandToUse = command;
- // convert system calls
- if (systemCall != null) {
- if (command != null)
- throw new SlcException("Cannot specify command AND systemCall");
- commandToUse = convertSystemCall(systemCall);
- }
-
- if (systemCalls.size() != 0) {
- if (commandsToUse.size() != 0)
- throw new SlcException(
- "Cannot specify commands AND systemCalls");
- for (SystemCall systemCall : systemCalls)
- commandsToUse.add(convertSystemCall(systemCall));
- }
-
- if (script != null) {
- // TODO: simply pass the script as a string command
- if (commandsToUse.size() != 0)
- throw new SlcException("Cannot specify commands and script");
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new InputStreamReader(
- script.getInputStream()));
- String line = null;
- while ((line = reader.readLine()) != null) {
- if (!StringUtils.hasText(line))
- continue;
- commandsToUse.add(line);
- }
- } catch (IOException e) {
- throw new SlcException("Cannot read script " + script, e);
- } finally {
- IOUtils.closeQuietly(reader);
- }
- }
-
- if (forceShell) {
- // for the time being do not interpret both \n and ;
- // priority to \n
- // until we know how to parse ; within ""
- if (commandToUse.indexOf('\n') >= 0) {
- StringTokenizer st = new StringTokenizer(commandToUse, "\n");
- while (st.hasMoreTokens()) {
- String cmd = st.nextToken();
- commandsToUse.add(cmd);
- }
- } else if (commandToUse.indexOf(';') >= 0) {
- StringTokenizer st = new StringTokenizer(commandToUse, ";");
- while (st.hasMoreTokens()) {
- String cmd = st.nextToken();
- commandsToUse.add(cmd);
- }
- } else {
- commandsToUse.add(commandToUse);
- }
- commandToUse = null;
- }
-
- // run as user
- if (user != null) {
- if (commandsToUse.size() > 0) {
- commandsToUse.add(0, "su - " + user);
- commandsToUse.add("exit");
- } else {
- if (command.indexOf('\"') >= 0)
- throw new SlcException(
- "Don't know how to su a command with \", use shell instead.");
- commandToUse = "su - " + user + " -c \"" + command + "\"";
- }
- }
-
- // execute command(s)
- if (commandToUse != null) {
- if (commandsToUse.size() != 0)
- throw new SlcException(
- "Specify either a single command or a list of commands.");
- remoteExec(session, commandToUse);
- } else {
- if (commandsToUse.size() == 0)
- throw new SlcException(
- "Neither a single command or a list of commands has been specified.");
-
- remoteExec(session, commandsToUse, script != null ? "script "
- + script.getFilename() : commandsToUse.size() + " commands");
- }
- }
-
- protected String convertSystemCall(SystemCall systemCall) {
- // TODO: prepend environment variables
- // TODO: deal with exec dir
- return systemCall.asCommand();
- }
-
- protected void remoteExec(Session session, final List<String> commands,
- String description) {
- try {
- final ChannelShell channel = (ChannelShell) session
- .openChannel("shell");
- channel.setInputStream(null);
- channel.setXForwarding(xForwarding);
- channel.setAgentForwarding(agentForwarding);
- channel.setEnv(new Hashtable<String, String>(env));
-
- /*
- * // Choose the pty-type "vt102".
- * ((ChannelShell)channel).setPtyType("vt102");
- */
- // Writer thread
- final BufferedWriter writer = new BufferedWriter(
- new OutputStreamWriter(channel.getOutputStream()));
-
- if (log.isDebugEnabled())
- log.debug("Run " + description + " on " + getSshTarget()
- + "...");
- channel.connect();
-
- // write commands to shell
- Thread writerThread = new Thread("Shell writer " + getSshTarget()) {
- @Override
- public void run() {
- try {
- for (String line : commands) {
- if (!StringUtils.hasText(line))
- continue;
- writer.write(line);
- writer.newLine();
- }
- writer.append("exit");
- writer.newLine();
- writer.flush();
- // channel.disconnect();
- } catch (IOException e) {
- throw new SlcException("Cannot write to shell on "
- + getSshTarget(), e);
- } finally {
- IOUtils.closeQuietly(writer);
- }
- }
- };
- writerThread.start();
-
- readStdOut(channel);
- checkExitStatus(channel);
- channel.disconnect();
-
- } catch (Exception e) {
- throw new SlcException("Cannot use SSH shell on " + getSshTarget(),
- e);
- }
-
- }
-
- protected void remoteExec(Session session, String command) {
- try {
- final ChannelExec channel = (ChannelExec) session
- .openChannel("exec");
- channel.setCommand(command);
-
- channel.setInputStream(null);
- channel.setXForwarding(xForwarding);
- channel.setAgentForwarding(agentForwarding);
- channel.setEnv(new Hashtable<String, String>(env));
- channel.setErrStream(null);
-
- // Standard Error
- readStdErr(channel);
-
- if (log.isTraceEnabled())
- log.trace("Run '" + command + "' on " + getSshTarget() + "...");
- channel.connect();
-
- readStdIn(channel);
- readStdOut(channel);
-
- if (streamHandler != null) {
- streamHandler.start();
- while (!channel.isClosed()) {
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- break;
- }
- }
- }
-
- checkExitStatus(channel);
- channel.disconnect();
- } catch (Exception e) {
- throw new SlcException("Cannot execute remotely '" + command
- + "' on " + getSshTarget(), e);
- }
- }
-
- protected void readStdOut(Channel channel) {
- try {
- if (stdOut != null) {
- OutputStream localStdOut = createOutputStream(stdOut);
- try {
- IOUtils.copy(channel.getInputStream(), localStdOut);
- } finally {
- IOUtils.closeQuietly(localStdOut);
- }
- } else if (streamHandler != null) {
- if (channel.getInputStream() != null)
- streamHandler.setProcessOutputStream(channel
- .getInputStream());
- } else {
- BufferedReader stdOut = null;
- try {
- InputStream in = channel.getInputStream();
- stdOut = new BufferedReader(new InputStreamReader(in));
- String line = null;
- while ((line = stdOut.readLine()) != null) {
- if (!line.trim().equals("")) {
-
- if (stdOutLines != null) {
- stdOutLines.add(line);
- if (logEvenIfStdOutLines && !quiet)
- log.info(line);
- } else {
- if (!quiet)
- log.info(line);
- }
- }
- }
- } finally {
- IOUtils.closeQuietly(stdOut);
- }
- }
- } catch (IOException e) {
- throw new SlcException("Cannot redirect stdout from "
- + getSshTarget(), e);
- }
- }
-
- protected void readStdErr(final ChannelExec channel) {
- if (streamHandler != null) {
- try {
- streamHandler.setProcessOutputStream(channel.getErrStream());
- } catch (IOException e) {
- throw new SlcException("Cannot read stderr from "
- + getSshTarget(), e);
- }
- } else {
- new Thread("stderr " + getSshTarget()) {
- public void run() {
- BufferedReader stdErr = null;
- try {
- InputStream in = channel.getErrStream();
- stdErr = new BufferedReader(new InputStreamReader(in));
- String line = null;
- while ((line = stdErr.readLine()) != null) {
- if (!line.trim().equals(""))
- log.error(line);
- }
- } catch (IOException e) {
- if (log.isDebugEnabled())
- log.error("Cannot read stderr from "
- + getSshTarget(), e);
- } finally {
- IOUtils.closeQuietly(stdErr);
- }
- }
- }.start();
- }
- }
-
- protected void readStdIn(final ChannelExec channel) {
- if (stdIn != null) {
- Thread stdInThread = new Thread("Stdin " + getSshTarget()) {
- @Override
- public void run() {
- OutputStream out = null;
- try {
- out = channel.getOutputStream();
- IOUtils.copy(stdIn.getInputStream(), out);
- } catch (IOException e) {
- throw new SlcException("Cannot write stdin on "
- + getSshTarget(), e);
- } finally {
- IOUtils.closeQuietly(out);
- }
- }
- };
- stdInThread.start();
- } else if (streamHandler != null) {
- try {
- streamHandler.setProcessInputStream(channel.getOutputStream());
- } catch (IOException e) {
- throw new SlcException("Cannot write stdin on "
- + getSshTarget(), e);
- }
- }
- }
-
- protected void checkExitStatus(Channel channel) {
- if (channel.isClosed()) {
- lastExitStatus = channel.getExitStatus();
- if (lastExitStatus == 0) {
- if (log.isTraceEnabled())
- log.trace("Remote execution exit status: " + lastExitStatus);
- } else {
- String msg = "Remote execution failed with " + " exit status: "
- + lastExitStatus;
- if (failOnBadExitStatus)
- throw new SlcException(msg);
- else
- log.error(msg);
- }
- }
-
- }
-
- protected OutputStream createOutputStream(Resource target) {
- FileOutputStream out = null;
- try {
-
- final File file;
- if (executionResources != null)
- file = new File(executionResources.getAsOsPath(target, true));
- else
- file = target.getFile();
- out = new FileOutputStream(file, false);
- } catch (IOException e) {
- log.error("Cannot get file for " + target, e);
- IOUtils.closeQuietly(out);
- }
- return out;
- }
-
- public Integer getLastExitStatus() {
- return lastExitStatus;
- }
-
- public void setStreamHandler(ExecuteStreamHandler executeStreamHandler) {
- this.streamHandler = executeStreamHandler;
- }
-
- public void setCommand(String command) {
- this.command = command;
- }
-
- public void setCommands(List<String> commands) {
- this.commands = commands;
- }
-
- public void setFailOnBadExitStatus(Boolean failOnBadExitStatus) {
- this.failOnBadExitStatus = failOnBadExitStatus;
- }
-
- public void setSystemCall(SystemCall systemCall) {
- this.systemCall = systemCall;
- }
-
- public void setSystemCalls(List<SystemCall> systemCalls) {
- this.systemCalls = systemCalls;
- }
-
- public void setScript(Resource script) {
- this.script = script;
- }
-
- public void setxForwarding(Boolean xForwarding) {
- this.xForwarding = xForwarding;
- }
-
- public void setAgentForwarding(Boolean agentForwarding) {
- this.agentForwarding = agentForwarding;
- }
-
- public void setEnv(Map<String, String> env) {
- this.env = env;
- }
-
- public void setForceShell(Boolean forceShell) {
- this.forceShell = forceShell;
- }
-
- public List<String> getCommands() {
- return commands;
- }
-
- public void setStdOutLines(List<String> stdOutLines) {
- this.stdOutLines = stdOutLines;
- }
-
- public void setLogEvenIfStdOutLines(Boolean logEvenIfStdOutLines) {
- this.logEvenIfStdOutLines = logEvenIfStdOutLines;
- }
-
- public void setQuiet(Boolean quiet) {
- this.quiet = quiet;
- }
-
- public void setStdIn(Resource stdIn) {
- this.stdIn = stdIn;
- }
-
- public void setStdOut(Resource stdOut) {
- this.stdOut = stdOut;
- }
-
- public void setExecutionResources(ExecutionResources executionResources) {
- this.executionResources = executionResources;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.Session;
-
-public class ScpFrom extends AbstractJschTask {
- private final static Log log = LogFactory.getLog(ScpFrom.class);
-
- private Resource localResource;
- private String remotePath;
- private Boolean mkdir = false;
-
- public void run(Session session) {
- if (localResource != null) {
- File lFile;
- try {
- lFile = localResource.getFile();
- } catch (IOException e) {
- throw new SlcException("Cannot interpret resource "
- + localResource + " as file.", e);
- }
- downloadFile(session, lFile, remotePath);
- }
- }
-
- protected void downloadFile(Session session, File localFile,
- String remoteFile) {
- OutputStream out = null;
- OutputStream channelOut;
- InputStream channelIn;
- try {
- // exec 'scp -f rfile' remotely
- String command = "scp -f " + remoteFile;
- Channel channel = session.openChannel("exec");
- ((ChannelExec) channel).setCommand(command);
-
- // get I/O streams for remote scp
- channelOut = channel.getOutputStream();
- channelIn = channel.getInputStream();
-
- channel.connect();
-
- byte[] buf = new byte[1024];
-
- // send '\0'
- buf[0] = 0;
- channelOut.write(buf, 0, 1);
- channelOut.flush();
-
- while (true) {
- int c = checkAck(channelIn);
- if (c != 'C') {
- break;
- }
-
- // read '0644 '
- channelIn.read(buf, 0, 5);
-
- long filesize = 0L;
- while (true) {
- if (channelIn.read(buf, 0, 1) < 0) {
- // error
- break;
- }
- if (buf[0] == ' ')
- break;
- filesize = filesize * 10L + (long) (buf[0] - '0');
- }
-
- String remoteFileName = null;
- for (int i = 0;; i++) {
- channelIn.read(buf, i, 1);
- if (buf[i] == (byte) 0x0a) {
- remoteFileName = new String(buf, 0, i);
- break;
- }
- }
-
- // System.out.println("filesize="+filesize+", file="+file);
-
- // send '\0'
- buf[0] = 0;
- channelOut.write(buf, 0, 1);
- channelOut.flush();
-
- // Create a s adirectory if it doesn't exists
- if (!localFile.exists() && mkdir)
- localFile.mkdirs();
-
- // read a content of lfile
- String localPath = localFile.isDirectory() ? localFile
- .getPath()
- + File.separator + remoteFileName : localFile.getPath();
-
- out = new FileOutputStream(localPath);
- int foo;
- while (true) {
- if (buf.length < filesize)
- foo = buf.length;
- else
- foo = (int) filesize;
- foo = channelIn.read(buf, 0, foo);
- if (foo < 0) {
- // error
- break;
- }
- out.write(buf, 0, foo);
- filesize -= foo;
- if (filesize == 0L)
- break;
- }
-
- checkAck(channelIn);
-
- // send '\0'
- buf[0] = 0;
- channelOut.write(buf, 0, 1);
- channelOut.flush();
-
- if (log.isDebugEnabled())
- log.debug("Finished downloading " + remoteFile + " on "
- + getSshTarget() + " to " + localPath);
- }
-
- channel.disconnect();
- // session.disconnect();
- } catch (Exception e) {
- throw new SlcException("Cannot download " + remoteFile + " to "
- + localFile, e);
- } finally {
- IOUtils.closeQuietly(out);
- }
- }
-
- public void setLocalResource(Resource localFile) {
- this.localResource = localFile;
- }
-
- public void setRemotePath(String remoteFile) {
- this.remotePath = remoteFile;
- }
-
- public void setMkdir(Boolean mkdir) {
- this.mkdir = mkdir;
- }
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.ByteArrayResource;
-import org.springframework.core.io.Resource;
-import org.springframework.util.AntPathMatcher;
-import org.springframework.util.PathMatcher;
-import org.springframework.util.StringUtils;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.Session;
-
-public class ScpTo extends AbstractJschTask {
- private final static Log log = LogFactory.getLog(ScpTo.class);
-
- private Resource localResource;
- private String remotePath;
-
- private String dir;
- private String remoteDir;
- private List<String> includes = new ArrayList<String>();
-
- private List<String> excludes = new ArrayList<String>();
-
- private PathMatcher pathMatcher;
-
- public void run(Session session) {
- if (StringUtils.hasText(dir)) {
- if (!StringUtils.hasText(remoteDir))
- throw new SlcException("Remote dir has to be specified.");
-
- String dirOs = dir.replace('/', File.separatorChar);
- if (dirOs.charAt(dir.length() - 1) != File.separatorChar) {
- dirOs = dirOs + File.separator;
- }
-
- if (pathMatcher == null)
- pathMatcher = new AntPathMatcher();
-
- log.info("Start multiple scp based on " + dirOs);
- scanDir(session, dirOs, "", includes, excludes);
- }
-
- if (localResource != null) {
- uploadResource(session, localResource);
- }
- }
-
- protected void scanDir(Session session, String dir, String currentRelPath,
- List<String> includes, List<String> excludes) {
- File[] files = new File(dir).listFiles();
- for (File file : files) {
- if (!file.isDirectory()) {
- String relPath = currentRelPath.concat(file.getName());
- if (match(relPath, includes, excludes, false)) {
- uploadFile(session, file, remoteDir + '/' + relPath);
- }
- } else {
- String relPath = currentRelPath.concat(file.getName()).concat(
- "/");
- if (match(relPath, includes, excludes, true)) {
- String nextDir = dir.concat(file.getName()).concat(
- File.separator);
- scanDir(session, nextDir, relPath, includes, excludes);
- }
- }
- }
- }
-
- protected Boolean match(String path, List<String> includes,
- List<String> excludes, boolean matchStart) {
- for (String patternIn : includes) {
- boolean matchIn = matchStart ? pathMatcher.matchStart(patternIn,
- path) : pathMatcher.match(patternIn, path);
- if (matchIn) {
- // Could be included, check excludes
- boolean excluded = false;
- ex: for (String patternEx : excludes) {
- boolean matchEx = matchStart ? pathMatcher.matchStart(
- patternEx, path) : pathMatcher.match(patternEx,
- path);
-
- if (matchEx) {
- excluded = true;
- break ex;
- }
- }
- if (!excluded)
- return true;
- }
- }
- return false;
- }
-
- protected void uploadFile(Session session, File file, String remoteFile) {
- try {
- upload(session, new FileInputStream(file), file.length(), file
- .getPath(), file.toString(), remoteFile);
- } catch (FileNotFoundException e) {
- throw new SlcException("Cannot upload " + file, e);
- }
- }
-
- protected void uploadResource(Session session, Resource resource) {
- String targetPath = remotePath != null ? remotePath : remoteDir + '/'
- + resource.getFilename();
- try {
- File lFile = resource.getFile();
- uploadFile(session, lFile, targetPath);
- } catch (IOException e) {
- // no underlying file found
- // load the resource in memory before transferring it
- InputStream in = null;
- try {
- byte[] arr;
- String path;
- if (resource instanceof ByteArrayResource) {
- arr = ((ByteArrayResource) resource).getByteArray();
- path = "bytearray";
- } else {
- in = resource.getInputStream();
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- IOUtils.copy(in, out);
- arr = out.toByteArray();
- path = resource.getURL().getPath();
- if (path.startsWith("/"))
- path = path.substring(1);
- }
- ByteArrayInputStream content = new ByteArrayInputStream(arr);
- upload(session, content, arr.length, path, resource.toString(),
- targetPath);
- arr = null;
- } catch (IOException e1) {
- throw new SlcException("Can not interpret resource "
- + localResource, e1);
- } finally {
- IOUtils.closeQuietly(in);
- // no need to close byte arrays streams
- }
- }
- }
-
- protected void upload(Session session, InputStream in, long size,
- String path, String sourceDesc, String remoteFile) {
- OutputStream channelOut;
- InputStream channelIn;
- try {
-
- // exec 'scp -t rfile' remotely
- String command = "scp -p -t " + remoteFile;
- Channel channel = session.openChannel("exec");
- ((ChannelExec) channel).setCommand(command);
-
- // get I/O streams for remote scp
- channelOut = channel.getOutputStream();
- channelIn = channel.getInputStream();
-
- channel.connect();
- checkAck(channelIn);
-
- // send "C0644 filesize filename", where filename should not include
- // '/'
- long filesize = size;
- command = "C0644 " + filesize + " ";
- int index = path.lastIndexOf('/');
- if (index > 0) {
- command += path.substring(index + 1);
- } else {
- command += path;
- }
- command += "\n";
-
- channelOut.write(command.getBytes());
- channelOut.flush();
- checkAck(channelIn);
-
- if (log.isTraceEnabled())
- log.debug("Start copy of " + sourceDesc + " to " + remoteFile
- + " on " + getSshTarget() + "...");
-
- final long oneMB = 1024l;// in KB
- final long tenMB = 10 * oneMB;// in KB
-
- // send a content of lfile
- byte[] buf = new byte[1024];
- long cycleCount = 0;
- long nbrOfBytes = 0;
- while (true) {
- int len = in.read(buf, 0, buf.length);
- if (len <= 0)
- break;
- channelOut.write(buf, 0, len); // out.flush();
- nbrOfBytes = nbrOfBytes + len;
- if (((cycleCount % oneMB) == 0) && cycleCount != 0)// each 1 MB
- System.out.print('#');
- if (((cycleCount % (tenMB)) == 0) && cycleCount != 0)// each 10
- // MB
- System.out.print(" - " + cycleCount / tenMB + "0 MB\n");
- cycleCount++;
- }
- // send '\0'
- buf[0] = 0;
- channelOut.write(buf, 0, 1);
- channelOut.flush();
- checkAck(channelIn);
-
- if (log.isDebugEnabled())
- log.debug("Transferred to " + remoteFile + " ("
- + sizeDesc(nbrOfBytes) + ") on " + getSshTarget()
- + " from " + sourceDesc);
-
- IOUtils.closeQuietly(channelOut);
-
- channel.disconnect();
- } catch (Exception e) {
- throw new SlcException("Cannot copy " + path + " to " + remoteFile,
- e);
- } finally {
- IOUtils.closeQuietly(in);
- }
- }
-
- protected String sizeDesc(Long nbrOfBytes) {
- if (nbrOfBytes < 1024)
- return nbrOfBytes + " B";
- else if (nbrOfBytes < 1024 * 1024)
- return (nbrOfBytes / 1024) + " KB";
- else
- return nbrOfBytes / (1024 * 1024) + " MB";
- }
-
- public void setLocalResource(Resource localFile) {
- this.localResource = localFile;
- }
-
- public void setRemotePath(String remoteFile) {
- this.remotePath = remoteFile;
- }
-
- public void setDir(String dir) {
- this.dir = dir;
- }
-
- public void setRemoteDir(String remoteDir) {
- this.remoteDir = remoteDir;
- }
-
- public void setIncludes(List<String> includes) {
- this.includes = includes;
- }
-
- public void setExcludes(List<String> excludes) {
- this.excludes = excludes;
- }
-
- public void setPathMatcher(PathMatcher pathMatcher) {
- this.pathMatcher = pathMatcher;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.util.Arrays;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-
-import com.jcraft.jsch.UserInfo;
-
-/** Basic implementation of user info. */
-public class SimpleUserInfo implements UserInfo {
- private Boolean permissive = true;
- private Boolean verbose = false;
-
- private final static Log log = LogFactory.getLog(SimpleUserInfo.class);
-
- protected String password;
- protected char[] passwordSafe;
- protected String passphrase;
- protected char[] passphraseSafe;
-
- public void reset() {
- if (passwordSafe != null)
- Arrays.fill(passwordSafe, (char) 0);
- passwordSafe = null;
- if (passphraseSafe != null)
- Arrays.fill(passphraseSafe, (char) 0);
- passphraseSafe = null;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public void setPassphrase(String passphrase) {
- this.passphrase = passphrase;
- }
-
- public String getPassphrase() {
- if (passphraseSafe != null)
- return new String(passphraseSafe);
- return passphrase;
- }
-
- public String getPassword() {
- if (passwordSafe != null)
- return new String(passwordSafe);
- return password;
- }
-
- public boolean promptPassphrase(String message) {
- if (permissive)
- return true;
- else {
- log.info(message);
- passwordSafe = readPassword(System.in);
- return passwordSafe != null;
- }
- }
-
- public boolean promptPassword(String message) {
- if (permissive)
- return true;
- else {
- log.info(message);
- passwordSafe = readPassword(System.in);
- return passwordSafe != null;
- }
- }
-
- public boolean promptYesNo(String message) {
- String msg = message + " (y/n): ";
- if (permissive) {
- if (verbose)
- log.info(msg + "y");
- return true;
- } else {
- log.info(msg);
- char c;
- try {
- c = (char) System.in.read();
- } catch (IOException e) {
- throw new SlcException("Cannot read stdin", e);
- }
- if (c == 'y')
- return true;
- else
- return false;
- }
- }
-
- public void showMessage(String message) {
- log.info(message);
- }
-
- public void setPermissive(Boolean permissive) {
- this.permissive = permissive;
- }
-
- public void setVerbose(Boolean verbose) {
- this.verbose = verbose;
- }
-
- protected char[] readPassword(InputStream in) {
-
- try {
- char[] lineBuffer;
- char[] buf;
- // int i;
-
- buf = lineBuffer = new char[128];
-
- int room = buf.length;
- int offset = 0;
- int c;
-
- loop: while (true) {
- switch (c = in.read()) {
- case -1:
- case '\n':
- break loop;
-
- case '\r':
- int c2 = in.read();
- if ((c2 != '\n') && (c2 != -1)) {
- if (!(in instanceof PushbackInputStream)) {
- in = new PushbackInputStream(in);
- }
- ((PushbackInputStream) in).unread(c2);
- } else
- break loop;
-
- default:
- if (--room < 0) {
- buf = new char[offset + 128];
- room = buf.length - offset - 1;
- System.arraycopy(lineBuffer, 0, buf, 0, offset);
- Arrays.fill(lineBuffer, ' ');
- lineBuffer = buf;
- }
- buf[offset++] = (char) c;
- break;
- }
- }
-
- if (offset == 0) {
- return null;
- }
-
- char[] ret = new char[offset];
- System.arraycopy(buf, 0, ret, 0, offset);
- Arrays.fill(buf, ' ');
-
- return ret;
- } catch (IOException e) {
- throw new SlcException("Cannot read password.", e);
- }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.deploy.DigestCheck;
-import org.argeo.slc.core.deploy.ResourceSet;
-import org.springframework.core.io.Resource;
-
-import com.jcraft.jsch.Session;
-
-public class SshFilesDeployment extends AbstractJschTask implements Runnable {
- private final static Log log = LogFactory.getLog(SshFilesDeployment.class);
- private String targetBase = "";
- private ResourceSet resourceSet;
- /**
- * Activate with algorithm as per
- * http://java.sun.com/j2se/1.5.0/docs/guide/security/CryptoSpec.html#AppA
- */
- private String checksum = "MD5";
- private int remoteChecksumsPerCall = 20;
-
- public SshFilesDeployment() {
- }
-
- public SshFilesDeployment(SshTarget sshTarget, ResourceSet resourceSet) {
- setSshTarget(sshTarget);
- this.resourceSet = resourceSet;
- }
-
- @Override
- void run(Session session) {
- JschMultiTasks multiTasks = new JschMultiTasks();
-
- Map<String, Resource> resources = resourceSet.listResources();
-
- // Analyze set
- List<String> subDirs = new ArrayList<String>();
- Map<String, String> targetPaths = new HashMap<String, String>();
- for (String relPath : resources.keySet()) {
- String parentDir;
- int lastIndexSubDir = relPath.lastIndexOf('/');
- if (lastIndexSubDir > 0)
- parentDir = targetBase + '/'
- + relPath.substring(0, lastIndexSubDir);
- else
- parentDir = targetBase;
-
- boolean skipDir = false;
- registerDirs: for (String registeredDir : new ArrayList<String>(
- subDirs)) {
- if (parentDir.equals(registeredDir)) {
- if (log.isTraceEnabled())
- log.trace("Already registered, skip " + parentDir);
- skipDir = true;
- break registerDirs;
- }
-
- if (parentDir.startsWith(registeredDir))
- if (subDirs.contains(registeredDir)) {
- subDirs.remove(registeredDir);
- if (log.isTraceEnabled())
- log.trace("Remove parent " + registeredDir + " of "
- + parentDir);
- continue registerDirs;
- }
-
- if (registeredDir.startsWith(parentDir)) {
- skipDir = true;
- if (log.isTraceEnabled())
- log.trace("Skip " + parentDir
- + " because child already registered.");
- break registerDirs;
- }
- }
-
- if (!subDirs.contains(parentDir) && !skipDir) {
- subDirs.add(parentDir);
- }
-
- targetPaths.put(relPath, targetBase + "/" + relPath);
- }
-
- // checksum
- List<String> targetPathsEqualsToLocal = new ArrayList<String>();
- if (checksum != null) {
- Map<String, String> remoteChecksums = new HashMap<String, String>();
- List<String> csLines = new ArrayList<String>();
- String csExecutable;
- if ("MD5".equals(checksum))
- csExecutable = "/usr/bin/md5sum";
- else if ("SHA".equals(checksum))
- csExecutable = "/usr/bin/sha1sum";
- else if ("SHA-256".equals(checksum))
- csExecutable = "/usr/bin/sha256sum";
- else if ("SHA-512".equals(checksum))
- csExecutable = "/usr/bin/sha512sum";
- else
- throw new SlcException(
- "Don't know how to remotely execute checksum "
- + checksum);
-
- StringBuffer csCmd = new StringBuffer(csExecutable);
- int numberOfPaths = targetPaths.size();
- int count = 0;
- for (String targetPath : targetPaths.values()) {
- csCmd.append(" ").append(targetPath);
- count++;
-
- if ((count % remoteChecksumsPerCall == 0)
- || count == numberOfPaths) {
- RemoteExec remoteCs = new RemoteExec();
- remoteCs.setSshTarget(getSshTarget());
- remoteCs.setCommand(csCmd.toString());
- remoteCs.setStdOutLines(csLines);
- remoteCs.setFailOnBadExitStatus(false);
- remoteCs.run(session);
- csCmd = new StringBuffer(csExecutable);
- }
-
- }
-
- remoteChecksums: for (String csLine : csLines) {
- StringTokenizer st = new StringTokenizer(csLine, ": ");
- String cs = st.nextToken();
- if (cs.equals(csExecutable)) {
- // remote does not exist
- continue remoteChecksums;
- } else {
- String targetPath = st.nextToken();
- if (log.isTraceEnabled())
- log.trace("REMOTE: " + targetPath + "=" + cs);
- remoteChecksums.put(targetPath, cs);
- }
- }
-
- // Local checksums
- for (String relPath : resources.keySet()) {
- Resource resource = resources.get(relPath);
- String targetPath = targetPaths.get(relPath);
- if (remoteChecksums.containsKey(targetPath)) {
- String cs = DigestCheck.digest(checksum, resource);
- if (log.isTraceEnabled())
- log.trace("LOCAL : " + targetPath + "=" + cs);
- if (remoteChecksums.get(targetPath).equals(cs))
- targetPathsEqualsToLocal.add(targetPath);
- }
- }
- }
-
- // Prepare multitask
-
- // Create dirs
- StringBuffer mkdirCmd = new StringBuffer("mkdir -p");
- RemoteExec remoteExec = new RemoteExec();
- for (String dir : subDirs) {
- // remoteExec.getCommands().add("mkdir -p " + dir);
- mkdirCmd.append(' ');
- if (dir.indexOf(' ') >= 0)
- mkdirCmd.append('\"').append(dir).append('\"');
- else
- mkdirCmd.append(dir);
- }
- remoteExec.setCommand(mkdirCmd.toString());
- multiTasks.getTasks().add(remoteExec);
-
- // Perform copies
- int copied = 0;
- int skipped = 0;
- copy: for (String relPath : resources.keySet()) {
- String targetPath = targetPaths.get(relPath);
- if (targetPathsEqualsToLocal.contains(targetPath)) {
- if (log.isTraceEnabled())
- log.trace("Skip copy of " + relPath
- + " since it is equal to remote " + targetPath);
- skipped++;
- continue copy;
- }
- // Copy resource
- Resource resource = resources.get(relPath);
- ScpTo scpTo = new ScpTo();
- scpTo.setLocalResource(resource);
- scpTo.setRemotePath(targetPath);
- multiTasks.getTasks().add(scpTo);
- copied++;
- // TODO: set permissions
- }
-
- multiTasks.setSshTarget(getSshTarget());
- multiTasks.run(session);
-
- if (checksum != null && log.isDebugEnabled())
- log.debug("Copied " + copied + " files, skipped " + skipped
- + " with same checksum.");
- }
-
- public void setTargetBase(String targetBase) {
- this.targetBase = targetBase;
- }
-
- public void setResourceSet(ResourceSet resourceSet) {
- this.resourceSet = resourceSet;
- }
-
- public void setChecksum(String checksum) {
- this.checksum = checksum;
- }
-
- /** Number of remote checksums per remote call */
- public void setRemoteChecksumsPerCall(int remoteChecksumsPerCall) {
- this.remoteChecksumsPerCall = remoteChecksumsPerCall;
- }
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-import org.springframework.util.StringUtils;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.Session;
-
-public class SshShell extends AbstractJschTask {
- private final static Log log = LogFactory.getLog(SshShell.class);
- private Resource input;
-
- @Override
- void run(Session session) {
- try {
- final Channel channel = session.openChannel("shell");
-
- // Enable agent-forwarding.
- // ((ChannelShell)channel).setAgentForwarding(true);
-
- // channel.setInputStream(System.in);
- // channel.setInputStream(input.getInputStream());
- /*
- * // a hack for MS-DOS prompt on Windows.
- * channel.setInputStream(new FilterInputStream(System.in){ public
- * int read(byte[] b, int off, int len)throws IOException{ return
- * in.read(b, off, (len>1024?1024:len)); } });
- */
-
- // channel.setOutputStream(System.out);
-
- /*
- * // Choose the pty-type "vt102".
- * ((ChannelShell)channel).setPtyType("vt102");
- */
-
- /*
- * // Set environment variable "LANG" as "ja_JP.eucJP".
- * ((ChannelShell)channel).setEnv("LANG", "ja_JP.eucJP");
- */
-
- // Writer thread
- final BufferedWriter writer = new BufferedWriter(
- new OutputStreamWriter(channel.getOutputStream()));
-
- // channel.connect();
- channel.connect(3 * 1000);
-
- // while (!channel.isConnected())
- // try {
- // Thread.sleep(500);
- // } catch (InterruptedException e1) {
- // // silent
- // }
-
- Thread writerThread = new Thread("Shell writer " + getSshTarget()) {
-
- @Override
- public void run() {
-
- if (log.isDebugEnabled())
- log.debug("Start writing to shell");
-
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new InputStreamReader(input
- .getInputStream()));
- String line = null;
- while ((line = reader.readLine()) != null) {
- if (!StringUtils.hasText(line))
- continue;
- writer.write(line);
- writer.newLine();
- }
- writer.append("exit");
- writer.newLine();
- writer.flush();
- // channel.disconnect();
- } catch (IOException e) {
- throw new SlcException("Cannot write to shell on "
- + getSshTarget(), e);
- } finally {
- IOUtils.closeQuietly(reader);
- }
- }
- };
- writerThread.start();
-
- BufferedReader execIn = null;
- try {
- execIn = new BufferedReader(new InputStreamReader(channel
- .getInputStream()));
- String line = null;
- while ((line = execIn.readLine()) != null) {
- if (!line.trim().equals(""))
- log.info(line);
- }
- } catch (Exception e) {
- throw new SlcException("Cannot read from shell on "
- + getSshTarget(), e);
- } finally {
- IOUtils.closeQuietly(execIn);
- }
-
- } catch (Exception e) {
- throw new SlcException("Cannot use SSH shell on " + getSshTarget(),
- e);
- }
- }
-
- public void setInput(Resource input) {
- this.input = input;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.io.File;
-
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.UserInfo;
-
-public class SshTarget {
- private String host;
- private Integer port = 22;
- private String user;
- private UserInfo userInfo = new SimpleUserInfo();
-
- private Boolean usePrivateKey = true;
- private File localPrivateKey = new File(System.getProperty("user.home")
- + File.separator + ".ssh" + File.separator + "id_rsa");
-
- /** cached session */
- private transient Session session;
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public Integer getPort() {
- return port;
- }
-
- public void setPort(Integer port) {
- this.port = port;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-
- public UserInfo getUserInfo() {
- return userInfo;
- }
-
- public void setUserInfo(UserInfo userInfo) {
- this.userInfo = userInfo;
- }
-
- public void setLocalPrivateKey(File localPrivateKey) {
- this.localPrivateKey = localPrivateKey;
- }
-
- public File getLocalPrivateKey() {
- return localPrivateKey;
- }
-
- public Boolean getUsePrivateKey() {
- return usePrivateKey;
- }
-
- public void setUsePrivateKey(Boolean usePrivateKey) {
- this.usePrivateKey = usePrivateKey;
- }
-
- public String toString() {
- return getUser() + "@" + getHost() + ":" + getPort();
- }
-
- public synchronized Session getSession() {
- return session;
- }
-
- public synchronized void setSession(Session session) {
- this.session = session;
- }
-}
+++ /dev/null
-package org.argeo.slc.jsch;
-
-import java.awt.Container;
-import java.awt.GridLayout;
-import java.awt.Panel;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Arrays;
-
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JPasswordField;
-
-/** Retrieves a password or a passphrase using standard Swing */
-public class SwingUserInfo extends SimpleUserInfo {
-
- private Boolean alwaysPrompt = false;
-
- public boolean promptPassphrase(String message) {
- if (passphrase != null)
- return true;
-
- if (!alwaysPrompt && passphraseSafe != null)
- return true;
-
- PasswordDialog dialog = new PasswordDialog(message) {
- private static final long serialVersionUID = 3266299327166418364L;
-
- @Override
- protected void useCredentials(char[] password) {
- passphraseSafe = new char[password.length];
- System.arraycopy(password, 0, passphraseSafe, 0,
- password.length);
- // passphraseSafe = Arrays.copyOf(password, password.length);
- }
- };
- dialog.setVisible(true);
- return dialog.getWasProvided();
- }
-
- public boolean promptPassword(String message) {
- if (password != null)
- return true;
-
- if (!alwaysPrompt && passwordSafe != null)
- return true;
-
- PasswordDialog dialog = new PasswordDialog(message) {
- private static final long serialVersionUID = 3266299327166418364L;
-
- @Override
- protected void useCredentials(char[] password) {
- // passwordSafe = Arrays.copyOf(password, password.length);
- passwordSafe = new char[password.length];
- System.arraycopy(password, 0, passwordSafe, 0, password.length);
- }
- };
- dialog.setVisible(true);
- return dialog.getWasProvided();
- }
-
- public void setAlwaysPrompt(Boolean alwaysPrompt) {
- this.alwaysPrompt = alwaysPrompt;
- }
-
- protected static class PasswordDialog extends JDialog implements
- ActionListener {
- private static final long serialVersionUID = 3399155607980846207L;
-
- private static final String OK = "ok";
-
- private JPasswordField password = new JPasswordField("", 10);
-
- private JButton okButton;
- private JButton cancelButton;
-
- private Boolean wasProvided = false;
-
- public PasswordDialog(String title) {
- setTitle(title);
- setModal(true);
- setLocationRelativeTo(null);
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-
- JPanel p1 = new JPanel(new GridLayout(1, 2, 3, 3));
- p1.add(new JLabel("Password"));
- password.setActionCommand(OK);
- password.addActionListener(this);
- p1.add(password);
- add("Center", p1);
-
- Panel p2 = new Panel();
- okButton = addButton(p2, "OK");
- okButton.setActionCommand(OK);
- cancelButton = addButton(p2, "Cancel");
- add("South", p2);
- setSize(240, 120);
-
- pack();
- }
-
- /** To be overridden */
- protected void useCredentials(char[] password) {
- // does nothing
- }
-
- private JButton addButton(Container c, String name) {
- JButton button = new JButton(name);
- button.addActionListener(this);
- c.add(button);
- return button;
- }
-
- public final void actionPerformed(ActionEvent evt) {
- Object source = evt.getSource();
- if (source == okButton || evt.getActionCommand().equals(OK)) {
- char[] p = password.getPassword();
- useCredentials(p);
- wasProvided = true;
- Arrays.fill(p, '0');
- cleanUp();
- } else if (source == cancelButton)
- cleanUp();
- }
-
- private void cleanUp() {
- password.setText("");
- dispose();
- }
-
- public Boolean getWasProvided() {
- return wasProvided;
- }
-
- }
-
-}
+++ /dev/null
-SINGLE_USER {
- com.sun.security.auth.module.Krb5LoginModule optional
- principal="${user.name}"
- useTicketCache=true;
-};
+++ /dev/null
-package org.argeo.slc.lib.jcr;
-
-import java.util.UUID;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryFactory;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.vfs2.FileObject;
-import org.apache.commons.vfs2.FileSelectInfo;
-import org.apache.commons.vfs2.FileSelector;
-import org.apache.commons.vfs2.FileSystemException;
-import org.apache.commons.vfs2.FileSystemManager;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.api.NodeUtils;
-import org.argeo.slc.SlcException;
-
-/** Backups a JCR repository */
-public class JcrRepositoryBackup implements Runnable {
- private final static Log log = LogFactory.getLog(JcrRepositoryBackup.class);
-
- private String sourceRepo;
- private String sourceDatastore;
- private String targetFile;
-
- private String sourceWksp;
-
- private String sourceUsername;
- private char[] sourcePassword;
-
- private RepositoryFactory repositoryFactory;
- private FileSystemManager fileSystemManager;
-
- public void run() {
- Session sourceDefaultSession = null;
- try {
- long begin = System.currentTimeMillis();
-
- FileObject archiveRoot = fileSystemManager.resolveFile(targetFile);
- archiveRoot.createFolder();
-
- String datastoreFolderName = "datastore";
- if (hasDatastore())
- backupDataStore(archiveRoot.resolveFile(datastoreFolderName));
-
- Repository sourceRepository = NodeUtils.getRepositoryByUri(
- repositoryFactory, sourceRepo);
- Credentials sourceCredentials = null;
- if (sourceUsername != null)
- sourceCredentials = new SimpleCredentials(sourceUsername,
- sourcePassword);
-
- sourceDefaultSession = sourceRepository.login(sourceCredentials);
- for (String sourceWorkspaceName : sourceDefaultSession
- .getWorkspace().getAccessibleWorkspaceNames()) {
- if (Thread.interrupted()) {
- log.error("Workspace backup interrupted");
- Thread.currentThread().interrupt();
- return;
- }
-
- if (sourceWksp != null && !sourceWksp.trim().equals("")
- && !sourceWorkspaceName.equals(sourceWksp))
- continue;
- Session sourceSession = null;
- JarOutputStream out = null;
- FileObject workspaceBackup = null;
- try {
- Manifest manifest = new Manifest();
- manifest.getMainAttributes().put(
- Attributes.Name.MANIFEST_VERSION, "1.0");
- manifest.getMainAttributes().putValue("Backup-UUID",
- UUID.randomUUID().toString());
- manifest.getMainAttributes().putValue("Backup-Timestamp",
- Long.toString(System.currentTimeMillis()));
- manifest.getMainAttributes().putValue(
- "Backup-JCR-Workspace", sourceWorkspaceName);
- workspaceBackup = fileSystemManager.resolveFile(targetFile
- + "/" + sourceWorkspaceName + ".jar");
-
- out = new JarOutputStream(workspaceBackup.getContent()
- .getOutputStream(), manifest);
- sourceSession = sourceRepository.login(sourceCredentials,
- sourceWorkspaceName);
- backupWorkspace(sourceSession, out);
- } finally {
- JcrUtils.logoutQuietly(sourceSession);
- IOUtils.closeQuietly(out);
- if (workspaceBackup != null)
- workspaceBackup.close();
- }
- }
-
- // in case some binaries have been added during the backup
- if (hasDatastore())
- backupDataStore(archiveRoot.resolveFile(datastoreFolderName));
-
- long duration = (System.currentTimeMillis() - begin) / 1000;// s
- log.info("Backed-up " + sourceRepo + " in " + (duration / 60)
- + "min " + (duration % 60) + "s");
- } catch (Exception e) {
- throw new SlcException("Cannot backup " + sourceRepo, e);
- } finally {
- JcrUtils.logoutQuietly(sourceDefaultSession);
- }
- }
-
- protected Boolean hasDatastore() {
- return sourceDatastore != null && !sourceDatastore.trim().equals("");
- }
-
- protected void backupWorkspace(Session sourceSession, JarOutputStream out) {
- try {
- if (log.isTraceEnabled())
- log.trace("Backup " + sourceSession.getWorkspace().getName()
- + "...");
- Boolean skipBinaries = hasDatastore();
- for (NodeIterator it = sourceSession.getRootNode().getNodes(); it
- .hasNext();) {
- if (Thread.interrupted()) {
- log.error("Node backup interrupted");
- Thread.currentThread().interrupt();
- return;
- }
- Node node = it.nextNode();
- JarEntry entry = new JarEntry(node.getPath());
- out.putNextEntry(entry);
- sourceSession.exportSystemView(node.getPath(), out,
- skipBinaries, false);
- out.flush();
- out.closeEntry();
- }
- if (log.isDebugEnabled())
- log.debug("Backed up " + sourceSession.getWorkspace().getName());
- } catch (Exception e) {
- throw new SlcException("Cannot backup "
- + sourceSession.getWorkspace().getName(), e);
- }
- }
-
- protected void backupDataStore(final FileObject targetDatastore) {
- try {
- targetDatastore.createFolder();
- final FileObject sourceDataStore = fileSystemManager
- .resolveFile(sourceDatastore);
- if (log.isDebugEnabled())
- log.debug("Backup " + sourceDatastore);
- targetDatastore.copyFrom(sourceDataStore, new FileSelector() {
- public boolean traverseDescendents(FileSelectInfo fileInfo)
- throws Exception {
- return true;
- }
-
- public boolean includeFile(FileSelectInfo fileInfo)
- throws Exception {
- String relativeName = fileInfo
- .getFile()
- .getName()
- .getPath()
- .substring(
- sourceDataStore.getName().getPath()
- .length());
- FileObject target = targetDatastore
- .resolveFile(relativeName);
- if (target.exists()) {
- return false;
- } else {
- return true;
- }
- }
- });
- if (log.isDebugEnabled())
- log.debug("Backed-up " + sourceDatastore);
- } catch (FileSystemException e) {
- throw new SlcException("Cannot backup datastore", e);
- }
- }
-
- public void setSourceRepo(String sourceRepo) {
- this.sourceRepo = sourceRepo;
- }
-
- public void setSourceWksp(String sourceWksp) {
- this.sourceWksp = sourceWksp;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setSourceUsername(String sourceUsername) {
- this.sourceUsername = sourceUsername;
- }
-
- public void setSourcePassword(char[] sourcePassword) {
- this.sourcePassword = sourcePassword;
- }
-
- public void setFileSystemManager(FileSystemManager fileSystemManager) {
- this.fileSystemManager = fileSystemManager;
- }
-
- public void setTargetFile(String targetFile) {
- this.targetFile = targetFile;
- }
-
- public void setSourceDatastore(String sourceDatastore) {
- this.sourceDatastore = sourceDatastore;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux;
-
-import org.argeo.slc.core.deploy.MultiResourceSet;
-import org.argeo.slc.core.deploy.ResourceSet;
-
-public class DefaultRedhatDeploymentData implements RedhatDeploymentData {
- private ResourceSet configurationFiles;
- private String runlevelsScript;
- private String permissionsScript;
-
- private RedhatDeploymentData parent;
-
- public ResourceSet getConfigurationFiles() {
- if (parent != null && parent.getConfigurationFiles() != null) {
- MultiResourceSet mrs = new MultiResourceSet();
- mrs.getResourceSets().add(parent.getConfigurationFiles());
- mrs.getResourceSets().add(configurationFiles);
- return mrs;
- } else {
- return configurationFiles;
- }
- }
-
- public String getRunlevelsScript() {
- if (parent != null && parent.getRunlevelsScript() != null)
- return parent.getRunlevelsScript() + "\n" + runlevelsScript;
- else
- return runlevelsScript;
- }
-
- public String getPermissionsScript() {
- if (parent != null && parent.getPermissionsScript() != null)
- return parent.getPermissionsScript() + "\n" + permissionsScript;
- else
- return permissionsScript;
- }
-
- public void setRunlevelsScript(String runlevelsScript) {
- this.runlevelsScript = runlevelsScript;
- }
-
- public void setConfigurationFiles(ResourceSet configurationFiles) {
- this.configurationFiles = configurationFiles;
- }
-
- public void setPermissionsScript(String permissionsScript) {
- this.permissionsScript = permissionsScript;
- }
-
- public void setParent(RedhatDeploymentData parentDeploymentData) {
- this.parent = parentDeploymentData;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux;
-
-import java.util.List;
-
-public class DefaultRpmDistribution implements RpmDistribution {
- private List<String> additionalPackages;
-
- public String getDistributionId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public List<String> getAdditionalPackages() {
- return additionalPackages;
- }
-
- public void setAdditionalPackages(List<String> additionalPackages) {
- this.additionalPackages = additionalPackages;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux;
-
-import java.io.File;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-
-/** Deploy and initialize an LXC container. */
-public class DeployLxcContainer implements Runnable {
-
- private String chroot;
-
- private Resource hostScript = new ClassPathResource(
- "/org/argeo/slc/lib/linux/lxc-init-host.sh", getClass()
- .getClassLoader());
- private Resource guestScript = new ClassPathResource(
- "/org/argeo/slc/lib/linux/lxc-init-guest.sh", getClass()
- .getClassLoader());;
-
- // private CallbackHandler callbackHandler;
-
- private Integer ram = 1024;
- private Integer vcpu = 2;
-
- @Override
- public void run() {
- if (chroot == null || chroot.trim().equals(""))
- throw new SlcException("A chroot directory must be defined");
-
- File chrootDir = new File(chroot);
- chrootDir.mkdirs();
-
- ScriptCall hostCall = new ScriptCall(hostScript);
- hostCall.setLogCommand(true);
- hostCall.arg(chroot);
- // hostCall.getEnvironmentVariables().put("CHROOT", chroot);
- // hostCall.setSudo("");
- // hostCall.setCallbackHandler(callbackHandler);
- hostCall.run();
-
- ScriptCall guestCall = new ScriptCall(guestScript);
- guestCall.setLogCommand(true);
- // guestCall.setSudo("");
- // guestCall.setCallbackHandler(callbackHandler);
- guestCall.setChroot(chroot);
- guestCall.run();
-
- SystemCall virtInstall = new SystemCall(
- "virt-install --connect lxc:/// --name " + chrootDir.getName()
- + " --ram " + ram + " --vcpu " + vcpu
- + " --filesystem " + chrootDir.getAbsolutePath()
- + ",/ --noautoconsole");
- virtInstall.setLogCommand(true);
- // virtInstall.setSudo("");
- virtInstall.run();
- }
-
- public void setChroot(String chroot) {
- this.chroot = chroot;
- }
-
- public void setHostScript(Resource hostScript) {
- this.hostScript = hostScript;
- }
-
- public void setGuestScript(Resource guestScript) {
- this.guestScript = guestScript;
- }
-
- // public void setCallbackHandler(CallbackHandler callbackHandler) {
- // this.callbackHandler = callbackHandler;
- // }
-
- public void setRam(Integer ram) {
- this.ram = ram;
- }
-
- public void setVcpu(Integer vcpu) {
- this.vcpu = vcpu;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux;
-
-import org.argeo.slc.core.deploy.ResourceSet;
-import org.argeo.slc.deploy.DeploymentData;
-
-public interface RedhatDeploymentData extends DeploymentData {
- public ResourceSet getConfigurationFiles();
-
- public String getRunlevelsScript();
-
- public String getPermissionsScript();
-}
+++ /dev/null
-package org.argeo.slc.lib.linux;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.deploy.LocalFilesDeployment;
-import org.argeo.slc.core.deploy.ResourceSet;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.argeo.slc.jsch.RemoteExec;
-import org.argeo.slc.jsch.SshFilesDeployment;
-import org.argeo.slc.jsch.SshTarget;
-
-public class RedhatHostManager {
-
- private SimpleLinuxHost host;
-
- // SSH
- private Boolean useSsh = true;
- private SshTarget sshTarget = null;
-
- public void installPackages() {
- StringBuffer cmd = new StringBuffer("yum --nogpgcheck -y install");
- for (String pkg : ((RpmDistribution) host.getDistribution())
- .getAdditionalPackages()) {
- cmd.append(' ').append(pkg);
- }
- executeCommand(cmd.toString());
-
- RedhatDeploymentData rdd = (RedhatDeploymentData) host
- .getDeploymentData();
- executeCommand(rdd.getRunlevelsScript());
- }
-
- public void deployConfig() {
- RedhatDeploymentData rdd = (RedhatDeploymentData) host
- .getDeploymentData();
- deploy(rdd.getConfigurationFiles());
- executeCommand(rdd.getPermissionsScript());
- }
-
- // GENERIC?
- protected void deploy(ResourceSet resourceSet) {
- if (useSsh)
- new SshFilesDeployment(getSshTarget(), resourceSet).run();
- else
- new LocalFilesDeployment(resourceSet).run();
-
- }
-
- protected void executeCommand(String command) {
- if (command == null)
- return;
-
- if (useSsh) {
- RemoteExec rExec = new RemoteExec(getSshTarget(), command);
- rExec.setFailOnBadExitStatus(false);
- rExec.run();
- } else
- new SystemCall(command).run();
- }
-
- protected SshTarget getSshTarget() {
- if (sshTarget == null)
- throw new SlcException("No SSH target defined");
- return sshTarget;
- }
-
- public void setHost(SimpleLinuxHost host) {
- this.host = host;
- }
-
- public void setUseSsh(Boolean useSsh) {
- this.useSsh = useSsh;
- }
-
- public void setSshTarget(SshTarget sshTarget) {
- this.sshTarget = sshTarget;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux;
-
-import java.util.List;
-
-import org.argeo.slc.build.Distribution;
-
-public interface RpmDistribution extends Distribution {
- public List<String> getAdditionalPackages();
-
- public void setAdditionalPackages(List<String> additionalPackages);
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-/** Call to the interpreter of a script language. */
-public class ScriptCall extends SystemCall implements InitializingBean {
- private Resource script;
- private List<Object> scriptArgs = new ArrayList<Object>();
-
- private Boolean localScriptCopy = false;
-
- /** For use in Spring. */
- public ScriptCall() {
- super();
- }
-
- /** For use in code ({@link #init()} is called). */
- public ScriptCall(Resource script) {
- this.script = script;
- init();
- }
-
- public void init() {
- initInterpreter();
- for (Object obj : scriptArgs) {
- arg(obj.toString());
- }
- }
-
- public void afterPropertiesSet() throws Exception {
- init();
- }
-
- protected void initInterpreter() {
- String ext = FilenameUtils.getExtension(script.getFilename());
-
- if (localScriptCopy) {
- File scriptFile = copyScript();
- if ("sh".equals(ext))
- arg("/bin/sh").arg(scriptFile.getAbsolutePath());
- else if ("pl".equals(ext))
- arg("/usr/bin/perl").arg(scriptFile.getAbsolutePath());
- else if ("py".equals(ext))
- arg("/usr/bin/python").arg(scriptFile.getAbsolutePath());
- else
- throw new SlcException(
- "Cannot initialize script intepreter for " + script);
- } else {
- setStdInFile(script);
- if ("sh".equals(ext))
- arg("/bin/sh").arg("-s");
- else if ("pl".equals(ext))
- arg("/usr/bin/perl").arg("/dev/stdin");
- else if ("py".equals(ext))
- arg("/usr/bin/python").arg("-");
- else
- throw new SlcException(
- "Cannot initialize script intepreter for " + script);
- }
- }
-
- private File copyScript() {
- InputStream in = null;
- OutputStream out = null;
- try {
- File scriptFile = File.createTempFile("script", ".sh");
- scriptFile.deleteOnExit();
- in = script.getInputStream();
- out = new FileOutputStream(scriptFile);
- IOUtils.copy(in, out);
- return scriptFile;
- } catch (Exception e) {
- throw new SlcException("Cannot copy " + script, e);
- } finally {
- IOUtils.closeQuietly(in);
- IOUtils.closeQuietly(out);
- }
- }
-
- public void setScript(Resource script) {
- this.script = script;
- }
-
- public void setScriptArgs(List<Object> scriptArgs) {
- this.scriptArgs = scriptArgs;
- }
-
- public void setLocalScriptCopy(Boolean localScriptCopy) {
- this.localScriptCopy = localScriptCopy;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux;
-
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class SimpleLinuxHost implements DeployedSystem {
- private DeploymentData deploymentData;
- private Distribution distribution;
- private TargetData targetData;
-
- public String getDeployedSystemId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public DeploymentData getDeploymentData() {
- return deploymentData;
- }
-
- public void setDeploymentData(DeploymentData deploymentData) {
- this.deploymentData = deploymentData;
- }
-
- public Distribution getDistribution() {
- return distribution;
- }
-
- public void setDistribution(Distribution distribution) {
- this.distribution = distribution;
- }
-
- public TargetData getTargetData() {
- return targetData;
- }
-
- public void setTargetData(TargetData targetData) {
- this.targetData = targetData;
- }
-
-}
+++ /dev/null
-echo demo | passwd root --stdin
-
-#Fix root login on console
-echo "pts/0" >>/etc/securetty
-sed -i s/"session required pam_selinux.so close"/"#session required pam_selinux.so close"/g /etc/pam.d/login
-sed -i s/"session required pam_selinux.so open"/"#session required pam_selinux.so open"/g /etc/pam.d/login
-sed -i s/"session required pam_loginuid.so"/"#session required pam_loginuid.so"/g /etc/pam.d/login
-
-#Configuring basic networking
-cat > /etc/sysconfig/network << EOF
-NETWORKING=yes
-HOSTNAME=demo
-EOF
-cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
-DEVICE=eth0
-BOOTPROTO=dhcp
-ONBOOT=yes
-EOF
-
-#Enabling sshd
-chkconfig sshd on
-
-# Fixing root login for sshd
-sed -i s/"session required pam_selinux.so close"/"#session required pam_selinux.so close"/g /etc/pam.d/sshd
-sed -i s/"session required pam_loginuid.so"/"#session required pam_loginuid.so"/g /etc/pam.d/sshd
-sed -i s/"session required pam_selinux.so open env_params"/"#session required pam_selinux.so open env_params"/g /etc/pam.d/sshd
-
-# Leaving the chroot'ed filesystem
-exit
\ No newline at end of file
+++ /dev/null
-#!/bin/sh
-CHROOT=$1
-echo Init LXC container $CHROOT
-
-mkdir $CHROOT/etc/yum.repos.d/ -p
-cat /etc/yum.repos.d/CentOS-Base.repo |sed s/'$releasever'/6/g > $CHROOT/etc/yum.repos.d/CentOS-Base.repo
-yum groupinstall core --installroot=$CHROOT --nogpgcheck -y
-yum install plymouth libselinux-python --installroot=$CHROOT --nogpgcheck -y
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
-\r
- Copyright (C) 2007-2012 Argeo GmbH\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
--->\r
-<!-- Copyright (C) 2007-2012 Mathieu Baudier Licensed under the Apache License, \r
- Version 2.0 (the "License"); you may not use this file except in compliance \r
- with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 \r
- Unless required by applicable law or agreed to in writing, software distributed \r
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES \r
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for \r
- the specific language governing permissions and limitations under the License. -->\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"\r
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:flow="http://www.argeo.org/schema/slc-flow"\r
- xsi:schemaLocation="\r
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd\r
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
- http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-1.2.xsd">\r
-\r
- <bean id="hostManager" class="org.argeo.slc.lib.linux.RedhatHostManager">\r
- <property name="sshTarget" ref="sshTarget" />\r
- <property name="host" ref="host" />\r
- </bean>\r
-\r
- <!-- Execution Flows -->\r
- <bean flow:as-flow="deployConfig" class="org.argeo.slc.core.execution.tasks.MethodCall"\r
- p:target-ref="hostManager" p:method="deployConfig" />\r
-\r
- <bean flow:as-flow="system/reboot" p:command="shutdown -r now"\r
- p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec" />\r
-\r
- <bean flow:as-flow="system/shutdown" p:command="shutdown -h now"\r
- p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec" />\r
-\r
- <bean flow:as-flow="system/packages/install" class="org.argeo.slc.core.execution.tasks.MethodCall"\r
- p:target-ref="hostManager" p:method="installPackages" />\r
-\r
- <bean flow:as-flow="system/packages/update" p:sshTarget-ref="sshTarget"\r
- class="org.argeo.slc.jsch.RemoteExec">\r
- <property name="systemCall">\r
- <bean class="org.argeo.slc.core.execution.tasks.SystemCall">\r
- <property name="cmd" value="yum -y update" />\r
- </bean>\r
- </property>\r
- </bean>\r
-\r
- <bean flow:as-flow="system/security/firewall" p:script="osgibundle:/scripts/firewall.sh"\r
- p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec" />\r
-\r
- <flow:flow name="system/security/authconfig">\r
- <flow:spec>\r
- <flow:primitive name="ldapserver" />\r
- <flow:primitive name="ldapbasedn" />\r
- </flow:spec>\r
- <bean p:sshTarget-ref="sshTarget" class="org.argeo.slc.jsch.RemoteExec">\r
- <flow:variable />\r
- <property name="systemCall">\r
- <bean class="org.argeo.slc.core.execution.tasks.SystemCall">\r
- <property name="command">\r
- <list>\r
- <value>authconfig</value>\r
- <value>--enableldap</value>\r
- <value>--enableldapauth</value>\r
- <value>--enablecache</value>\r
- <value>--enablemkhomedir</value>\r
- <value>--ldapserver=@{ldapserver}</value>\r
- <value>--ldapbasedn=@{ldapbasedn}</value>\r
- <value>--passalgo=sha256</value>\r
- <value>--updateall</value>\r
- </list>\r
- </property>\r
- </bean>\r
- </property>\r
- </bean>\r
- </flow:flow>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.exec.Executor;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-
-/** Rebuild an SRPM in mock. (Historical) Replaces the build-mock.sh script. */
-public class BuildInMock implements Runnable {
- private final static Log log = LogFactory.getLog(BuildInMock.class);
-
- /** Mock flavour provided by the EPEL repository */
- public final static String EPEL = "EPEL";
- /** Mock flavour provided by CentOS until v5 */
- public final static String CENTOS = "CENTOS";
-
- public final static String NOARCH = "noarch";
-
- private String mockVar = "/var/lib/mock";
-
- private String mockFlavour = EPEL;
- private String mockConfig = null;
-
- private String repository;
- private String release = null;
- private String level = null;
- private String arch = NOARCH;
-
- private String rpmPackage = null;
-
- private Boolean mkdirs = true;
-
- private RpmBuildEnvironment buildEnvironment;
- private Executor executor;
-
- private String debuginfoDirName = "debuginfo";
-
- public void run() {
- // TODO check if caller is in mock group
-
- String cfgId = repository + "-" + release + "-" + arch;
- String cfg = mockConfig != null ? mockConfig : "slc/" + cfgId;
-
- // prepare mock call
- SystemCall mock = new SystemCall();
- if (arch != null)
- mock.arg("setarch").arg(arch);
- mock.arg("mock");
- if (mockFlavour.equals(EPEL))
- mock.arg("-v");
- else if (mockFlavour.equals(CENTOS))
- mock.arg("--debug");
- if (arch != null)
- mock.arg("--arch=" + arch);
- mock.arg("-r").arg(cfg);
-
- mock.arg("--scm-enable");
- mock.arg("--scm-option").arg("package=" + rpmPackage);
-
- mock.setLogCommand(true);
-
- // mock command execution
- mock.setExecutor(executor);
- mock.run();
-
- // File repoDir = new File(buildEnvironment.getStagingBase() + "/"
- // + repository + "/" + level + "/" + release);
- File repoDir = new File(buildEnvironment.getStagingBase() + "/"
- + repository + "-" + release + "-staging");
- File srpmDir = new File(repoDir, "SRPMS");
- if (mkdirs)
- srpmDir.mkdirs();
- File archDir = null;
- File debuginfoDir = null;
- if (!arch.equals(NOARCH)) {
- archDir = new File(repoDir, arch);
- debuginfoDir = new File(archDir, debuginfoDirName);
- debuginfoDir.mkdirs();
- }
-
- // copy RPMs
- Set<File> reposToRecreate = new HashSet<File>();
- File resultDir = new File(mockVar + "/" + cfgId + "/result");
- rpms: for (File file : resultDir.listFiles()) {
- if (file.isDirectory())
- continue rpms;
-
- File[] targetDirs;
- if (file.getName().contains(".src.rpm"))
- targetDirs = new File[] { srpmDir };
- else if (file.getName().contains("-debuginfo-"))
- targetDirs = new File[] { debuginfoDir };
- else if (!arch.equals(NOARCH)
- && file.getName().contains("." + arch + ".rpm"))
- targetDirs = new File[] { archDir };
- else if (file.getName().contains(".noarch.rpm")) {
- List<File> dirs = new ArrayList<File>();
- for (String arch : buildEnvironment.getArchs())
- dirs.add(new File(repoDir, arch));
- targetDirs = dirs.toArray(new File[dirs.size()]);
- } else if (file.getName().contains(".rpm"))
- throw new SlcException("Don't know where to copy " + file);
- else {
- if (log.isTraceEnabled())
- log.trace("Skip " + file);
- continue rpms;
- }
-
- reposToRecreate.addAll(Arrays.asList(targetDirs));
- copyToDirs(file, targetDirs);
- }
-
- // recreate changed repos
- for (File repoToRecreate : reposToRecreate) {
- SystemCall createrepo = new SystemCall();
- createrepo.arg("createrepo");
- // sqllite db
- createrepo.arg("-d");
- // debuginfo
- if (!repoToRecreate.getName().equals(debuginfoDirName))
- createrepo.arg("-x").arg(debuginfoDirName + "/*");
- // quiet
- createrepo.arg("-q");
- createrepo.arg(repoToRecreate.getAbsolutePath());
-
- createrepo.setExecutor(executor);
- createrepo.run();
- log.info("Updated repo " + repoToRecreate);
- }
- }
-
- protected void copyToDirs(File file, File[] dirs) {
- for (File dir : dirs) {
- try {
- FileUtils.copyFileToDirectory(file, dir);
- if (log.isDebugEnabled())
- log.debug(file + " => " + dir);
- } catch (IOException e) {
- throw new SlcException("Cannot copy " + file + " to " + dir, e);
- }
- }
- }
-
- public void setMockFlavour(String mockFlavour) {
- this.mockFlavour = mockFlavour;
- }
-
- public void setMockConfig(String mockConfig) {
- this.mockConfig = mockConfig;
- }
-
- public void setRepository(String repo) {
- this.repository = repo;
- }
-
- public void setRelease(String release) {
- this.release = release;
- }
-
- public void setLevel(String level) {
- this.level = level;
- }
-
- public void setArch(String arch) {
- this.arch = arch;
- }
-
- public void setRpmPackage(String rpmPackage) {
- this.rpmPackage = rpmPackage;
- }
-
- public void setMockVar(String mockVar) {
- this.mockVar = mockVar;
- }
-
- public void setMkdirs(Boolean mkdirs) {
- this.mkdirs = mkdirs;
- }
-
- public void setBuildEnvironment(RpmBuildEnvironment buildEnvironment) {
- this.buildEnvironment = buildEnvironment;
- }
-
- public void setExecutor(Executor executor) {
- this.executor = executor;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.exec.Executor;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.UrlResource;
-
-/** Generates an SRPM from a spec file */
-public class CreateSrpm implements Runnable {
- private final static Log log = LogFactory.getLog(CreateSrpm.class);
-
- private File topdir;
-
- /** Directory where to cache downloaded distributions. */
- private File distributionCache;
-
- private Resource specFile;
-
- private RpmBuildEnvironment rpmBuildEnvironment;
-
- private Boolean overwriteSources = false;
-
- private File srpmFile;
-
- private Executor executor;
-
- public void run() {
- File sourcesDir = new File(topdir, "SOURCES");
- sourcesDir.mkdirs();
- File specsDir = new File(topdir, "SPECS");
- File srpmsDir = new File(topdir, "SRPMS");
-
- try {
- // Parse spec file and copy required resources
- RpmSpecFile spec = new RpmSpecFile(specFile);
- copyToSources(spec, sourcesDir);
-
- // Copy spec file
- File targetFile = new File(specsDir, specFile.getFilename())
- .getCanonicalFile();
- copyResourceToFile(specFile, targetFile);
-
- // Generate rpmbuild config files
- rpmBuildEnvironment.writeRpmbuildConfigFiles(topdir);
-
- // Build SRPM
- srpmsDir.mkdirs();
- SystemCall packageSrpm = new SystemCall();
- packageSrpm.arg("rpmbuild");
- packageSrpm.arg("-bs").arg("--nodeps");
- packageSrpm.arg("--rcfile=rpmrc");
- packageSrpm.arg("--macros=" + RpmBuildEnvironment.defaultMacroFiles
- + ":rpmmacros");
- // buildSrpm.arg("-D", "_topdir " + topdir.getCanonicalPath() + "");
- packageSrpm.arg("SPECS/" + specFile.getFilename());
- packageSrpm.setExecDir(topdir.getCanonicalPath());
- packageSrpm.setLogCommand(true);
-
- // Execute
- packageSrpm.setExecutor(executor);
- String answer = packageSrpm.function();
-
- // Extract generated SRPM path
- // TODO: make it safer
- String srpmPath = answer.split(":")[1].trim();
- srpmFile = new File(srpmPath);
- } catch (IOException e) {
- throw new SlcException("Cannot generate SRPM from " + specFile, e);
- }
-
- }
-
- protected void copyToSources(RpmSpecFile spec, File sourcesDir) {
- try {
- List<Resource> toCopyToSources = new ArrayList<Resource>();
- List<Resource> toDownload = new ArrayList<Resource>();
- for (String file : spec.getSources().values()) {
- try {
- Resource res;
- try {
- res = specFile.createRelative("../SOURCES/" + file);
- if (!res.exists())
- res = new UrlResource(file);
-
- } catch (Exception e) {
- res = new UrlResource(file);
- toDownload.add(res);
- }
- toCopyToSources.add(res);
- } catch (Exception e) {
- log.error("Cannot interpret " + file, e);
- }
- }
- for (String file : spec.getPatches().values()) {
- try {
- Resource res;
- try {
- res = specFile.createRelative("../SOURCES/" + file);
- if (!res.exists()) {
- res = new UrlResource(file);
- }
- } catch (Exception e) {
- res = new UrlResource(file);
- toDownload.add(res);
- }
- toCopyToSources.add(res);
- } catch (Exception e) {
- log.error("Cannot interpret " + file, e);
- }
- }
-
- // FIXME: we may have missed some files here
- for (Resource res : toCopyToSources) {
- File targetDir;
- if (distributionCache != null && toDownload.contains(res)) {
- if (!distributionCache.exists())
- distributionCache.mkdirs();
- targetDir = distributionCache;
- if (log.isDebugEnabled())
- log.debug("Cache " + res + " in " + targetDir);
- } else
- targetDir = sourcesDir;
- File targetFile = new File(targetDir, res.getFilename())
- .getCanonicalFile();
- if (!targetFile.exists() || overwriteSources)
- copyResourceToFile(res, targetFile);
- if (!targetDir.equals(sourcesDir)) {
- File fileInSourcesDir = new File(sourcesDir,
- targetFile.getName());
- if (!fileInSourcesDir.exists()
- || !(fileInSourcesDir.length() == targetFile
- .length()))
- FileUtils.copyFile(targetFile, fileInSourcesDir);
- }
- }
- } catch (Exception e) {
- throw new SlcException("Cannot copy to " + sourcesDir, e);
- }
- }
-
- private static void copyResourceToFile(Resource res, File targetFile) {
- try {
- if (targetFile.equals(res.getFile())) {
- if (log.isDebugEnabled())
- log.debug("Target identical to source, skipping... "
- + targetFile + " <=> " + res);
- return;
- }
- } catch (IOException e1) {
- // silent
- }
-
- OutputStream out = null;
- InputStream in = null;
- try {
- out = FileUtils.openOutputStream(targetFile);
- in = res.getInputStream();
- IOUtils.copy(in, out);
- if (log.isDebugEnabled())
- log.debug("Copied " + targetFile + " from " + res);
- } catch (Exception e) {
- throw new SlcException("Cannot copy " + res + " to " + targetFile,
- e);
- } finally {
- IOUtils.closeQuietly(in);
- IOUtils.closeQuietly(out);
- }
-
- }
-
- public void setSpecFile(Resource specFile) {
- this.specFile = specFile;
- }
-
- public void setTopdir(File topdir) {
- this.topdir = topdir;
- }
-
- public void setOverwriteSources(Boolean overwriteSources) {
- this.overwriteSources = overwriteSources;
- }
-
- public File getSrpmFile() {
- return srpmFile;
- }
-
- public void setRpmBuildEnvironment(RpmBuildEnvironment rpmBuildEnvironment) {
- this.rpmBuildEnvironment = rpmBuildEnvironment;
- }
-
- public void setDistributionCache(File distributionCache) {
- this.distributionCache = distributionCache;
- }
-
- public void setExecutor(Executor executor) {
- this.executor = executor;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.File;
-
-import org.argeo.slc.core.execution.tasks.SystemCall;
-
-/** Install an SRPM into a working copy */
-public class ImportSrpm implements Runnable {
- private File baseDir;
- private File srpmFile;
- private RpmBuildEnvironment rpmBuildEnvironment;
-
- public void run() {
- SystemCall rpmQuery = new SystemCall(
- "rpm --queryformat '%{NAME}\n' -qp " + srpmFile);
- String packageName = rpmQuery.function();
-
- File topdir = new File(baseDir, packageName);
-
- // prepare SVN
- // TODO: do it with SVNKit
- topdir.mkdirs();
- new SystemCall("svn add " + topdir).run();
- new SystemCall("svn propset svn:ignore rpm*\nBUILD\nSRPMS\nRPMS " + topdir).run();
- File sourcesDir = new File(topdir, "SOURCES");
- sourcesDir.mkdirs();
- new SystemCall("svn add " + sourcesDir).run();
- new SystemCall("svn propset svn:ignore *gz\n*bz2\n*.zip\n*.jar " + sourcesDir).run();
- File specsDir = new File(topdir, "SPECS");
- specsDir.mkdirs();
- new SystemCall("svn add " + specsDir).run();
-
- // Write rpm config files
- File rpmmacroFile = new File(topdir, "rpmmacros");
- File rpmrcFile = new File(topdir, "rpmrc");
- rpmBuildEnvironment.writeRpmbuildConfigFiles(topdir, rpmmacroFile,
- rpmrcFile);
-
- // Install SRPM
- SystemCall installSrpm = new SystemCall();
- installSrpm.arg("rpm");
- installSrpm.arg("-Uvh");
- installSrpm.arg("--rcfile=" + rpmrcFile.getAbsolutePath());
- installSrpm.arg(srpmFile.getAbsolutePath());
- installSrpm.setExecDir(topdir.getAbsolutePath());
- installSrpm.setLogCommand(true);
- installSrpm.run();
- }
-
- public void setBaseDir(File basedir) {
- this.baseDir = basedir;
- }
-
- public void setSrpmFile(File srpmFile) {
- this.srpmFile = srpmFile;
- }
-
- public void setRpmBuildEnvironment(RpmBuildEnvironment rpmBuildEnvironment) {
- this.rpmBuildEnvironment = rpmBuildEnvironment;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.io.FileUtils;
-import org.argeo.slc.SlcException;
-
-/**
- * Defines a build environment. This information is typically used by other
- * components performing the various actions related to RPM build.
- */
-public class RpmBuildEnvironment {
- static String defaultMacroFiles = "/usr/lib/rpm/macros:/usr/lib/rpm/ia32e-linux/macros:/usr/lib/rpm/redhat/macros:/etc/rpm/macros.*:/etc/rpm/macros:/etc/rpm/ia32e-linux/macros:~/.rpmmacros";
-
- private Map<String, String> rpmmacros = new HashMap<String, String>();
-
- private List<String> archs = new ArrayList<String>();
-
- private String stagingBase = "/mnt/slc/repos/rpm";
-
- /** Write (topdir)/rpmmacros and (topdir)/rpmrc */
- public void writeRpmbuildConfigFiles(File topdir) {
- writeRpmbuildConfigFiles(topdir, new File(topdir, "rpmmacros"),
- new File(topdir, "rpmrc"));
- }
-
- public void writeRpmbuildConfigFiles(File topdir, File rpmmacroFile,
- File rpmrcFile) {
- try {
- List<String> macroLines = new ArrayList<String>();
- macroLines.add("%_topdir " + topdir.getCanonicalPath());
- for (String macroKey : rpmmacros.keySet()) {
- macroLines.add(macroKey + " " + rpmmacros.get(macroKey));
- }
- FileUtils.writeLines(rpmmacroFile, macroLines);
-
- List<String> rpmrcLines = new ArrayList<String>();
- rpmrcLines.add("include: /usr/lib/rpm/rpmrc");
- rpmrcLines.add("macrofiles: " + defaultMacroFiles + ":"
- + rpmmacroFile.getCanonicalPath());
- FileUtils.writeLines(rpmrcFile, rpmrcLines);
- } catch (IOException e) {
- throw new SlcException("Cannot write rpmbuild config files", e);
- }
-
- }
-
- public Map<String, String> getRpmmacros() {
- return rpmmacros;
- }
-
- public void setRpmmacros(Map<String, String> rpmmacros) {
- this.rpmmacros = rpmmacros;
- }
-
- public String getDefaultMacroFiles() {
- return defaultMacroFiles;
- }
-
- public void setDefaultMacroFiles(String defaultMacroFiles) {
- this.defaultMacroFiles = defaultMacroFiles;
- }
-
- public void setArchs(List<String> archs) {
- this.archs = archs;
- }
-
- public List<String> getArchs() {
- return archs;
- }
-
- public String getStagingBase() {
- return stagingBase;
- }
-
- public void setStagingBase(String stagingBase) {
- this.stagingBase = stagingBase;
- }
-}
+++ /dev/null
-package org.argeo.slc.lib.linux.rpmfactory;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.io.IOUtils;
-import org.springframework.core.io.Resource;
-
-public class RpmSpecFile {
- private Resource specFile;
-
- private String name;
- private String version;
- private String release;
- private Map<String, String> sources = new HashMap<String, String>();
- private Map<String, String> patches = new HashMap<String, String>();
-
- public RpmSpecFile(Resource specFile) {
- this.specFile = specFile;
- parseSpecFile();
- }
-
- public void init() {
- parseSpecFile();
- }
-
- @SuppressWarnings("unchecked")
- protected void parseSpecFile() {
- try {
- List<String> lines = (List<String>) IOUtils.readLines(specFile
- .getInputStream());
-
- lines: for (String line : lines) {
- int indexSemiColon = line.indexOf(':');
- if (indexSemiColon <= 0)
- continue lines;
- String directive = line.substring(0, indexSemiColon).trim();
- String value = line.substring(indexSemiColon + 1).trim();
- if ("name".equals(directive.toLowerCase()))
- name = value;
- else if ("version".equals(directive.toLowerCase()))
- version = value;
- else if ("release".equals(directive.toLowerCase()))
- release = value;
- else if (directive.toLowerCase().startsWith("source"))
- sources.put(directive, interpret(value));
- else if (directive.toLowerCase().startsWith("patch"))
- patches.put(directive, interpret(value));
- }
-
- } catch (IOException e) {
- throw new RuntimeException("Cannot parse spec file " + specFile, e);
- }
- }
-
- protected String interpret(String value) {
- StringBuffer buf = new StringBuffer(value.length());
- StringBuffer currKey = null;
- boolean mayBeKey = false;
- chars: for (char c : value.toCharArray()) {
- if (c == '%')
- mayBeKey = true;
- else if (c == '{') {
- if (mayBeKey)
- currKey = new StringBuffer();
- } else if (c == '}') {
- if (currKey == null)
- continue chars;
- String key = currKey.toString();
- if ("name".equals(key.toLowerCase()))
- buf.append(name);
- else if ("version".equals(key.toLowerCase()))
- buf.append(version);
- else
- buf.append("%{").append(key).append('}');
- currKey = null;
- } else {
- if (currKey != null)
- currKey.append(c);
- else
- buf.append(c);
- }
- }
- return buf.toString();
- }
-
- public Resource getSpecFile() {
- return specFile;
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getRelease() {
- return release;
- }
-
- public Map<String, String> getSources() {
- return sources;
- }
-
- public Map<String, String> getPatches() {
- return patches;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.vbox;
-
-import org.argeo.slc.UnsupportedException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-import org.springframework.beans.factory.BeanNameAware;
-import org.springframework.beans.factory.InitializingBean;
-
-public class VBoxMachine implements DeployedSystem, BeanNameAware,
- InitializingBean {
- private String deployedSystemId = null;
- private String name;
- private String beanName;
-
- public String getDeployedSystemId() {
- return deployedSystemId;
- }
-
- public DeploymentData getDeploymentData() {
- throw new UnsupportedException();
- }
-
- public Distribution getDistribution() {
- throw new UnsupportedException();
- }
-
- public TargetData getTargetData() {
- throw new UnsupportedException();
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setDeployedSystemId(String deployedSystemId) {
- this.deployedSystemId = deployedSystemId;
- }
-
- public void setBeanName(String beanName) {
- this.beanName = name;
- }
-
- public void afterPropertiesSet() throws Exception {
- if (name == null)
- name = beanName;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.vbox;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-import org.springframework.core.io.Resource;
-
-public class VBoxManager {
- private final static Log log = LogFactory.getLog(VBoxManager.class);
-
- private VBoxMachine vm;
- private String executable = "VBoxManage";
-
- private List<VBoxNat> nats = new ArrayList<VBoxNat>();
-
- public void importOvf(Resource ovfDefinition) {
- try {
- List<Object> cmd = new ArrayList<Object>();
- cmd.add(executable);
- cmd.add("import");
- cmd.add(ovfDefinition.getFile().getCanonicalPath());
- cmd.add("--vsys 0 --vmname <name>");
- cmd.add("0");
- cmd.add("--vmname");
- cmd.add(vm.getName());
- new SystemCall(cmd).run();
- } catch (IOException e) {
- throw new SlcException("Cannot import OVF appliance "
- + ovfDefinition, e);
- }
- }
-
- public void startVm() {
- startVm("gui");
- }
-
- public void startVmHeadless() {
- startVm("vrdp");
- }
-
- public void startVm(String type) {
- List<Object> cmd = new ArrayList<Object>();
- cmd.add(executable);
- cmd.add("startvm");
- cmd.add(vm.getName());
- cmd.add("--type");
- cmd.add(type);
- new SystemCall(cmd).run();
- }
-
- public void applyNats() {
- StringBuffer script = new StringBuffer("");
- for (VBoxNat vBoxNat : nats) {
- for (String id : vBoxNat.getMappings().keySet()) {
- VBoxPortMapping mapping = vBoxNat.getMappings().get(id);
-
- // Try to delete rule first
- try {
- StringBuffer delCmd = new StringBuffer(
- "VBoxManage modifyvm");
- delCmd.append(" \"").append(vm.getName()).append("\"");
- delCmd.append(" --natpf").append(vBoxNat.getDevice())
- .append(" ");
- delCmd.append(" delete ");
- delCmd.append("\"").append(id).append("\"");
- new SystemCall(delCmd.toString()).run();
- script.append(delCmd).append("\n");
- } catch (Exception e) {
- // silent
- }
-
- StringBuffer cmd = new StringBuffer("VBoxManage modifyvm");
- cmd.append(" \"").append(vm.getName()).append("\"");
- cmd.append(" --natpf").append(vBoxNat.getDevice()).append(" ");
- cmd.append("\"");
- cmd.append(id).append(",");
- cmd.append(mapping.getProtocol()).append(",");
- cmd.append(",");
- cmd.append(mapping.getHostPort()).append(",");
- cmd.append(vBoxNat.getGuestIp()).append(",");
- cmd.append(mapping.getGuestPort());
- cmd.append("\"");
-
- new SystemCall(cmd.toString()).run();
- script.append(cmd).append("\n");
-
- // Older VirtualBox
- // new SystemCall(createNatCommand(id, vBoxNat.getDevice(),
- // "Protocol", mapping.getProtocol(), script)).run();
- // script.append('\n');
- // new SystemCall(createNatCommand(id, vBoxNat.getDevice(),
- // "GuestPort", mapping.getGuest(), script)).run();
- // script.append('\n');
- // new SystemCall(createNatCommand(id, vBoxNat.getDevice(),
- // "HostPort", mapping.getHost(), script)).run();
- // script.append('\n');
- // script.append('\n');
- }
- script.append('\n');
- }
-
- if (log.isDebugEnabled())
- log.debug("Port setting script:\n" + script);
- }
-
- protected List<Object> createNatCommand(String id, String device,
- String cfgKey, String value, StringBuffer script) {
- List<Object> cmd = new ArrayList<Object>();
- cmd.add(executable);
- cmd.add("setextradata");
- cmd.add(vm.getName());
- cmd.add("VBoxInternal/Devices/" + device + "/0/LUN#0/Config/" + id
- + "/" + cfgKey);
- cmd.add(value);
-
- for (Object arg : cmd) {
- script.append(arg).append(' ');
- }
-
- return cmd;
- }
-
- public String getExecutable() {
- return executable;
- }
-
- public void setExecutable(String executable) {
- this.executable = executable;
- }
-
- public List<VBoxNat> getNats() {
- return nats;
- }
-
- public void setNats(List<VBoxNat> boxNats) {
- nats = boxNats;
- }
-
- public void setVm(VBoxMachine vm) {
- this.vm = vm;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.vbox;
-
-import java.util.Map;
-
-/** The NAT mapping table */
-public class VBoxNat {
- private String device = "1";
- private String guestIp = "";
- private Map<String, VBoxPortMapping> mappings;
-
- public String getDevice() {
- return device;
- }
-
- public void setDevice(String device) {
- this.device = device;
- }
-
- public Map<String, VBoxPortMapping> getMappings() {
- return mappings;
- }
-
- public void setMappings(Map<String, VBoxPortMapping> mappings) {
- this.mappings = mappings;
- }
-
- public String getGuestIp() {
- return guestIp;
- }
-
- public void setGuestIp(String guestIp) {
- this.guestIp = guestIp;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.lib.vbox;
-
-/** The mapping of one port. */
-public class VBoxPortMapping {
- private String protocol = "TCP";
- private String guestPort;
- private String hostPort;
-
- public String getProtocol() {
- return protocol;
- }
-
- public void setProtocol(String type) {
- this.protocol = type;
- }
-
- public String getGuestPort() {
- return guestPort;
- }
-
- public void setGuestPort(String guestPort) {
- this.guestPort = guestPort;
- }
-
- public String getHostPort() {
- return hostPort;
- }
-
- public void setHostPort(String hostPort) {
- this.hostPort = hostPort;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.log4j;
-
-import java.util.Date;
-import java.util.concurrent.BlockingQueue;
-
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-import org.argeo.slc.execution.ExecutionStep;
-import org.argeo.slc.runtime.ExecutionThread;
-import org.argeo.slc.runtime.ProcessThreadGroup;
-
-/** Not meant to be used directly in standard log4j config */
-public class SlcExecutionAppender extends AppenderSkeleton {
-
- private Boolean disabled = false;
-
- private String level = null;
-
- private Level log4jLevel = null;
-
- /** Marker to prevent stack overflow */
- private ThreadLocal<Boolean> dispatching = new ThreadLocal<Boolean>() {
-
- @Override
- protected Boolean initialValue() {
- return false;
- }
- };
-
- // private Layout layout = null;
- // private String pattern = "%m - %c%n";
- private Boolean onlyExecutionThread = false;
-
- public void init() {
- // if (layout != null)
- // setLayout(layout);
- // else
- // setLayout(new PatternLayout(pattern));
- Logger.getRootLogger().addAppender(this);
- }
-
- @Override
- protected void append(LoggingEvent event) {
- if (disabled)
- return;
-
- if (dispatching.get())
- return;
-
- if (level != null && !level.trim().equals("")) {
- if (log4jLevel == null || !log4jLevel.toString().equals(level))
- try {
- log4jLevel = Level.toLevel(level);
- } catch (Exception e) {
- System.err.println("Log4j level could not be set for level '" + level + "', resetting it to null.");
- e.printStackTrace();
- level = null;
- }
-
- if (log4jLevel != null && !event.getLevel().isGreaterOrEqual(log4jLevel)) {
- return;
- }
- }
-
- // Check whether we are within an executing process
- Thread currentThread = Thread.currentThread();
- if (currentThread.getThreadGroup() instanceof ProcessThreadGroup) {
- if (onlyExecutionThread && !(currentThread instanceof ExecutionThread))
- return;
-
- final String type;
- if (event.getLevel().equals(Level.ERROR) || event.getLevel().equals(Level.FATAL))
- type = ExecutionStep.ERROR;
- else if (event.getLevel().equals(Level.WARN))
- type = ExecutionStep.WARNING;
- else if (event.getLevel().equals(Level.INFO))
- type = ExecutionStep.INFO;
- else if (event.getLevel().equals(Level.DEBUG))
- type = ExecutionStep.DEBUG;
- else if (event.getLevel().equals(Level.TRACE))
- type = ExecutionStep.TRACE;
- else
- type = ExecutionStep.INFO;
-
- ExecutionStep step = new ExecutionStep(event.getLoggerName(), new Date(event.getTimeStamp()), type,
- event.getMessage().toString());
-
- try {
- dispatching.set(true);
- BlockingQueue<ExecutionStep> steps = ((ProcessThreadGroup) currentThread.getThreadGroup()).getSteps();
- if (steps.remainingCapacity() == 0) {
- stdOut("WARNING: execution steps queue is full, skipping step: " + step);
- // FIXME understand why it block indefinitely: the queue
- // should be emptied by the logging thread
- } else {
- steps.add(step);
- }
- } finally {
- dispatching.set(false);
- }
- }
- }
-
- public void destroy() throws Exception {
- Logger.getRootLogger().removeAppender(this);
- }
-
- public void close() {
- }
-
- public boolean requiresLayout() {
- return false;
- }
-
- // public void setLayout(Layout layout) {
- // this.layout = layout;
- // }
-
- /** For development purpose, since using regular logging is not easy here */
- static void stdOut(Object obj) {
- System.out.println(obj);
- }
-
- // public void setPattern(String pattern) {
- // this.pattern = pattern;
- // }
-
- public void setOnlyExecutionThread(Boolean onlyExecutionThread) {
- this.onlyExecutionThread = onlyExecutionThread;
- }
-
- public void setDisabled(Boolean disabled) {
- this.disabled = disabled;
- }
-
- public void setLevel(String level) {
- this.level = level;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.mail;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.mail.Message;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
-
-/** Sends a mail via JavaMail, local mail command or Google Mail. */
-public class SendMail implements Runnable {
- // See:
- // http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailUsage
- // http://java.sun.com/products/javamail/FAQ.html#gmail
-
- private final static Log log = LogFactory.getLog(SendMail.class);
-
- private String host;
- private String from;
- private String to;
- private String subject;
- private String text;
- private String username;
- private String password;
- private Map<String, String> javaMailProperties = new HashMap<String, String>();
-
- public void run() {
- if ("local".equals(host))
- sendWithMailCommand();
- else if ("smtp.gmail.com".equals(host))
- sendWithGMail();
- else
- sendWithJavaMail();
- }
-
- protected void sendWithMailCommand() {
- SystemCall mail = new SystemCall("mail");
- mail.arg("-s", subject).arg(to);
- mail.run();
- if (log.isDebugEnabled())
- log.debug("Sent mail to " + to + " with OS mail command");
- }
-
- protected void sendWithJavaMail() {
- try {
- // Get system properties
- Properties props = System.getProperties();
-
- // Setup mail server
- props.put("mail.smtp.host", host);
-
- for (String key : javaMailProperties.keySet())
- props.put(key, javaMailProperties.get(key));
-
- // Get session
- Session session = Session.getDefaultInstance(props, null);
-
- // Define message
- MimeMessage message = new MimeMessage(session);
- buildJavaMailMessage(message);
-
- // Send message
- Transport.send(message);
- if (log.isDebugEnabled())
- log.debug("Sent mail to " + to + " with JavaMail");
- } catch (Exception e) {
- throw new SlcException("Cannot send message.", e);
- }
- }
-
- protected void sendWithGMail() {
- try {
- Properties props = new Properties();
- props.put("mail.smtps.auth", "true");
- props.put("mail.smtps.host", host);
- Session session = Session.getDefaultInstance(props, null);
- MimeMessage message = new MimeMessage(session);
- buildJavaMailMessage(message);
- Transport t = session.getTransport("smtps");
- try {
- t.connect(host, username, password);
- t.sendMessage(message, message.getAllRecipients());
- } finally {
- t.close();
- }
- if (log.isDebugEnabled())
- log.debug("Sent mail to " + to + " with Google Mail");
- } catch (Exception e) {
- throw new SlcException("Cannot send message.", e);
- }
- }
-
- protected void buildJavaMailMessage(Message message) throws Exception {
- message.setFrom(new InternetAddress(from));
- message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
- message.setSubject(subject);
- message.setText(text);
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public void setFrom(String from) {
- this.from = from;
- }
-
- public void setTo(String to) {
- this.to = to;
- }
-
- public void setSubject(String subject) {
- this.subject = subject;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public void setJavaMailProperties(Map<String, String> javaMailProperties) {
- this.javaMailProperties = javaMailProperties;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import java.io.File;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployEnvironment;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.Deployment;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdApplicationDeployment implements Deployment {
- private static final Log log = LogFactory
- .getLog(HttpdApplicationDeployment.class);
-
- private HttpdApplicationTargetData targetData;
- private DeploymentData deploymentData;
- private SimpleHttpdApplication deployedSystem;
- private Distribution distribution;
-
- private DeployEnvironment deployEnvironment;
-
- public void run() {
- try {
- deployEnvironment.unpackTo(distribution, targetData
- .getTargetRootLocation(), null);
-
- // FIXME: make it generic
- String deployDataPath = targetData.getTargetRootLocation()
- .getCanonicalPath();
-
- deployEnvironment.unpackTo(deploymentData,
- new File(deployDataPath), null);
- deployedSystem = new SimpleHttpdApplication();
- deployedSystem.setTargetData(targetData);
-
- log.info("Deployed " + distribution + " to " + targetData);
- } catch (Exception e) {
- throw new SlcException("Cannot deploy " + distribution + " to "
- + targetData, e);
- }
-
- }
-
- public void setTargetData(TargetData targetData) {
- this.targetData = (HttpdApplicationTargetData) targetData;
- }
-
- public void setDeploymentData(DeploymentData deploymentData) {
- this.deploymentData = deploymentData;
- }
-
- public DeployedSystem getDeployedSystem() {
- return deployedSystem;
- }
-
- public void setDistribution(Distribution distribution) {
- this.distribution = distribution;
- }
-
- public void setDeployEnvironment(DeployEnvironment deployEnvironment) {
- this.deployEnvironment = deployEnvironment;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdApplicationTargetData implements TargetData {
- private HttpdServer webServer;
- private String relativePath;
- private String targetRootPath;
-
- public HttpdServer getWebServer() {
- return webServer;
- }
-
- public void setWebServer(HttpdServer webServer) {
- this.webServer = webServer;
- }
-
- public String getRelativePath() {
- return relativePath;
- }
-
- /**
- * If targetRootLocation not set, used to build the targetRootLocation,
- * relative to the webserver base.
- */
- public void setRelativePath(String relativePath) {
- this.relativePath = relativePath;
- }
-
- public String getTargetRootPath() {
- return targetRootPath;
- }
-
- public void setTargetRootPath(String targetRootPath) {
- this.targetRootPath = targetRootPath;
- }
-
- public URL getTargetBaseUrl() {
- try {
- URL wsUrl = getWebServer().getBaseUrl();
- // TODO: use URI
- return new URL(wsUrl, wsUrl.getFile() + '/' + relativePath);
- } catch (MalformedURLException e) {
- throw new SlcException("Cannot get base url for " + relativePath, e);
- }
- }
-
- public File getTargetRootLocation() {
- if (targetRootPath != null && !targetRootPath.equals("")) {
- return new File(targetRootPath);
- } else {
- HttpdServerTargetData targetData = (HttpdServerTargetData) getWebServer()
- .getTargetData();
- String path = targetData.getServerRoot() + File.separator
- + getRelativePath();
- return new File(path);
- }
- }
-
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdServer implements WebServer {
- private HttpdServerTargetData targetData;
- private HttpdServerDeploymentData deploymentData;
-
- public URL getBaseUrl() {
- try {
- return new URL("http://localhost:" + targetData.getPort());
- } catch (IOException e) {
- throw new SlcException("Cannot get url for Httpd server "
- + getDeployedSystemId(), e);
- }
- }
-
- public String getDeployedSystemId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Distribution getDistribution() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public DeploymentData getDeploymentData() {
- return deploymentData;
- }
-
- public TargetData getTargetData() {
- return targetData;
- }
-
- public void setTargetData(TargetData targetData) {
- this.targetData = (HttpdServerTargetData)targetData;
- }
-
- public void setDeploymentData(DeploymentData deploymentData) {
- this.deploymentData = (HttpdServerDeploymentData)deploymentData;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.Deployment;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdServerDeployment implements Deployment {
-// private HttpdServerTargetData targetData;
-
- public void run() {
- // TODO Auto-generated method stub
-
- }
-
- public DeployedSystem getDeployedSystem() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setDeploymentData(DeploymentData deploymentData) {
- // TODO Auto-generated method stub
-
- }
-
- public void setDistribution(Distribution distribution) {
- }
-
- public void setTargetData(TargetData targetData) {
-// this.targetData = (HttpdServerTargetData) targetData;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import org.argeo.slc.deploy.DeploymentData;
-
-public class HttpdServerDeploymentData implements DeploymentData {
- private String configFile;
-
- public String getConfigFile() {
- return configFile;
- }
-
- public void setConfigFile(String configFile) {
- this.configFile = configFile;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.deploy.DeployedSystemManager;
-
-public class HttpdServerManager implements DeployedSystemManager<HttpdServer> {
- private final static Log log = LogFactory.getLog(HttpdServerManager.class);
-
- private HttpdServer httpdServer;
-
- public void start() {
- runProcessAsync(createCommandLine("start"));
- log.info("Started httpd server with root "
- + getHttpdServerTargetData().getServerRoot());
- }
-
- public void stop() {
- runProcessAsync(createCommandLine("stop"));
- log.info("Stopped httpd server with root "
- + getHttpdServerTargetData().getServerRoot());
- }
-
- protected String[] createCommandLine(String action) {
- String httpdPath = getHttpdServerTargetData().getExecutables()
- .getExecutablePath("httpd");
- String[] cmd = { httpdPath, "-d",
- getHttpdServerTargetData().getServerRoot(), "-f",
- getHttpdServerDeploymentData().getConfigFile(), "-k", action };
- if (log.isDebugEnabled())
- log.debug("Command line: " + Arrays.asList(cmd));
- return cmd;
- }
-
- protected static void runProcessAsync(String... command) {
- ProcessBuilder procBuilder = new ProcessBuilder(command);
- procBuilder.redirectErrorStream(true);
- try {
- Process proc = procBuilder.start();
- final InputStream in = proc.getInputStream();
- Thread logThread = new Thread() {
-
- @Override
- public void run() {
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(in));
- String line = null;
- try {
- while ((line = reader.readLine()) != null)
- log.info(line);
- } catch (IOException e) {
- log.error("Failed to read stdout", e);
- }
- }
- };
-
- logThread.start();
- } catch (IOException e) {
- throw new SlcException("Could not run command", e);
- }
- }
-
- public void setDeployedSystem(HttpdServer httpdServer) {
- this.httpdServer = httpdServer;
- }
-
- protected HttpdServerDeploymentData getHttpdServerDeploymentData() {
- return (HttpdServerDeploymentData) httpdServer.getDeploymentData();
- }
-
- protected HttpdServerTargetData getHttpdServerTargetData() {
- return (HttpdServerTargetData) httpdServer.getTargetData();
- }
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import org.argeo.slc.deploy.InstalledExecutables;
-import org.argeo.slc.deploy.TargetData;
-
-public class HttpdServerTargetData implements TargetData {
- private String serverRoot;
- private Integer port;
- private InstalledExecutables executables;
-
- public String getServerRoot() {
- return serverRoot;
- }
-
- public void setServerRoot(String serverRoot) {
- this.serverRoot = serverRoot;
- }
-
- public Integer getPort() {
- return port;
- }
-
- public void setPort(Integer port) {
- this.port = port;
- }
-
- public InstalledExecutables getExecutables() {
- return executables;
- }
-
- public void setExecutables(InstalledExecutables executables) {
- this.executables = executables;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import java.io.File;
-import java.net.URL;
-
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeploymentData;
-
-public class SimpleHttpdApplication implements WebApplication {
- private HttpdApplicationTargetData targetData;
- private Distribution distribution;
-
- public void setDistribution(Distribution distribution) {
- this.distribution = distribution;
- }
-
- public URL getBaseUrl() {
- return targetData.getTargetBaseUrl();
- }
-
- public File getRootLocation() {
- return targetData.getTargetRootLocation();
- }
-
- public String getDeployedSystemId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public HttpdApplicationTargetData getTargetData() {
- return targetData;
- }
-
- public void setTargetData(HttpdApplicationTargetData targetData) {
- this.targetData = targetData;
- }
-
- public Distribution getDistribution() {
- return distribution;
- }
-
- public DeploymentData getDeploymentData() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import java.io.File;
-import java.net.URL;
-
-import org.argeo.slc.deploy.DeployedSystem;
-
-public interface WebApplication extends DeployedSystem {
- public URL getBaseUrl();
-
- public File getRootLocation();
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import java.net.URL;
-
-import org.argeo.slc.deploy.DeployedSystem;
-
-public interface WebServer extends DeployedSystem {
- public URL getBaseUrl();
-}
+++ /dev/null
-package org.argeo.slc.support.deploy.db;
-
-import java.sql.Connection;
-
-public interface DbModel {
- public void createSchema(Connection connection);
-}
+++ /dev/null
-package org.argeo.slc.support.deploy.db;
-
-import javax.sql.DataSource;
-
-public interface JdbcAware {
- public DataSource getDataSource();
-}
+++ /dev/null
-package org.argeo.slc.support.deploy.db;
-
-import javax.sql.DataSource;
-
-import org.argeo.slc.build.Distribution;
-import org.argeo.slc.deploy.DeployedSystem;
-import org.argeo.slc.deploy.DeploymentData;
-import org.argeo.slc.deploy.TargetData;
-
-public class SimpleJdbcDatabase implements DeployedSystem, JdbcAware {
- private DataSource dataSource;
-
- public String getDeployedSystemId() {
- return dataSource.toString();
- }
-
- public DataSource getDataSource() {
- return dataSource;
- }
-
- public void setDataSource(DataSource dataSource) {
- this.dataSource = dataSource;
- }
-
- @Override
- public Distribution getDistribution() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public DeploymentData getDeploymentData() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public TargetData getTargetData() {
- throw new UnsupportedOperationException();
- }
-}
+++ /dev/null
-package org.argeo.slc.vfs;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.apache.commons.io.IOExceptionWithCause;
-import org.apache.commons.vfs2.FileObject;
-import org.apache.commons.vfs2.FileSystemException;
-import org.apache.commons.vfs2.NameScope;
-import org.argeo.slc.SlcException;
-import org.springframework.core.io.Resource;
-
-public class VfsResource implements Resource {
- private FileObject fileObject;
-
- public VfsResource(FileObject fileObject) {
- this.fileObject = fileObject;
- }
-
- public Resource createRelative(String relativePath) throws IOException {
- return new VfsResource(fileObject.resolveFile(relativePath,
- NameScope.DESCENDENT_OR_SELF));
- }
-
- public boolean exists() {
- try {
- return fileObject.exists();
- } catch (FileSystemException e) {
- throw new SlcException("Cannot find out whether " + fileObject
- + " exists", e);
- }
- }
-
- public String getDescription() {
- return "VFS resource " + fileObject;
- }
-
- public File getFile() throws IOException {
- throw new IOException("Cannot access " + getDescription()
- + " as a local file");
- // TODO: access local files
- // if(fileObject instanceof LocalFile){
- // ((LocalFile)fileObject).
- // }
- // return null;
- }
-
- public String getFilename() {
- return fileObject.getName().getBaseName();
- }
-
- public URI getURI() throws IOException {
- try {
- return new URI(fileObject.getName().getURI());
- } catch (URISyntaxException e) {
- throw new IOExceptionWithCause(e);
- }
- }
-
- public URL getURL() throws IOException {
- return fileObject.getURL();
- }
-
- public boolean isOpen() {
- return fileObject.isContentOpen();
- }
-
- public boolean isReadable() {
- try {
- return fileObject.isReadable();
- } catch (FileSystemException e) {
- throw new SlcException("Cannot find out whether " + fileObject
- + " is readable", e);
- }
- }
-
- public long lastModified() throws IOException {
- return fileObject.getContent().getLastModifiedTime();
- }
-
- public InputStream getInputStream() throws IOException {
- return fileObject.getContent().getInputStream();
- }
-
- public FileObject getFileObject() {
- return fileObject;
- }
-
- public long contentLength(){
- return -1;
- }
-}
+++ /dev/null
-package org.argeo.slc.vfs;
-
-import org.apache.commons.vfs2.CacheStrategy;
-import org.apache.commons.vfs2.FileSystemManager;
-import org.apache.commons.vfs2.impl.StandardFileSystemManager;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-public class VfsResourceFactory implements FactoryBean, InitializingBean {
- private String url;
- private FileSystemManager fileSystemManager;
-
- public Object getObject() throws Exception {
- return new VfsResource(fileSystemManager.resolveFile(url));
- }
-
- public Class<?> getObjectType() {
- return Resource.class;
- }
-
- public boolean isSingleton() {
- return false;
- }
-
- public void afterPropertiesSet() throws Exception {
- if (fileSystemManager == null) {
- fileSystemManager = new StandardFileSystemManager();
- ((StandardFileSystemManager) fileSystemManager)
- .setCacheStrategy(CacheStrategy.ON_RESOLVE);
- ((StandardFileSystemManager) fileSystemManager).init();
- }
-
- }
-
-}
+++ /dev/null
-package org.argeo.slc.vfs;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.vfs2.FileObject;
-import org.apache.commons.vfs2.FileSystemException;
-import org.apache.commons.vfs2.FileSystemManager;
-import org.apache.commons.vfs2.VFS;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.core.deploy.ResourceSet;
-import org.springframework.core.io.Resource;
-
-public class VfsResourceSet implements ResourceSet {
- private String base;
-
- public Map<String, Resource> listResources() {
- try {
- FileSystemManager fileSystemManager = VFS.getManager();
- FileObject fileObject = fileSystemManager.resolveFile(base);
- Map<String, Resource> map = new HashMap<String, Resource>();
- addToMap(map, "", fileObject);
-
- // TODO: add filters
- return map;
- } catch (FileSystemException e) {
- throw new SlcException("Cannot list VFS resources from " + base, e);
- }
- }
-
- /** recursive */
- protected void addToMap(Map<String, Resource> map, String parentPath,
- FileObject fileObject) {
- try {
- String newParentPath = parentPath
- + fileObject.getName().getBaseName() + '/';
- if (fileObject.getType().hasChildren()) {
- for (FileObject child : fileObject.getChildren()) {
- addToMap(map, newParentPath, child);
- }
- } else {
- map.put(parentPath + fileObject.getName().getBaseName(),
- new VfsResource(fileObject));
- }
- } catch (FileSystemException e) {
- throw new SlcException("Cannot add children from " + parentPath, e);
- }
- }
-
- public void setBase(String base) {
- this.base = base;
- }
-
-}
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>legacy</artifactId>
- <version>2.1-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>SLC Legacy Argeo Software</name>
- <modules>
- <!-- Legacy UI -->
- <module>org.argeo.legacy.fake.java8</module>
-<!-- <module>argeo-commons</module> -->
-
- <!-- Legacy Runtime -->
- <module>org.argeo.slc.spring</module>
- <module>org.argeo.slc.support</module>
- <module>org.argeo.slc.launcher</module>
-
- <!-- Legacy Modules -->
- <module>org.argeo.slc.agent</module>
- <module>org.argeo.slc.agent.jcr</module>
- <module>org.argeo.slc.server.repo</module>
-
- <!-- Legacy UI -->
- <module>org.argeo.slc.client.ui</module>
- <module>org.argeo.slc.client.ui.dist</module>
- <module>org.argeo.slc.client.rap</module>
-
- <!-- To be imported by Spring-based modules -->
- <module>lib</module>
-
- <!-- Spring-based modules demo -->
- <module>org.argeo.slc.demo.ant</module>
- <module>org.argeo.slc.demo.basic</module>
- <module>org.argeo.slc.demo.minimal</module>
-
- <module>dep</module>
- </modules>
- <dependencies>
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp</artifactId>
- <version>${version.argeo-tp}</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.xerces</artifactId>
- </exclusion>
- <!-- Avoid slf4j implementations lurking in the classpath. -->
- <exclusion>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>biz.aQute.bndlib</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>slf4j.osgi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/classes" path="src"/>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-Require-Capability: cms.datamodel;filter:="(name=ldap)",\
- cms.datamodel;filter:="(name=argeo)"
+#Require-Capability: cms.datamodel;filter:="(name=ldap)",\
+# cms.datamodel;filter:="(name=argeo)"
Provide-Capability: cms.datamodel;name=slc;cnd=/org/argeo/slc/slc.cnd
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.api</artifactId>
- <name>SLC API</name>
-</project>
\ No newline at end of file
--- /dev/null
+package org.argeo.slc;
+
+public enum ManifestConstants {
+ // OSGi
+ BUNDLE_SYMBOLICNAME("Bundle-SymbolicName"), //
+ BUNDLE_VERSION("Bundle-Version"), //
+ BUNDLE_LICENSE("Bundle-License"), //
+ EXPORT_PACKAGE("Export-Package"), //
+ IMPORT_PACKAGE("Import-Package"), //
+ // SLC
+ SLC_CATEGORY("SLC-Category"), //
+ SLC_ORIGIN_M2("SLC-Origin-M2"), //
+ SLC_ORIGIN_MANIFEST_NOT_MODIFIED("SLC-Origin-ManifestNotModified"), //
+ SLC_ORIGIN_URI("SLC-Origin-URI"),//
+ ;
+
+ final String value;
+
+ private ManifestConstants(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+
+}
*/
public interface NameVersion {
/** The name of the component. */
- public String getName();
+ String getName();
/** The version of the component. */
- public String getVersion();
+ String getVersion();
+
+ /**
+ * The forward compatible branch of this version, by default it is
+ * [major].[minor].
+ */
+ default String getBranch() {
+ String[] parts = getVersion().split("\\.");
+ if (parts.length < 2)
+ throw new IllegalStateException("Version " + getVersion() + " cannot be interpreted as branch.");
+ return parts[0] + "." + parts[1];
+ }
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/classes" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>>>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
+++ /dev/null
-/MANIFEST.MF
-Import-Package: javax.jcr.nodetype,\
-org.argeo.slc.repo,\
-org.osgi.*;version=0.0.0,\
-*
-
\ No newline at end of file
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
+additional.bundles = org.argeo.init,\
+ org.slf4j.api
\ No newline at end of file
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.factory</artifactId>
- <name>SLC Factory</name>
- <dependencies>
- <!-- SLC -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.runtime</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.repo</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.factory;
+
+import static java.lang.System.Logger.Level.DEBUG;
+import static org.argeo.slc.ManifestConstants.BUNDLE_LICENSE;
+import static org.argeo.slc.ManifestConstants.BUNDLE_SYMBOLICNAME;
+import static org.argeo.slc.ManifestConstants.BUNDLE_VERSION;
+import static org.argeo.slc.ManifestConstants.EXPORT_PACKAGE;
+import static org.argeo.slc.ManifestConstants.SLC_ORIGIN_M2;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
+import java.net.URL;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.PathMatcher;
+import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import org.argeo.slc.DefaultNameVersion;
+import org.argeo.slc.ManifestConstants;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.factory.m2.DefaultArtifact;
+import org.argeo.slc.factory.m2.MavenConventionsUtils;
+
+import aQute.bnd.osgi.Analyzer;
+import aQute.bnd.osgi.Jar;
+
+/** The central class for A2 packaging. */
+public class A2Factory {
+ private final static Logger logger = System.getLogger(A2Factory.class.getName());
+
+ private final static String COMMON_BND = "common.bnd";
+
+ private Path originBase;
+ private Path a2Base;
+
+ /** key is URI prefix, value list of base URLs */
+ private Map<String, List<String>> mirrors = new HashMap<String, List<String>>();
+
+ public A2Factory(Path a2Base) {
+ this.originBase = Paths.get(System.getProperty("user.home"), ".cache", "argeo/slc/origin");
+ this.a2Base = a2Base;
+
+ // TODO make it configurable
+ List<String> eclipseMirrors = new ArrayList<>();
+ eclipseMirrors.add("https://archive.eclipse.org/");
+ eclipseMirrors.add("http://ftp-stud.hs-esslingen.de/Mirrors/eclipse/");
+ eclipseMirrors.add("http://ftp.fau.de/eclipse/");
+
+ mirrors.put("http://www.eclipse.org/downloads", eclipseMirrors);
+ }
+
+ public void processCategory(Path targetCategoryBase) {
+ try {
+ DirectoryStream<Path> bnds = Files.newDirectoryStream(targetCategoryBase,
+ (p) -> p.getFileName().toString().endsWith(".bnd")
+ && !p.getFileName().toString().equals(COMMON_BND));
+ for (Path p : bnds) {
+ processSingleM2ArtifactDistributionUnit(p);
+ }
+
+ DirectoryStream<Path> dus = Files.newDirectoryStream(targetCategoryBase, (p) -> Files.isDirectory(p));
+ for (Path duDir : dus) {
+ processM2BasedDistributionUnit(duDir);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot process category " + targetCategoryBase, e);
+ }
+ }
+
+ public void processSingleM2ArtifactDistributionUnit(Path bndFile) {
+ try {
+ String category = bndFile.getParent().getFileName().toString();
+ Path targetCategoryBase = a2Base.resolve(category);
+ Properties fileProps = new Properties();
+ try (InputStream in = Files.newInputStream(bndFile)) {
+ fileProps.load(in);
+ }
+
+ String m2Coordinates = fileProps.getProperty(SLC_ORIGIN_M2.toString());
+ if (m2Coordinates == null)
+ throw new IllegalArgumentException("No M2 coordinates available for " + bndFile);
+ DefaultArtifact artifact = new DefaultArtifact(m2Coordinates);
+ URL url = MavenConventionsUtils.mavenCentralUrl(artifact);
+ Path downloaded = download(url, originBase, artifact.toM2Coordinates() + ".jar");
+
+ Path targetBundleDir = processBndJar(downloaded, targetCategoryBase, fileProps, artifact);
+
+ downloadAndProcessM2Sources(artifact, targetBundleDir);
+
+ createJar(targetBundleDir);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot process " + bndFile, e);
+ }
+ }
+
+ public void processM2BasedDistributionUnit(Path duDir) {
+ try {
+ String category = duDir.getParent().getFileName().toString();
+ Path targetCategoryBase = a2Base.resolve(category);
+ Path commonBnd = duDir.resolve(COMMON_BND);
+ Properties commonProps = new Properties();
+ try (InputStream in = Files.newInputStream(commonBnd)) {
+ commonProps.load(in);
+ }
+
+ String m2Version = commonProps.getProperty(SLC_ORIGIN_M2.toString());
+ if (m2Version == null) {
+ logger.log(Level.WARNING, "Ignoring " + duDir + " as it is not an M2-based distribution unit");
+ return;// ignore, this is probably an Eclipse archive
+ }
+ if (!m2Version.startsWith(":")) {
+ throw new IllegalStateException("Only the M2 version can be specified: " + m2Version);
+ }
+ m2Version = m2Version.substring(1);
+
+ // String license = commonProps.getProperty(BUNDLE_LICENSE.toString());
+
+ DirectoryStream<Path> ds = Files.newDirectoryStream(duDir,
+ (p) -> p.getFileName().toString().endsWith(".bnd")
+ && !p.getFileName().toString().equals(COMMON_BND));
+ for (Path p : ds) {
+ Properties fileProps = new Properties();
+ try (InputStream in = Files.newInputStream(p)) {
+ fileProps.load(in);
+ }
+ String m2Coordinates = fileProps.getProperty(SLC_ORIGIN_M2.toString());
+ DefaultArtifact artifact = new DefaultArtifact(m2Coordinates);
+
+ // temporary rewrite, for migration
+ String localLicense = fileProps.getProperty(BUNDLE_LICENSE.toString());
+ if (localLicense != null || artifact.getVersion() != null) {
+ fileProps.remove(BUNDLE_LICENSE.toString());
+ fileProps.put(SLC_ORIGIN_M2.toString(), artifact.getGroupId() + ":" + artifact.getArtifactId());
+ try (Writer writer = Files.newBufferedWriter(p)) {
+ for (Object key : fileProps.keySet()) {
+ String value = fileProps.getProperty(key.toString());
+ writer.write(key + ": " + value + '\n');
+ }
+ logger.log(DEBUG, () -> "Migrated " + p);
+ }
+ }
+
+ artifact.setVersion(m2Version);
+ URL url = MavenConventionsUtils.mavenCentralUrl(artifact);
+ Path downloaded = download(url, originBase, artifact.toM2Coordinates() + ".jar");
+
+ // prepare manifest entries
+ Properties mergeProps = new Properties();
+ mergeProps.putAll(commonProps);
+
+ // Map<String, String> entries = new HashMap<>();
+// for (Object key : commonProps.keySet()) {
+// entries.put(key.toString(), commonProps.getProperty(key.toString()));
+// }
+ fileEntries: for (Object key : fileProps.keySet()) {
+ if (ManifestConstants.SLC_ORIGIN_M2.toString().equals(key))
+ continue fileEntries;
+ String value = fileProps.getProperty(key.toString());
+ Object previousValue = mergeProps.put(key.toString(), value);
+ if (previousValue != null) {
+ logger.log(Level.WARNING,
+ downloaded + ": " + key + " was " + previousValue + ", overridden with " + value);
+ }
+ }
+ mergeProps.put(ManifestConstants.SLC_ORIGIN_M2.toString(), artifact.toM2Coordinates());
+ Path targetBundleDir = processBndJar(downloaded, targetCategoryBase, mergeProps, artifact);
+// logger.log(Level.DEBUG, () -> "Processed " + downloaded);
+
+ // sources
+ downloadAndProcessM2Sources(artifact, targetBundleDir);
+
+ createJar(targetBundleDir);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot process " + duDir, e);
+ }
+
+ }
+
+ protected void downloadAndProcessM2Sources(DefaultArtifact artifact, Path targetBundleDir) throws IOException {
+ DefaultArtifact sourcesArtifact = new DefaultArtifact(artifact.toM2Coordinates(), "sources");
+ URL sourcesUrl = MavenConventionsUtils.mavenCentralUrl(sourcesArtifact);
+ Path sourcesDownloaded = download(sourcesUrl, originBase, artifact.toM2Coordinates() + ".sources.jar");
+ processM2SourceJar(sourcesDownloaded, targetBundleDir);
+ logger.log(Level.DEBUG, () -> "Processed source " + sourcesDownloaded);
+
+ }
+
+ protected Path processBndJar(Path downloaded, Path targetCategoryBase, Properties fileProps,
+ DefaultArtifact artifact) {
+
+ try {
+ Map<String, String> additionalEntries = new TreeMap<>();
+ boolean doNotModify = Boolean.parseBoolean(fileProps
+ .getOrDefault(ManifestConstants.SLC_ORIGIN_MANIFEST_NOT_MODIFIED.toString(), "false").toString());
+
+ // we always force the symbolic name
+
+ if (doNotModify) {
+ fileEntries: for (Object key : fileProps.keySet()) {
+ if (ManifestConstants.SLC_ORIGIN_M2.toString().equals(key))
+ continue fileEntries;
+ String value = fileProps.getProperty(key.toString());
+ additionalEntries.put(key.toString(), value);
+ }
+ } else {
+ if (artifact != null) {
+ if (!fileProps.containsKey(BUNDLE_SYMBOLICNAME.toString())) {
+ fileProps.put(BUNDLE_SYMBOLICNAME.toString(), artifact.getName());
+ }
+ if (!fileProps.containsKey(BUNDLE_VERSION.toString())) {
+ fileProps.put(BUNDLE_VERSION.toString(), artifact.getVersion());
+ }
+ }
+
+ if (!fileProps.containsKey(EXPORT_PACKAGE.toString())) {
+ fileProps.put(EXPORT_PACKAGE.toString(),
+ "*;version=\"" + fileProps.getProperty(BUNDLE_VERSION.toString()) + "\"");
+ }
+// if (!fileProps.contains(IMPORT_PACKAGE.toString())) {
+// fileProps.put(IMPORT_PACKAGE.toString(), "*");
+// }
+
+ try (Analyzer bndAnalyzer = new Analyzer()) {
+ bndAnalyzer.setProperties(fileProps);
+ Jar jar = new Jar(downloaded.toFile());
+ bndAnalyzer.setJar(jar);
+ Manifest manifest = bndAnalyzer.calcManifest();
+
+ keys: for (Object key : manifest.getMainAttributes().keySet()) {
+ Object value = manifest.getMainAttributes().get(key);
+
+ switch (key.toString()) {
+ case "Tool":
+ case "Bnd-LastModified":
+ case "Created-By":
+ continue keys;
+ }
+ if ("Require-Capability".equals(key.toString())
+ && value.toString().equals("osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=1.1))\""))
+ continue keys;// hack for very old classes
+ additionalEntries.put(key.toString(), value.toString());
+ logger.log(DEBUG, () -> key + "=" + value);
+
+ }
+ }
+
+// try (Builder bndBuilder = new Builder()) {
+// Jar jar = new Jar(downloaded.toFile());
+// bndBuilder.addClasspath(jar);
+// Path targetBundleDir = targetCategoryBase.resolve(artifact.getName() + "." + artifact.getBranch());
+//
+// Jar target = new Jar(targetBundleDir.toFile());
+// bndBuilder.setJar(target);
+// return targetBundleDir;
+// }
+ }
+ Path targetBundleDir = processBundleJar(downloaded, targetCategoryBase, additionalEntries);
+ logger.log(Level.DEBUG, () -> "Processed " + downloaded);
+ return targetBundleDir;
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot BND process " + downloaded, e);
+ }
+
+ }
+
+ protected void processM2SourceJar(Path file, Path targetBundleDir) throws IOException {
+ try (JarInputStream jarIn = new JarInputStream(Files.newInputStream(file), false)) {
+ Path targetSourceDir = targetBundleDir.resolve("OSGI-OPT/src");
+
+ // TODO make it less dangerous?
+ if (Files.exists(targetSourceDir)) {
+ deleteDirectory(targetSourceDir);
+ } else {
+ Files.createDirectories(targetSourceDir);
+ }
+
+ // copy entries
+ JarEntry entry;
+ entries: while ((entry = jarIn.getNextJarEntry()) != null) {
+ if (entry.isDirectory())
+ continue entries;
+ if (entry.getName().startsWith("META-INF"))// skip META-INF entries
+ continue entries;
+ Path target = targetSourceDir.resolve(entry.getName());
+ Files.createDirectories(target.getParent());
+ Files.copy(jarIn, target);
+ logger.log(Level.TRACE, () -> "Copied source " + target);
+ }
+ }
+
+ }
+
+ public void processEclipseArchive(Path duDir) {
+ try {
+ String category = duDir.getParent().getFileName().toString();
+ Path targetCategoryBase = a2Base.resolve(category);
+ Files.createDirectories(targetCategoryBase);
+ // first delete all directories from previous builds
+ for (Path dir : Files.newDirectoryStream(targetCategoryBase, (p) -> Files.isDirectory(p))) {
+ deleteDirectory(dir);
+ }
+
+ Files.createDirectories(originBase);
+
+ Path commonBnd = duDir.resolve(COMMON_BND);
+ Properties commonProps = new Properties();
+ try (InputStream in = Files.newInputStream(commonBnd)) {
+ commonProps.load(in);
+ }
+ Properties includes = new Properties();
+ try (InputStream in = Files.newInputStream(duDir.resolve("includes.properties"))) {
+ includes.load(in);
+ }
+ String url = commonProps.getProperty(ManifestConstants.SLC_ORIGIN_URI.toString());
+ Path downloaded = tryDownload(url, originBase);
+
+ FileSystem zipFs = FileSystems.newFileSystem(downloaded, (ClassLoader) null);
+
+ List<PathMatcher> pathMatchers = new ArrayList<>();
+ for (Object pattern : includes.keySet()) {
+ PathMatcher pathMatcher = zipFs.getPathMatcher("glob:/" + pattern);
+ pathMatchers.add(pathMatcher);
+ }
+
+ Files.walkFileTree(zipFs.getRootDirectories().iterator().next(), new SimpleFileVisitor<Path>() {
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ pathMatchers: for (PathMatcher pathMatcher : pathMatchers) {
+ if (pathMatcher.matches(file)) {
+ if (file.getFileName().toString().contains(".source_")) {
+ processEclipseSourceJar(file, targetCategoryBase);
+ logger.log(Level.DEBUG, () -> "Processed source " + file);
+
+ } else {
+ processBundleJar(file, targetCategoryBase, new HashMap<>());
+ logger.log(Level.DEBUG, () -> "Processed " + file);
+ }
+ break pathMatchers;
+ }
+ }
+ return FileVisitResult.CONTINUE;
+ }
+ });
+
+ DirectoryStream<Path> dirs = Files.newDirectoryStream(targetCategoryBase, (p) -> Files.isDirectory(p));
+ for (Path dir : dirs) {
+ createJar(dir);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot process " + duDir, e);
+ }
+
+ }
+
+ protected Path processBundleJar(Path file, Path targetBase, Map<String, String> entries) throws IOException {
+ DefaultNameVersion nameVersion;
+ Path targetBundleDir;
+ try (JarInputStream jarIn = new JarInputStream(Files.newInputStream(file), false)) {
+ Manifest manifest = new Manifest(jarIn.getManifest());
+
+ // remove problematic entries in MANIFEST
+ manifest.getEntries().clear();
+// Set<String> entriesToDelete = new HashSet<>();
+// for (String key : manifest.getEntries().keySet()) {
+//// logger.log(DEBUG, "## " + key);
+// Attributes attrs = manifest.getAttributes(key);
+// for (Object attrName : attrs.keySet()) {
+//// logger.log(DEBUG, attrName + "=" + attrs.get(attrName));
+// if ("Specification-Version".equals(attrName.toString())
+// || "Implementation-Version".equals(attrName.toString())) {
+// entriesToDelete.add(key);
+//
+// }
+// }
+// }
+// for (String key : entriesToDelete) {
+// manifest.getEntries().remove(key);
+// }
+
+ String symbolicNameFromEntries = entries.get(BUNDLE_SYMBOLICNAME.toString());
+ String versionFromEntries = entries.get(BUNDLE_VERSION.toString());
+
+ if (symbolicNameFromEntries != null && versionFromEntries != null) {
+ nameVersion = new DefaultNameVersion(symbolicNameFromEntries, versionFromEntries);
+ } else {
+ nameVersion = nameVersionFromManifest(manifest);
+ if (versionFromEntries != null && !nameVersion.getVersion().equals(versionFromEntries)) {
+ logger.log(Level.WARNING, "Original version is " + nameVersion.getVersion()
+ + " while new version is " + versionFromEntries);
+ }
+ if (symbolicNameFromEntries != null) {
+ // we always force our symbolic name
+ nameVersion.setName(symbolicNameFromEntries);
+ }
+ }
+ targetBundleDir = targetBase.resolve(nameVersion.getName() + "." + nameVersion.getBranch());
+
+ // TODO make it less dangerous?
+// if (Files.exists(targetBundleDir)) {
+// deleteDirectory(targetBundleDir);
+// }
+
+ // copy entries
+ JarEntry entry;
+ entries: while ((entry = jarIn.getNextJarEntry()) != null) {
+ if (entry.isDirectory())
+ continue entries;
+ if (entry.getName().endsWith(".RSA") || entry.getName().endsWith(".SF"))
+ continue entries;
+ Path target = targetBundleDir.resolve(entry.getName());
+ Files.createDirectories(target.getParent());
+ Files.copy(jarIn, target);
+ logger.log(Level.TRACE, () -> "Copied " + target);
+ }
+
+ // copy MANIFEST
+ Path manifestPath = targetBundleDir.resolve("META-INF/MANIFEST.MF");
+ Files.createDirectories(manifestPath.getParent());
+ for (String key : entries.keySet()) {
+ String value = entries.get(key);
+ Object previousValue = manifest.getMainAttributes().putValue(key, value);
+ if (previousValue != null && !previousValue.equals(value)) {
+ if (ManifestConstants.IMPORT_PACKAGE.toString().equals(key)
+ || ManifestConstants.EXPORT_PACKAGE.toString().equals(key))
+ logger.log(Level.WARNING, file.getFileName() + ": " + key + " was modified");
+
+ else
+ logger.log(Level.WARNING, file.getFileName() + ": " + key + " was " + previousValue
+ + ", overridden with " + value);
+ }
+ }
+ try (OutputStream out = Files.newOutputStream(manifestPath)) {
+ manifest.write(out);
+ }
+ }
+ return targetBundleDir;
+ }
+
+ protected void processEclipseSourceJar(Path file, Path targetBase) throws IOException {
+ try {
+ Path targetBundleDir;
+ try (JarInputStream jarIn = new JarInputStream(Files.newInputStream(file), false)) {
+ Manifest manifest = jarIn.getManifest();
+
+ String[] relatedBundle = manifest.getMainAttributes().getValue("Eclipse-SourceBundle").split(";");
+ String version = relatedBundle[1].substring("version=\"".length());
+ version = version.substring(0, version.length() - 1);
+ NameVersion nameVersion = new DefaultNameVersion(relatedBundle[0], version);
+ targetBundleDir = targetBase.resolve(nameVersion.getName() + "." + nameVersion.getBranch());
+
+ Path targetSourceDir = targetBundleDir.resolve("OSGI-OPT/src");
+
+ // TODO make it less dangerous?
+ if (Files.exists(targetSourceDir)) {
+// deleteDirectory(targetSourceDir);
+ } else {
+ Files.createDirectories(targetSourceDir);
+ }
+
+ // copy entries
+ JarEntry entry;
+ entries: while ((entry = jarIn.getNextJarEntry()) != null) {
+ if (entry.isDirectory())
+ continue entries;
+ if (entry.getName().startsWith("META-INF"))// skip META-INF entries
+ continue entries;
+ Path target = targetSourceDir.resolve(entry.getName());
+ Files.createDirectories(target.getParent());
+ Files.copy(jarIn, target);
+ logger.log(Level.TRACE, () -> "Copied source " + target);
+ }
+
+ // copy MANIFEST
+// Path manifestPath = targetBundleDir.resolve("META-INF/MANIFEST.MF");
+// Files.createDirectories(manifestPath.getParent());
+// try (OutputStream out = Files.newOutputStream(manifestPath)) {
+// manifest.write(out);
+// }
+ }
+ } catch (IOException e) {
+ throw new IllegalStateException("Cannot process " + file, e);
+ }
+
+ }
+
+ static void deleteDirectory(Path path) throws IOException {
+ if (!Files.exists(path))
+ return;
+ Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult postVisitDirectory(Path directory, IOException e) throws IOException {
+ if (e != null)
+ throw e;
+ Files.delete(directory);
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ Files.delete(file);
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ }
+
+ protected DefaultNameVersion nameVersionFromManifest(Manifest manifest) {
+ Attributes attrs = manifest.getMainAttributes();
+ // symbolic name
+ String symbolicName = attrs.getValue(ManifestConstants.BUNDLE_SYMBOLICNAME.toString());
+ if (symbolicName == null)
+ return null;
+ // make sure there is no directive
+ symbolicName = symbolicName.split(";")[0];
+
+ String version = attrs.getValue(ManifestConstants.BUNDLE_VERSION.toString());
+ return new DefaultNameVersion(symbolicName, version);
+ }
+
+ protected Path tryDownload(String uri, Path dir) throws IOException {
+ // find mirror
+ List<String> urlBases = null;
+ String uriPrefix = null;
+ uriPrefixes: for (String uriPref : mirrors.keySet()) {
+ if (uri.startsWith(uriPref)) {
+ if (mirrors.get(uriPref).size() > 0) {
+ urlBases = mirrors.get(uriPref);
+ uriPrefix = uriPref;
+ break uriPrefixes;
+ }
+ }
+ }
+ if (urlBases == null)
+ try {
+ return download(new URL(uri), dir, null);
+ } catch (FileNotFoundException e) {
+ throw new FileNotFoundException("Cannot find " + uri);
+ }
+
+ // try to download
+ for (String urlBase : urlBases) {
+ String relativePath = uri.substring(uriPrefix.length());
+ URL url = new URL(urlBase + relativePath);
+ try {
+ return download(url, dir, null);
+ } catch (FileNotFoundException e) {
+ logger.log(Level.WARNING, "Cannot download " + url + ", trying another mirror");
+ }
+ }
+ throw new FileNotFoundException("Cannot find " + uri);
+ }
+
+// protected String simplifyName(URL u) {
+// String name = u.getPath().substring(u.getPath().lastIndexOf('/') + 1);
+//
+// }
+
+ protected Path download(URL url, Path dir, String name) throws IOException {
+
+ Path dest;
+ if (name == null) {
+ name = url.getPath().substring(url.getPath().lastIndexOf('/') + 1);
+ }
+
+ dest = dir.resolve(name);
+ if (Files.exists(dest)) {
+ logger.log(Level.TRACE, () -> "File " + dest + " already exists for " + url + ", not downloading again");
+ return dest;
+ }
+
+ try (InputStream in = url.openStream()) {
+ Files.copy(in, dest);
+ logger.log(Level.DEBUG, () -> "Downloaded " + dest + " from " + url);
+ }
+ return dest;
+ }
+
+ protected Path createJar(Path bundleDir) throws IOException {
+ Path jarPath = bundleDir.getParent().resolve(bundleDir.getFileName() + ".jar");
+ Path manifestPath = bundleDir.resolve("META-INF/MANIFEST.MF");
+ Manifest manifest;
+ try (InputStream in = Files.newInputStream(manifestPath)) {
+ manifest = new Manifest(in);
+ }
+ try (JarOutputStream jarOut = new JarOutputStream(Files.newOutputStream(jarPath), manifest)) {
+ Files.walkFileTree(bundleDir, new SimpleFileVisitor<Path>() {
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ if (file.getFileName().toString().equals("MANIFEST.MF"))
+ return super.visitFile(file, attrs);
+ JarEntry entry = new JarEntry(bundleDir.relativize(file).toString());
+ jarOut.putNextEntry(entry);
+ Files.copy(file, jarOut);
+ return super.visitFile(file, attrs);
+ }
+
+ });
+ }
+ deleteDirectory(bundleDir);
+ return jarPath;
+ }
+
+ public static void main(String[] args) {
+ Path factoryBase = Paths.get("../../output/a2").toAbsolutePath().normalize();
+ A2Factory factory = new A2Factory(factoryBase);
+
+ Path descriptorsBase = Paths.get("../tp").toAbsolutePath().normalize();
+
+// factory.processSingleM2ArtifactDistributionUnit(descriptorsBase.resolve("org.argeo.tp.apache").resolve("org.apache.xml.resolver.bnd"));
+// factory.processM2BasedDistributionUnit(descriptorsBase.resolve("org.argeo.tp.apache/apache-sshd"));
+// factory.processM2BasedDistributionUnit(descriptorsBase.resolve("org.argeo.tp.jetty/jetty"));
+// factory.processM2BasedDistributionUnit(descriptorsBase.resolve("org.argeo.tp.jetty/jetty-websocket"));
+// factory.processCategory(descriptorsBase.resolve("org.argeo.tp.eclipse.rcp"));
+// System.exit(0);
+
+ // Eclipse
+ factory.processEclipseArchive(
+ descriptorsBase.resolve("org.argeo.tp.eclipse.equinox").resolve("eclipse-equinox"));
+ factory.processEclipseArchive(descriptorsBase.resolve("org.argeo.tp.eclipse.rap").resolve("eclipse-rap"));
+ factory.processEclipseArchive(descriptorsBase.resolve("org.argeo.tp.eclipse.rcp").resolve("eclipse-rcp"));
+
+ System.exit(0);
+
+ // Maven
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.sdk"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.apache"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.jetty"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.jcr"));
+ }
+}
--- /dev/null
+package org.argeo.slc.factory.m2;
+
+public interface Artifact {
+ String getGroupId();
+
+ String getArtifactId();
+
+ String getVersion();
+
+ default String getBaseVersion() {
+ return getVersion();
+ }
+
+// boolean isSnapshot();
+
+ default String getClassifier() {
+ return "";
+ }
+
+ default String getExtension() {
+ return "jar";
+ }
+
+}
--- /dev/null
+package org.argeo.slc.factory.m2;
+
+import org.argeo.slc.DefaultCategoryNameVersion;
+
+/**
+ * Simple representation of an M2 artifact, not taking into account classifiers,
+ * types, etc.
+ */
+public class DefaultArtifact extends DefaultCategoryNameVersion implements Artifact {
+ private String classifier;
+
+ public DefaultArtifact(String m2coordinates) {
+ this(m2coordinates, null);
+ }
+
+ public DefaultArtifact(String m2coordinates, String classifier) {
+ String[] parts = m2coordinates.split(":");
+ setCategory(parts[0]);
+ setName(parts[1]);
+ if (parts.length > 2) {
+ setVersion(parts[2]);
+ }
+ this.classifier = classifier;
+ }
+
+ @Override
+ public String getGroupId() {
+ return getCategory();
+ }
+
+ @Override
+ public String getArtifactId() {
+ return getName();
+ }
+
+ public String toM2Coordinates() {
+ return getCategory() + ":" + getName() + (getVersion() != null ? ":" + getVersion() : "");
+ }
+
+ public String getClassifier() {
+ return classifier != null ? classifier : "";
+ }
+
+}
--- /dev/null
+package org.argeo.slc.factory.m2;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Set;
+
+/**
+ * Static utilities around Maven which are NOT using the Maven APIs (conventions
+ * based).
+ */
+public class MavenConventionsUtils {
+ public final static String MAVEN_CENTRAL_BASE_URL = "https://repo1.maven.org/maven2/";
+
+ /**
+ * Path to the file identified by this artifact <b>without</b> using Maven APIs
+ * (convention based). Default location of repository (~/.m2/repository) is used
+ * here.
+ *
+ * @see MavenConventionsUtils#artifactToFile(String, Artifact)
+ */
+ public static File artifactToFile(Artifact artifact) {
+ return artifactToFile(System.getProperty("user.home") + File.separator + ".m2" + File.separator + "repository",
+ artifact);
+ }
+
+ /**
+ * Path to the file identified by this artifact <b>without</b> using Maven APIs
+ * (convention based).
+ *
+ * @param repositoryPath path to the related local repository location
+ * @param 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
+ + 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();
+ }
+
+ /** Absolute path to the file */
+ public static String artifactPath(String artifactBasePath, Artifact 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 file */
+ public static URL mavenCentralUrl(Artifact artifact) {
+ String url = artifactUrl(MAVEN_CENTRAL_BASE_URL, artifact);
+ try {
+ return new URL(url);
+ } catch (MalformedURLException e) {
+ // it should not happen
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /** 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);
+ }
+
+ /** Absolute path to the directory of this group */
+ public static String groupPath(String artifactBasePath, String groupId) {
+ 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();
+ }
+
+ 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("<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("</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("<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("<groupId>").append(a.getGroupId()).append("</groupId>");
+ if (!a.getExtension().equals("jar"))
+ p.append("<type>").append(a.getExtension()).append("</type>");
+ p.append("</dependency>\n");
+ }
+ p.append("</dependencies>\n");
+
+ // Dependency management
+ p.append("<dependencyManagement>\n");
+ p.append("<dependencies>\n");
+ for (Artifact a : artifacts) {
+ p.append("\t<dependency>");
+ 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")) {
+ p.append("<type>").append(a.getExtension()).append("</type>");
+ p.append("<scope>import</scope>");
+ }
+ p.append("</dependency>\n");
+ }
+ p.append("</dependencies>\n");
+ p.append("</dependencyManagement>\n");
+
+ // Repositories
+ // p.append("<repositories>\n");
+ // p.append("<repository><id>argeo</id><url>http://maven.argeo.org/argeo</url></repository>\n");
+ // p.append("</repositories>\n");
+
+ p.append("</project>\n");
+ return p.toString();
+ }
+
+ /** Singleton */
+ private MavenConventionsUtils() {
+ }
+}
+++ /dev/null
-package org.argeo.slc.rpmfactory;
-
-import java.io.File;
-import java.util.List;
-
-import javax.jcr.Node;
-
-/**
- * Defines a build environment. This information is typically used by other
- * components performing the various actions related to RPM build.
- */
-public interface RpmFactory {
- //
- // DIRECT ACTIONS ON JCR REPOSITORY
- //
- public void indexWorkspace(String workspace);
-
- public Node newDistribution(String distributionId);
-
- //
- // CONFIG FILES GENERATION
- //
- /** Creates a mock config file. */
- public File getMockConfigFile(String arch, String branch);
-
- /** Creates a yum config file. */
- public File getYumRepoFile(String arch);
-
- //
- // WORKSPACES
- //
- public String getStagingWorkspace();
-
- /**
- * @return the name of the testing workspace, or null if and only if the
- * testing workspace was not enabled.
- */
- public String getTestingWorkspace();
-
- public String getStableWorkspace();
-
- public File getWorkspaceDir(String workspace);
-
- //
- // ARCH DEPENDENT INFOS
- //
- public List<String> getArchs();
-
- public String getMockConfig(String arch);
-
- public String getIdWithArch(String arch);
-
- public File getResultDir(String arch);
-
- //
- // DEPLOYMENT
- //
- public String getGitBaseUrl();
-
- public Boolean isDeveloperInstance();
-
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory;
-
-import org.argeo.jcr.proxy.ResourceProxy;
-
-/** Marker interface (useful for OSGi services references), may be extended later */
-public interface RpmProxyService extends ResourceProxy {
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory;
-
-/** A YUM compatible repository of RPM packages. */
-public interface RpmRepository {
- public String getId();
-
- public String getUrl();
-
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-import org.argeo.slc.rpmfactory.RpmRepository;
-
-/** Common method to RPM repositories. */
-public abstract class AbstractRpmRepository implements RpmRepository {
- private String id;
- private String url;
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public String getUrl() {
- return url;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.exec.Executor;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.rpmfactory.RpmFactory;
-import org.argeo.slc.runtime.tasks.SystemCall;
-
-/** Build an RPM in mock. */
-public class BuildInMock implements Runnable {
- private final static Log log = LogFactory.getLog(BuildInMock.class);
- private final static String NOARCH = "noarch";
-
- private String rpmPackage = null;
- private String branch = null;
- private String arch = NOARCH;
-
- private RpmFactory rpmFactory;
- private Executor executor;
-
- private String debuginfoDirName = "debuginfo";
- private String mockExecutable = "/usr/bin/mock";
-
- private List<String> preBuildCommands = new ArrayList<String>();
-
- public void run() {
- if (!rpmFactory.isDeveloperInstance()) {
- // clean/init
- SystemCall mockClean = createBaseMockCall();
- mockClean.arg("--init");
- mockClean.run();
- }
-
- // pre build commands
- for (String preBuildCmd : preBuildCommands) {
- SystemCall mockClean = createBaseMockCall();
- mockClean.arg("--chroot").arg(preBuildCmd);
- mockClean.run();
- }
-
- // actual build
- SystemCall mockBuild = createBaseMockCall();
- mockBuild.arg("--scm-enable");
- mockBuild.arg("--scm-option").arg("package=" + rpmPackage);
- mockBuild.arg("--no-clean");
- //
- //
- mockBuild.run();
- //
-
- // copy RPMs to target directories
- File stagingDir = rpmFactory.getWorkspaceDir(rpmFactory
- .getStagingWorkspace());
- File srpmDir = new File(stagingDir, "SRPMS");
- srpmDir.mkdirs();
- File archDir = null;
- File debuginfoDir = null;
- if (!arch.equals(NOARCH)) {
- archDir = new File(stagingDir, arch);
- debuginfoDir = new File(archDir, debuginfoDirName);
- debuginfoDir.mkdirs();
- }
-
- Set<File> reposToRecreate = new HashSet<File>();
- File resultDir = rpmFactory.getResultDir(arch);
- if (resultDir.exists())
- rpms: for (File file : resultDir.listFiles()) {
- if (file.isDirectory())
- continue rpms;
-
- File[] targetDirs;
- if (file.getName().contains(".src.rpm"))
- targetDirs = new File[] { srpmDir };
- else if (file.getName().contains("-debuginfo-"))
- targetDirs = new File[] { debuginfoDir };
- else if (!arch.equals(NOARCH)
- && file.getName().contains("." + arch + ".rpm"))
- targetDirs = new File[] { archDir };
- else if (file.getName().contains(".noarch.rpm")) {
- List<File> dirs = new ArrayList<File>();
- for (String arch : rpmFactory.getArchs())
- dirs.add(new File(stagingDir, arch));
- targetDirs = dirs.toArray(new File[dirs.size()]);
- } else if (file.getName().contains(".rpm"))
- throw new SlcException("Don't know where to copy " + file);
- else {
- if (log.isTraceEnabled())
- log.trace("Skip " + file);
- continue rpms;
- }
-
- reposToRecreate.addAll(Arrays.asList(targetDirs));
- copyToDirs(file, targetDirs);
- }
-
- // recreate changed repos
- for (File repoToRecreate : reposToRecreate) {
- SystemCall createrepo = new SystemCall();
- createrepo.arg("createrepo");
- // sqllite db
- createrepo.arg("-d");
- // debuginfo
- if (!repoToRecreate.getName().equals(debuginfoDirName))
- createrepo.arg("-x").arg(debuginfoDirName + "/*");
- // quiet
- createrepo.arg("-q");
- createrepo.arg(repoToRecreate.getAbsolutePath());
-
- createrepo.setExecutor(executor);
- createrepo.run();
- log.info("Updated repo " + repoToRecreate);
- }
-
- // index staging workspace
- rpmFactory.indexWorkspace(rpmFactory.getStagingWorkspace());
- }
-
- /** Creates a mock call with all the common options such as config file etc. */
- protected SystemCall createBaseMockCall() {
- String mockCfg = rpmFactory.getMockConfig(arch);
- File mockConfigFile = rpmFactory.getMockConfigFile(arch, branch);
-
- // prepare mock call
- SystemCall mock = new SystemCall();
-
- if (arch != null)
- mock.arg("setarch").arg(arch);
- mock.arg(mockExecutable);
- mock.arg("-v");
- mock.arg("--configdir=" + mockConfigFile.getAbsoluteFile().getParent());
- if (arch != null)
- mock.arg("--arch=" + arch);
- mock.arg("-r").arg(mockCfg);
-
- mock.setLogCommand(true);
- mock.setExecutor(executor);
-
- return mock;
- }
-
- protected void copyToDirs(File file, File[] dirs) {
- for (File dir : dirs) {
- try {
- FileUtils.copyFileToDirectory(file, dir);
- if (log.isDebugEnabled())
- log.debug(file + " => " + dir);
- } catch (IOException e) {
- throw new SlcException("Cannot copy " + file + " to " + dir, e);
- }
- }
- }
-
- public void setArch(String arch) {
- this.arch = arch;
- }
-
- public void setRpmPackage(String rpmPackage) {
- this.rpmPackage = rpmPackage;
- }
-
- public void setBranch(String branch) {
- this.branch = branch;
- }
-
- public void setRpmFactory(RpmFactory env) {
- this.rpmFactory = env;
- }
-
- public void setExecutor(Executor executor) {
- this.executor = executor;
- }
-
- public void setMockExecutable(String mockExecutable) {
- this.mockExecutable = mockExecutable;
- }
-
- public void setPreBuildCommands(List<String> preBuildCommands) {
- this.preBuildCommands = preBuildCommands;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.StringTokenizer;
-
-import javax.jcr.Node;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-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.rpmfactory.RpmFactory;
-import org.argeo.slc.runtime.tasks.SystemCall;
-
-/**
- * Gather RPMs from various sources (local builds or third party) into a
- * consistent distributable set (typically to be used to generate an ISO).
- */
-public class CreateRpmDistribution implements Runnable {
- private final static Log log = LogFactory
- .getLog(CreateRpmDistribution.class);
-
- private RpmFactory rpmFactory;
- private RpmDistribution rpmDistribution;
-
- private String arch = "x86_64";
-
- private String repoqueryExecutable = "/usr/bin/repoquery";
-
- @Override
- public void run() {
- Session session = null;
- // Reader reader = null;
- try {
- Node baseFolder = rpmFactory.newDistribution(rpmDistribution
- .getId());
- session = baseFolder.getSession();
- Node targetFolder = baseFolder.addNode(arch, NodeType.NT_FOLDER);
-
- SystemCall repoquery = new SystemCall();
- repoquery.arg(repoqueryExecutable);
-
- File yumConfigFile = rpmFactory.getYumRepoFile(arch);
- repoquery.arg("-c", yumConfigFile.getAbsolutePath());
- repoquery.arg("--requires");
- repoquery.arg("--resolve");
- repoquery.arg("--location");
- repoquery.arg("--archlist=" + arch);
-
- for (String rpmPackage : rpmDistribution.getPackages())
- repoquery.arg(rpmPackage);
-
- if (log.isDebugEnabled())
- log.debug("Command:\n" + repoquery.asCommand());
-
- String output = repoquery.function();
-
- if (log.isDebugEnabled())
- log.debug(output + "\n");
- // reader = new StringReader(output);
- StringTokenizer lines = new StringTokenizer(output, "\n");
- // List<String> dependencies = IOUtils.readLines(reader);
- dependencies: while (lines.hasMoreTokens()) {
- String urlStr = lines.nextToken();
- InputStream in = null;
- try {
- URL url = new URL(urlStr);
- String fileName = FilenameUtils.getName(url.getFile());
- String[] tokens = fileName.split("-");
- if (tokens.length < 3)
- continue dependencies;
- StringBuilder buf = new StringBuilder();
- for (int i = 0; i < tokens.length - 2; i++) {
- if (i != 0)
- buf.append('-');
- buf.append(tokens[i]);
-
- }
- String packageName = buf.toString();
- for (RpmPackageSet excluded : rpmDistribution
- .getExcludedPackages()) {
- if (excluded.contains(packageName)) {
- if (log.isDebugEnabled())
- log.debug("Skipped " + packageName);
- continue dependencies;// skip
- }
- }
- in = url.openStream();
- JcrUtils.copyStreamAsFile(targetFolder, fileName, in);
- targetFolder.getSession().save();
- if (log.isDebugEnabled())
- log.debug("Copied " + packageName);
- } catch (Exception e) {
- log.error("Cannot copy " + urlStr, e);
- } finally {
- IOUtils.closeQuietly(in);
- }
- }
-
- // createrepo
- File workspaceDir = rpmFactory.getWorkspaceDir(rpmDistribution
- .getId());
- SystemCall createrepo = new SystemCall();
- createrepo.arg("createrepo");
- createrepo.arg("-q");
- createrepo.arg("-d");
- File archDir = new File(workspaceDir.getPath()
- + targetFolder.getPath());
- createrepo.arg(archDir.getAbsolutePath());
- createrepo.run();
- } catch (Exception e) {
- throw new SlcException("Cannot generate distribution "
- + rpmDistribution.getId(), e);
- } finally {
- JcrUtils.logoutQuietly(session);
- // IOUtils.closeQuietly(reader);
- }
- }
-
- public void setRpmDistribution(RpmDistribution rpmDistribution) {
- this.rpmDistribution = rpmDistribution;
- }
-
- public void setRpmFactory(RpmFactory rpmFactory) {
- this.rpmFactory = rpmFactory;
- }
-
- public void setArch(String arch) {
- this.arch = arch;
- }
-
- public void setRepoqueryExecutable(String yumdownloaderExecutable) {
- this.repoqueryExecutable = yumdownloaderExecutable;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.exec.Executor;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.rpmfactory.RpmFactory;
-import org.argeo.slc.runtime.tasks.SystemCall;
-
-/** Releases the content of staging to a public repository. */
-public class ReleaseStaging implements Runnable {
- private final static Log log = LogFactory.getLog(ReleaseStaging.class);
-
- private RpmFactory rpmFactory;
- private Executor executor;
-
- private String debuginfoDirName = "debuginfo";
-
- @Override
- public void run() {
- String sourceWorkspace = rpmFactory.getStagingWorkspace();
- File sourceRepoDir = rpmFactory.getWorkspaceDir(sourceWorkspace);
- String targetWorkspace = rpmFactory.getTestingWorkspace() != null ? rpmFactory
- .getTestingWorkspace() : rpmFactory.getStableWorkspace();
- File targetRepoDir = rpmFactory.getWorkspaceDir(targetWorkspace);
- List<File> reposToRecreate = new ArrayList<File>();
-
- stagingChildren: for (File dir : sourceRepoDir.listFiles()) {
- if (!dir.isDirectory())
- continue stagingChildren;
- if (dir.getName().equals("lost+found"))
- continue stagingChildren;
-
- File targetDir = new File(targetRepoDir, dir.getName());
- try {
- FileUtils.copyDirectory(dir, targetDir);
- if (log.isDebugEnabled())
- log.debug(dir + " => " + targetDir);
- } catch (IOException e) {
- throw new SlcException(sourceRepoDir
- + " could not be copied properly, check it manually."
- + " Metadata have NOT been updated.", e);
- }
-
- reposToRecreate.add(dir);
- reposToRecreate.add(targetDir);
- File debugInfoDir = new File(dir, debuginfoDirName);
- if (debugInfoDir.exists())
- reposToRecreate.add(debugInfoDir);
- File targetDebugInfoDir = new File(targetDir, debuginfoDirName);
- if (targetDebugInfoDir.exists())
- reposToRecreate.add(targetDebugInfoDir);
-
- }
-
- // clear staging
- for (File dir : sourceRepoDir.listFiles()) {
- try {
- if (dir.getName().equals("lost+found"))
- continue;
- if (dir.isDirectory())
- FileUtils.deleteDirectory(dir);
- } catch (IOException e) {
- log.error("Could not delete " + dir + ". " + e);
- }
- }
-
- // recreate changed repos
- for (File repoToRecreate : reposToRecreate) {
- repoToRecreate.mkdirs();
- SystemCall createrepo = new SystemCall();
- createrepo.arg("createrepo");
- // sqllite db
- createrepo.arg("-d");
- // debuginfo
- if (!repoToRecreate.getName().equals(debuginfoDirName))
- createrepo.arg("-x").arg(debuginfoDirName + "/*");
- // quiet
- createrepo.arg("-q");
- createrepo.arg(repoToRecreate.getAbsolutePath());
-
- createrepo.setExecutor(executor);
- createrepo.run();
- log.info("Updated repo " + repoToRecreate);
- }
-
- rpmFactory.indexWorkspace(sourceWorkspace);
- rpmFactory.indexWorkspace(targetWorkspace);
- }
-
- public void setRpmFactory(RpmFactory rpmFactory) {
- this.rpmFactory = rpmFactory;
- }
-
- public void setExecutor(Executor executor) {
- this.executor = executor;
- }
-
- public void setDebuginfoDirName(String debuginfoDirName) {
- this.debuginfoDirName = debuginfoDirName;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-import java.util.List;
-
-/** A consistent distributable set of RPM. */
-public class RpmDistribution {
- private String id;
- private List<String> packages;
- private List<RpmPackageSet> excludedPackages;
-
- public List<String> getPackages() {
- return packages;
- }
-
- public void setPackages(List<String> packages) {
- this.packages = packages;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public List<RpmPackageSet> getExcludedPackages() {
- return excludedPackages;
- }
-
- public void setExcludedPackages(List<RpmPackageSet> excludedPackages) {
- this.excludedPackages = excludedPackages;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.NodeIndexerVisitor;
-import org.argeo.slc.repo.RpmIndexer;
-import org.argeo.slc.rpmfactory.RpmFactory;
-import org.argeo.slc.rpmfactory.RpmRepository;
-import org.argeo.slc.runtime.tasks.SystemCall;
-
-/**
- * Defines a build environment. This information is typically used by other
- * components performing the various actions related to RPM build.
- */
-public class RpmFactoryImpl implements RpmFactory {
- private Log log = LogFactory.getLog(RpmFactoryImpl.class);
-
- private Repository rpmRepository;
- private Repository distRepository;
-
- private String id;
- private List<RpmRepository> repositories = new ArrayList<RpmRepository>();
- private List<String> archs = new ArrayList<String>();
-
- private String rpmBase = "/mnt/slc/repos/rpm";
- private String distBase = "/mnt/slc/repos/dist";
- private String mockVar = "/var/lib/mock";
- private String mockEtc = "/etc/mock";
-
- private DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmm");
-
- private String gitWorkspace = "git";
-
- private String localUrlBase = "http://localhost:7070/";
- /** If not null or empty, this is a developer instance. */
- private String gitDevBaseUrl = null;
-
- private Boolean withTestingRepository = false;
-
- private String yumConfigMainSection = "cachedir=/var/cache/yum\n"
- + "debuglevel=1\n" + "reposdir=/dev/null\n"
- + "logfile=/var/log/yum.log\n" + "retries=20\n" + "obsoletes=1\n"
- + "gpgcheck=0\n" + "assumeyes=1\n" + "syslog_ident=mock\n"
- + "syslog_device=\n" + "http_caching=none\n";
-
- private String defaultMacroFiles = "/usr/lib/rpm/macros:"
- + "/usr/lib/rpm/ia32e-linux/macros:"
- + "/usr/lib/rpm/redhat/macros:" + "/etc/rpm/macros.*:"
- + "/etc/rpm/macros:" + "/etc/rpm/ia32e-linux/macros:"
- + "~/.rpmmacros";
- private Map<String, String> rpmmacros = new HashMap<String, String>();
-
- // set by init
- private String proxiedReposBase;
- private String managedReposBase;
-
- private String stagingWorkspace;
- private String testingWorkspace;
- private String stableWorkspace;
-
- private File rpmFactoryBaseDir;
- private File mockConfDir;
- private File yumConfDir;
-
- public void init() {
- // local URL bases
- proxiedReposBase = localUrlBase + "repo/rpm/";
- managedReposBase = localUrlBase + "data/public/rpm/";
-
- // local directories
- rpmFactoryBaseDir.mkdirs();
- mockConfDir = new File(rpmFactoryBaseDir.getPath() + "/conf/mock");
- mockConfDir.mkdirs();
- yumConfDir = new File(rpmFactoryBaseDir.getPath() + "/conf/yum");
- yumConfDir.mkdirs();
-
- // managed repositories
- stagingWorkspace = id + "-staging";
- if (withTestingRepository)
- testingWorkspace = id + "-testing";
- stableWorkspace = id;
-
- initDistWorkspace(stableWorkspace);
- initGitWorkspace();
- initRpmWorkspace(stagingWorkspace);
- if (withTestingRepository)
- initRpmWorkspace(testingWorkspace);
- initRpmWorkspace(stableWorkspace);
- }
-
- protected void initRpmWorkspace(String workspace) {
- Session session = null;
- try {
- session = JcrUtils.loginOrCreateWorkspace(rpmRepository, workspace);
- JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
- JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
- "jcr:all");
-
- for (String arch : archs) {
- Node archFolder = JcrUtils.mkfolders(session, "/" + arch);
- session.save();
- File workspaceDir = getWorkspaceDir(workspace);
- try {
- if (!archFolder.hasNode("repodata")) {
- // touch a file in order to make sure this is properly
- // mounted.
- File touch = new File(workspaceDir, ".touch");
- touch.createNewFile();
- touch.delete();
-
- SystemCall createrepo = new SystemCall();
- createrepo.arg("createrepo");
- createrepo.arg("-q");
- File archDir = new File(workspaceDir, arch);
- createrepo.arg(archDir.getAbsolutePath());
- createrepo.run();
- }
- } catch (IOException e) {
- log.error(workspaceDir + " not properly mounted.", e);
- }
- }
- } catch (Exception e) {
- throw new SlcException("Cannot initialize workspace " + workspace,
- e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- }
-
- /** Caller must logout the underlying session. */
- public Node newDistribution(String distributionId) {
- Session session = null;
- try {
- session = JcrUtils.loginOrCreateWorkspace(rpmRepository,
- distributionId);
- JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
- JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
- "jcr:all");
-
- Calendar now = new GregorianCalendar();
- String folderName = dateFormat.format(now.getTime());
- return JcrUtils.mkfolders(session, "/" + folderName);
- } catch (Exception e) {
- JcrUtils.logoutQuietly(session);
- throw new SlcException("Cannot initialize distribution workspace "
- + distributionId, e);
- }
- }
-
- protected void initGitWorkspace() {
- Session session = null;
- try {
- session = JcrUtils.loginOrCreateWorkspace(rpmRepository,
- gitWorkspace);
- JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
- JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
- "jcr:all");
- } catch (Exception e) {
- throw new SlcException("Cannot initialize workspace "
- + gitWorkspace, e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- }
-
- protected void initDistWorkspace(String workspace) {
- Session session = null;
- try {
- session = JcrUtils
- .loginOrCreateWorkspace(distRepository, workspace);
- JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
- } catch (RepositoryException e) {
- throw new SlcException("Cannot initialize workspace " + workspace,
- e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- }
-
- public void destroy() {
-
- }
-
- public String generateMockConfigFile(String arch, String branch) {
- StringBuffer buf = new StringBuffer();
-
- buf.append("config_opts['root'] = '" + getIdWithArch(arch) + "'\n");
- buf.append("config_opts['target_arch'] = '" + arch + "'\n");
- buf.append("config_opts['legal_host_arches'] = ('" + arch + "',)\n");
- buf.append("config_opts['chroot_setup_cmd'] = 'groupinstall buildsys-build'\n");
- // buf.append("config_opts['dist'] = 'el6'\n");
- buf.append("config_opts['plugin_conf']['yum_cache_enable'] = False\n");
-
- buf.append("config_opts['scm'] = False\n");
- buf.append("config_opts['scm_opts']['method'] = 'git'\n");
- buf.append("config_opts['scm_opts']['spec'] = 'SCM_PKG.spec'\n");
- buf.append("config_opts['scm_opts']['ext_src_dir'] = '"
- + getSourcesDir().getAbsolutePath() + "'\n");
- buf.append("config_opts['scm_opts']['git_timestamps'] = True\n");
-
- // development
- if (gitDevBaseUrl != null && !gitDevBaseUrl.trim().equals(""))
- buf.append("config_opts['scm_opts']['git_get'] = 'git clone "
- + (branch != null ? "-b " + branch : "") + " "
- + gitDevBaseUrl + "/SCM_PKG SCM_PKG'\n");
- else
- buf.append("config_opts['scm_opts']['git_get'] = 'git clone "
- + (branch != null ? "-b " + branch : "") + " "
- + getGitBaseUrl() + "/SCM_PKG.git SCM_PKG'\n");
-
- buf.append("\nconfig_opts['yum.conf'] = \"\"\"\n");
- buf.append(generateYumConfigFile(arch)).append('\n');
- buf.append("\"\"\"\n");
- return buf.toString();
- }
-
- public String generateYumConfigFile(String arch) {
- StringBuffer buf = new StringBuffer();
- buf.append("[main]\n");
- buf.append(yumConfigMainSection).append('\n');
-
- for (RpmRepository repository : repositories) {
- buf.append('[').append(repository.getId()).append("]\n");
- buf.append("name=").append(repository.getId()).append('\n');
- if (repository instanceof ThirdPartyRpmRepository) {
- buf.append("#baseurl=").append(repository.getUrl())
- .append(arch).append('/').append("\n");
- buf.append("baseurl=").append(proxiedReposBase)
- .append(repository.getId()).append('/').append(arch)
- .append('/').append("\n");
- if (((ThirdPartyRpmRepository) repository).getYumConf() != null)
- buf.append(
- ((ThirdPartyRpmRepository) repository).getYumConf()
- .trim()).append('\n');
- }
- }
-
- // managed repos
- addManagedRepository(buf, stagingWorkspace, arch);
- if (withTestingRepository)
- addManagedRepository(buf, testingWorkspace, arch);
- addManagedRepository(buf, stableWorkspace, arch);
- return buf.toString();
- }
-
- protected void addManagedRepository(StringBuffer buf, String workspace,
- String arch) {
- buf.append('[').append(workspace).append("]\n");
- buf.append("baseurl=").append(managedReposBase).append(workspace)
- .append('/').append(arch).append('/').append("\n");
- buf.append("gpgcheck=0").append("\n");
- }
-
- /** Creates a mock config file. */
- public File getMockConfigFile(String arch, String branch) {
- File mockSiteDefaultsFile = new File(mockConfDir, "site-defaults.cfg");
- File mockLoggingFile = new File(mockConfDir, "logging.ini");
- File mockConfigFile = new File(mockConfDir, getIdWithArch(arch)
- + ".cfg");
- try {
- if (!mockSiteDefaultsFile.exists())
- mockSiteDefaultsFile.createNewFile();
- if (!mockLoggingFile.exists())
- FileUtils.copyFile(new File(mockEtc + "/logging.ini"),
- mockLoggingFile);
-
- FileUtils.writeStringToFile(mockConfigFile,
- generateMockConfigFile(arch, branch));
- return mockConfigFile;
- } catch (IOException e) {
- throw new SlcException("Cannot write mock config file to "
- + mockConfigFile, e);
- }
- }
-
- /** Creates a yum config file. */
- public File getYumRepoFile(String arch) {
- File yumConfigFile = new File(yumConfDir, getIdWithArch(arch) + ".repo");
- try {
- FileUtils.writeStringToFile(yumConfigFile,
- generateYumConfigFile(arch));
- return yumConfigFile;
- } catch (IOException e) {
- throw new SlcException("Cannot write yum config file to "
- + yumConfigFile, e);
- }
- }
-
- public File getResultDir(String arch) {
- return new File(mockVar + "/" + getIdWithArch(arch) + "/result");
- }
-
- public File getWorkspaceDir(String workspace) {
- return new File(rpmBase + "/" + workspace);
- }
-
- public File getSourcesDir() {
- return new File(distBase + "/" + stableWorkspace);
- }
-
- public String getMockConfig(String arch) {
- return getIdWithArch(arch);
- }
-
- public String getIdWithArch(String arch) {
- return id + "-" + arch;
- }
-
- public String getGitBaseUrl() {
- return managedReposBase + gitWorkspace;
- }
-
- public void indexWorkspace(String workspace) {
- Session session = null;
- try {
- session = rpmRepository.login(workspace);
- session.getRootNode().accept(
- new NodeIndexerVisitor(new RpmIndexer()));
- if (log.isDebugEnabled())
- log.debug("Indexed workspace " + workspace);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot index workspace " + workspace, e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
- }
-
- public Boolean isDeveloperInstance() {
- return gitDevBaseUrl != null;
- }
-
- /** Write (topdir)/rpmmacros and (topdir)/rpmrc */
- public void writeRpmbuildConfigFiles(File topdir) {
- writeRpmbuildConfigFiles(topdir, new File(topdir, "rpmmacros"),
- new File(topdir, "rpmrc"));
- }
-
- public void writeRpmbuildConfigFiles(File topdir, File rpmmacroFile,
- File rpmrcFile) {
- try {
- List<String> macroLines = new ArrayList<String>();
- macroLines.add("%_topdir " + topdir.getCanonicalPath());
- for (String macroKey : rpmmacros.keySet()) {
- macroLines.add(macroKey + " " + rpmmacros.get(macroKey));
- }
- FileUtils.writeLines(rpmmacroFile, macroLines);
-
- List<String> rpmrcLines = new ArrayList<String>();
- rpmrcLines.add("include: /usr/lib/rpm/rpmrc");
- rpmrcLines.add("macrofiles: " + defaultMacroFiles + ":"
- + rpmmacroFile.getCanonicalPath());
- FileUtils.writeLines(rpmrcFile, rpmrcLines);
- } catch (IOException e) {
- throw new SlcException("Cannot write rpmbuild config files", e);
- }
-
- }
-
- public Map<String, String> getRpmmacros() {
- return rpmmacros;
- }
-
- public void setRpmmacros(Map<String, String> rpmmacros) {
- this.rpmmacros = rpmmacros;
- }
-
- public String getDefaultMacroFiles() {
- return defaultMacroFiles;
- }
-
- public void setDefaultMacroFiles(String defaultMacroFiles) {
- this.defaultMacroFiles = defaultMacroFiles;
- }
-
- public void setArchs(List<String> archs) {
- this.archs = archs;
- }
-
- public List<String> getArchs() {
- return archs;
- }
-
- public void setRpmBase(String stagingBase) {
- this.rpmBase = stagingBase;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public void setMockVar(String mockVar) {
- this.mockVar = mockVar;
- }
-
- public void setRpmRepository(Repository rpmRepository) {
- this.rpmRepository = rpmRepository;
- }
-
- public void setDistRepository(Repository distRepository) {
- this.distRepository = distRepository;
- }
-
- public void setLocalUrlBase(String localUrlBase) {
- this.localUrlBase = localUrlBase;
- }
-
- public void setYumConfigMainSection(String yumConfigMainSection) {
- this.yumConfigMainSection = yumConfigMainSection;
- }
-
- public void setRepositories(List<RpmRepository> repositories) {
- this.repositories = repositories;
- }
-
- public void setRpmFactoryBaseDir(File rpmFactoryBaseDir) {
- this.rpmFactoryBaseDir = rpmFactoryBaseDir;
- }
-
- public String getStagingWorkspace() {
- return stagingWorkspace;
- }
-
- public String getTestingWorkspace() {
- return testingWorkspace;
- }
-
- public String getStableWorkspace() {
- return stableWorkspace;
- }
-
- public void setWithTestingRepository(Boolean withTestingRepository) {
- this.withTestingRepository = withTestingRepository;
- }
-
- public void setGitDevBaseUrl(String gitBaseUrl) {
- this.gitDevBaseUrl = gitBaseUrl;
- }
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-/** Set of RPM packages */
-public interface RpmPackageSet {
- public Boolean contains(String rpmPackage);
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.security.AccessControlException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.jcr.proxy.AbstractUrlProxy;
-import org.argeo.slc.SlcConstants;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.argeo.slc.repo.RepoConstants;
-import org.argeo.slc.rpmfactory.RpmProxyService;
-import org.argeo.slc.rpmfactory.RpmRepository;
-
-/** Synchronises the node repository with remote Maven repositories */
-public class RpmProxyServiceImpl extends AbstractUrlProxy implements
- RpmProxyService, ArgeoNames, SlcNames {
- private final static Log log = LogFactory.getLog(RpmProxyServiceImpl.class);
-
- private Set<RpmRepository> defaultRepositories = new HashSet<RpmRepository>();
-
- @Override
- protected void beforeInitSessionSave(Session session)
- throws RepositoryException {
- JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
- try {
- JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
- "jcr:all");
- } catch (AccessControlException e) {
- if (log.isTraceEnabled())
- log.trace("Cannot give jcr:all privileges to "+SlcConstants.ROLE_SLC);
- }
-
- JcrUtils.mkdirsSafe(session, RepoConstants.PROXIED_REPOSITORIES);
- }
-
- /**
- * Retrieve and add this file to the repository
- */
- @Override
- protected Node retrieve(Session session, String path) {
- StringBuilder relativePathBuilder = new StringBuilder();
- String repoId = extractRepoId(path, relativePathBuilder);
- // remove starting '/'
- String relativePath = relativePathBuilder.toString().substring(1);
-
- RpmRepository sourceRepo = null;
- for (Iterator<RpmRepository> reposIt = defaultRepositories.iterator(); reposIt
- .hasNext();) {
- RpmRepository rpmRepo = reposIt.next();
- if (rpmRepo.getId().equals(repoId)) {
- sourceRepo = rpmRepo;
- break;
- }
- }
-
- if (sourceRepo == null)
- throw new SlcException("No RPM repository found for " + path);
-
- try {
- String baseUrl = sourceRepo.getUrl();
- String remoteUrl = baseUrl + relativePath;
- Node node = proxyUrl(session, remoteUrl, path);
- if (node != null) {
- registerSource(sourceRepo, node, remoteUrl);
- if (log.isDebugEnabled())
- log.debug("Imported " + remoteUrl + " to " + node);
- return node;
- }
- } catch (Exception e) {
- throw new SlcException("Cannot proxy " + path, e);
- }
- JcrUtils.discardQuietly(session);
- throw new SlcException("No proxy found for " + path);
- }
-
- protected void registerSource(RpmRepository sourceRepo, Node node,
- String remoteUrl) throws RepositoryException {
- node.addMixin(SlcTypes.SLC_KNOWN_ORIGIN);
- Node origin;
- if (!node.hasNode(SLC_ORIGIN))
- origin = node.addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
- else
- origin = node.getNode(SLC_ORIGIN);
-
- // proxied repository
- Node proxiedRepository;
- String proxiedRepositoryPath = RepoConstants.PROXIED_REPOSITORIES + '/'
- + sourceRepo.getId();
- Session session = node.getSession();
- if (session.itemExists(proxiedRepositoryPath)) {
- proxiedRepository = session.getNode(proxiedRepositoryPath);
- } else {
- proxiedRepository = session.getNode(
- RepoConstants.PROXIED_REPOSITORIES).addNode(
- sourceRepo.getId());
- proxiedRepository.addMixin(NodeType.MIX_REFERENCEABLE);
- JcrUtils.urlToAddressProperties(proxiedRepository,
- sourceRepo.getUrl());
- proxiedRepository.setProperty(SLC_URL, sourceRepo.getUrl());
- }
-
- origin.setProperty(SLC_PROXY, proxiedRepository);
- JcrUtils.urlToAddressProperties(origin, remoteUrl);
- }
-
- /** Returns the first token of the path */
- protected String extractRepoId(String path, StringBuilder relativePath) {
- StringBuilder workspace = new StringBuilder();
- StringBuilder buf = workspace;
- for (int i = 1; i < path.length(); i++) {
- char c = path.charAt(i);
- if (c == '/') {
- buf = relativePath;
- }
- buf.append(c);
- }
- return workspace.toString();
- }
-
- @Override
- protected Boolean shouldUpdate(Session clientSession, String nodePath) {
- // if (nodePath.contains("/repodata/"))
- // return true;
- return super.shouldUpdate(clientSession, nodePath);
- }
-
- public void setDefaultRepositories(Set<RpmRepository> defaultRepositories) {
- this.defaultRepositories = defaultRepositories;
- }
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class RpmSpecFile {
- private Path specFile;
-
- private String name;
- private String version;
- private String release;
- private Map<String, String> sources = new HashMap<String, String>();
- private Map<String, String> patches = new HashMap<String, String>();
-
- public RpmSpecFile(Path specFile) {
- this.specFile = specFile;
- parseSpecFile();
- }
-
- public void init() {
- parseSpecFile();
- }
-
- protected void parseSpecFile() {
- try {
- List<String> lines = (List<String>) Files.readAllLines(specFile);
-
- lines: for (String line : lines) {
- int indexSemiColon = line.indexOf(':');
- if (indexSemiColon <= 0)
- continue lines;
- String directive = line.substring(0, indexSemiColon).trim();
- String value = line.substring(indexSemiColon + 1).trim();
- if ("name".equals(directive.toLowerCase()))
- name = value;
- else if ("version".equals(directive.toLowerCase()))
- version = value;
- else if ("release".equals(directive.toLowerCase()))
- release = value;
- else if (directive.toLowerCase().startsWith("source"))
- sources.put(directive, interpret(value));
- else if (directive.toLowerCase().startsWith("patch"))
- patches.put(directive, interpret(value));
- }
-
- } catch (IOException e) {
- throw new RuntimeException("Cannot parse spec file " + specFile, e);
- }
- }
-
- protected String interpret(String value) {
- StringBuffer buf = new StringBuffer(value.length());
- StringBuffer currKey = null;
- boolean mayBeKey = false;
- chars: for (char c : value.toCharArray()) {
- if (c == '%')
- mayBeKey = true;
- else if (c == '{') {
- if (mayBeKey)
- currKey = new StringBuffer();
- } else if (c == '}') {
- if (currKey == null)
- continue chars;
- String key = currKey.toString();
- if ("name".equals(key.toLowerCase()))
- buf.append(name);
- else if ("version".equals(key.toLowerCase()))
- buf.append(version);
- else
- buf.append("%{").append(key).append('}');
- currKey = null;
- } else {
- if (currKey != null)
- currKey.append(c);
- else
- buf.append(c);
- }
- }
- return buf.toString();
- }
-
- public Path getSpecFile() {
- return specFile;
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getRelease() {
- return release;
- }
-
- public Map<String, String> getSources() {
- return sources;
- }
-
- public Map<String, String> getPatches() {
- return patches;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-/** Local build repository, used only for builds. */
-public class StagingRpmRepository extends AbstractRpmRepository {
-
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-/**
- * A repository of third party RPMs used for the build. RPM used by the builds
- * will be cached within the system.
- */
-public class ThirdPartyRpmRepository extends AbstractRpmRepository {
- private String yumConf;
-
- public String getYumConf() {
- return yumConf;
- }
-
- public void setYumConf(String yumConf) {
- this.yumConf = yumConf;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.rpmfactory.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.LineIterator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.SlcException;
-
-/**
- * Reads the output of a 'yum list all' command and interpret the list of
- * packages.
- */
-public class YumListParser implements RpmPackageSet {
- private final static Log log = LogFactory.getLog(YumListParser.class);
-
- private Set<String> installed = new TreeSet<String>();
- /** Not installed but available */
- private Set<String> installable = new TreeSet<String>();
-
- private Path yumListOutput;
-
- public void init() {
- if (yumListOutput != null) {
- try (InputStream in = Files.newInputStream(yumListOutput)) {
- load(in);
- if (log.isDebugEnabled())
- log.debug(installed.size() + " installed, " + installable.size() + " installable, from "
- + yumListOutput);
- } catch (IOException e) {
- throw new SlcException("Cannot initialize yum list parser", e);
- }
- }
- }
-
- public Boolean contains(String packageName) {
- if (installed.contains(packageName))
- return true;
- else
- return installable.contains(packageName);
- }
-
- protected void load(InputStream in) throws IOException {
- Boolean readingInstalled = false;
- Boolean readingAvailable = false;
- LineIterator it = IOUtils.lineIterator(in, "UTF-8");
- while (it.hasNext()) {
- String line = it.nextLine();
- if (line.trim().equals("Installed Packages")) {
- readingInstalled = true;
- } else if (line.trim().equals("Available Packages")) {
- readingAvailable = true;
- readingInstalled = false;
- } else if (readingAvailable) {
- if (Character.isLetterOrDigit(line.charAt(0))) {
- installable.add(extractRpmName(line));
- }
- } else if (readingInstalled) {
- if (Character.isLetterOrDigit(line.charAt(0))) {
- installed.add(extractRpmName(line));
- }
- }
- }
- }
-
- protected String extractRpmName(String line) {
- StringTokenizer st = new StringTokenizer(line, " \t");
- String packageName = st.nextToken();
- // consider the arch as an extension
- return FilenameUtils.getBaseName(packageName);
- // return packageName.split("\\.")[0];
- }
-
- public Set<String> getInstalled() {
- return installed;
- }
-
- public Set<String> getInstallable() {
- return installable;
- }
-
- public void setYumListOutput(Path yumListOutput) {
- this.yumListOutput = yumListOutput;
- }
-
-}
Import-Package: javax.jcr.nodetype,\
javax.jcr.security,\
+org.apache.jackrabbit.api;version="[1,4)",\
+org.apache.jackrabbit.commons;version="[1,4)",\
+org.apache.jackrabbit.*;version="[1,4)",\
*
\ No newline at end of file
output.. = bin/
bin.includes = META-INF/,\
.
+additional.bundles = org.junit,\
+ org.hamcrest,\
+ org.apache.jackrabbit.core,\
+ javax.jcr,\
+ org.apache.jackrabbit.api,\
+ org.apache.jackrabbit.data,\
+ org.apache.jackrabbit.jcr.commons,\
+ org.apache.jackrabbit.spi,\
+ org.apache.jackrabbit.spi.commons,\
+ org.slf4j.api,\
+ org.apache.commons.collections,\
+ EDU.oswego.cs.dl.util.concurrent,\
+ org.apache.lucene,\
+ org.apache.tika.core,\
+ org.apache.commons.dbcp,\
+ org.apache.jackrabbit.jcr2spi,\
+ org.apache.jackrabbit.spi2dav,\
+ org.apache.httpcomponents.httpclient,\
+ org.apache.httpcomponents.httpcore,\
+ org.apache.tika.parsers
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.jcr</artifactId>
- <name>SLC JCR implementations</name>
- <dependencies>
- <!-- SLC -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.api</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.runtime</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- Commons -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.enterprise</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.api</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.cms</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.jcr</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- </dependencies>
-</project>
\ No newline at end of file
--- /dev/null
+package org.argeo.cli.jcr;
+
+import org.argeo.slc.cli.CommandsCli;
+
+/** File utilities. */
+public class JcrCommands extends CommandsCli {
+
+ public JcrCommands(String commandName) {
+ super(commandName);
+ addCommand("sync", new JcrSync());
+ }
+
+ @Override
+ public String getDescription() {
+ return "Utilities around remote and local JCR repositories";
+ }
+
+}
--- /dev/null
+package org.argeo.cli.jcr;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.argeo.jackrabbit.client.ClientDavexRepositoryFactory;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.cli.CommandArgsException;
+import org.argeo.slc.cli.CommandRuntimeException;
+import org.argeo.slc.cli.DescribedCommand;
+import org.argeo.slc.sync.SyncResult;
+
+public class JcrSync implements DescribedCommand<SyncResult<Node>> {
+ public final static String DEFAULT_LOCALFS_CONFIG = "repository-localfs.xml";
+
+ final static Option deleteOption = Option.builder().longOpt("delete").desc("delete from target").build();
+ final static Option recursiveOption = Option.builder("r").longOpt("recursive").desc("recurse into directories")
+ .build();
+ final static Option progressOption = Option.builder().longOpt("progress").hasArg(false).desc("show progress")
+ .build();
+
+ @Override
+ public SyncResult<Node> apply(List<String> t) {
+ try {
+ CommandLine line = toCommandLine(t);
+ List<String> remaining = line.getArgList();
+ if (remaining.size() == 0) {
+ throw new CommandArgsException("There must be at least one argument");
+ }
+ URI sourceUri = new URI(remaining.get(0));
+ URI targetUri;
+ if (remaining.size() == 1) {
+ targetUri = Paths.get(System.getProperty("user.dir")).toUri();
+ } else {
+ targetUri = new URI(remaining.get(1));
+ }
+ boolean delete = line.hasOption(deleteOption.getLongOpt());
+ boolean recursive = line.hasOption(recursiveOption.getLongOpt());
+
+ // TODO make it configurable
+ String sourceWorkspace = "home";
+ String targetWorkspace = sourceWorkspace;
+
+ final Repository sourceRepository;
+ final Session sourceSession;
+ Credentials sourceCredentials = null;
+ final Repository targetRepository;
+ final Session targetSession;
+ Credentials targetCredentials = null;
+
+ if ("http".equals(sourceUri.getScheme()) || "https".equals(sourceUri.getScheme())) {
+ sourceRepository = createRemoteRepository(sourceUri);
+ } else if (null == sourceUri.getScheme() || "file".equals(sourceUri.getScheme())) {
+ RepositoryConfig repositoryConfig = RepositoryConfig.create(
+ JcrSync.class.getResourceAsStream(DEFAULT_LOCALFS_CONFIG), sourceUri.getPath().toString());
+ sourceRepository = RepositoryImpl.create(repositoryConfig);
+ sourceCredentials = new SimpleCredentials("admin", "admin".toCharArray());
+ } else {
+ throw new IllegalArgumentException("Unsupported scheme " + sourceUri.getScheme());
+ }
+ sourceSession = JcrUtils.loginOrCreateWorkspace(sourceRepository, sourceWorkspace, sourceCredentials);
+
+ if ("http".equals(targetUri.getScheme()) || "https".equals(targetUri.getScheme())) {
+ targetRepository = createRemoteRepository(targetUri);
+ } else if (null == targetUri.getScheme() || "file".equals(targetUri.getScheme())) {
+ RepositoryConfig repositoryConfig = RepositoryConfig.create(
+ JcrSync.class.getResourceAsStream(DEFAULT_LOCALFS_CONFIG), targetUri.getPath().toString());
+ targetRepository = RepositoryImpl.create(repositoryConfig);
+ targetCredentials = new SimpleCredentials("admin", "admin".toCharArray());
+ } else {
+ throw new IllegalArgumentException("Unsupported scheme " + targetUri.getScheme());
+ }
+ targetSession = JcrUtils.loginOrCreateWorkspace(targetRepository, targetWorkspace, targetCredentials);
+
+ JcrUtils.copy(sourceSession.getRootNode(), targetSession.getRootNode());
+ return new SyncResult<Node>();
+ } catch (URISyntaxException e) {
+ throw new CommandArgsException(e);
+ } catch (Exception e) {
+ throw new CommandRuntimeException(e, this, t);
+ }
+ }
+
+ protected Repository createRemoteRepository(URI uri) throws RepositoryException {
+ RepositoryFactory repositoryFactory = new ClientDavexRepositoryFactory();
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(ClientDavexRepositoryFactory.JACKRABBIT_DAVEX_URI, uri.toString());
+ // FIXME make it configurable
+ params.put(ClientDavexRepositoryFactory.JACKRABBIT_REMOTE_DEFAULT_WORKSPACE, "sys");
+ return repositoryFactory.getRepository(params);
+ }
+
+ @Override
+ public Options getOptions() {
+ Options options = new Options();
+ options.addOption(recursiveOption);
+ options.addOption(deleteOption);
+ options.addOption(progressOption);
+ return options;
+ }
+
+ @Override
+ public String getUsage() {
+ return "[source URI] [target URI]";
+ }
+
+ public static void main(String[] args) {
+ DescribedCommand.mainImpl(new JcrSync(), args);
+ }
+
+ @Override
+ public String getDescription() {
+ return "Synchronises JCR repositories";
+ }
+
+}
--- /dev/null
+/** JCR CLI commands. */
+package org.argeo.cli.jcr;
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<!--
+
+ Copyright (C) 2007-2012 Argeo GmbH
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.6//EN"
+ "http://jackrabbit.apache.org/dtd/repository-2.0.dtd">
+<Repository>
+ <!-- File system and datastore -->
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/repository" />
+ </FileSystem>
+ <DataStore class="org.apache.jackrabbit.core.data.FileDataStore">
+ <param name="path" value="${rep.home}/datastore" />
+ </DataStore>
+
+ <!-- Workspace templates -->
+ <Workspaces rootPath="${rep.home}/workspaces"
+ defaultWorkspace="main" configRootPath="/workspaces" />
+ <Workspace name="${wsp.name}">
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${wsp.home}" />
+ </FileSystem>
+ <PersistenceManager
+ class="org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager">
+ <param name="blobFSBlockSize" value="1" />
+ </PersistenceManager>
+ <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${rep.home}/repository/index" />
+ </SearchIndex>
+ </Workspace>
+
+ <!-- Versioning -->
+ <Versioning rootPath="${rep.home}/version">
+ <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+ <param name="path" value="${rep.home}/version" />
+ </FileSystem>
+ <PersistenceManager
+ class="org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager">
+ <param name="blobFSBlockSize" value="1" />
+ </PersistenceManager>
+ </Versioning>
+
+ <!-- Indexing -->
+ <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+ <param name="path" value="${rep.home}/repository/index" />
+ <param name="tikaConfigPath" value="tika-config.xml"/>
+ </SearchIndex>
+
+ <!-- Security -->
+ <Security appName="Jackrabbit">
+ <SecurityManager
+ class="org.apache.jackrabbit.core.security.simple.SimpleSecurityManager"
+ workspaceName="security" />
+ <AccessManager
+ class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager" />
+ <LoginModule
+ class="org.apache.jackrabbit.core.security.simple.SimpleLoginModule">
+ <param name="anonymousId" value="anonymous" />
+ <param name="adminId" value="admin" />
+ </LoginModule>
+ </Security>
+</Repository>
\ No newline at end of file
import javax.jcr.Node;
import javax.jcr.RepositoryException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.SlcNames;
* itself if metadata node name is set to null)
*/
public class JcrMetadataWriter implements Runnable {
- private final static Log log = LogFactory.getLog(JcrMetadataWriter.class);
+ private final static CmsLog log = CmsLog.getLog(JcrMetadataWriter.class);
private Node baseNode;
private String metadataNodeName = SlcNames.SLC_METADATA;
try {
Node metadataNode;
if (metadataNodeName != null)
- metadataNode = baseNode.hasNode(metadataNodeName) ? baseNode
- .getNode(metadataNodeName) : baseNode
- .addNode(metadataNodeName);
+ metadataNode = baseNode.hasNode(metadataNodeName) ? baseNode.getNode(metadataNodeName)
+ : baseNode.addNode(metadataNodeName);
else
metadataNode = baseNode;
baseNode.getSession().save();
if (log.isDebugEnabled())
- log.debug("Wrote " + metadata.size() + " metadata entries to "
- + metadataNode);
+ log.debug("Wrote " + metadata.size() + " metadata entries to " + metadataNode);
} catch (RepositoryException e) {
throw new SlcException("Cannot write metadata to " + baseNode, e);
} finally {
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.SlcNames;
* {@link SlcTypes#SLC_TEST_RESULT}.
*/
public class JcrTestResult implements TestResult, SlcNames, AttachmentsEnabled {
- private final static Log log = LogFactory.getLog(JcrTestResult.class);
+ private final static CmsLog log = CmsLog.getLog(JcrTestResult.class);
/** Should only be set for an already existing result. */
private String uuid;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
-import org.argeo.api.NodeUtils;
+import org.argeo.cms.jcr.CmsJcrUtils;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.SlcNames;
*/
public static String getSlcResultsBasePath(Session session) {
try {
- Node userHome = NodeUtils.getUserHome(session);
+ Node userHome = CmsJcrUtils.getUserHome(session);
if (userHome == null)
throw new SlcException("No user home available for "
+ session.getUserID());
*/
public static String getMyResultsBasePath(Session session) {
try {
- Node userHome = NodeUtils.getUserHome(session);
+ Node userHome = CmsJcrUtils.getUserHome(session);
if (userHome == null)
throw new SlcException("No user home available for "
+ session.getUserID());
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
-import org.argeo.api.NodeUtils;
+import org.argeo.cms.jcr.CmsJcrUtils;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.DefaultNameVersion;
import org.argeo.slc.NameVersion;
/** Get the base for the user processi. */
public static String getSlcProcessesBasePath(Session session) {
try {
- Node userHome = NodeUtils.getUserHome(session);
+ Node userHome = CmsJcrUtils.getUserHome(session);
if (userHome == null)
throw new SlcException("No user home available for "
+ session.getUserID());
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.SlcNames;
* Synchronizes the local execution runtime with a JCR repository. For the time
* being the state is completely reset from one start to another.
*/
-public class JcrExecutionModulesListener implements ExecutionModulesListener,
- SlcNames {
+public class JcrExecutionModulesListener implements ExecutionModulesListener, SlcNames {
private final static String SLC_EXECUTION_MODULES_PROPERTY = "slc.executionModules";
- private final static Log log = LogFactory
- .getLog(JcrExecutionModulesListener.class);
+ private final static CmsLog log = CmsLog.getLog(JcrExecutionModulesListener.class);
private JcrAgent agent;
private ExecutionModulesManager modulesManager;
private Repository repository;
/**
- * We don't use a thread bound session because many different threads will
- * call this critical component and we don't want to login each time. We
- * therefore rather protect access to this session via synchronized.
+ * We don't use a thread bound session because many different threads will call
+ * this critical component and we don't want to login each time. We therefore
+ * rather protect access to this session via synchronized.
*/
private Session session;
if (modulesManager != null) {
Node agentNode = session.getNode(agent.getNodePath());
- List<ModuleDescriptor> moduleDescriptors = modulesManager
- .listModules();
+ List<ModuleDescriptor> moduleDescriptors = modulesManager.listModules();
// scan SLC-ExecutionModule metadata
for (ModuleDescriptor md : moduleDescriptors) {
- if (md.getMetadata().containsKey(
- ExecutionModuleDescriptor.SLC_EXECUTION_MODULE)) {
- String moduleNodeName = SlcJcrUtils
- .getModuleNodeName(md);
- Node moduleNode = agentNode.hasNode(moduleNodeName) ? agentNode
- .getNode(moduleNodeName) : agentNode
- .addNode(moduleNodeName);
+ if (md.getMetadata().containsKey(ExecutionModuleDescriptor.SLC_EXECUTION_MODULE)) {
+ String moduleNodeName = SlcJcrUtils.getModuleNodeName(md);
+ Node moduleNode = agentNode.hasNode(moduleNodeName) ? agentNode.getNode(moduleNodeName)
+ : agentNode.addNode(moduleNodeName);
moduleNode.addMixin(SlcTypes.SLC_EXECUTION_MODULE);
moduleNode.setProperty(SLC_NAME, md.getName());
moduleNode.setProperty(SLC_VERSION, md.getVersion());
- moduleNode.setProperty(Property.JCR_TITLE,
- md.getTitle());
- moduleNode.setProperty(Property.JCR_DESCRIPTION,
- md.getDescription());
+ moduleNode.setProperty(Property.JCR_TITLE, md.getTitle());
+ moduleNode.setProperty(Property.JCR_DESCRIPTION, md.getDescription());
moduleNode.setProperty(SLC_STARTED, md.getStarted());
}
}
// scan execution modules property
- String executionModules = System
- .getProperty(SLC_EXECUTION_MODULES_PROPERTY);
+ String executionModules = System.getProperty(SLC_EXECUTION_MODULES_PROPERTY);
if (executionModules != null) {
for (String executionModule : executionModules.split(",")) {
allModules: for (ModuleDescriptor md : moduleDescriptors) {
- String moduleNodeName = SlcJcrUtils
- .getModuleNodeName(md);
+ String moduleNodeName = SlcJcrUtils.getModuleNodeName(md);
if (md.getName().equals(executionModule)) {
- Node moduleNode = agentNode
- .hasNode(moduleNodeName) ? agentNode
- .getNode(moduleNodeName) : agentNode
- .addNode(moduleNodeName);
- moduleNode
- .addMixin(SlcTypes.SLC_EXECUTION_MODULE);
+ Node moduleNode = agentNode.hasNode(moduleNodeName) ? agentNode.getNode(moduleNodeName)
+ : agentNode.addNode(moduleNodeName);
+ moduleNode.addMixin(SlcTypes.SLC_EXECUTION_MODULE);
moduleNode.setProperty(SLC_NAME, md.getName());
- moduleNode.setProperty(SLC_VERSION,
- md.getVersion());
- moduleNode.setProperty(Property.JCR_TITLE,
- md.getTitle());
- moduleNode.setProperty(
- Property.JCR_DESCRIPTION,
- md.getDescription());
- moduleNode.setProperty(SLC_STARTED,
- md.getStarted());
+ moduleNode.setProperty(SLC_VERSION, md.getVersion());
+ moduleNode.setProperty(Property.JCR_TITLE, md.getTitle());
+ moduleNode.setProperty(Property.JCR_DESCRIPTION, md.getDescription());
+ moduleNode.setProperty(SLC_STARTED, md.getStarted());
break allModules;
}
}
* EXECUTION MODULES LISTENER
*/
- public synchronized void executionModuleAdded(
- ModuleDescriptor moduleDescriptor) {
+ public synchronized void executionModuleAdded(ModuleDescriptor moduleDescriptor) {
syncExecutionModule(moduleDescriptor);
}
protected void syncExecutionModule(ModuleDescriptor moduleDescriptor) {
try {
Node agentNode = session.getNode(agent.getNodePath());
- String moduleNodeName = SlcJcrUtils
- .getModuleNodeName(moduleDescriptor);
- Node moduleNode = agentNode.hasNode(moduleNodeName) ? agentNode
- .getNode(moduleNodeName) : agentNode
- .addNode(moduleNodeName);
+ String moduleNodeName = SlcJcrUtils.getModuleNodeName(moduleDescriptor);
+ Node moduleNode = agentNode.hasNode(moduleNodeName) ? agentNode.getNode(moduleNodeName)
+ : agentNode.addNode(moduleNodeName);
moduleNode.addMixin(SlcTypes.SLC_EXECUTION_MODULE);
moduleNode.setProperty(SLC_NAME, moduleDescriptor.getName());
moduleNode.setProperty(SLC_VERSION, moduleDescriptor.getVersion());
- moduleNode.setProperty(Property.JCR_TITLE,
- moduleDescriptor.getTitle());
- moduleNode.setProperty(Property.JCR_DESCRIPTION,
- moduleDescriptor.getDescription());
+ moduleNode.setProperty(Property.JCR_TITLE, moduleDescriptor.getTitle());
+ moduleNode.setProperty(Property.JCR_DESCRIPTION, moduleDescriptor.getDescription());
moduleNode.setProperty(SLC_STARTED, moduleDescriptor.getStarted());
session.save();
} catch (RepositoryException e) {
}
}
- public synchronized void executionModuleRemoved(
- ModuleDescriptor moduleDescriptor) {
+ public synchronized void executionModuleRemoved(ModuleDescriptor moduleDescriptor) {
try {
String moduleName = SlcJcrUtils.getModuleNodeName(moduleDescriptor);
Node agentNode = session.getNode(agent.getNodePath());
session.save();
} catch (RepositoryException e) {
JcrUtils.discardQuietly(session);
- throw new SlcException("Cannot remove module " + moduleDescriptor,
- e);
+ throw new SlcException("Cannot remove module " + moduleDescriptor, e);
}
}
- public synchronized void executionFlowAdded(ModuleDescriptor module,
- ExecutionFlowDescriptor efd) {
+ public synchronized void executionFlowAdded(ModuleDescriptor module, ExecutionFlowDescriptor efd) {
try {
Node agentNode = session.getNode(agent.getNodePath());
- Node moduleNode = agentNode.getNode(SlcJcrUtils
- .getModuleNodeName(module));
+ Node moduleNode = agentNode.getNode(SlcJcrUtils.getModuleNodeName(module));
String relativePath = getExecutionFlowRelativePath(efd);
@SuppressWarnings("unused")
Node flowNode = null;
if (!moduleNode.hasNode(relativePath)) {
- flowNode = createExecutionFlowNode(moduleNode, relativePath,
- efd);
+ flowNode = createExecutionFlowNode(moduleNode, relativePath, efd);
session.save();
} else {
flowNode = moduleNode.getNode(relativePath);
log.trace("Flow " + efd + " added to JCR");
} catch (RepositoryException e) {
JcrUtils.discardQuietly(session);
- throw new SlcException("Cannot add flow " + efd + " from module "
- + module, e);
+ throw new SlcException("Cannot add flow " + efd + " from module " + module, e);
}
}
- protected Node createExecutionFlowNode(Node moduleNode,
- String relativePath, ExecutionFlowDescriptor efd)
+ protected Node createExecutionFlowNode(Node moduleNode, String relativePath, ExecutionFlowDescriptor efd)
throws RepositoryException {
Node flowNode = null;
List<String> pathTokens = Arrays.asList(relativePath.split("/"));
if (names.hasNext())
currNode = currNode.addNode(name);
else
- flowNode = currNode.addNode(name,
- SlcTypes.SLC_EXECUTION_FLOW);
+ flowNode = currNode.addNode(name, SlcTypes.SLC_EXECUTION_FLOW);
}
}
flowNode.setProperty(SLC_NAME, efd.getName());
String endName = pathTokens.get(pathTokens.size() - 1);
flowNode.setProperty(Property.JCR_TITLE, endName);
- if (efd.getDescription() != null
- && !efd.getDescription().trim().equals("")) {
+ if (efd.getDescription() != null && !efd.getDescription().trim().equals("")) {
flowNode.setProperty(Property.JCR_DESCRIPTION, efd.getDescription());
} else {
flowNode.setProperty(Property.JCR_DESCRIPTION, endName);
mapExecutionSpec(flowNode, executionSpec);
} else {
// reference spec node
- Node executionSpecsNode = moduleNode.hasNode(SLC_EXECUTION_SPECS) ? moduleNode
- .getNode(SLC_EXECUTION_SPECS) : moduleNode
- .addNode(SLC_EXECUTION_SPECS);
- Node executionSpecNode = executionSpecsNode.addNode(esName,
- SlcTypes.SLC_EXECUTION_SPEC);
+ Node executionSpecsNode = moduleNode.hasNode(SLC_EXECUTION_SPECS) ? moduleNode.getNode(SLC_EXECUTION_SPECS)
+ : moduleNode.addNode(SLC_EXECUTION_SPECS);
+ Node executionSpecNode = executionSpecsNode.addNode(esName, SlcTypes.SLC_EXECUTION_SPEC);
executionSpecNode.setProperty(SLC_NAME, esName);
executionSpecNode.setProperty(Property.JCR_TITLE, esName);
- if (executionSpec.getDescription() != null
- && !executionSpec.getDescription().trim().equals(""))
- executionSpecNode.setProperty(Property.JCR_DESCRIPTION,
- executionSpec.getDescription());
+ if (executionSpec.getDescription() != null && !executionSpec.getDescription().trim().equals(""))
+ executionSpecNode.setProperty(Property.JCR_DESCRIPTION, executionSpec.getDescription());
mapExecutionSpec(executionSpecNode, executionSpec);
flowNode.setProperty(SLC_SPEC, executionSpecNode);
}
// flow values
for (String attr : efd.getValues().keySet()) {
- ExecutionSpecAttribute esa = executionSpec.getAttributes()
- .get(attr);
+ ExecutionSpecAttribute esa = executionSpec.getAttributes().get(attr);
if (esa instanceof PrimitiveSpecAttribute) {
PrimitiveSpecAttribute psa = (PrimitiveSpecAttribute) esa;
// if spec reference there will be no node at this stage
Node valueNode = JcrUtils.getOrAdd(flowNode, attr);
valueNode.setProperty(SLC_TYPE, psa.getType());
- SlcJcrUtils.setPrimitiveAsProperty(valueNode, SLC_VALUE,
- (PrimitiveValue) efd.getValues().get(attr));
+ SlcJcrUtils.setPrimitiveAsProperty(valueNode, SLC_VALUE, (PrimitiveValue) efd.getValues().get(attr));
}
}
}
/**
- * Base can be either an execution spec node, or an execution flow node (in
- * case the execution spec is internal)
+ * Base can be either an execution spec node, or an execution flow node (in case
+ * the execution spec is internal)
*/
- protected void mapExecutionSpec(Node baseNode, ExecutionSpec executionSpec)
- throws RepositoryException {
+ protected void mapExecutionSpec(Node baseNode, ExecutionSpec executionSpec) throws RepositoryException {
for (String attrName : executionSpec.getAttributes().keySet()) {
- ExecutionSpecAttribute esa = executionSpec.getAttributes().get(
- attrName);
+ ExecutionSpecAttribute esa = executionSpec.getAttributes().get(attrName);
Node attrNode = baseNode.addNode(attrName);
// booleans
attrNode.addMixin(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE);
index = count;
Node choiceNode = attrNode.addNode(choice.getName());
choiceNode.addMixin(NodeType.MIX_TITLE);
- choiceNode.setProperty(Property.JCR_TITLE,
- choice.getName());
- if (choice.getDescription() != null
- && !choice.getDescription().trim().equals(""))
- choiceNode.setProperty(Property.JCR_DESCRIPTION,
- choice.getDescription());
+ choiceNode.setProperty(Property.JCR_TITLE, choice.getName());
+ if (choice.getDescription() != null && !choice.getDescription().trim().equals(""))
+ choiceNode.setProperty(Property.JCR_DESCRIPTION, choice.getDescription());
count++;
}
}
}
- public synchronized void executionFlowRemoved(ModuleDescriptor module,
- ExecutionFlowDescriptor executionFlow) {
+ public synchronized void executionFlowRemoved(ModuleDescriptor module, ExecutionFlowDescriptor executionFlow) {
try {
Node agentNode = session.getNode(agent.getNodePath());
- Node moduleNode = agentNode.getNode(SlcJcrUtils
- .getModuleNodeName(module));
+ Node moduleNode = agentNode.getNode(SlcJcrUtils.getModuleNodeName(module));
String relativePath = getExecutionFlowRelativePath(executionFlow);
if (moduleNode.hasNode(relativePath))
moduleNode.getNode(relativePath).remove();
agentNode.getSession().save();
} catch (RepositoryException e) {
- throw new SlcException("Cannot remove flow " + executionFlow
- + " from module " + module, e);
+ throw new SlcException("Cannot remove flow " + executionFlow + " from module " + module, e);
}
}
*/
/** @return the relative path, never starts with '/' */
@SuppressWarnings("deprecation")
- protected String getExecutionFlowRelativePath(
- ExecutionFlowDescriptor executionFlow) {
- String relativePath = executionFlow.getPath() == null ? executionFlow
- .getName() : executionFlow.getPath() + '/'
- + executionFlow.getName();
+ protected String getExecutionFlowRelativePath(ExecutionFlowDescriptor executionFlow) {
+ String relativePath = executionFlow.getPath() == null ? executionFlow.getName()
+ : executionFlow.getPath() + '/' + executionFlow.getName();
// we assume that it is more than one char long
if (relativePath.charAt(0) == '/')
relativePath = relativePath.substring(1);
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
/** Execution process implementation based on a JCR node. */
public class JcrExecutionProcess implements ExecutionProcess, SlcNames {
- private final static Log log = LogFactory.getLog(JcrExecutionProcess.class);
+ private final static CmsLog log = CmsLog.getLog(JcrExecutionProcess.class);
private final Node node;
private Long nextLogLine = 1l;
}
/**
- * Synchronized in order to make sure that there is no concurrent
- * modification of {@link #nextLogLine}.
+ * Synchronized in order to make sure that there is no concurrent modification
+ * of {@link #nextLogLine}.
*/
public synchronized void addSteps(List<ExecutionStep> steps) {
try {
// skip
continue steps;
- String relPath = SLC_LOG + '/'
- + step.getThread().replace('/', '_') + '/'
+ String relPath = SLC_LOG + '/' + step.getThread().replace('/', '_') + '/'
+ step.getLocation().replace('.', '/');
String path = node.getPath() + '/' + relPath;
// clean special character
path = path.replace('@', '_');
Node location = JcrUtils.mkdirs(node.getSession(), path);
- Node logEntry = location.addNode(Long.toString(nextLogLine),
- type);
+ Node logEntry = location.addNode(Long.toString(nextLogLine), type);
logEntry.setProperty(SLC_MESSAGE, step.getLog());
Calendar calendar = new GregorianCalendar();
calendar.setTime(step.getTimestamp());
Node realizedFlowNode = nit.nextNode();
if (realizedFlowNode.hasNode(SLC_ADDRESS)) {
- String flowPath = realizedFlowNode.getNode(SLC_ADDRESS)
- .getProperty(Property.JCR_PATH).getString();
- NameVersion moduleNameVersion = SlcJcrUtils
- .moduleNameVersion(flowPath);
- ((ProcessThread) Thread.currentThread())
- .getExecutionModulesManager().start(
- moduleNameVersion);
+ String flowPath = realizedFlowNode.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString();
+ NameVersion moduleNameVersion = SlcJcrUtils.moduleNameVersion(flowPath);
+ ((ProcessThread) Thread.currentThread()).getExecutionModulesManager().start(moduleNameVersion);
}
- RealizedFlow realizedFlow = new JcrRealizedFlow(
- realizedFlowNode);
+ RealizedFlow realizedFlow = new JcrRealizedFlow(realizedFlowNode);
if (realizedFlow != null)
realizedFlows.add(realizedFlow);
}
try {
return node.getPath();
} catch (RepositoryException e) {
- throw new SlcException("Cannot get process node path for " + node,
- e);
+ throw new SlcException("Cannot get process node path for " + node, e);
}
}
try {
return node.getSession().getRepository();
} catch (RepositoryException e) {
- throw new SlcException("Cannot get process JCR repository for "
- + node, e);
+ throw new SlcException("Cannot get process JCR repository for " + node, e);
}
}
}
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.argeo.api.NodeConstants;
+import org.argeo.api.cms.CmsConstants;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.SlcNames;
Session session = null;
if (getProcess() instanceof JcrExecutionProcess)
try {
- session = ((JcrExecutionProcess) getProcess()).getRepository().login(NodeConstants.HOME_WORKSPACE);
+ session = ((JcrExecutionProcess) getProcess()).getRepository().login(CmsConstants.HOME_WORKSPACE);
List<RealizedFlow> realizedFlows = getProcess().getRealizedFlows();
for (RealizedFlow realizedFlow : realizedFlows) {
<classpathentry kind="src" output="target/classes" path="src"/>
<classpathentry kind="src" path="ext/test"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="output" path="bin"/>
</classpath>
javax.xml.transform.*,\
javax.xml.parsers.*,\
javax.jcr.nodetype,\
-org.eclipse.aether.*;version=1.0.1,\
org.osgi.*;version=0.0.0,\
*
-Private-Package: org.eclipse.aether.*
-
Require-Capability: cms.datamodel; filter:="(name=slc)"
Provide-Capability: cms.datamodel; name=java,\
cms.datamodel; name=dist,\
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.repo</artifactId>
- <name>SLC Repo</name>
- <dependencies>
- <!-- SLC API -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.api</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
-
- <!-- Commons -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.jcr</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.cms</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <!-- BND -->
- <dependency>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>biz.aQute.bndlib</artifactId>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
import javax.jcr.RepositoryException;
import javax.jcr.nodetype.NodeType;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.SlcNames;
* files and other non artifact files).
*/
public class ArtifactIndexer implements NodeIndexer, SlcNames {
- private Log log = LogFactory.getLog(ArtifactIndexer.class);
+ private CmsLog log = CmsLog.getLog(ArtifactIndexer.class);
private Boolean force = false;
public Boolean support(String path) {
artifact = AetherUtils.convertPathToArtifact(relativePath, null);
// support() guarantees that artifact won't be null, no NPE check
fileNode.addMixin(SlcTypes.SLC_ARTIFACT);
- fileNode.setProperty(SlcNames.SLC_ARTIFACT_ID,
- artifact.getArtifactId());
+ fileNode.setProperty(SlcNames.SLC_ARTIFACT_ID, artifact.getArtifactId());
fileNode.setProperty(SlcNames.SLC_GROUP_ID, artifact.getGroupId());
- fileNode.setProperty(SlcNames.SLC_ARTIFACT_VERSION,
- artifact.getVersion());
- fileNode.setProperty(SlcNames.SLC_ARTIFACT_EXTENSION,
- artifact.getExtension());
+ fileNode.setProperty(SlcNames.SLC_ARTIFACT_VERSION, artifact.getVersion());
+ fileNode.setProperty(SlcNames.SLC_ARTIFACT_EXTENSION, artifact.getExtension());
// can be null but ok for JCR API
- fileNode.setProperty(SlcNames.SLC_ARTIFACT_CLASSIFIER,
- artifact.getClassifier());
+ fileNode.setProperty(SlcNames.SLC_ARTIFACT_CLASSIFIER, artifact.getClassifier());
JcrUtils.updateLastModified(fileNode);
// make sure there are checksums
String shaNodeName = fileNode.getName() + ".sha1";
if (!fileNode.getParent().hasNode(shaNodeName)) {
String sha = JcrUtils.checksumFile(fileNode, "SHA-1");
- JcrUtils.copyBytesAsFile(fileNode.getParent(), shaNodeName,
- sha.getBytes());
+ JcrUtils.copyBytesAsFile(fileNode.getParent(), shaNodeName, sha.getBytes());
}
String md5NodeName = fileNode.getName() + ".md5";
if (!fileNode.getParent().hasNode(md5NodeName)) {
String md5 = JcrUtils.checksumFile(fileNode, "MD5");
- JcrUtils.copyBytesAsFile(fileNode.getParent(), md5NodeName,
- md5.getBytes());
+ JcrUtils.copyBytesAsFile(fileNode.getParent(), md5NodeName, md5.getBytes());
}
// Create a default pom if none already exist
String fileNodeName = fileNode.getName();
String pomName = null;
if (fileNodeName.endsWith(".jar"))
- pomName = fileNodeName.substring(0, fileNodeName.length()
- - ".jar".length())
- + ".pom";
+ pomName = fileNodeName.substring(0, fileNodeName.length() - ".jar".length()) + ".pom";
if (pomName != null && !fileNode.getParent().hasNode(pomName)) {
String pom = generatePomForBundle(fileNode);
- Node pomNode = JcrUtils.copyBytesAsFile(fileNode.getParent(),
- pomName, pom.getBytes());
+ Node pomNode = JcrUtils.copyBytesAsFile(fileNode.getParent(), pomName, pom.getBytes());
// corresponding check sums
String sha = JcrUtils.checksumFile(pomNode, "SHA-1");
- JcrUtils.copyBytesAsFile(fileNode.getParent(), pomName
- + ".sha1", sha.getBytes());
+ JcrUtils.copyBytesAsFile(fileNode.getParent(), pomName + ".sha1", sha.getBytes());
String md5 = JcrUtils.checksumFile(fileNode, "MD5");
- JcrUtils.copyBytesAsFile(fileNode.getParent(),
- pomName + ".md5", md5.getBytes());
+ JcrUtils.copyBytesAsFile(fileNode.getParent(), pomName + ".md5", md5.getBytes());
}
// set higher levels
Node artifactVersionBase = fileNode.getParent();
- if (!artifactVersionBase
- .isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
- artifactVersionBase
- .addMixin(SlcTypes.SLC_ARTIFACT_VERSION_BASE);
- artifactVersionBase.setProperty(SlcNames.SLC_ARTIFACT_VERSION,
- artifact.getBaseVersion());
- artifactVersionBase.setProperty(SlcNames.SLC_ARTIFACT_ID,
- artifact.getArtifactId());
- artifactVersionBase.setProperty(SlcNames.SLC_GROUP_ID,
- artifact.getGroupId());
+ if (!artifactVersionBase.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
+ artifactVersionBase.addMixin(SlcTypes.SLC_ARTIFACT_VERSION_BASE);
+ artifactVersionBase.setProperty(SlcNames.SLC_ARTIFACT_VERSION, artifact.getBaseVersion());
+ artifactVersionBase.setProperty(SlcNames.SLC_ARTIFACT_ID, artifact.getArtifactId());
+ artifactVersionBase.setProperty(SlcNames.SLC_GROUP_ID, artifact.getGroupId());
}
JcrUtils.updateLastModified(artifactVersionBase);
Node artifactBase = artifactVersionBase.getParent();
if (!artifactBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
artifactBase.addMixin(SlcTypes.SLC_ARTIFACT_BASE);
- artifactBase.setProperty(SlcNames.SLC_ARTIFACT_ID,
- artifact.getArtifactId());
- artifactBase.setProperty(SlcNames.SLC_GROUP_ID,
- artifact.getGroupId());
+ artifactBase.setProperty(SlcNames.SLC_ARTIFACT_ID, artifact.getArtifactId());
+ artifactBase.setProperty(SlcNames.SLC_GROUP_ID, artifact.getGroupId());
}
JcrUtils.updateLastModified(artifactBase);
// + " is also artifact base");
// }
groupBase.addMixin(SlcTypes.SLC_GROUP_BASE);
- groupBase.setProperty(SlcNames.SLC_GROUP_BASE_ID,
- artifact.getGroupId());
+ groupBase.setProperty(SlcNames.SLC_GROUP_BASE_ID, artifact.getGroupId());
}
- JcrUtils.updateLastModifiedAndParents(groupBase,
- RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH);
+ JcrUtils.updateLastModifiedAndParents(groupBase, RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH);
if (log.isTraceEnabled())
log.trace("Indexed artifact " + artifact + " on " + fileNode);
} catch (Exception e) {
- throw new SlcException("Cannot index artifact " + artifact
- + " metadata on node " + fileNode, e);
+ throw new SlcException("Cannot index artifact " + artifact + " metadata on node " + fileNode, e);
}
}
private String generatePomForBundle(Node n) throws RepositoryException {
StringBuffer p = new StringBuffer();
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>");
// Categorized name version
- p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
- .append("</groupId>\n");
- p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
- .append("</artifactId>\n");
- p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
- .append("</version>\n");
+ p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID)).append("</groupId>\n");
+ p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID)).append("</artifactId>\n");
+ p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION)).append("</version>\n");
// TODO make it more generic
p.append("<packaging>jar</packaging>\n");
if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
- p.append("<name>")
- .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
- .append("</name>\n");
+ p.append("<name>").append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME)).append("</name>\n");
if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
- p.append("<description>")
- .append(JcrUtils
- .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
+ p.append("<description>").append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
.append("</description>\n");
// Dependencies in case of a distribution
if (n.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION)) {
- p.append(getDependenciesSnippet(n.getNode(SlcNames.SLC_MODULES)
- .getNodes()));
- p.append(getDependencyManagementSnippet(n.getNode(
- SlcNames.SLC_MODULES).getNodes()));
+ p.append(getDependenciesSnippet(n.getNode(SlcNames.SLC_MODULES).getNodes()));
+ p.append(getDependencyManagementSnippet(n.getNode(SlcNames.SLC_MODULES).getNodes()));
}
p.append("</project>\n");
return p.toString();
}
- private String getDependenciesSnippet(NodeIterator nit)
- throws RepositoryException {
+ private String getDependenciesSnippet(NodeIterator nit) throws RepositoryException {
StringBuilder b = new StringBuilder();
b.append("<dependencies>\n");
while (nit.hasNext()) {
Node currModule = nit.nextNode();
if (currModule.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
- b.append(getDependencySnippet(
- currModule.getProperty(SlcNames.SLC_CATEGORY)
- .getString(),
- currModule.getProperty(SlcNames.SLC_NAME).getString(),
- null));
+ b.append(getDependencySnippet(currModule.getProperty(SlcNames.SLC_CATEGORY).getString(),
+ currModule.getProperty(SlcNames.SLC_NAME).getString(), null));
}
}
b.append("</dependencies>\n");
return b.toString();
}
- private String getDependencyManagementSnippet(NodeIterator nit)
- throws RepositoryException {
+ private String getDependencyManagementSnippet(NodeIterator nit) throws RepositoryException {
StringBuilder b = new StringBuilder();
b.append("<dependencyManagement>\n");
b.append("<dependencies>\n");
while (nit.hasNext()) {
Node currModule = nit.nextNode();
if (currModule.isNodeType(SlcTypes.SLC_MODULE_COORDINATES)) {
- b.append(getDependencySnippet(
- currModule.getProperty(SlcNames.SLC_CATEGORY)
- .getString(),
+ b.append(getDependencySnippet(currModule.getProperty(SlcNames.SLC_CATEGORY).getString(),
currModule.getProperty(SlcNames.SLC_NAME).getString(),
- currModule.getProperty(SlcNames.SLC_VERSION)
- .getString()));
+ currModule.getProperty(SlcNames.SLC_VERSION).getString()));
}
}
b.append("</dependencies>\n");
return b.toString();
}
- private String getDependencySnippet(String category, String name,
- String version) {
+ private String getDependencySnippet(String category, String name, String version) {
StringBuilder b = new StringBuilder();
b.append("<dependency>\n");
b.append("\t<groupId>").append(category).append("</groupId>\n");
final static String RESOURCES = "/org/argeo/slc/repo/license/";
/** GNU */
- public final static FreeLicense GPL_v3 = new FreeLicense(
- "GNU General Public License, version 3.0",
- "http://www.gnu.org/licenses/gpl-3.0.txt",
- "http://www.gnu.org/licenses/", RESOURCES + "gpl-3.0.txt") {
+ public final static FreeLicense GPL_v3 = new FreeLicense("GPL-3.0-or-later",
+ "http://www.gnu.org/licenses/gpl-3.0.txt", null, RESOURCES + "gpl-3.0.txt") {
};
- public final static FreeLicense GPL_v2 = new FreeLicense(
- "GNU General Public License, version 2.0",
- "http://www.gnu.org/licenses/gpl-2.0.txt",
- "http://www.gnu.org/licenses/", RESOURCES + "gpl-2.0.txt") {
+ public final static FreeLicense GPL_v2 = new FreeLicense("GPL-2.0-or-later",
+ "http://www.gnu.org/licenses/gpl-2.0.txt", null, RESOURCES + "gpl-2.0.txt") {
};
public final static FreeLicense GPL = GPL_v3;
- public final static FreeLicense LGPL_v3 = new FreeLicense(
- "GNU Lesser General Public License, version 3.0",
- "http://www.gnu.org/licenses/lgpl-3.0.txt",
- "http://www.gnu.org/licenses/", RESOURCES + "lgpl-3.0.txt") {
+ public final static FreeLicense LGPL_v3 = new FreeLicense("LGPL-3.0-or-later",
+ "http://www.gnu.org/licenses/lgpl-3.0.txt", null, RESOURCES + "lgpl-3.0.txt") {
};
- public final static FreeLicense LGPL_v2 = new FreeLicense(
- "GNU Lesser General Public License, version 2.1",
- "http://www.gnu.org/licenses/lgpl-2.1.txt",
- "http://www.gnu.org/licenses/", RESOURCES + "lgpl-2.1.txt") {
+ public final static FreeLicense LGPL_v2 = new FreeLicense("LGPL-2.0-or-later",
+ "http://www.gnu.org/licenses/lgpl-2.1.txt", null, RESOURCES + "lgpl-2.1.txt") {
};
public final static FreeLicense LGPL = LGPL_v3;
/** Apache */
- public final static FreeLicense APACHE_v2 = new FreeLicense(
- "Apache License, Version 2.0",
- "http://www.apache.org/licenses/LICENSE-2.0.txt",
- "http://www.apache.org/licenses/", RESOURCES + "apache-2.0.txt") {
+ public final static FreeLicense APACHE_v2 = new FreeLicense("Apache-2.0",
+ "http://www.apache.org/licenses/LICENSE-2.0.txt", null, RESOURCES + "apache-2.0.txt") {
};
public final static FreeLicense APACHE = APACHE_v2;
/** Eclipse */
- public final static FreeLicense EPL_v1 = new FreeLicense(
- "Eclipse Public License, Version 1.0",
- "http://www.eclipse.org/legal/epl-v10.html",
- "http://www.eclipse.org/legal/eplfaq.php", RESOURCES
- + "epl-1.0.txt") {
+ public final static FreeLicense EPL_v1 = new FreeLicense("EPL-1.0", "http://www.eclipse.org/legal/epl-v10.html",
+ null, RESOURCES + "epl-1.0.txt") {
+ };
+ public final static FreeLicense EPL_v2 = new FreeLicense("EPL-2.0", "http://www.eclipse.org/legal/epl-v20.html",
+ null, RESOURCES + "epl-1.0.txt") {
};
public final static FreeLicense EPL = EPL_v1;
/** Miscellaneous */
- public final static FreeLicense MIT = new FreeLicense("The MIT License",
- "http://opensource.org/licenses/MIT", null, RESOURCES + "mit.txt") {
+ public final static FreeLicense MIT = new FreeLicense("MIT", "http://opensource.org/licenses/MIT", null,
+ RESOURCES + "mit.txt") {
};
- public final static FreeLicense BSD_NEW = new FreeLicense(
- "The BSD 3-Clause License",
- "http://opensource.org/licenses/BSD-3-Clause", null, RESOURCES
- + "bsd-3-clause.txt") {
+ public final static FreeLicense BSD_NEW = new FreeLicense("BSD-3-Clause",
+ "http://opensource.org/licenses/BSD-3-Clause", null, RESOURCES + "bsd-3-clause.txt") {
};
public final static FreeLicense BSD = BSD_NEW;
- public final static FreeLicense CDDL_v1 = new FreeLicense(
- "Common Development and Distribution License",
- "http://opensource.org/licenses/CDDL-1.0", null, RESOURCES
- + "cddl-1.0.txt") {
+ public final static FreeLicense CDDL_v1 = new FreeLicense("CDDL-1.0", "http://opensource.org/licenses/CDDL-1.0",
+ null, RESOURCES + "cddl-1.0.txt") {
};
public final static FreeLicense CDDL = CDDL_v1;
+ public final static FreeLicense MOZILLA_v2 = new FreeLicense("MPL-2.0", "https://opensource.org/licenses/MPL-2.0",
+ null, RESOURCES + "cddl-1.0.txt") {
+ };
+ public final static FreeLicense MOZILLA = MOZILLA_v2;
+
/** Public domain corner case */
public final static License PUBLIC_DOMAIN = new License() {
String text = IOUtils.toString(in);
return text;
} catch (Exception e) {
- throw new SlcException("Cannot retrieve license " + name + " from "
- + url, e);
+ throw new SlcException("Cannot retrieve license " + name + " from " + url, e);
} finally {
IOUtils.closeQuietly(in);
}
@Override
public String toString() {
- return name + " (" + uri + ")";
+ StringBuilder sb = new StringBuilder(name != null ? name : uri);
+// if (link != null)
+// sb.append(';').append("link=").append(link);
+// else if (uri != null && name != null)
+// sb.append(';').append("link=").append(uri);
+ return sb.toString();
}
}
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.SlcNames;
* from MANIFEST)
*/
public class JarFileIndexer implements NodeIndexer, SlcNames {
- private final static Log log = LogFactory.getLog(JarFileIndexer.class);
+ private final static CmsLog log = CmsLog.getLog(JarFileIndexer.class);
private Boolean force = false;
public Boolean support(String path) {
manifest.write(bo);
byte[] newManifest = bo.toByteArray();
if (fileNode.hasProperty(SLC_MANIFEST)) {
- byte[] storedManifest = JcrUtils.getBinaryAsBytes(fileNode
- .getProperty(SLC_MANIFEST));
+ byte[] storedManifest = JcrUtils.getBinaryAsBytes(fileNode.getProperty(SLC_MANIFEST));
if (Arrays.equals(newManifest, storedManifest)) {
if (log.isTraceEnabled())
- log.trace("Manifest not changed, doing nothing "
- + fileNode);
+ log.trace("Manifest not changed, doing nothing " + fileNode);
return;
}
}
}
- private void getI18nValues(Binary fileBinary, Attributes attrs)
- throws IOException {
+ private void getI18nValues(Binary fileBinary, Attributes attrs) throws IOException {
JarInputStream jarIn = null;
try {
jarIn = new JarInputStream(fileBinary.getStream());
browse: if (bundleLocalization != null) {
JarEntry entry = jarIn.getNextJarEntry();
while (entry != null) {
- if (entry.getName().equals(
- bundleLocalization + ".properties")) {
+ if (entry.getName().equals(bundleLocalization + ".properties")) {
jarEntry = entry;
// if(je.getSize() != -1){
}
}
} catch (RepositoryException e) {
- throw new SlcException(
- "Error while reading the jar binary content " + fileBinary,
- e);
+ throw new SlcException("Error while reading the jar binary content " + fileBinary, e);
} catch (IOException ioe) {
- throw new SlcException("unable to get internationalized values",
- ioe);
+ throw new SlcException("unable to get internationalized values", ioe);
} finally {
IOUtils.closeQuietly(jarIn);
}
}
- protected void addOsgiMetadata(Node fileNode, Attributes attrs)
- throws RepositoryException {
+ protected void addOsgiMetadata(Node fileNode, Attributes attrs) throws RepositoryException {
// TODO remove this ?
// Compulsory for the time being, because bundle artifact extends
addAttr(Constants.BUNDLE_LOCALIZATION, fileNode, attrs);
// required execution environment
- if (attrs.containsKey(new Name(
- Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)))
- fileNode.setProperty(SlcNames.SLC_
- + Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, attrs
- .getValue(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)
- .split(","));
+ if (attrs.containsKey(new Name(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT)))
+ fileNode.setProperty(SlcNames.SLC_ + Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT,
+ attrs.getValue(Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT).split(","));
// bundle classpath
if (attrs.containsKey(new Name(Constants.BUNDLE_CLASSPATH)))
Version version = new Version(attrs.getValue(Constants.BUNDLE_VERSION));
fileNode.setProperty(SlcNames.SLC_BUNDLE_VERSION, version.toString());
cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.BUNDLE_VERSION);
- Node bundleVersionNode = fileNode.addNode(SlcNames.SLC_
- + Constants.BUNDLE_VERSION, SlcTypes.SLC_OSGI_VERSION);
+ Node bundleVersionNode = fileNode.addNode(SlcNames.SLC_ + Constants.BUNDLE_VERSION, SlcTypes.SLC_OSGI_VERSION);
mapOsgiVersion(version, bundleVersionNode);
// fragment
if (attrs.containsKey(new Name(Constants.FRAGMENT_HOST))) {
String fragmentHost = attrs.getValue(Constants.FRAGMENT_HOST);
String[] tokens = fragmentHost.split(";");
- Node node = fileNode.addNode(SlcNames.SLC_
- + Constants.FRAGMENT_HOST, SlcTypes.SLC_FRAGMENT_HOST);
+ Node node = fileNode.addNode(SlcNames.SLC_ + Constants.FRAGMENT_HOST, SlcTypes.SLC_FRAGMENT_HOST);
node.setProperty(SlcNames.SLC_SYMBOLIC_NAME, tokens[0]);
for (int i = 1; i < tokens.length; i++) {
if (tokens[i].startsWith(Constants.BUNDLE_VERSION_ATTRIBUTE)) {
- node.setProperty(SlcNames.SLC_BUNDLE_VERSION,
- attributeValue(tokens[i]));
+ node.setProperty(SlcNames.SLC_BUNDLE_VERSION, attributeValue(tokens[i]));
}
}
}
List<String> packages = parseCommaSeparated(importPackages);
for (String pkg : packages) {
String[] tokens = pkg.split(";");
- Node node = fileNode.addNode(SlcNames.SLC_
- + Constants.IMPORT_PACKAGE,
- SlcTypes.SLC_IMPORTED_PACKAGE);
+ Node node = fileNode.addNode(SlcNames.SLC_ + Constants.IMPORT_PACKAGE, SlcTypes.SLC_IMPORTED_PACKAGE);
node.setProperty(SlcNames.SLC_NAME, tokens[0]);
for (int i = 1; i < tokens.length; i++) {
if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
- node.setProperty(SlcNames.SLC_VERSION,
- attributeValue(tokens[i]));
- } else if (tokens[i]
- .startsWith(Constants.RESOLUTION_DIRECTIVE)) {
- node.setProperty(
- SlcNames.SLC_OPTIONAL,
- directiveValue(tokens[i]).equals(
- Constants.RESOLUTION_OPTIONAL));
+ node.setProperty(SlcNames.SLC_VERSION, attributeValue(tokens[i]));
+ } else if (tokens[i].startsWith(Constants.RESOLUTION_DIRECTIVE)) {
+ node.setProperty(SlcNames.SLC_OPTIONAL,
+ directiveValue(tokens[i]).equals(Constants.RESOLUTION_OPTIONAL));
}
}
}
// dynamic import package
cleanSubNodes(fileNode, SlcNames.SLC_ + Constants.DYNAMICIMPORT_PACKAGE);
if (attrs.containsKey(new Name(Constants.DYNAMICIMPORT_PACKAGE))) {
- String importPackages = attrs
- .getValue(Constants.DYNAMICIMPORT_PACKAGE);
+ String importPackages = attrs.getValue(Constants.DYNAMICIMPORT_PACKAGE);
List<String> packages = parseCommaSeparated(importPackages);
for (String pkg : packages) {
String[] tokens = pkg.split(";");
- Node node = fileNode.addNode(SlcNames.SLC_
- + Constants.DYNAMICIMPORT_PACKAGE,
+ Node node = fileNode.addNode(SlcNames.SLC_ + Constants.DYNAMICIMPORT_PACKAGE,
SlcTypes.SLC_DYNAMIC_IMPORTED_PACKAGE);
node.setProperty(SlcNames.SLC_NAME, tokens[0]);
for (int i = 1; i < tokens.length; i++) {
if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
- node.setProperty(SlcNames.SLC_VERSION,
- attributeValue(tokens[i]));
+ node.setProperty(SlcNames.SLC_VERSION, attributeValue(tokens[i]));
}
}
}
List<String> packages = parseCommaSeparated(exportPackages);
for (String pkg : packages) {
String[] tokens = pkg.split(";");
- Node node = fileNode.addNode(SlcNames.SLC_
- + Constants.EXPORT_PACKAGE,
- SlcTypes.SLC_EXPORTED_PACKAGE);
+ Node node = fileNode.addNode(SlcNames.SLC_ + Constants.EXPORT_PACKAGE, SlcTypes.SLC_EXPORTED_PACKAGE);
node.setProperty(SlcNames.SLC_NAME, tokens[0]);
// TODO: are these cleans really necessary?
cleanSubNodes(node, SlcNames.SLC_USES);
for (int i = 1; i < tokens.length; i++) {
if (tokens[i].startsWith(Constants.VERSION_ATTRIBUTE)) {
String versionStr = attributeValue(tokens[i]);
- Node versionNode = node.addNode(SlcNames.SLC_VERSION,
- SlcTypes.SLC_OSGI_VERSION);
+ Node versionNode = node.addNode(SlcNames.SLC_VERSION, SlcTypes.SLC_OSGI_VERSION);
mapOsgiVersion(new Version(versionStr), versionNode);
} else if (tokens[i].startsWith(Constants.USES_DIRECTIVE)) {
String usedPackages = directiveValue(tokens[i]);
// log.debug("usedPackage='" +
// usedPackage +
// "'");
- Node usesNode = node.addNode(SlcNames.SLC_USES,
- SlcTypes.SLC_JAVA_PACKAGE);
+ Node usesNode = node.addNode(SlcNames.SLC_USES, SlcTypes.SLC_JAVA_PACKAGE);
usesNode.setProperty(SlcNames.SLC_NAME, usedPackage);
}
}
List<String> bundles = parseCommaSeparated(requireBundle);
for (String bundle : bundles) {
String[] tokens = bundle.split(";");
- Node node = fileNode.addNode(SlcNames.SLC_
- + Constants.REQUIRE_BUNDLE,
- SlcTypes.SLC_REQUIRED_BUNDLE);
+ Node node = fileNode.addNode(SlcNames.SLC_ + Constants.REQUIRE_BUNDLE, SlcTypes.SLC_REQUIRED_BUNDLE);
node.setProperty(SlcNames.SLC_SYMBOLIC_NAME, tokens[0]);
for (int i = 1; i < tokens.length; i++) {
- if (tokens[i]
- .startsWith(Constants.BUNDLE_VERSION_ATTRIBUTE)) {
- node.setProperty(SlcNames.SLC_BUNDLE_VERSION,
- attributeValue(tokens[i]));
- } else if (tokens[i]
- .startsWith(Constants.RESOLUTION_DIRECTIVE)) {
- node.setProperty(
- SlcNames.SLC_OPTIONAL,
- directiveValue(tokens[i]).equals(
- Constants.RESOLUTION_OPTIONAL));
+ if (tokens[i].startsWith(Constants.BUNDLE_VERSION_ATTRIBUTE)) {
+ node.setProperty(SlcNames.SLC_BUNDLE_VERSION, attributeValue(tokens[i]));
+ } else if (tokens[i].startsWith(Constants.RESOLUTION_DIRECTIVE)) {
+ node.setProperty(SlcNames.SLC_OPTIONAL,
+ directiveValue(tokens[i]).equals(Constants.RESOLUTION_OPTIONAL));
}
}
}
}
- private void addAttr(String key, Node node, Attributes attrs)
- throws RepositoryException {
+ private void addAttr(String key, Node node, Attributes attrs) throws RepositoryException {
addAttr(new Name(key), node, attrs);
}
- private void addAttr(Name key, Node node, Attributes attrs)
- throws RepositoryException {
+ private void addAttr(Name key, Node node, Attributes attrs) throws RepositoryException {
if (attrs.containsKey(key)) {
String value = attrs.getValue(key);
node.setProperty(SlcNames.SLC_ + key, value);
}
}
- private void cleanSubNodes(Node node, String name)
- throws RepositoryException {
+ private void cleanSubNodes(Node node, String name) throws RepositoryException {
if (node.hasNode(name)) {
NodeIterator nit = node.getNodes(name);
while (nit.hasNext())
return res;
}
- protected void mapOsgiVersion(Version version, Node versionNode)
- throws RepositoryException {
+ protected void mapOsgiVersion(Version version, Node versionNode) throws RepositoryException {
versionNode.setProperty(SlcNames.SLC_AS_STRING, version.toString());
versionNode.setProperty(SlcNames.SLC_MAJOR, version.getMajor());
versionNode.setProperty(SlcNames.SLC_MINOR, version.getMinor());
versionNode.setProperty(SlcNames.SLC_MICRO, version.getMicro());
if (!version.getQualifier().equals(""))
- versionNode.setProperty(SlcNames.SLC_QUALIFIER,
- version.getQualifier());
+ versionNode.setProperty(SlcNames.SLC_QUALIFIER, version.getQualifier());
}
public void setForce(Boolean force) {
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.DefaultCategoryNameVersion;
* file contains a tag "dependencyManagement" that list all modules</li> </list>
*/
public class ModularDistributionIndexer implements NodeIndexer, SlcNames {
- private final static Log log = LogFactory.getLog(ModularDistributionIndexer.class);
+ private final static CmsLog log = CmsLog.getLog(ModularDistributionIndexer.class);
// Constants for csv indexing
private final static String INDEX_FILE_NAME = "modularDistribution.csv";
import javax.jcr.Session;
import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
* "...-sources.jar"
*/
public class PdeSourcesIndexer implements NodeIndexer {
- private Log log = LogFactory.getLog(PdeSourcesIndexer.class);
+ private CmsLog log = CmsLog.getLog(PdeSourcesIndexer.class);
private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH;
package org.argeo.slc.repo;
-import org.argeo.api.NodeConstants;
+import org.argeo.api.cms.CmsConstants;
/** SLC repository constants */
public interface RepoConstants {
String SLC_CATEGORY_ID = "SLC-Category";
// TODO find a more generic way
- String DEFAULT_DEFAULT_WORKSPACE = NodeConstants.SYS_WORKSPACE;
+ String DEFAULT_DEFAULT_WORKSPACE = CmsConstants.SYS_WORKSPACE;
}
import javax.jcr.query.QueryResult;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
+import org.argeo.cms.jcr.CmsJcrUtils;
import org.argeo.jcr.JcrMonitor;
import org.argeo.jcr.JcrUtils;
-import org.argeo.api.NodeUtils;
import org.argeo.slc.SlcException;
import org.xml.sax.SAXException;
* we copy the content of the source workspace into the target one.
*/
public class RepoSync implements Runnable {
- private final static Log log = LogFactory.getLog(RepoSync.class);
+ private final static CmsLog log = CmsLog.getLog(RepoSync.class);
// Centralizes definition of workspaces that must be ignored by the sync.
private final static List<String> IGNORED_WKSP_LIST = Arrays.asList("security", "localrepo");
// Setup
if (sourceRepository == null)
- sourceRepository = NodeUtils.getRepositoryByUri(repositoryFactory, sourceRepoUri);
+ sourceRepository = CmsJcrUtils.getRepositoryByUri(repositoryFactory, sourceRepoUri);
if (sourceCredentials == null && sourceUsername != null)
sourceCredentials = new SimpleCredentials(sourceUsername, sourcePassword);
// FIXME make it more generic
sourceDefaultSession = sourceRepository.login(sourceCredentials, RepoConstants.DEFAULT_DEFAULT_WORKSPACE);
if (targetRepository == null)
- targetRepository = NodeUtils.getRepositoryByUri(repositoryFactory, targetRepoUri);
+ targetRepository = CmsJcrUtils.getRepositoryByUri(repositoryFactory, targetRepoUri);
if (targetCredentials == null && targetUsername != null)
targetCredentials = new SimpleCredentials(targetUsername, targetPassword);
targetDefaultSession = targetRepository.login(targetCredentials);
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.cms.ArgeoNames;
import org.argeo.cms.ArgeoTypes;
+import org.argeo.cms.jcr.CmsJcrUtils;
+import org.argeo.cms.security.Keyring;
import org.argeo.jcr.JcrMonitor;
import org.argeo.jcr.JcrUtils;
-import org.argeo.api.NodeUtils;
-import org.argeo.api.security.Keyring;
import org.argeo.slc.DefaultNameVersion;
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
/** Utilities around repo */
public class RepoUtils implements ArgeoNames, SlcNames {
- private final static Log log = LogFactory.getLog(RepoUtils.class);
+ private final static CmsLog log = CmsLog.getLog(RepoUtils.class);
/** Packages a regular sources jar as PDE source. */
public static void packagesAsPdeSource(File sourceFile,
if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) {
String uri = repoNode.getProperty(ARGEO_URI).getString();
if (uri.startsWith("http")) {// http, https
- repository = NodeUtils.getRepositoryByUri(
+ repository = CmsJcrUtils.getRepositoryByUri(
repositoryFactory, uri);
} else if (uri.startsWith("vm:")) {// alias
- repository = NodeUtils.getRepositoryByUri(
+ repository = CmsJcrUtils.getRepositoryByUri(
repositoryFactory, uri);
} else {
throw new SlcException("Unsupported repository uri " + uri);
// Anonymous URI only workspace
if (repoNode == null)
// Anonymous
- currRepo = NodeUtils.getRepositoryByUri(repositoryFactory, uri);
+ currRepo = CmsJcrUtils.getRepositoryByUri(repositoryFactory, uri);
else {
currRepo = RepoUtils.getRepository(repositoryFactory, keyring,
repoNode);
monitor.worked(1);
} catch (RepositoryException e) {
- throw new SlcException("Cannot copy " + fromNode + " to " + toNode,
- e);
+ throw new SlcException("Cannot copy " + fromNode + " to " + toNode, e);
}
}
+++ /dev/null
-package org.argeo.slc.repo;
-
-import static org.redline_rpm.header.Header.HeaderTag.HEADERIMMUTABLE;
-import static org.redline_rpm.header.Signature.SignatureTag.SIGNATURES;
-
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.FilenameUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.SlcNames;
-import org.argeo.slc.SlcTypes;
-import org.redline_rpm.ChannelWrapper.Key;
-import org.redline_rpm.ReadableChannelWrapper;
-import org.redline_rpm.header.AbstractHeader;
-import org.redline_rpm.header.Format;
-import org.redline_rpm.header.Header;
-
-/** Indexes an RPM file. */
-public class RpmIndexer implements NodeIndexer, SlcNames {
- private Boolean force = false;
-
- @Override
- public Boolean support(String path) {
- return FilenameUtils.getExtension(path).equals("rpm");
- }
-
- @Override
- public void index(Node node) {
- try {
- if (!support(node.getPath()))
- return;
-
- // Already indexed
- if (!force && node.isNodeType(SlcTypes.SLC_RPM))
- return;
-
- if (!node.isNodeType(NodeType.NT_FILE))
- return;
-
- InputStream in = node.getNode(Node.JCR_CONTENT)
- .getProperty(Property.JCR_DATA).getBinary().getStream();
- ReadableChannelWrapper channel = new ReadableChannelWrapper(
- Channels.newChannel(in));
- Format format = readRpmInfo(channel);
-
- node.addMixin(SlcTypes.SLC_RPM);
- node.setProperty(SLC_NAME, readTag(format, Header.HeaderTag.NAME));
- String rpmVersion = readTag(format, Header.HeaderTag.VERSION);
- String rpmRelease = readTag(format, Header.HeaderTag.RELEASE);
- node.setProperty(SLC_RPM_VERSION, rpmVersion);
- node.setProperty(SLC_RPM_RELEASE, rpmRelease);
- node.setProperty(SLC_VERSION, rpmVersion + "-" + rpmRelease);
-
- String arch = readTag(format, Header.HeaderTag.ARCH);
- if (arch != null)
- node.setProperty(SLC_RPM_ARCH, arch);
-
- String archiveSize = readTag(format, Header.HeaderTag.ARCHIVESIZE);
- if (archiveSize != null)
- node.setProperty(SLC_RPM_ARCHIVE_SIZE,
- Long.parseLong(archiveSize));
-
- node.getSession().save();
- } catch (Exception e) {
- throw new SlcException("Cannot index " + node, e);
- }
-
- }
-
- @SuppressWarnings("unused")
- public Format readRpmInfo(ReadableChannelWrapper channel) throws Exception {
- Format format = new Format();
-
- Key<Integer> lead = channel.start();
- format.getLead().read(channel);
- // System.out.println( "Lead ended at '" + in.finish( lead) + "'.");
-
- Key<Integer> signature = channel.start();
- int count = format.getSignature().read(channel);
- int expected = ByteBuffer
- .wrap((byte[]) format.getSignature().getEntry(SIGNATURES)
- .getValues(), 8, 4).getInt()
- / -16;
- // System.out.println( "Signature ended at '" + in.finish( signature) +
- // "' and contained '" + count + "' headers (expected '" + expected +
- // "').");
-
- Key<Integer> header = channel.start();
- count = format.getHeader().read(channel);
- expected = ByteBuffer.wrap(
- (byte[]) format.getHeader().getEntry(HEADERIMMUTABLE)
- .getValues(), 8, 4).getInt()
- / -16;
- // System.out.println( "Header ended at '" + in.finish( header) +
- // " and contained '" + count + "' headers (expected '" + expected +
- // "').");
-
- return format;
- }
-
- private String readTag(Format format, Header.HeaderTag tag) {
- AbstractHeader.Entry<?> entry = format.getHeader().getEntry(tag);
- if (entry == null)
- return null;
- if (entry.getValues() == null)
- return null;
- Object[] values = (Object[]) entry.getValues();
- return values[0].toString().trim();
- }
-}
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcConstants;
import org.argeo.slc.SlcException;
/** Generic operations on a JCR-based repo. */
abstract class AbstractJcrRepoManager {
- private final static Log log = LogFactory
- .getLog(AbstractJcrRepoManager.class);
+ private final static CmsLog log = CmsLog.getLog(AbstractJcrRepoManager.class);
private String securityWorkspace = "security";
private Repository jcrRepository;
public void init() {
try {
adminSession = jcrRepository.login();
- String[] workspaceNames = adminSession.getWorkspace()
- .getAccessibleWorkspaceNames();
+ String[] workspaceNames = adminSession.getWorkspace().getAccessibleWorkspaceNames();
for (String workspaceName : workspaceNames) {
if (workspaceName.equals(securityWorkspace))
continue;
try {
try {
jcrRepository.login(workspaceName);
- throw new SlcException("Workspace " + workspaceName
- + " exists already.");
+ throw new SlcException("Workspace " + workspaceName + " exists already.");
} catch (NoSuchWorkspaceException e) {
// try to create workspace
adminSession.getWorkspace().createWorkspace(workspaceName);
workspaceInit(workspaceName);
}
} catch (RepositoryException e) {
- throw new SlcException("Cannot create workspace " + workspaceName,
- e);
+ throw new SlcException("Cannot create workspace " + workspaceName, e);
}
}
try {
workspaceAdminSession = jcrRepository.login(workspaceName);
workspaceSessions.put(workspaceName, adminSession);
- JcrUtils.addPrivilege(workspaceAdminSession, "/",
- SlcConstants.ROLE_SLC, "jcr:all");
- WorkspaceIndexer workspaceIndexer = new WorkspaceIndexer(
- workspaceAdminSession, nodeIndexers);
+ JcrUtils.addPrivilege(workspaceAdminSession, "/", SlcConstants.ROLE_SLC, "jcr:all");
+ WorkspaceIndexer workspaceIndexer = new WorkspaceIndexer(workspaceAdminSession, nodeIndexers);
workspaceIndexers.put(workspaceName, workspaceIndexer);
} catch (RepositoryException e) {
log.error("Cannot initialize workspace " + workspaceName, e);
import javax.jcr.RepositoryFactory;
import javax.jcr.Session;
-import org.argeo.api.security.Keyring;
+import org.argeo.cms.security.Keyring;
import org.argeo.slc.repo.RepoService;
import org.argeo.slc.repo.RepoUtils;
import javax.jcr.observation.EventIterator;
import javax.jcr.observation.EventListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.repo.NodeIndexer;
/** Maintains the metadata of a workspace, using listeners */
public class WorkspaceIndexer {
- private final static Log log = LogFactory.getLog(WorkspaceIndexer.class);
+ private final static CmsLog log = CmsLog.getLog(WorkspaceIndexer.class);
private final Session adminSession;
private IndexingListener artifactListener;
import java.util.regex.Pattern;
import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.slc.SlcException;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
public static final Pattern SNAPSHOT_TIMESTAMP = Pattern
.compile("^(.*-)?([0-9]{8}.[0-9]{6}-[0-9]+)$");
- private final static Log log = LogFactory.getLog(AetherUtils.class);
+ private final static CmsLog log = CmsLog.getLog(AetherUtils.class);
/** Logs a dependency node and its transitive dependencies as a tree. */
public static void logDependencyNode(int depth,
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrMonitor;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
* group.
*/
public class GenerateBinaries implements Runnable, SlcNames {
- private final static Log log = LogFactory.getLog(GenerateBinaries.class);
+ private final static CmsLog log = CmsLog.getLog(GenerateBinaries.class);
// Connection info
private Repository repository;
private List<String> excludedSuffixes = new ArrayList<String>();
// Indexes
- private Set<Artifact> binaries = new TreeSet<Artifact>(
- new ArtifactIdComparator());
- private Set<Artifact> sources = new TreeSet<Artifact>(
- new ArtifactIdComparator());
+ private Set<Artifact> binaries = new TreeSet<Artifact>(new ArtifactIdComparator());
+ private Set<Artifact> sources = new TreeSet<Artifact>(new ArtifactIdComparator());
// local cache
private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
Session session = null;
try {
session = repository.login(credentials, workspace);
- Node groupNode = session.getNode(MavenConventionsUtils.groupPath(
- artifactBasePath, groupId));
+ Node groupNode = session.getNode(MavenConventionsUtils.groupPath(artifactBasePath, groupId));
internalPreProcessing(groupNode, null);
internalProcessing(groupNode, null);
} catch (Exception e) {
- throw new SlcException("Cannot normalize group " + groupId + " in "
- + workspace, e);
+ throw new SlcException("Cannot normalize group " + groupId + " in " + workspace, e);
} finally {
JcrUtils.logoutQuietly(session);
}
* Generates binaries-, sources- and sdk-version.pom artifacts for the given
* version (or the highest of all children version if none is precised).
*
- * By default, it includes each latest version of all artifact of this
- * group.
+ * By default, it includes each latest version of all artifact of this group.
*
* The 3 generated artifacts are then marked as modular distributions and
* indexed.
*/
- public static void processGroupNode(Node groupNode, String version,
- JcrMonitor monitor) throws RepositoryException {
+ public static void processGroupNode(Node groupNode, String version, JcrMonitor monitor) throws RepositoryException {
// TODO set artifactsBase based on group node
GenerateBinaries gb = new GenerateBinaries();
- String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
- .getString();
+ String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID).getString();
gb.setGroupId(groupId);
gb.setVersion(version);
// TODO use already done pre-processing
}
/** Only builds local indexes. Does not change anything in the local Session */
- public static GenerateBinaries preProcessGroupNode(Node groupNode,
- JcrMonitor monitor) throws RepositoryException {
+ public static GenerateBinaries preProcessGroupNode(Node groupNode, JcrMonitor monitor) throws RepositoryException {
// TODO set artifactsBase based on group node
GenerateBinaries gb = new GenerateBinaries();
- String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
- .getString();
+ String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID).getString();
gb.setGroupId(groupId);
// gb.setVersion(version);
// gb.setOverridePoms(overridePoms);
}
public Artifact getHighestArtifactVersion() throws RepositoryException {
- return allArtifactsHighestVersion == null ? null : RepoUtils
- .asArtifact(allArtifactsHighestVersion);
+ return allArtifactsHighestVersion == null ? null : RepoUtils.asArtifact(allArtifactsHighestVersion);
}
// //////////////////////////////////////
* Browse all children of a Node considered as a folder that follows Aether
* conventions i.e that has Aether's artifact base as children.
*
- * Each of such child contains a set of Aether artifact versions. This
- * methods build the binaries {@code Set<Artifact>} and other indexes. It
- * does not impact the
+ * Each of such child contains a set of Aether artifact versions. This methods
+ * build the binaries {@code Set<Artifact>} and other indexes. It does not
+ * impact the
*/
- protected void internalPreProcessing(Node groupNode, JcrMonitor monitor)
- throws RepositoryException {
+ protected void internalPreProcessing(Node groupNode, JcrMonitor monitor) throws RepositoryException {
if (monitor != null)
monitor.subTask("Pre processing group " + groupId);
// gathering latest versions of each artifact
allArtifactsHighestVersion = null;
- aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases
- .hasNext();) {
+ aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases.hasNext();) {
Node aBase = aBases.nextNode();
if (aBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
Node highestAVersion = getArtifactLatestVersion(aBase);
else {
// retrieve relevant child node
// Information is stored on the NT_FILE child node.
- for (NodeIterator files = highestAVersion.getNodes(); files
- .hasNext();) {
+ for (NodeIterator files = highestAVersion.getNodes(); files.hasNext();) {
Node file = files.nextNode();
if (file.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
if (log.isDebugEnabled())
}
/** Does the real job : writes JCR META-DATA and generates binaries */
- protected void internalProcessing(Node groupNode, JcrMonitor monitor)
- throws RepositoryException {
+ protected void internalProcessing(Node groupNode, JcrMonitor monitor) throws RepositoryException {
if (monitor != null)
monitor.subTask("Processing group " + groupId);
// => the version can then be left empty
if (version == null || version.trim().equals(""))
if (allArtifactsHighestVersion != null)
- version = allArtifactsHighestVersion.getProperty(
- SLC_ARTIFACT_VERSION).getString();
+ version = allArtifactsHighestVersion.getProperty(SLC_ARTIFACT_VERSION).getString();
else
- throw new SlcException("Group version " + version
- + " is empty.");
+ throw new SlcException("Group version " + version + " is empty.");
// int bundleCount = symbolicNamesToNodes.size();
// int count = 1;
// }
// indexes
- Set<Artifact> indexes = new TreeSet<Artifact>(
- new ArtifactIdComparator());
+ Set<Artifact> indexes = new TreeSet<Artifact>(new ArtifactIdComparator());
Artifact indexArtifact;
- indexArtifact = writeIndex(session, RepoConstants.BINARIES_ARTIFACT_ID,
- binaries);
+ indexArtifact = writeIndex(session, RepoConstants.BINARIES_ARTIFACT_ID, binaries);
indexes.add(indexArtifact);
- indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID,
- sources);
+ indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID, sources);
indexes.add(indexArtifact);
// sdk
monitor.worked(1);
}
- protected void preProcessBundleArtifact(Node bundleNode)
- throws RepositoryException {
+ protected void preProcessBundleArtifact(Node bundleNode) throws RepositoryException {
String symbolicName = JcrUtils.get(bundleNode, SLC_SYMBOLIC_NAME);
// Sanity check.
// Manage source bundles
if (symbolicName.endsWith(".source")) {
// TODO make a shared node with classifier 'sources'?
- String bundleName = RepoUtils
- .extractBundleNameFromSourceName(symbolicName);
+ String bundleName = RepoUtils.extractBundleNameFromSourceName(symbolicName);
for (String excludedSuffix : excludedSuffixes) {
if (bundleName.endsWith(excludedSuffix))
return;// skip adding to sources
// Extra check. to remove
if (bundleNode.getSession().hasPendingChanges())
- throw new SlcException("Pending changes in the session, "
- + "this should not be true here.");
+ throw new SlcException("Pending changes in the session, " + "this should not be true here.");
}
// protected void processBundleArtifact(Node bundleNode)
// LOCAL WRITERS
//
- private Artifact writeIndex(Session session, String artifactId,
- Set<Artifact> artifacts) throws RepositoryException {
- Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
- version);
- Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(
- parentPomCoordinates) : null;
- String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
- artifacts, parentArtifact);
- Node node = RepoUtils.copyBytesAsArtifact(
- session.getNode(artifactBasePath), artifact, pom.getBytes());
+ private Artifact writeIndex(Session session, String artifactId, Set<Artifact> artifacts)
+ throws RepositoryException {
+ Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom", version);
+ Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(parentPomCoordinates) : null;
+ String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact, artifacts, parentArtifact);
+ Node node = RepoUtils.copyBytesAsArtifact(session.getNode(artifactBasePath), artifact, pom.getBytes());
artifactIndexer.index(node);
// TODO factorize
String pomSha = JcrUtils.checksumFile(node, "SHA-1");
- JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
- pomSha.getBytes());
+ JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1", pomSha.getBytes());
String pomMd5 = JcrUtils.checksumFile(node, "MD5");
- JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
- pomMd5.getBytes());
+ JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5", pomMd5.getBytes());
session.save();
return artifact;
}
private Node getArtifactLatestVersion(Node artifactBase) {
try {
Node highestAVersion = null;
- for (NodeIterator aVersions = artifactBase.getNodes(); aVersions
- .hasNext();) {
+ for (NodeIterator aVersions = artifactBase.getNodes(); aVersions.hasNext();) {
Node aVersion = aVersions.nextNode();
if (aVersion.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
if (highestAVersion == null) {
if (currVersion.compareTo(currentHighestVersion) > 0) {
highestAVersion = aVersion;
}
- if (currVersion
- .compareTo(extractOsgiVersion(allArtifactsHighestVersion)) > 0) {
+ if (currVersion.compareTo(extractOsgiVersion(allArtifactsHighestVersion)) > 0) {
allArtifactsHighestVersion = aVersion;
}
}
}
return highestAVersion;
} catch (RepositoryException re) {
- throw new SlcException("Unable to get latest version for node "
- + artifactBase, re);
+ throw new SlcException("Unable to get latest version for node " + artifactBase, re);
}
}
- private Version extractOsgiVersion(Node artifactVersion)
- throws RepositoryException {
- String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION)
- .getString();
+ private Version extractOsgiVersion(Node artifactVersion) throws RepositoryException {
+ String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION).getString();
String cleanVersion = rawVersion.replace("-SNAPSHOT", ".SNAPSHOT");
Version osgiVersion = null;
// log invalid version value to enable tracking them
//
// // 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>");
//
// // Artifact
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.SlcNames;
/** Create a distribution node from a set of artifacts */
public class IndexDistribution implements Runnable {
- private final static Log log = LogFactory.getLog(IndexDistribution.class);
+ private final static CmsLog log = CmsLog.getLog(IndexDistribution.class);
private Repository repository;
private String workspace;
import java.io.File;
import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.eclipse.aether.artifact.Artifact;
/**
* based).
*/
public class MavenConventionsUtils {
- private final static Log log = LogFactory.getLog(MavenConventionsUtils.class);
+ private final static CmsLog log = CmsLog.getLog(MavenConventionsUtils.class);
/**
* Path to the file identified by this artifact <b>without</b> using Maven
import javax.jcr.security.AccessControlException;
import javax.jcr.security.Privilege;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.cms.ArgeoNames;
import org.argeo.jcr.JcrUtils;
import org.argeo.jcr.proxy.AbstractUrlProxy;
import org.eclipse.aether.repository.RemoteRepository;
/** Synchronises the node repository with remote Maven repositories */
-public class MavenProxyServiceImpl extends AbstractUrlProxy implements
- MavenProxyService, ArgeoNames, SlcNames {
- private final static Log log = LogFactory
- .getLog(MavenProxyServiceImpl.class);
+public class MavenProxyServiceImpl extends AbstractUrlProxy implements MavenProxyService, ArgeoNames, SlcNames {
+ private final static CmsLog log = CmsLog.getLog(MavenProxyServiceImpl.class);
private List<RemoteRepository> defaultRepositories = new ArrayList<RemoteRepository>();
/** Initialises the artifacts area. */
@Override
- protected void beforeInitSessionSave(Session session)
- throws RepositoryException {
+ protected void beforeInitSessionSave(Session session) throws RepositoryException {
JcrUtils.addPrivilege(session, "/", SlcConstants.USER_ANONYMOUS, Privilege.JCR_READ);
try {
- JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
- Privilege.JCR_ALL);
+ JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC, Privilege.JCR_ALL);
} catch (AccessControlException e) {
if (log.isTraceEnabled())
- log.trace("Cannot give jcr:all privileges to "
- + SlcConstants.ROLE_SLC);
+ log.trace("Cannot give jcr:all privileges to " + SlcConstants.ROLE_SLC);
}
JcrUtils.mkdirsSafe(session, RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH);
- Node proxiedRepositories = JcrUtils.mkdirsSafe(session,
- RepoConstants.PROXIED_REPOSITORIES);
+ Node proxiedRepositories = JcrUtils.mkdirsSafe(session, RepoConstants.PROXIED_REPOSITORIES);
for (RemoteRepository repository : defaultRepositories) {
if (!proxiedRepositories.hasNode(repository.getId())) {
- Node proxiedRepository = proxiedRepositories.addNode(repository
- .getId());
+ Node proxiedRepository = proxiedRepositories.addNode(repository.getId());
proxiedRepository.addMixin(NodeType.MIX_REFERENCEABLE);
- JcrUtils.urlToAddressProperties(proxiedRepository,
- repository.getUrl());
+ JcrUtils.urlToAddressProperties(proxiedRepository, repository.getUrl());
// proxiedRepository.setProperty(SLC_URL, repository.getUrl());
- proxiedRepository.setProperty(SLC_TYPE,
- repository.getContentType());
+ proxiedRepository.setProperty(SLC_TYPE, repository.getContentType());
}
}
}
throw new SlcException("Session has pending changed");
Node node = null;
for (Node proxiedRepository : getBaseUrls(session)) {
- String baseUrl = JcrUtils
- .urlFromAddressProperties(proxiedRepository);
+ String baseUrl = JcrUtils.urlFromAddressProperties(proxiedRepository);
node = proxyUrl(session, baseUrl, path);
if (node != null) {
node.addMixin(SlcTypes.SLC_KNOWN_ORIGIN);
- Node origin = node
- .addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
+ Node origin = node.addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
origin.setProperty(SLC_PROXY, proxiedRepository);
JcrUtils.urlToAddressProperties(origin, baseUrl + path);
if (log.isDebugEnabled())
}
}
- protected synchronized List<Node> getBaseUrls(Session session)
- throws RepositoryException {
+ protected synchronized List<Node> getBaseUrls(Session session) throws RepositoryException {
List<Node> baseUrls = new ArrayList<Node>();
- for (NodeIterator nit = session.getNode(
- RepoConstants.PROXIED_REPOSITORIES).getNodes(); nit.hasNext();) {
+ for (NodeIterator nit = session.getNode(RepoConstants.PROXIED_REPOSITORIES).getNodes(); nit.hasNext();) {
Node proxiedRepository = nit.nextNode();
baseUrls.add(proxiedRepository);
}
return baseUrls;
}
- public void setDefaultRepositories(
- List<RemoteRepository> defaultRepositories) {
+ public void setDefaultRepositories(List<RemoteRepository> defaultRepositories) {
this.defaultRepositories = defaultRepositories;
}
}
import javax.jcr.query.qom.QueryObjectModelFactory;
import javax.jcr.query.qom.Selector;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
*/
public class Migration_01_03 implements Runnable, SlcNames {
final String SPRING_SOURCE_PREFIX = "com.springsource";
- private final static Log log = LogFactory.getLog(Migration_01_03.class);
+ private final static CmsLog log = CmsLog.getLog(Migration_01_03.class);
private Repository repository;
private String sourceWorkspace;
private Session origSession;
private Session targetSession;
- private List<String> systemPackages = OsgiProfile.PROFILE_JAVA_SE_1_6
- .getSystemPackages();
+ private List<String> systemPackages = OsgiProfile.PROFILE_JAVA_SE_1_6.getSystemPackages();
private String artifactBasePath = "/";
private JarFileIndexer jarFileIndexer = new JarFileIndexer();
public void init() throws RepositoryException {
- origSession = JcrUtils.loginOrCreateWorkspace(repository,
- sourceWorkspace);
- targetSession = JcrUtils.loginOrCreateWorkspace(repository,
- targetWorkspace);
+ origSession = JcrUtils.loginOrCreateWorkspace(repository, sourceWorkspace);
+ targetSession = JcrUtils.loginOrCreateWorkspace(repository, targetWorkspace);
// works only in OSGi!!
// systemPackages = Arrays.asList(System.getProperty(
try {
// clear target
- NodeIterator nit = targetSession.getNode(artifactBasePath)
- .getNodes();
+ NodeIterator nit = targetSession.getNode(artifactBasePath).getNodes();
while (nit.hasNext()) {
Node node = nit.nextNode();
- if (node.isNodeType(NodeType.NT_FOLDER)
- || node.isNodeType(NodeType.NT_UNSTRUCTURED)) {
+ if (node.isNodeType(NodeType.NT_FOLDER) || node.isNodeType(NodeType.NT_UNSTRUCTURED)) {
node.remove();
node.getSession().save();
if (log.isDebugEnabled())
processOrigArtifactVersion(origArtifactNode);
}
} catch (Exception e) {
- throw new SlcException("Cannot perform v1.3 migration from "
- + sourceWorkspace + " to " + targetWorkspace, e);
+ throw new SlcException("Cannot perform v1.3 migration from " + sourceWorkspace + " to " + targetWorkspace,
+ e);
} finally {
JcrUtils.discardQuietly(targetSession);
}
}
- protected void processOrigArtifactVersion(Node origArtifactNode)
- throws RepositoryException, IOException {
+ protected void processOrigArtifactVersion(Node origArtifactNode) throws RepositoryException, IOException {
Artifact origArtifact = RepoUtils.asArtifact(origArtifactNode);
// skip eclipse artifacts
- if ((origArtifact.getGroupId().startsWith("org.eclipse") && !(origArtifact
- .getArtifactId().equals("org.eclipse.osgi")
- || origArtifact.getArtifactId().equals(
- "org.eclipse.osgi.source") || origArtifact
- .getArtifactId().startsWith("org.eclipse.rwt.widgets.upload")))
+ if ((origArtifact.getGroupId().startsWith("org.eclipse")
+ && !(origArtifact.getArtifactId().equals("org.eclipse.osgi")
+ || origArtifact.getArtifactId().equals("org.eclipse.osgi.source")
+ || origArtifact.getArtifactId().startsWith("org.eclipse.rwt.widgets.upload")))
|| origArtifact.getArtifactId().startsWith("com.ibm.icu")) {
if (log.isDebugEnabled())
log.debug("Skip " + origArtifact);
}
// skip SpringSource ActiveMQ
- if (origArtifact.getArtifactId().startsWith(
- "com.springsource.org.apache.activemq"))
+ if (origArtifact.getArtifactId().startsWith("com.springsource.org.apache.activemq"))
return;
- String origJarNodeName = MavenConventionsUtils
- .artifactFileName(origArtifact);
+ String origJarNodeName = MavenConventionsUtils.artifactFileName(origArtifact);
if (!origArtifactNode.hasNode(origJarNodeName))
- throw new SlcException("Cannot find jar node for "
- + origArtifactNode);
+ throw new SlcException("Cannot find jar node for " + origArtifactNode);
Node origJarNode = origArtifactNode.getNode(origJarNodeName);
// read MANIFEST
- Binary manifestBinary = origJarNode.getProperty(SLC_MANIFEST)
- .getBinary();
+ Binary manifestBinary = origJarNode.getProperty(SLC_MANIFEST).getBinary();
Manifest origManifest = new Manifest(manifestBinary.getStream());
JcrUtils.closeQuietly(manifestBinary);
Manifest targetManifest = new Manifest(origManifest);
// transform symbolic name
- String origSymbolicName = origManifest.getMainAttributes().getValue(
- Constants.BUNDLE_SYMBOLICNAME);
+ String origSymbolicName = origManifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
final String targetSymbolicName;
if (symbolicNamesMapping.containsKey(origSymbolicName)) {
targetSymbolicName = symbolicNamesMapping.get(origSymbolicName);
} else if (origSymbolicName.startsWith(SPRING_SOURCE_PREFIX)
&& !origSymbolicName.equals(SPRING_SOURCE_PREFIX + ".json")) {
- targetSymbolicName = origSymbolicName
- .substring(SPRING_SOURCE_PREFIX.length() + 1);
+ targetSymbolicName = origSymbolicName.substring(SPRING_SOURCE_PREFIX.length() + 1);
} else {
targetSymbolicName = origSymbolicName;
}
if (!targetSymbolicName.equals(origSymbolicName)) {
- targetManifest.getMainAttributes().putValue(
- Constants.BUNDLE_SYMBOLICNAME, targetSymbolicName);
+ targetManifest.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, targetSymbolicName);
manifestModified = true;
if (log.isDebugEnabled())
- log.debug(Constants.BUNDLE_SYMBOLICNAME + " to "
- + targetSymbolicName + " \t\tfrom " + origSymbolicName);
+ log.debug(
+ Constants.BUNDLE_SYMBOLICNAME + " to " + targetSymbolicName + " \t\tfrom " + origSymbolicName);
}
// skip excluded bundles
return;
// check fragment host
- if (origManifest.getMainAttributes().containsKey(
- new Name(Constants.FRAGMENT_HOST))) {
- String origFragmentHost = origManifest.getMainAttributes()
- .getValue(Constants.FRAGMENT_HOST);
+ if (origManifest.getMainAttributes().containsKey(new Name(Constants.FRAGMENT_HOST))) {
+ String origFragmentHost = origManifest.getMainAttributes().getValue(Constants.FRAGMENT_HOST);
String targetFragmentHost;
if (symbolicNamesMapping.containsKey(origFragmentHost)) {
targetFragmentHost = symbolicNamesMapping.get(origFragmentHost);
} else if (origFragmentHost.startsWith(SPRING_SOURCE_PREFIX)
&& !origFragmentHost.equals(SPRING_SOURCE_PREFIX + ".json")) {
- targetFragmentHost = origFragmentHost
- .substring(SPRING_SOURCE_PREFIX.length() + 1);
- } else if (origFragmentHost
- .equals("org.argeo.dep.jacob;bundle-version=\"[1.14.3,1.14.4)\"")) {
+ targetFragmentHost = origFragmentHost.substring(SPRING_SOURCE_PREFIX.length() + 1);
+ } else if (origFragmentHost.equals("org.argeo.dep.jacob;bundle-version=\"[1.14.3,1.14.4)\"")) {
// this one for those who think I cannot be pragmatic - mbaudier
targetFragmentHost = "com.jacob;bundle-version=\"[1.14.3,1.14.4)\"";
} else {
}
if (!targetFragmentHost.equals(origFragmentHost)) {
- targetManifest.getMainAttributes().putValue(
- Constants.FRAGMENT_HOST, targetFragmentHost);
+ targetManifest.getMainAttributes().putValue(Constants.FRAGMENT_HOST, targetFragmentHost);
manifestModified = true;
if (log.isDebugEnabled())
- log.debug(Constants.FRAGMENT_HOST + " to "
- + targetFragmentHost + " from " + origFragmentHost);
+ log.debug(Constants.FRAGMENT_HOST + " to " + targetFragmentHost + " from " + origFragmentHost);
}
}
// javax with versions
StringBuffer targetImportPackages = new StringBuffer("");
- NodeIterator origImportPackages = origJarNode.getNodes(SLC_
- + Constants.IMPORT_PACKAGE);
+ NodeIterator origImportPackages = origJarNode.getNodes(SLC_ + Constants.IMPORT_PACKAGE);
Boolean importPackagesModified = false;
while (origImportPackages.hasNext()) {
Node importPackage = origImportPackages.nextNode();
String pkg = importPackage.getProperty(SLC_NAME).getString();
targetImportPackages.append(pkg);
if (importPackage.hasProperty(SLC_VERSION)) {
- String sourceVersion = importPackage.getProperty(SLC_VERSION)
- .getString();
+ String sourceVersion = importPackage.getProperty(SLC_VERSION).getString();
String targetVersion = sourceVersion;
if (systemPackages.contains(pkg)) {
- if (!(sourceVersion.trim().equals("0") || sourceVersion
- .trim().equals("0.0.0"))) {
+ if (!(sourceVersion.trim().equals("0") || sourceVersion.trim().equals("0.0.0"))) {
targetVersion = null;
importPackagesModified = true;
if (log.isDebugEnabled())
- log.debug(origSymbolicName
- + ": Nullify version of " + pkg + " from "
- + sourceVersion);
+ log.debug(origSymbolicName + ": Nullify version of " + pkg + " from " + sourceVersion);
}
}
if (targetVersion != null)
- targetImportPackages.append(";version=\"")
- .append(targetVersion).append("\"");
+ targetImportPackages.append(";version=\"").append(targetVersion).append("\"");
}
if (importPackage.hasProperty(SLC_OPTIONAL)) {
- Boolean optional = importPackage.getProperty(SLC_OPTIONAL)
- .getBoolean();
+ Boolean optional = importPackage.getProperty(SLC_OPTIONAL).getBoolean();
if (optional)
targetImportPackages.append(";resolution:=\"optional\"");
}
if (importPackagesModified) {
- targetManifest.getMainAttributes().putValue(
- Constants.IMPORT_PACKAGE, targetImportPackages.toString());
+ targetManifest.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, targetImportPackages.toString());
manifestModified = true;
}
// target coordinates
final String targetGroupId;
- if (origArtifact.getArtifactId().startsWith(
- "org.eclipse.rwt.widgets.upload"))
+ if (origArtifact.getArtifactId().startsWith("org.eclipse.rwt.widgets.upload"))
targetGroupId = "org.argeo.tp.rap";
else if (origArtifact.getArtifactId().startsWith("org.polymap"))
targetGroupId = "org.argeo.tp.rap";
targetGroupId = "org.argeo.tp";
String targetArtifactId = targetSymbolicName.split(";")[0];
- Artifact targetArtifact = new DefaultArtifact(targetGroupId,
- targetArtifactId, "jar", origArtifact.getVersion());
- String targetParentPath = MavenConventionsUtils.artifactParentPath(
- artifactBasePath, targetArtifact);
- String targetFileName = MavenConventionsUtils
- .artifactFileName(targetArtifact);
+ Artifact targetArtifact = new DefaultArtifact(targetGroupId, targetArtifactId, "jar",
+ origArtifact.getVersion());
+ String targetParentPath = MavenConventionsUtils.artifactParentPath(artifactBasePath, targetArtifact);
+ String targetFileName = MavenConventionsUtils.artifactFileName(targetArtifact);
String targetJarPath = targetParentPath + '/' + targetFileName;
// copy
- Node targetParentNode = JcrUtils.mkfolders(targetSession,
- targetParentPath);
+ Node targetParentNode = JcrUtils.mkfolders(targetSession, targetParentPath);
targetSession.save();
if (manifestModified) {
- Binary origBinary = origJarNode.getNode(Node.JCR_CONTENT)
- .getProperty(Property.JCR_DATA).getBinary();
- byte[] targetJarBytes = RepoUtils.modifyManifest(
- origBinary.getStream(), targetManifest);
- JcrUtils.copyBytesAsFile(targetParentNode, targetFileName,
- targetJarBytes);
+ Binary origBinary = origJarNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary();
+ byte[] targetJarBytes = RepoUtils.modifyManifest(origBinary.getStream(), targetManifest);
+ JcrUtils.copyBytesAsFile(targetParentNode, targetFileName, targetJarBytes);
JcrUtils.closeQuietly(origBinary);
} else {// just copy
- targetSession.getWorkspace().copy(sourceWorkspace,
- origJarNode.getPath(), targetJarPath);
+ targetSession.getWorkspace().copy(sourceWorkspace, origJarNode.getPath(), targetJarPath);
}
targetSession.save();
targetSession.save();
// sources
- Artifact origSourceArtifact = new DefaultArtifact(
- origArtifact.getGroupId(), origArtifact.getArtifactId()
- + ".source", "jar", origArtifact.getVersion());
- String origSourcePath = MavenConventionsUtils.artifactPath(
- artifactBasePath, origSourceArtifact);
+ Artifact origSourceArtifact = new DefaultArtifact(origArtifact.getGroupId(),
+ origArtifact.getArtifactId() + ".source", "jar", origArtifact.getVersion());
+ String origSourcePath = MavenConventionsUtils.artifactPath(artifactBasePath, origSourceArtifact);
if (origSession.itemExists(origSourcePath)) {
Node origSourceJarNode = origSession.getNode(origSourcePath);
- Artifact targetSourceArtifact = new DefaultArtifact(targetGroupId,
- targetArtifactId + ".source", "jar",
+ Artifact targetSourceArtifact = new DefaultArtifact(targetGroupId, targetArtifactId + ".source", "jar",
origArtifact.getVersion());
- String targetSourceParentPath = MavenConventionsUtils
- .artifactParentPath(artifactBasePath, targetSourceArtifact);
- String targetSourceFileName = MavenConventionsUtils
- .artifactFileName(targetSourceArtifact);
- String targetSourceJarPath = targetSourceParentPath + '/'
- + targetSourceFileName;
-
- Node targetSourceParentNode = JcrUtils.mkfolders(targetSession,
- targetSourceParentPath);
+ String targetSourceParentPath = MavenConventionsUtils.artifactParentPath(artifactBasePath,
+ targetSourceArtifact);
+ String targetSourceFileName = MavenConventionsUtils.artifactFileName(targetSourceArtifact);
+ String targetSourceJarPath = targetSourceParentPath + '/' + targetSourceFileName;
+
+ Node targetSourceParentNode = JcrUtils.mkfolders(targetSession, targetSourceParentPath);
targetSession.save();
if (!targetSymbolicName.equals(origSymbolicName)) {
- Binary origBinary = origSourceJarNode.getNode(Node.JCR_CONTENT)
- .getProperty(Property.JCR_DATA).getBinary();
- NameVersion targetNameVersion = RepoUtils
- .readNameVersion(targetManifest);
- byte[] targetJarBytes = RepoUtils.packageAsPdeSource(
- origBinary.getStream(), targetNameVersion);
- JcrUtils.copyBytesAsFile(targetSourceParentNode,
- targetSourceFileName, targetJarBytes);
+ Binary origBinary = origSourceJarNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA)
+ .getBinary();
+ NameVersion targetNameVersion = RepoUtils.readNameVersion(targetManifest);
+ byte[] targetJarBytes = RepoUtils.packageAsPdeSource(origBinary.getStream(), targetNameVersion);
+ JcrUtils.copyBytesAsFile(targetSourceParentNode, targetSourceFileName, targetJarBytes);
JcrUtils.closeQuietly(origBinary);
} else {// just copy
- targetSession.getWorkspace().copy(sourceWorkspace,
- origSourceJarNode.getPath(), targetSourceJarPath);
+ targetSession.getWorkspace().copy(sourceWorkspace, origSourceJarNode.getPath(), targetSourceJarPath);
}
targetSession.save();
// reindex
- Node targetSourceJarNode = targetSession
- .getNode(targetSourceJarPath);
+ Node targetSourceJarNode = targetSession.getNode(targetSourceJarPath);
artifactIndexer.index(targetSourceJarNode);
jarFileIndexer.index(targetSourceJarNode);
* UTILITIES
*/
- static NodeIterator listArtifactVersions(Session session)
- throws RepositoryException {
+ static NodeIterator listArtifactVersions(Session session) throws RepositoryException {
QueryManager queryManager = session.getWorkspace().getQueryManager();
QueryObjectModelFactory factory = queryManager.getQOMFactory();
final String artifactVersionsSelector = "artifactVersions";
- Selector source = factory.selector(SlcTypes.SLC_ARTIFACT_VERSION_BASE,
- artifactVersionsSelector);
+ Selector source = factory.selector(SlcTypes.SLC_ARTIFACT_VERSION_BASE, artifactVersionsSelector);
- Ordering orderByArtifactId = factory.ascending(factory.propertyValue(
- artifactVersionsSelector, SlcNames.SLC_ARTIFACT_ID));
+ Ordering orderByArtifactId = factory
+ .ascending(factory.propertyValue(artifactVersionsSelector, SlcNames.SLC_ARTIFACT_ID));
Ordering[] orderings = { orderByArtifactId };
- QueryObjectModel query = factory.createQuery(source, null, orderings,
- null);
+ QueryObjectModel query = factory.createQuery(source, null, orderings, null);
QueryResult result = query.execute();
return result.getNodes();
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.repo.OsgiFactory;
public class ArchiveSourcesProvider implements SourcesProvider {
- private final static Log log = LogFactory
- .getLog(ArchiveSourcesProvider.class);
+ private final static CmsLog log = CmsLog.getLog(ArchiveSourcesProvider.class);
private OsgiFactory osgiFactory;
private String uri;
log.debug("Wrapping " + uri);
Node distNode = osgiFactory.getDist(distSession, uri);
- zin = new ZipInputStream(distNode.getNode(Node.JCR_CONTENT)
- .getProperty(Property.JCR_DATA).getBinary().getStream());
+ zin = new ZipInputStream(
+ distNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream());
// prepare
Set<String> directories = new TreeSet<String>();
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.DefaultNameVersion;
* need further modification.
*/
public class ArchiveWrapper implements Runnable, ModuleSet, Distribution {
- private final static Log log = LogFactory.getLog(ArchiveWrapper.class);
+ private final static CmsLog log = CmsLog.getLog(ArchiveWrapper.class);
private OsgiFactory osgiFactory;
private String version;
package org.argeo.slc.repo.osgi;
+import static org.argeo.slc.ManifestConstants.SLC_ORIGIN_M2;
+import static org.argeo.slc.ManifestConstants.SLC_ORIGIN_URI;
+
import java.io.IOException;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.ManifestConstants;
import org.argeo.slc.ModuleSet;
import org.argeo.slc.NameVersion;
import org.argeo.slc.build.Distribution;
import org.argeo.slc.execution.ExecutionFlow;
import org.argeo.slc.repo.ArgeoOsgiDistribution;
import org.argeo.slc.repo.ArtifactDistribution;
+import org.argeo.slc.repo.FreeLicense;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.osgi.framework.Constants;
* A consistent and versioned OSGi distribution, which can be built and tested.
*/
public class ArgeoOsgiDistributionImpl extends ArtifactDistribution implements ArgeoOsgiDistribution {
- private final static Log log = LogFactory.getLog(ArgeoOsgiDistributionImpl.class);
+ private final static CmsLog log = CmsLog.getLog(ArgeoOsgiDistributionImpl.class);
private List<Object> modules = new ArrayList<Object>();
public void init() {
if (log.isDebugEnabled())
log.debug(describe());
-// migrateTov2(Paths.get(System.getProperty("user.home"), "dev/git/gpl/argeo-tp/argeo-tp"));
+ migrateTov2(Paths.get(System.getProperty("user.home"), "dev/git/unstable/argeo-tp/migration"));
}
public void destroy() {
else
log.warn("No license for " + cnv);
if (bw.getDoNotModify()) {
- props.put("SLC-Source-Original", "true");
+ props.put(ManifestConstants.SLC_ORIGIN_MANIFEST_NOT_MODIFIED.toString(), "true");
}
// props.put("SLC-Category", cnv.getCategory());
if (cnv instanceof MavenWrapper) {
MavenWrapper mw = (MavenWrapper) cnv;
String sourceCoords = mw.getSourceCoords();
- props.put("SLC-Source-M2", sourceCoords);
+ props.put(SLC_ORIGIN_M2.toString(), sourceCoords);
Artifact mavenCnv = new DefaultArtifact(sourceCoords);
if (mavenCnv.getArtifactId().equals(cnv.getName()))
props.remove(Constants.BUNDLE_SYMBOLICNAME);
props.remove(Constants.BUNDLE_VERSION);
} else if (cnv instanceof UriWrapper) {
UriWrapper mw = (UriWrapper) cnv;
- props.put("SLC-Source-URI", mw.getEffectiveUri());
+ props.put(SLC_ORIGIN_URI.toString(), mw.getEffectiveUri());
if (mw.getUri() == null && mw.getBaseUri() != null) {
log.warn("Base URI for " + cnv);
- props.put("SLC-Source-BaseURI", mw.getBaseUri());
- props.put("SLC-Source-VersionSeparator", mw.getVersionSeparator());
+ props.put("SLC-Origin-BaseURI", mw.getBaseUri());
+ props.put("SLC-Origin-VersionSeparator", mw.getVersionSeparator());
}
} else {
log.warn("Unidentified BND wrapper " + cnv);
log.debug(" includes: " + aw.getIncludes());
log.debug(" excludes: " + aw.getExcludes());
log.debug(" beans : " + aw.getWrappers());
+
+ String uri = aw.getUri();
+ String duName = null;
+ String category = null;
+ String oldCategory = null;
+ if (uri.startsWith("http://www.eclipse.org/downloads/rt/rap/3.10/e4/rap-e4")) {
+ duName = "eclipse-rap";
+ category = "org.argeo.tp.eclipse.rap";
+ oldCategory = "org.argeo.tp.rap.e4";
+ } else if (uri.startsWith("http://www.eclipse.org/downloads/equinox/")) {
+ duName = "eclipse-equinox";
+ category = "org.argeo.tp.eclipse.equinox";
+ oldCategory = "org.argeo.tp.equinox";
+ } else if (uri.startsWith("http://www.eclipse.org/downloads/eclipse/downloads/drops4")) {
+ duName = "eclipse-rcp";
+ category = "org.argeo.tp.eclipse.rcp";
+ oldCategory = "org.argeo.tp.rcp.e4";
+ }
+
+ if (duName != null) {
+ try {
+ Path duDir = baseDir.resolve(category).resolve(duName);
+ Files.createDirectories(duDir);
+ Path bndPath = duDir.resolve("common.bnd");
+ Path includesPath = duDir.resolve("includes.properties");
+
+ Map<String, String> props = new TreeMap<>();
+ props.put(ManifestConstants.SLC_ORIGIN_URI.toString(), aw.getUri());
+ props.put(ManifestConstants.SLC_ORIGIN_MANIFEST_NOT_MODIFIED.toString(), "true");
+ props.put(Constants.BUNDLE_LICENSE, FreeLicense.EPL.toString());
+ // write BND file
+ try (Writer bndWriter = Files.newBufferedWriter(bndPath);
+ Writer includesWriter = Files.newBufferedWriter(includesPath);) {
+ // writer.write("# " + cnv + "\n");
+ props: for (String key : props.keySet()) {
+ String value = props.get(key);
+ if (Constants.EXPORT_PACKAGE.equals(key) && "*".equals(value.trim()))
+ continue props;
+
+ bndWriter.write(key + ": " + value + '\n');
+ }
+
+ for (String key : aw.getIncludes().keySet()) {
+ String value = aw.getIncludes().get(key);
+ if (value.equals(oldCategory))
+ value = category;
+ includesWriter.write(key + "=" + value + '\n');
+ }
+ if (log.isTraceEnabled())
+ log.trace("Wrote " + bndPath);
+ }
+ } catch (IOException e) {
+ log.error("Could not process " + aw, e);
+ }
+
+ }
}
}
import java.util.jar.Manifest;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.SlcException;
import org.argeo.slc.build.Distribution;
/** Utilities around the BND library, which manipulates OSGi metadata. */
public class BndWrapper implements Constants, CategoryNameVersion, Distribution {
- private final static Log log = LogFactory.getLog(BndWrapper.class);
+ private final static CmsLog log = CmsLog.getLog(BndWrapper.class);
private String groupId;
private String name;
// License
if (license != null) {
- StringBuilder sb = new StringBuilder(license.getUri());
- if (license.getName() != null)
- sb.append(';').append("description=").append(license.getName());
- if (license.getLink() != null)
- sb.append(';').append("link=").append(license.getLink());
- properties.setProperty(BUNDLE_LICENSE, sb.toString());
+ properties.setProperty(BUNDLE_LICENSE, license.toString());
// TODO add LICENSE.TXT
} else {
log.warn("No license set for " + toString());
import javax.jcr.Session;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
*/
@Deprecated
public class ImportBundlesZip implements Runnable {
- private final static Log log = LogFactory.getLog(ImportBundlesZip.class);
+ private final static CmsLog log = CmsLog.getLog(ImportBundlesZip.class);
private Repository repository;
private String workspace;
private String groupId;
ZipEntry zipEntry = null;
entries: while ((zipEntry = zipIn.getNextEntry()) != null) {
String entryName = zipEntry.getName();
- if (!entryName.endsWith(".jar")
- || entryName.contains("feature"))
+ if (!entryName.endsWith(".jar") || entryName.contains("feature"))
continue entries;// skip
byte[] jarBytes = IOUtils.toByteArray(zipIn);
zipIn.closeEntry();
continue entries;
}
- String bundleName = RepoUtils
- .extractBundleNameFromSourceName(nv.getName());
+ String bundleName = RepoUtils.extractBundleNameFromSourceName(nv.getName());
// skip excluded bundles and their sources
if (excludedBundles.contains(bundleName))
continue entries;
// continue entries;
// }
- Artifact artifact = new DefaultArtifact(groupId, nv.getName(),
- "jar", nv.getVersion());
- Node artifactNode = RepoUtils.copyBytesAsArtifact(
- session.getNode(artifactBasePath), artifact, jarBytes);
+ Artifact artifact = new DefaultArtifact(groupId, nv.getName(), "jar", nv.getVersion());
+ Node artifactNode = RepoUtils.copyBytesAsArtifact(session.getNode(artifactBasePath), artifact,
+ jarBytes);
jarBytes = null;// superstition, in order to free memory
// indexes
log.debug("Imported " + entryName + " to " + artifactNode);
}
} catch (Exception e) {
- throw new SlcException("Cannot import zip " + zipFile + " to "
- + workspace, e);
+ throw new SlcException("Cannot import zip " + zipFile + " to " + workspace, e);
} finally {
IOUtils.closeQuietly(zipIn);
IOUtils.closeQuietly(jarIn);
import javax.jcr.Session;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.DefaultNameVersion;
import org.argeo.slc.SlcException;
* repositories.
*/
public class MavenWrapper extends BndWrapper implements Runnable {
- private final static Log log = LogFactory.getLog(MavenWrapper.class);
+ private final static CmsLog log = CmsLog.getLog(MavenWrapper.class);
private String sourceCoords;
import javax.jcr.Session;
import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrMonitor;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
*/
@Deprecated
public class NormalizeGroup implements Runnable, SlcNames {
- private final static Log log = LogFactory.getLog(NormalizeGroup.class);
+ private final static CmsLog log = CmsLog.getLog(NormalizeGroup.class);
private Repository repository;
private String workspace;
// private JarFileIndexer jarFileIndexer = new JarFileIndexer();
/** TODO make it more generic */
- private List<String> systemPackages = OsgiProfile.PROFILE_JAVA_SE_1_6
- .getSystemPackages();
+ private List<String> systemPackages = OsgiProfile.PROFILE_JAVA_SE_1_6.getSystemPackages();
// indexes
private Map<String, String> packagesToSymbolicNames = new HashMap<String, String>();
private Map<String, Node> symbolicNamesToNodes = new HashMap<String, Node>();
- private Set<Artifact> binaries = new TreeSet<Artifact>(
- new ArtifactIdComparator());
- private Set<Artifact> sources = new TreeSet<Artifact>(
- new ArtifactIdComparator());
+ private Set<Artifact> binaries = new TreeSet<Artifact>(new ArtifactIdComparator());
+ private Set<Artifact> sources = new TreeSet<Artifact>(new ArtifactIdComparator());
public void run() {
Session session = null;
try {
session = repository.login(workspace);
- Node groupNode = session.getNode(MavenConventionsUtils.groupPath(
- artifactBasePath, groupId));
+ Node groupNode = session.getNode(MavenConventionsUtils.groupPath(artifactBasePath, groupId));
processGroupNode(groupNode, null);
} catch (Exception e) {
- throw new SlcException("Cannot normalize group " + groupId + " in "
- + workspace, e);
+ throw new SlcException("Cannot normalize group " + groupId + " in " + workspace, e);
} finally {
JcrUtils.logoutQuietly(session);
}
}
- public static void processGroupNode(Node groupNode, String version,
- Boolean overridePoms, JcrMonitor monitor)
+ public static void processGroupNode(Node groupNode, String version, Boolean overridePoms, JcrMonitor monitor)
throws RepositoryException {
// TODO set artifactsBase based on group node
NormalizeGroup ng = new NormalizeGroup();
- String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID)
- .getString();
+ String groupId = groupNode.getProperty(SlcNames.SLC_GROUP_BASE_ID).getString();
ng.setGroupId(groupId);
ng.setVersion(version);
ng.setOverridePoms(overridePoms);
ng.processGroupNode(groupNode, monitor);
}
- protected void processGroupNode(Node groupNode, JcrMonitor monitor)
- throws RepositoryException {
+ protected void processGroupNode(Node groupNode, JcrMonitor monitor) throws RepositoryException {
if (monitor != null)
monitor.subTask("Group " + groupId);
Node allArtifactsHighestVersion = null;
Session session = groupNode.getSession();
- aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases
- .hasNext();) {
+ aBases: for (NodeIterator aBases = groupNode.getNodes(); aBases.hasNext();) {
Node aBase = aBases.nextNode();
if (aBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE)) {
Node highestAVersion = null;
- for (NodeIterator aVersions = aBase.getNodes(); aVersions
- .hasNext();) {
+ for (NodeIterator aVersions = aBase.getNodes(); aVersions.hasNext();) {
Node aVersion = aVersions.nextNode();
if (aVersion.isNodeType(SlcTypes.SLC_ARTIFACT_VERSION_BASE)) {
if (highestAVersion == null) {
if (currVersion.compareTo(currentHighestVersion) > 0) {
highestAVersion = aVersion;
}
- if (currVersion
- .compareTo(extractOsgiVersion(allArtifactsHighestVersion)) > 0) {
+ if (currVersion.compareTo(extractOsgiVersion(allArtifactsHighestVersion)) > 0) {
allArtifactsHighestVersion = aVersion;
}
}
}
if (highestAVersion == null)
continue aBases;
- for (NodeIterator files = highestAVersion.getNodes(); files
- .hasNext();) {
+ for (NodeIterator files = highestAVersion.getNodes(); files.hasNext();) {
Node file = files.nextNode();
if (file.isNodeType(SlcTypes.SLC_BUNDLE_ARTIFACT)) {
preProcessBundleArtifact(file);
// => the version can then be left empty
if (version == null || version.trim().equals(""))
if (allArtifactsHighestVersion != null)
- version = allArtifactsHighestVersion.getProperty(
- SLC_ARTIFACT_VERSION).getString();
+ version = allArtifactsHighestVersion.getProperty(SLC_ARTIFACT_VERSION).getString();
else
version = "0.0";
// throw new SlcException("Group version " + version
processBundleArtifact(bundleNode);
bundleNode.getSession().save();
if (log.isDebugEnabled())
- log.debug(count + "/" + bundleCount + " Processed "
- + bundleNode.getName());
+ log.debug(count + "/" + bundleCount + " Processed " + bundleNode.getName());
count++;
}
// indexes
- Set<Artifact> indexes = new TreeSet<Artifact>(
- new ArtifactIdComparator());
- Artifact indexArtifact = writeIndex(session,
- RepoConstants.BINARIES_ARTIFACT_ID, binaries);
+ Set<Artifact> indexes = new TreeSet<Artifact>(new ArtifactIdComparator());
+ Artifact indexArtifact = writeIndex(session, RepoConstants.BINARIES_ARTIFACT_ID, binaries);
indexes.add(indexArtifact);
- indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID,
- sources);
+ indexArtifact = writeIndex(session, RepoConstants.SOURCES_ARTIFACT_ID, sources);
indexes.add(indexArtifact);
// sdk
writeIndex(session, RepoConstants.SDK_ARTIFACT_ID, indexes);
monitor.worked(1);
}
- private Version extractOsgiVersion(Node artifactVersion)
- throws RepositoryException {
- String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION)
- .getString();
+ private Version extractOsgiVersion(Node artifactVersion) throws RepositoryException {
+ String rawVersion = artifactVersion.getProperty(SLC_ARTIFACT_VERSION).getString();
String cleanVersion = rawVersion.replace("-SNAPSHOT", ".SNAPSHOT");
Version osgiVersion = null;
// log invalid version value to enable tracking them
return tmpVersion;
}
- private Artifact writeIndex(Session session, String artifactId,
- Set<Artifact> artifacts) throws RepositoryException {
- Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom",
- version);
- Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(
- parentPomCoordinates) : null;
- String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact,
- artifacts, parentArtifact);
- Node node = RepoUtils.copyBytesAsArtifact(
- session.getNode(artifactBasePath), artifact, pom.getBytes());
+ private Artifact writeIndex(Session session, String artifactId, Set<Artifact> artifacts)
+ throws RepositoryException {
+ Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom", version);
+ Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact(parentPomCoordinates) : null;
+ String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact, artifacts, parentArtifact);
+ Node node = RepoUtils.copyBytesAsArtifact(session.getNode(artifactBasePath), artifact, pom.getBytes());
artifactIndexer.index(node);
// TODO factorize
String pomSha = JcrUtils.checksumFile(node, "SHA-1");
- JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1",
- pomSha.getBytes());
+ JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".sha1", pomSha.getBytes());
String pomMd5 = JcrUtils.checksumFile(node, "MD5");
- JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5",
- pomMd5.getBytes());
+ JcrUtils.copyBytesAsFile(node.getParent(), node.getName() + ".md5", pomMd5.getBytes());
session.save();
return artifact;
}
- protected void preProcessBundleArtifact(Node bundleNode)
- throws RepositoryException {
+ protected void preProcessBundleArtifact(Node bundleNode) throws RepositoryException {
String symbolicName = JcrUtils.get(bundleNode, SLC_SYMBOLIC_NAME);
if (symbolicName.endsWith(".source")) {
// TODO make a shared node with classifier 'sources'?
- String bundleName = RepoUtils
- .extractBundleNameFromSourceName(symbolicName);
+ String bundleName = RepoUtils.extractBundleNameFromSourceName(symbolicName);
for (String excludedSuffix : excludedSuffixes) {
if (bundleName.endsWith(excludedSuffix))
return;// skip adding to sources
return;
}
- NodeIterator exportPackages = bundleNode.getNodes(SLC_
- + Constants.EXPORT_PACKAGE);
+ NodeIterator exportPackages = bundleNode.getNodes(SLC_ + Constants.EXPORT_PACKAGE);
while (exportPackages.hasNext()) {
Node exportPackage = exportPackages.nextNode();
String pkg = JcrUtils.get(exportPackage, SLC_NAME);
bundleNode.getSession().save();
}
- protected void processBundleArtifact(Node bundleNode)
- throws RepositoryException {
+ protected void processBundleArtifact(Node bundleNode) throws RepositoryException {
Node artifactFolder = bundleNode.getParent();
String baseName = FilenameUtils.getBaseName(bundleNode.getName());
return;// skip
String pom = generatePomForBundle(bundleNode);
- Node pomNode = JcrUtils.copyBytesAsFile(artifactFolder, pomName,
- pom.getBytes());
+ Node pomNode = JcrUtils.copyBytesAsFile(artifactFolder, pomName, pom.getBytes());
// checksum
String bundleSha = JcrUtils.checksumFile(bundleNode, "SHA-1");
- JcrUtils.copyBytesAsFile(artifactFolder,
- bundleNode.getName() + ".sha1", bundleSha.getBytes());
+ JcrUtils.copyBytesAsFile(artifactFolder, bundleNode.getName() + ".sha1", bundleSha.getBytes());
String pomSha = JcrUtils.checksumFile(pomNode, "SHA-1");
- JcrUtils.copyBytesAsFile(artifactFolder, pomNode.getName() + ".sha1",
- pomSha.getBytes());
+ JcrUtils.copyBytesAsFile(artifactFolder, pomNode.getName() + ".sha1", pomSha.getBytes());
}
private String generatePomForBundle(Node n) throws RepositoryException {
// 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>");
// Artifact
- p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID))
- .append("</groupId>\n");
- p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID))
- .append("</artifactId>\n");
- p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION))
- .append("</version>\n");
+ p.append("<groupId>").append(JcrUtils.get(n, SLC_GROUP_ID)).append("</groupId>\n");
+ p.append("<artifactId>").append(JcrUtils.get(n, SLC_ARTIFACT_ID)).append("</artifactId>\n");
+ p.append("<version>").append(JcrUtils.get(n, SLC_ARTIFACT_VERSION)).append("</version>\n");
p.append("<packaging>pom</packaging>\n");
if (n.hasProperty(SLC_ + Constants.BUNDLE_NAME))
- p.append("<name>")
- .append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME))
- .append("</name>\n");
+ p.append("<name>").append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_NAME)).append("</name>\n");
if (n.hasProperty(SLC_ + Constants.BUNDLE_DESCRIPTION))
- p.append("<description>")
- .append(JcrUtils
- .get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
+ p.append("<description>").append(JcrUtils.get(n, SLC_ + Constants.BUNDLE_DESCRIPTION))
.append("</description>\n");
// Dependencies
Set<String> dependenciesSymbolicNames = new TreeSet<String>();
Set<String> optionalSymbolicNames = new TreeSet<String>();
- NodeIterator importPackages = n.getNodes(SLC_
- + Constants.IMPORT_PACKAGE);
+ NodeIterator importPackages = n.getNodes(SLC_ + Constants.IMPORT_PACKAGE);
while (importPackages.hasNext()) {
Node importPackage = importPackages.nextNode();
String pkg = JcrUtils.get(importPackage, SLC_NAME);
if (packagesToSymbolicNames.containsKey(pkg)) {
- String dependencySymbolicName = packagesToSymbolicNames
- .get(pkg);
+ String dependencySymbolicName = packagesToSymbolicNames.get(pkg);
if (JcrUtils.check(importPackage, SLC_OPTIONAL))
optionalSymbolicNames.add(dependencySymbolicName);
else
dependenciesSymbolicNames.add(dependencySymbolicName);
} else {
- if (!JcrUtils.check(importPackage, SLC_OPTIONAL)
- && !systemPackages.contains(pkg))
+ if (!JcrUtils.check(importPackage, SLC_OPTIONAL) && !systemPackages.contains(pkg))
log.warn("No bundle found for pkg " + pkg);
}
}
if (n.hasNode(SLC_ + Constants.FRAGMENT_HOST)) {
- String fragmentHost = JcrUtils.get(
- n.getNode(SLC_ + Constants.FRAGMENT_HOST),
- SLC_SYMBOLIC_NAME);
+ String fragmentHost = JcrUtils.get(n.getNode(SLC_ + Constants.FRAGMENT_HOST), SLC_SYMBOLIC_NAME);
dependenciesSymbolicNames.add(fragmentHost);
}
List<Node> optionalDependencyNodes = new ArrayList<Node>();
for (String depSymbName : optionalSymbolicNames) {
if (symbolicNamesToNodes.containsKey(depSymbName))
- optionalDependencyNodes.add(symbolicNamesToNodes
- .get(depSymbName));
+ optionalDependencyNodes.add(symbolicNamesToNodes.get(depSymbName));
else
log.warn("Could not find node for " + depSymbName);
}
p.append("<dependencies>\n");
for (Node dependencyNode : dependencyNodes) {
p.append("<dependency>\n");
- p.append("\t<groupId>")
- .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
- .append("</groupId>\n");
- p.append("\t<artifactId>")
- .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
- .append("</artifactId>\n");
+ p.append("\t<groupId>").append(JcrUtils.get(dependencyNode, SLC_GROUP_ID)).append("</groupId>\n");
+ p.append("\t<artifactId>").append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID)).append("</artifactId>\n");
p.append("</dependency>\n");
}
p.append("<!-- OPTIONAL -->\n");
for (Node dependencyNode : optionalDependencyNodes) {
p.append("<dependency>\n");
- p.append("\t<groupId>")
- .append(JcrUtils.get(dependencyNode, SLC_GROUP_ID))
- .append("</groupId>\n");
- p.append("\t<artifactId>")
- .append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID))
- .append("</artifactId>\n");
+ p.append("\t<groupId>").append(JcrUtils.get(dependencyNode, SLC_GROUP_ID)).append("</groupId>\n");
+ p.append("\t<artifactId>").append(JcrUtils.get(dependencyNode, SLC_ARTIFACT_ID)).append("</artifactId>\n");
p.append("\t<optional>true</optional>\n");
p.append("</dependency>\n");
}
p.append("<dependencies>\n");
p.append("<dependency>\n");
p.append("\t<groupId>").append(groupId).append("</groupId>\n");
- p.append("\t<artifactId>")
- .append(ownSymbolicName.endsWith(".source") ? RepoConstants.SOURCES_ARTIFACT_ID
- : RepoConstants.BINARIES_ARTIFACT_ID)
- .append("</artifactId>\n");
+ p.append("\t<artifactId>").append(ownSymbolicName.endsWith(".source") ? RepoConstants.SOURCES_ARTIFACT_ID
+ : RepoConstants.BINARIES_ARTIFACT_ID).append("</artifactId>\n");
p.append("\t<version>").append(version).append("</version>\n");
p.append("\t<type>pom</type>\n");
p.append("\t<scope>import</scope>\n");
import javax.jcr.security.Privilege;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcConstants;
import org.argeo.slc.SlcException;
/** Default implementation of {@link OsgiFactory}. */
public class OsgiFactoryImpl implements OsgiFactory, SlcNames {
- private final static Log log = LogFactory.getLog(OsgiFactoryImpl.class);
+ private final static CmsLog log = CmsLog.getLog(OsgiFactoryImpl.class);
private String workspace;
private Repository distRepository;
public class OsgiProfile {
public final static String PROP_SYSTEM_PACKAGES = "org.osgi.framework.system.packages";
- public final static OsgiProfile PROFILE_JAVA_SE_1_6 = new OsgiProfile(
- "JavaSE-1.6.profile");
+ public final static OsgiProfile PROFILE_JAVA_SE_1_6 = new OsgiProfile("JavaSE-1.6.profile");
private final URL url;
private final Properties properties;
}
public OsgiProfile(String name) {
- this(OsgiProfile.class.getClassLoader().getResource(
- '/'
- + OsgiProfile.class.getPackage().getName()
- .replace('.', '/') + '/' + name));
+ this(OsgiProfile.class.getClassLoader()
+ .getResource('/' + OsgiProfile.class.getPackage().getName().replace('.', '/') + '/' + name));
}
public List<String> getSystemPackages() {
- String[] splitted = properties.getProperty(PROP_SYSTEM_PACKAGES).split(
- ",");
+ String[] splitted = properties.getProperty(PROP_SYSTEM_PACKAGES).split(",");
List<String> res = new ArrayList<String>();
for (String pkg : splitted) {
res.add(pkg.trim());
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.CategoryNameVersion;
import org.argeo.slc.NameVersion;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
-/** Executes the processes required so that all managed bundles are available. */
+/**
+ * Executes the processes required so that all managed bundles are available.
+ */
public class ProcessDistribution implements Runnable {
- private final static Log log = LogFactory.getLog(ProcessDistribution.class);
+ private final static CmsLog log = CmsLog.getLog(ProcessDistribution.class);
private ArgeoOsgiDistribution osgiDistribution;
private OsgiFactory osgiFactory;
Session javaSession = null;
try {
javaSession = osgiFactory.openJavaSession();
- for (Iterator<? extends NameVersion> it = osgiDistribution
- .nameVersions(); it.hasNext();)
+ for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();)
processNameVersion(javaSession, it.next());
// Check sources
- for (Iterator<? extends NameVersion> it = osgiDistribution
- .nameVersions(); it.hasNext();) {
+ for (Iterator<? extends NameVersion> it = osgiDistribution.nameVersions(); it.hasNext();) {
CategoryNameVersion nv = (CategoryNameVersion) it.next();
- Artifact artifact = new DefaultArtifact(nv.getCategory(),
- nv.getName() + ".source", "jar", nv.getVersion());
+ Artifact artifact = new DefaultArtifact(nv.getCategory(), nv.getName() + ".source", "jar",
+ nv.getVersion());
String path = MavenConventionsUtils.artifactPath("/", artifact);
if (!javaSession.itemExists(path))
log.warn("No source available for " + nv);
// explicitly create the corresponding modular distribution as we
// have here all necessary info.
- ModularDistributionFactory mdf = new ModularDistributionFactory(
- osgiFactory, osgiDistribution);
+ ModularDistributionFactory mdf = new ModularDistributionFactory(osgiFactory, osgiDistribution);
mdf.run();
} catch (RepositoryException e) {
- throw new SlcException("Cannot process distribution "
- + osgiDistribution, e);
+ throw new SlcException("Cannot process distribution " + osgiDistribution, e);
} finally {
JcrUtils.logoutQuietly(javaSession);
}
}
- protected void processNameVersion(Session javaSession,
- NameVersion nameVersion) throws RepositoryException {
+ protected void processNameVersion(Session javaSession, NameVersion nameVersion) throws RepositoryException {
if (log.isTraceEnabled())
log.trace("Check " + nameVersion + "...");
if (!(nameVersion instanceof CategoryNameVersion))
throw new SlcException("Unsupported type " + nameVersion.getClass());
CategoryNameVersion nv = (CategoryNameVersion) nameVersion;
- Artifact artifact = new DefaultArtifact(nv.getCategory(), nv.getName(),
- "jar", nv.getVersion());
+ Artifact artifact = new DefaultArtifact(nv.getCategory(), nv.getName(), "jar", nv.getVersion());
String path = MavenConventionsUtils.artifactPath("/", artifact);
if (!javaSession.itemExists(path)) {
if (nv instanceof BndWrapper) {
/**
* Writes sources into a ZIP (or a JAR), under the same sirectory structure.
*
- * @param packages
- * the packages to import
- * @param out
- * the ZIP or JAR to write to
+ * @param packages the packages to import
+ * @param out the ZIP or JAR to write to
*/
public void writeSources(List<String> packages, ZipOutputStream zout);
}
import org.eclipse.aether.artifact.Artifact;
/**
- * An artifact whose identity is derived from another artifact. <em>Note:</em> Instances of this class are immutable and
- * the exposed mutators return new objects rather than changing the current instance.
+ * An artifact whose identity is derived from another artifact. <em>Note:</em>
+ * Instances of this class are immutable and the exposed mutators return new
+ * objects rather than changing the current instance.
*/
-final class SubArtifact
- extends AbstractArtifact
-{
-
- private final Artifact mainArtifact;
-
- private final String classifier;
-
- private final String extension;
-
- private final File file;
-
- private final Map<String, String> properties;
-
- /**
- * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
- * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
- * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
- * used to refer to the GPG signature of an artifact.
- *
- * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
- * @param classifier The classifier for this artifact, may be {@code null} if none.
- * @param extension The extension for this artifact, may be {@code null} if none.
- */
- public SubArtifact( Artifact mainArtifact, String classifier, String extension )
- {
- this( mainArtifact, classifier, extension, (File) null );
- }
-
- /**
- * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
- * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
- * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
- * used to refer to the GPG signature of an artifact.
- *
- * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
- * @param classifier The classifier for this artifact, may be {@code null} if none.
- * @param extension The extension for this artifact, may be {@code null} if none.
- * @param file The file for this artifact, may be {@code null} if unresolved.
- */
- public SubArtifact( Artifact mainArtifact, String classifier, String extension, File file )
- {
- this( mainArtifact, classifier, extension, null, file );
- }
-
- /**
- * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
- * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
- * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
- * used to refer to the GPG signature of an artifact.
- *
- * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
- * @param classifier The classifier for this artifact, may be {@code null} if none.
- * @param extension The extension for this artifact, may be {@code null} if none.
- * @param properties The properties of the artifact, may be {@code null}.
- */
- public SubArtifact( Artifact mainArtifact, String classifier, String extension, Map<String, String> properties )
- {
- this( mainArtifact, classifier, extension, properties, null );
- }
-
- /**
- * Creates a new sub artifact. The classifier and extension specified for this artifact may use the asterisk
- * character "*" to refer to the corresponding property of the main artifact. For instance, the classifier
- * "*-sources" can be used to refer to the source attachment of an artifact. Likewise, the extension "*.asc" can be
- * used to refer to the GPG signature of an artifact.
- *
- * @param mainArtifact The artifact from which to derive the identity, must not be {@code null}.
- * @param classifier The classifier for this artifact, may be {@code null} if none.
- * @param extension The extension for this artifact, may be {@code null} if none.
- * @param properties The properties of the artifact, may be {@code null}.
- * @param file The file for this artifact, may be {@code null} if unresolved.
- */
- public SubArtifact( Artifact mainArtifact, String classifier, String extension, Map<String, String> properties,
- File file )
- {
- if ( mainArtifact == null )
- {
- throw new IllegalArgumentException( "no artifact specified" );
- }
- this.mainArtifact = mainArtifact;
- this.classifier = classifier;
- this.extension = extension;
- this.file = file;
- this.properties = copyProperties( properties );
- }
-
- private SubArtifact( Artifact mainArtifact, String classifier, String extension, File file,
- Map<String, String> properties )
- {
- // NOTE: This constructor assumes immutability of the provided properties, for internal use only
- this.mainArtifact = mainArtifact;
- this.classifier = classifier;
- this.extension = extension;
- this.file = file;
- this.properties = properties;
- }
-
- public String getGroupId()
- {
- return mainArtifact.getGroupId();
- }
-
- public String getArtifactId()
- {
- return mainArtifact.getArtifactId();
- }
-
- public String getVersion()
- {
- return mainArtifact.getVersion();
- }
-
- public String getBaseVersion()
- {
- return mainArtifact.getBaseVersion();
- }
-
- public boolean isSnapshot()
- {
- return mainArtifact.isSnapshot();
- }
-
- public String getClassifier()
- {
- return expand( classifier, mainArtifact.getClassifier() );
- }
-
- public String getExtension()
- {
- return expand( extension, mainArtifact.getExtension() );
- }
-
- public File getFile()
- {
- return file;
- }
-
- public Artifact setFile( File file )
- {
- if ( ( this.file == null ) ? file == null : this.file.equals( file ) )
- {
- return this;
- }
- return new SubArtifact( mainArtifact, classifier, extension, file, properties );
- }
-
- public Map<String, String> getProperties()
- {
- return properties;
- }
-
- public Artifact setProperties( Map<String, String> properties )
- {
- if ( this.properties.equals( properties ) || ( properties == null && this.properties.isEmpty() ) )
- {
- return this;
- }
- return new SubArtifact( mainArtifact, classifier, extension, properties, file );
- }
-
- private static String expand( String pattern, String replacement )
- {
- String result = "";
- if ( pattern != null )
- {
- result = pattern.replace( "*", replacement );
-
- if ( replacement.length() <= 0 )
- {
- if ( pattern.startsWith( "*" ) )
- {
- int i = 0;
- for ( ; i < result.length(); i++ )
- {
- char c = result.charAt( i );
- if ( c != '-' && c != '.' )
- {
- break;
- }
- }
- result = result.substring( i );
- }
- if ( pattern.endsWith( "*" ) )
- {
- int i = result.length() - 1;
- for ( ; i >= 0; i-- )
- {
- char c = result.charAt( i );
- if ( c != '-' && c != '.' )
- {
- break;
- }
- }
- result = result.substring( 0, i + 1 );
- }
- }
- }
- return result;
- }
+final class SubArtifact extends AbstractArtifact {
+
+ private final Artifact mainArtifact;
+
+ private final String classifier;
+
+ private final String extension;
+
+ private final File file;
+
+ private final Map<String, String> properties;
+
+ /**
+ * Creates a new sub artifact. The classifier and extension specified for this
+ * artifact may use the asterisk character "*" to refer to the corresponding
+ * property of the main artifact. For instance, the classifier "*-sources" can
+ * be used to refer to the source attachment of an artifact. Likewise, the
+ * extension "*.asc" can be used to refer to the GPG signature of an artifact.
+ *
+ * @param mainArtifact The artifact from which to derive the identity, must not
+ * be {@code null}.
+ * @param classifier The classifier for this artifact, may be {@code null} if
+ * none.
+ * @param extension The extension for this artifact, may be {@code null} if
+ * none.
+ */
+ public SubArtifact(Artifact mainArtifact, String classifier, String extension) {
+ this(mainArtifact, classifier, extension, (File) null);
+ }
+
+ /**
+ * Creates a new sub artifact. The classifier and extension specified for this
+ * artifact may use the asterisk character "*" to refer to the corresponding
+ * property of the main artifact. For instance, the classifier "*-sources" can
+ * be used to refer to the source attachment of an artifact. Likewise, the
+ * extension "*.asc" can be used to refer to the GPG signature of an artifact.
+ *
+ * @param mainArtifact The artifact from which to derive the identity, must not
+ * be {@code null}.
+ * @param classifier The classifier for this artifact, may be {@code null} if
+ * none.
+ * @param extension The extension for this artifact, may be {@code null} if
+ * none.
+ * @param file The file for this artifact, may be {@code null} if
+ * unresolved.
+ */
+ public SubArtifact(Artifact mainArtifact, String classifier, String extension, File file) {
+ this(mainArtifact, classifier, extension, null, file);
+ }
+
+ /**
+ * Creates a new sub artifact. The classifier and extension specified for this
+ * artifact may use the asterisk character "*" to refer to the corresponding
+ * property of the main artifact. For instance, the classifier "*-sources" can
+ * be used to refer to the source attachment of an artifact. Likewise, the
+ * extension "*.asc" can be used to refer to the GPG signature of an artifact.
+ *
+ * @param mainArtifact The artifact from which to derive the identity, must not
+ * be {@code null}.
+ * @param classifier The classifier for this artifact, may be {@code null} if
+ * none.
+ * @param extension The extension for this artifact, may be {@code null} if
+ * none.
+ * @param properties The properties of the artifact, may be {@code null}.
+ */
+ public SubArtifact(Artifact mainArtifact, String classifier, String extension, Map<String, String> properties) {
+ this(mainArtifact, classifier, extension, properties, null);
+ }
+
+ /**
+ * Creates a new sub artifact. The classifier and extension specified for this
+ * artifact may use the asterisk character "*" to refer to the corresponding
+ * property of the main artifact. For instance, the classifier "*-sources" can
+ * be used to refer to the source attachment of an artifact. Likewise, the
+ * extension "*.asc" can be used to refer to the GPG signature of an artifact.
+ *
+ * @param mainArtifact The artifact from which to derive the identity, must not
+ * be {@code null}.
+ * @param classifier The classifier for this artifact, may be {@code null} if
+ * none.
+ * @param extension The extension for this artifact, may be {@code null} if
+ * none.
+ * @param properties The properties of the artifact, may be {@code null}.
+ * @param file The file for this artifact, may be {@code null} if
+ * unresolved.
+ */
+ public SubArtifact(Artifact mainArtifact, String classifier, String extension, Map<String, String> properties,
+ File file) {
+ if (mainArtifact == null) {
+ throw new IllegalArgumentException("no artifact specified");
+ }
+ this.mainArtifact = mainArtifact;
+ this.classifier = classifier;
+ this.extension = extension;
+ this.file = file;
+ this.properties = copyProperties(properties);
+ }
+
+ private SubArtifact(Artifact mainArtifact, String classifier, String extension, File file,
+ Map<String, String> properties) {
+ // NOTE: This constructor assumes immutability of the provided properties, for
+ // internal use only
+ this.mainArtifact = mainArtifact;
+ this.classifier = classifier;
+ this.extension = extension;
+ this.file = file;
+ this.properties = properties;
+ }
+
+ public String getGroupId() {
+ return mainArtifact.getGroupId();
+ }
+
+ public String getArtifactId() {
+ return mainArtifact.getArtifactId();
+ }
+
+ public String getVersion() {
+ return mainArtifact.getVersion();
+ }
+
+ public String getBaseVersion() {
+ return mainArtifact.getBaseVersion();
+ }
+
+ public boolean isSnapshot() {
+ return mainArtifact.isSnapshot();
+ }
+
+ public String getClassifier() {
+ return expand(classifier, mainArtifact.getClassifier());
+ }
+
+ public String getExtension() {
+ return expand(extension, mainArtifact.getExtension());
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public Artifact setFile(File file) {
+ if ((this.file == null) ? file == null : this.file.equals(file)) {
+ return this;
+ }
+ return new SubArtifact(mainArtifact, classifier, extension, file, properties);
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ public Artifact setProperties(Map<String, String> properties) {
+ if (this.properties.equals(properties) || (properties == null && this.properties.isEmpty())) {
+ return this;
+ }
+ return new SubArtifact(mainArtifact, classifier, extension, properties, file);
+ }
+
+ private static String expand(String pattern, String replacement) {
+ String result = "";
+ if (pattern != null) {
+ result = pattern.replace("*", replacement);
+
+ if (replacement.length() <= 0) {
+ if (pattern.startsWith("*")) {
+ int i = 0;
+ for (; i < result.length(); i++) {
+ char c = result.charAt(i);
+ if (c != '-' && c != '.') {
+ break;
+ }
+ }
+ result = result.substring(i);
+ }
+ if (pattern.endsWith("*")) {
+ int i = result.length() - 1;
+ for (; i >= 0; i--) {
+ char c = result.charAt(i);
+ if (c != '-' && c != '.') {
+ break;
+ }
+ }
+ result = result.substring(0, i + 1);
+ }
+ }
+ }
+ return result;
+ }
}
\ No newline at end of file
import javax.jcr.Session;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.api.cms.CmsLog;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.DefaultNameVersion;
import org.argeo.slc.SlcException;
import aQute.bnd.osgi.Jar;
public class UriWrapper extends BndWrapper implements Runnable {
- private final static Log log = LogFactory.getLog(UriWrapper.class);
+ private final static CmsLog log = CmsLog.getLog(UriWrapper.class);
private String uri;
private String baseUri;
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.slc.rpmfactory</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+/MANIFEST.MF
--- /dev/null
+Import-Package: javax.jcr.nodetype,\
+org.argeo.slc.repo,\
+org.osgi.*;version=0.0.0,\
+*
+
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.rpmfactory;
+
+import java.io.File;
+import java.util.List;
+
+import javax.jcr.Node;
+
+/**
+ * Defines a build environment. This information is typically used by other
+ * components performing the various actions related to RPM build.
+ */
+public interface RpmFactory {
+ //
+ // DIRECT ACTIONS ON JCR REPOSITORY
+ //
+ public void indexWorkspace(String workspace);
+
+ public Node newDistribution(String distributionId);
+
+ //
+ // CONFIG FILES GENERATION
+ //
+ /** Creates a mock config file. */
+ public File getMockConfigFile(String arch, String branch);
+
+ /** Creates a yum config file. */
+ public File getYumRepoFile(String arch);
+
+ //
+ // WORKSPACES
+ //
+ public String getStagingWorkspace();
+
+ /**
+ * @return the name of the testing workspace, or null if and only if the
+ * testing workspace was not enabled.
+ */
+ public String getTestingWorkspace();
+
+ public String getStableWorkspace();
+
+ public File getWorkspaceDir(String workspace);
+
+ //
+ // ARCH DEPENDENT INFOS
+ //
+ public List<String> getArchs();
+
+ public String getMockConfig(String arch);
+
+ public String getIdWithArch(String arch);
+
+ public File getResultDir(String arch);
+
+ //
+ // DEPLOYMENT
+ //
+ public String getGitBaseUrl();
+
+ public Boolean isDeveloperInstance();
+
+}
--- /dev/null
+package org.argeo.slc.rpmfactory;
+
+import org.argeo.jcr.proxy.ResourceProxy;
+
+/** Marker interface (useful for OSGi services references), may be extended later */
+public interface RpmProxyService extends ResourceProxy {
+}
--- /dev/null
+package org.argeo.slc.rpmfactory;
+
+/** A YUM compatible repository of RPM packages. */
+public interface RpmRepository {
+ public String getId();
+
+ public String getUrl();
+
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import org.argeo.slc.rpmfactory.RpmRepository;
+
+/** Common method to RPM repositories. */
+public abstract class AbstractRpmRepository implements RpmRepository {
+ private String id;
+ private String url;
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String getUrl() {
+ return url;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.exec.Executor;
+import org.apache.commons.io.FileUtils;
+import org.argeo.api.cms.CmsLog;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.runtime.tasks.SystemCall;
+
+/** Build an RPM in mock. */
+public class BuildInMock implements Runnable {
+ private final static CmsLog log = CmsLog.getLog(BuildInMock.class);
+ private final static String NOARCH = "noarch";
+
+ private String rpmPackage = null;
+ private String branch = null;
+ private String arch = NOARCH;
+
+ private RpmFactory rpmFactory;
+ private Executor executor;
+
+ private String debuginfoDirName = "debuginfo";
+ private String mockExecutable = "/usr/bin/mock";
+
+ private List<String> preBuildCommands = new ArrayList<String>();
+
+ public void run() {
+ if (!rpmFactory.isDeveloperInstance()) {
+ // clean/init
+ SystemCall mockClean = createBaseMockCall();
+ mockClean.arg("--init");
+ mockClean.run();
+ }
+
+ // pre build commands
+ for (String preBuildCmd : preBuildCommands) {
+ SystemCall mockClean = createBaseMockCall();
+ mockClean.arg("--chroot").arg(preBuildCmd);
+ mockClean.run();
+ }
+
+ // actual build
+ SystemCall mockBuild = createBaseMockCall();
+ mockBuild.arg("--scm-enable");
+ mockBuild.arg("--scm-option").arg("package=" + rpmPackage);
+ mockBuild.arg("--no-clean");
+ //
+ //
+ mockBuild.run();
+ //
+
+ // copy RPMs to target directories
+ File stagingDir = rpmFactory.getWorkspaceDir(rpmFactory
+ .getStagingWorkspace());
+ File srpmDir = new File(stagingDir, "SRPMS");
+ srpmDir.mkdirs();
+ File archDir = null;
+ File debuginfoDir = null;
+ if (!arch.equals(NOARCH)) {
+ archDir = new File(stagingDir, arch);
+ debuginfoDir = new File(archDir, debuginfoDirName);
+ debuginfoDir.mkdirs();
+ }
+
+ Set<File> reposToRecreate = new HashSet<File>();
+ File resultDir = rpmFactory.getResultDir(arch);
+ if (resultDir.exists())
+ rpms: for (File file : resultDir.listFiles()) {
+ if (file.isDirectory())
+ continue rpms;
+
+ File[] targetDirs;
+ if (file.getName().contains(".src.rpm"))
+ targetDirs = new File[] { srpmDir };
+ else if (file.getName().contains("-debuginfo-"))
+ targetDirs = new File[] { debuginfoDir };
+ else if (!arch.equals(NOARCH)
+ && file.getName().contains("." + arch + ".rpm"))
+ targetDirs = new File[] { archDir };
+ else if (file.getName().contains(".noarch.rpm")) {
+ List<File> dirs = new ArrayList<File>();
+ for (String arch : rpmFactory.getArchs())
+ dirs.add(new File(stagingDir, arch));
+ targetDirs = dirs.toArray(new File[dirs.size()]);
+ } else if (file.getName().contains(".rpm"))
+ throw new SlcException("Don't know where to copy " + file);
+ else {
+ if (log.isTraceEnabled())
+ log.trace("Skip " + file);
+ continue rpms;
+ }
+
+ reposToRecreate.addAll(Arrays.asList(targetDirs));
+ copyToDirs(file, targetDirs);
+ }
+
+ // recreate changed repos
+ for (File repoToRecreate : reposToRecreate) {
+ SystemCall createrepo = new SystemCall();
+ createrepo.arg("createrepo");
+ // sqllite db
+ createrepo.arg("-d");
+ // debuginfo
+ if (!repoToRecreate.getName().equals(debuginfoDirName))
+ createrepo.arg("-x").arg(debuginfoDirName + "/*");
+ // quiet
+ createrepo.arg("-q");
+ createrepo.arg(repoToRecreate.getAbsolutePath());
+
+ createrepo.setExecutor(executor);
+ createrepo.run();
+ log.info("Updated repo " + repoToRecreate);
+ }
+
+ // index staging workspace
+ rpmFactory.indexWorkspace(rpmFactory.getStagingWorkspace());
+ }
+
+ /** Creates a mock call with all the common options such as config file etc. */
+ protected SystemCall createBaseMockCall() {
+ String mockCfg = rpmFactory.getMockConfig(arch);
+ File mockConfigFile = rpmFactory.getMockConfigFile(arch, branch);
+
+ // prepare mock call
+ SystemCall mock = new SystemCall();
+
+ if (arch != null)
+ mock.arg("setarch").arg(arch);
+ mock.arg(mockExecutable);
+ mock.arg("-v");
+ mock.arg("--configdir=" + mockConfigFile.getAbsoluteFile().getParent());
+ if (arch != null)
+ mock.arg("--arch=" + arch);
+ mock.arg("-r").arg(mockCfg);
+
+ mock.setLogCommand(true);
+ mock.setExecutor(executor);
+
+ return mock;
+ }
+
+ protected void copyToDirs(File file, File[] dirs) {
+ for (File dir : dirs) {
+ try {
+ FileUtils.copyFileToDirectory(file, dir);
+ if (log.isDebugEnabled())
+ log.debug(file + " => " + dir);
+ } catch (IOException e) {
+ throw new SlcException("Cannot copy " + file + " to " + dir, e);
+ }
+ }
+ }
+
+ public void setArch(String arch) {
+ this.arch = arch;
+ }
+
+ public void setRpmPackage(String rpmPackage) {
+ this.rpmPackage = rpmPackage;
+ }
+
+ public void setBranch(String branch) {
+ this.branch = branch;
+ }
+
+ public void setRpmFactory(RpmFactory env) {
+ this.rpmFactory = env;
+ }
+
+ public void setExecutor(Executor executor) {
+ this.executor = executor;
+ }
+
+ public void setMockExecutable(String mockExecutable) {
+ this.mockExecutable = mockExecutable;
+ }
+
+ public void setPreBuildCommands(List<String> preBuildCommands) {
+ this.preBuildCommands = preBuildCommands;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.StringTokenizer;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.argeo.api.cms.CmsLog;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.runtime.tasks.SystemCall;
+
+/**
+ * Gather RPMs from various sources (local builds or third party) into a
+ * consistent distributable set (typically to be used to generate an ISO).
+ */
+public class CreateRpmDistribution implements Runnable {
+ private final static CmsLog log = CmsLog
+ .getLog(CreateRpmDistribution.class);
+
+ private RpmFactory rpmFactory;
+ private RpmDistribution rpmDistribution;
+
+ private String arch = "x86_64";
+
+ private String repoqueryExecutable = "/usr/bin/repoquery";
+
+ @Override
+ public void run() {
+ Session session = null;
+ // Reader reader = null;
+ try {
+ Node baseFolder = rpmFactory.newDistribution(rpmDistribution
+ .getId());
+ session = baseFolder.getSession();
+ Node targetFolder = baseFolder.addNode(arch, NodeType.NT_FOLDER);
+
+ SystemCall repoquery = new SystemCall();
+ repoquery.arg(repoqueryExecutable);
+
+ File yumConfigFile = rpmFactory.getYumRepoFile(arch);
+ repoquery.arg("-c", yumConfigFile.getAbsolutePath());
+ repoquery.arg("--requires");
+ repoquery.arg("--resolve");
+ repoquery.arg("--location");
+ repoquery.arg("--archlist=" + arch);
+
+ for (String rpmPackage : rpmDistribution.getPackages())
+ repoquery.arg(rpmPackage);
+
+ if (log.isDebugEnabled())
+ log.debug("Command:\n" + repoquery.asCommand());
+
+ String output = repoquery.function();
+
+ if (log.isDebugEnabled())
+ log.debug(output + "\n");
+ // reader = new StringReader(output);
+ StringTokenizer lines = new StringTokenizer(output, "\n");
+ // List<String> dependencies = IOUtils.readLines(reader);
+ dependencies: while (lines.hasMoreTokens()) {
+ String urlStr = lines.nextToken();
+ InputStream in = null;
+ try {
+ URL url = new URL(urlStr);
+ String fileName = FilenameUtils.getName(url.getFile());
+ String[] tokens = fileName.split("-");
+ if (tokens.length < 3)
+ continue dependencies;
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < tokens.length - 2; i++) {
+ if (i != 0)
+ buf.append('-');
+ buf.append(tokens[i]);
+
+ }
+ String packageName = buf.toString();
+ for (RpmPackageSet excluded : rpmDistribution
+ .getExcludedPackages()) {
+ if (excluded.contains(packageName)) {
+ if (log.isDebugEnabled())
+ log.debug("Skipped " + packageName);
+ continue dependencies;// skip
+ }
+ }
+ in = url.openStream();
+ JcrUtils.copyStreamAsFile(targetFolder, fileName, in);
+ targetFolder.getSession().save();
+ if (log.isDebugEnabled())
+ log.debug("Copied " + packageName);
+ } catch (Exception e) {
+ log.error("Cannot copy " + urlStr, e);
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+ }
+
+ // createrepo
+ File workspaceDir = rpmFactory.getWorkspaceDir(rpmDistribution
+ .getId());
+ SystemCall createrepo = new SystemCall();
+ createrepo.arg("createrepo");
+ createrepo.arg("-q");
+ createrepo.arg("-d");
+ File archDir = new File(workspaceDir.getPath()
+ + targetFolder.getPath());
+ createrepo.arg(archDir.getAbsolutePath());
+ createrepo.run();
+ } catch (Exception e) {
+ throw new SlcException("Cannot generate distribution "
+ + rpmDistribution.getId(), e);
+ } finally {
+ JcrUtils.logoutQuietly(session);
+ // IOUtils.closeQuietly(reader);
+ }
+ }
+
+ public void setRpmDistribution(RpmDistribution rpmDistribution) {
+ this.rpmDistribution = rpmDistribution;
+ }
+
+ public void setRpmFactory(RpmFactory rpmFactory) {
+ this.rpmFactory = rpmFactory;
+ }
+
+ public void setArch(String arch) {
+ this.arch = arch;
+ }
+
+ public void setRepoqueryExecutable(String yumdownloaderExecutable) {
+ this.repoqueryExecutable = yumdownloaderExecutable;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.exec.Executor;
+import org.apache.commons.io.FileUtils;
+import org.argeo.api.cms.CmsLog;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.runtime.tasks.SystemCall;
+
+/** Releases the content of staging to a public repository. */
+public class ReleaseStaging implements Runnable {
+ private final static CmsLog log = CmsLog.getLog(ReleaseStaging.class);
+
+ private RpmFactory rpmFactory;
+ private Executor executor;
+
+ private String debuginfoDirName = "debuginfo";
+
+ @Override
+ public void run() {
+ String sourceWorkspace = rpmFactory.getStagingWorkspace();
+ File sourceRepoDir = rpmFactory.getWorkspaceDir(sourceWorkspace);
+ String targetWorkspace = rpmFactory.getTestingWorkspace() != null ? rpmFactory
+ .getTestingWorkspace() : rpmFactory.getStableWorkspace();
+ File targetRepoDir = rpmFactory.getWorkspaceDir(targetWorkspace);
+ List<File> reposToRecreate = new ArrayList<File>();
+
+ stagingChildren: for (File dir : sourceRepoDir.listFiles()) {
+ if (!dir.isDirectory())
+ continue stagingChildren;
+ if (dir.getName().equals("lost+found"))
+ continue stagingChildren;
+
+ File targetDir = new File(targetRepoDir, dir.getName());
+ try {
+ FileUtils.copyDirectory(dir, targetDir);
+ if (log.isDebugEnabled())
+ log.debug(dir + " => " + targetDir);
+ } catch (IOException e) {
+ throw new SlcException(sourceRepoDir
+ + " could not be copied properly, check it manually."
+ + " Metadata have NOT been updated.", e);
+ }
+
+ reposToRecreate.add(dir);
+ reposToRecreate.add(targetDir);
+ File debugInfoDir = new File(dir, debuginfoDirName);
+ if (debugInfoDir.exists())
+ reposToRecreate.add(debugInfoDir);
+ File targetDebugInfoDir = new File(targetDir, debuginfoDirName);
+ if (targetDebugInfoDir.exists())
+ reposToRecreate.add(targetDebugInfoDir);
+
+ }
+
+ // clear staging
+ for (File dir : sourceRepoDir.listFiles()) {
+ try {
+ if (dir.getName().equals("lost+found"))
+ continue;
+ if (dir.isDirectory())
+ FileUtils.deleteDirectory(dir);
+ } catch (IOException e) {
+ log.error("Could not delete " + dir + ". " + e);
+ }
+ }
+
+ // recreate changed repos
+ for (File repoToRecreate : reposToRecreate) {
+ repoToRecreate.mkdirs();
+ SystemCall createrepo = new SystemCall();
+ createrepo.arg("createrepo");
+ // sqllite db
+ createrepo.arg("-d");
+ // debuginfo
+ if (!repoToRecreate.getName().equals(debuginfoDirName))
+ createrepo.arg("-x").arg(debuginfoDirName + "/*");
+ // quiet
+ createrepo.arg("-q");
+ createrepo.arg(repoToRecreate.getAbsolutePath());
+
+ createrepo.setExecutor(executor);
+ createrepo.run();
+ log.info("Updated repo " + repoToRecreate);
+ }
+
+ rpmFactory.indexWorkspace(sourceWorkspace);
+ rpmFactory.indexWorkspace(targetWorkspace);
+ }
+
+ public void setRpmFactory(RpmFactory rpmFactory) {
+ this.rpmFactory = rpmFactory;
+ }
+
+ public void setExecutor(Executor executor) {
+ this.executor = executor;
+ }
+
+ public void setDebuginfoDirName(String debuginfoDirName) {
+ this.debuginfoDirName = debuginfoDirName;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import java.util.List;
+
+/** A consistent distributable set of RPM. */
+public class RpmDistribution {
+ private String id;
+ private List<String> packages;
+ private List<RpmPackageSet> excludedPackages;
+
+ public List<String> getPackages() {
+ return packages;
+ }
+
+ public void setPackages(List<String> packages) {
+ this.packages = packages;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<RpmPackageSet> getExcludedPackages() {
+ return excludedPackages;
+ }
+
+ public void setExcludedPackages(List<RpmPackageSet> excludedPackages) {
+ this.excludedPackages = excludedPackages;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.commons.io.FileUtils;
+import org.argeo.api.cms.CmsLog;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.NodeIndexerVisitor;
+import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.rpmfactory.RpmRepository;
+import org.argeo.slc.runtime.tasks.SystemCall;
+
+/**
+ * Defines a build environment. This information is typically used by other
+ * components performing the various actions related to RPM build.
+ */
+public class RpmFactoryImpl implements RpmFactory {
+ private CmsLog log = CmsLog.getLog(RpmFactoryImpl.class);
+
+ private Repository rpmRepository;
+ private Repository distRepository;
+
+ private String id;
+ private List<RpmRepository> repositories = new ArrayList<RpmRepository>();
+ private List<String> archs = new ArrayList<String>();
+
+ private String rpmBase = "/mnt/slc/repos/rpm";
+ private String distBase = "/mnt/slc/repos/dist";
+ private String mockVar = "/var/lib/mock";
+ private String mockEtc = "/etc/mock";
+
+ private DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmm");
+
+ private String gitWorkspace = "git";
+
+ private String localUrlBase = "http://localhost:7070/";
+ /** If not null or empty, this is a developer instance. */
+ private String gitDevBaseUrl = null;
+
+ private Boolean withTestingRepository = false;
+
+ private String yumConfigMainSection = "cachedir=/var/cache/yum\n"
+ + "debuglevel=1\n" + "reposdir=/dev/null\n"
+ + "logfile=/var/log/yum.log\n" + "retries=20\n" + "obsoletes=1\n"
+ + "gpgcheck=0\n" + "assumeyes=1\n" + "syslog_ident=mock\n"
+ + "syslog_device=\n" + "http_caching=none\n";
+
+ private String defaultMacroFiles = "/usr/lib/rpm/macros:"
+ + "/usr/lib/rpm/ia32e-linux/macros:"
+ + "/usr/lib/rpm/redhat/macros:" + "/etc/rpm/macros.*:"
+ + "/etc/rpm/macros:" + "/etc/rpm/ia32e-linux/macros:"
+ + "~/.rpmmacros";
+ private Map<String, String> rpmmacros = new HashMap<String, String>();
+
+ // set by init
+ private String proxiedReposBase;
+ private String managedReposBase;
+
+ private String stagingWorkspace;
+ private String testingWorkspace;
+ private String stableWorkspace;
+
+ private File rpmFactoryBaseDir;
+ private File mockConfDir;
+ private File yumConfDir;
+
+ public void init() {
+ // local URL bases
+ proxiedReposBase = localUrlBase + "repo/rpm/";
+ managedReposBase = localUrlBase + "data/public/rpm/";
+
+ // local directories
+ rpmFactoryBaseDir.mkdirs();
+ mockConfDir = new File(rpmFactoryBaseDir.getPath() + "/conf/mock");
+ mockConfDir.mkdirs();
+ yumConfDir = new File(rpmFactoryBaseDir.getPath() + "/conf/yum");
+ yumConfDir.mkdirs();
+
+ // managed repositories
+ stagingWorkspace = id + "-staging";
+ if (withTestingRepository)
+ testingWorkspace = id + "-testing";
+ stableWorkspace = id;
+
+ initDistWorkspace(stableWorkspace);
+ initGitWorkspace();
+ initRpmWorkspace(stagingWorkspace);
+ if (withTestingRepository)
+ initRpmWorkspace(testingWorkspace);
+ initRpmWorkspace(stableWorkspace);
+ }
+
+ protected void initRpmWorkspace(String workspace) {
+ Session session = null;
+ try {
+ session = JcrUtils.loginOrCreateWorkspace(rpmRepository, workspace);
+ JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+ JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+ "jcr:all");
+
+ for (String arch : archs) {
+ Node archFolder = JcrUtils.mkfolders(session, "/" + arch);
+ session.save();
+ File workspaceDir = getWorkspaceDir(workspace);
+ try {
+ if (!archFolder.hasNode("repodata")) {
+ // touch a file in order to make sure this is properly
+ // mounted.
+ File touch = new File(workspaceDir, ".touch");
+ touch.createNewFile();
+ touch.delete();
+
+ SystemCall createrepo = new SystemCall();
+ createrepo.arg("createrepo");
+ createrepo.arg("-q");
+ File archDir = new File(workspaceDir, arch);
+ createrepo.arg(archDir.getAbsolutePath());
+ createrepo.run();
+ }
+ } catch (IOException e) {
+ log.error(workspaceDir + " not properly mounted.", e);
+ }
+ }
+ } catch (Exception e) {
+ throw new SlcException("Cannot initialize workspace " + workspace,
+ e);
+ } finally {
+ JcrUtils.logoutQuietly(session);
+ }
+ }
+
+ /** Caller must logout the underlying session. */
+ public Node newDistribution(String distributionId) {
+ Session session = null;
+ try {
+ session = JcrUtils.loginOrCreateWorkspace(rpmRepository,
+ distributionId);
+ JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+ JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+ "jcr:all");
+
+ Calendar now = new GregorianCalendar();
+ String folderName = dateFormat.format(now.getTime());
+ return JcrUtils.mkfolders(session, "/" + folderName);
+ } catch (Exception e) {
+ JcrUtils.logoutQuietly(session);
+ throw new SlcException("Cannot initialize distribution workspace "
+ + distributionId, e);
+ }
+ }
+
+ protected void initGitWorkspace() {
+ Session session = null;
+ try {
+ session = JcrUtils.loginOrCreateWorkspace(rpmRepository,
+ gitWorkspace);
+ JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+ JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+ "jcr:all");
+ } catch (Exception e) {
+ throw new SlcException("Cannot initialize workspace "
+ + gitWorkspace, e);
+ } finally {
+ JcrUtils.logoutQuietly(session);
+ }
+ }
+
+ protected void initDistWorkspace(String workspace) {
+ Session session = null;
+ try {
+ session = JcrUtils
+ .loginOrCreateWorkspace(distRepository, workspace);
+ JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot initialize workspace " + workspace,
+ e);
+ } finally {
+ JcrUtils.logoutQuietly(session);
+ }
+ }
+
+ public void destroy() {
+
+ }
+
+ public String generateMockConfigFile(String arch, String branch) {
+ StringBuffer buf = new StringBuffer();
+
+ buf.append("config_opts['root'] = '" + getIdWithArch(arch) + "'\n");
+ buf.append("config_opts['target_arch'] = '" + arch + "'\n");
+ buf.append("config_opts['legal_host_arches'] = ('" + arch + "',)\n");
+ buf.append("config_opts['chroot_setup_cmd'] = 'groupinstall buildsys-build'\n");
+ // buf.append("config_opts['dist'] = 'el6'\n");
+ buf.append("config_opts['plugin_conf']['yum_cache_enable'] = False\n");
+
+ buf.append("config_opts['scm'] = False\n");
+ buf.append("config_opts['scm_opts']['method'] = 'git'\n");
+ buf.append("config_opts['scm_opts']['spec'] = 'SCM_PKG.spec'\n");
+ buf.append("config_opts['scm_opts']['ext_src_dir'] = '"
+ + getSourcesDir().getAbsolutePath() + "'\n");
+ buf.append("config_opts['scm_opts']['git_timestamps'] = True\n");
+
+ // development
+ if (gitDevBaseUrl != null && !gitDevBaseUrl.trim().equals(""))
+ buf.append("config_opts['scm_opts']['git_get'] = 'git clone "
+ + (branch != null ? "-b " + branch : "") + " "
+ + gitDevBaseUrl + "/SCM_PKG SCM_PKG'\n");
+ else
+ buf.append("config_opts['scm_opts']['git_get'] = 'git clone "
+ + (branch != null ? "-b " + branch : "") + " "
+ + getGitBaseUrl() + "/SCM_PKG.git SCM_PKG'\n");
+
+ buf.append("\nconfig_opts['yum.conf'] = \"\"\"\n");
+ buf.append(generateYumConfigFile(arch)).append('\n');
+ buf.append("\"\"\"\n");
+ return buf.toString();
+ }
+
+ public String generateYumConfigFile(String arch) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("[main]\n");
+ buf.append(yumConfigMainSection).append('\n');
+
+ for (RpmRepository repository : repositories) {
+ buf.append('[').append(repository.getId()).append("]\n");
+ buf.append("name=").append(repository.getId()).append('\n');
+ if (repository instanceof ThirdPartyRpmRepository) {
+ buf.append("#baseurl=").append(repository.getUrl())
+ .append(arch).append('/').append("\n");
+ buf.append("baseurl=").append(proxiedReposBase)
+ .append(repository.getId()).append('/').append(arch)
+ .append('/').append("\n");
+ if (((ThirdPartyRpmRepository) repository).getYumConf() != null)
+ buf.append(
+ ((ThirdPartyRpmRepository) repository).getYumConf()
+ .trim()).append('\n');
+ }
+ }
+
+ // managed repos
+ addManagedRepository(buf, stagingWorkspace, arch);
+ if (withTestingRepository)
+ addManagedRepository(buf, testingWorkspace, arch);
+ addManagedRepository(buf, stableWorkspace, arch);
+ return buf.toString();
+ }
+
+ protected void addManagedRepository(StringBuffer buf, String workspace,
+ String arch) {
+ buf.append('[').append(workspace).append("]\n");
+ buf.append("baseurl=").append(managedReposBase).append(workspace)
+ .append('/').append(arch).append('/').append("\n");
+ buf.append("gpgcheck=0").append("\n");
+ }
+
+ /** Creates a mock config file. */
+ public File getMockConfigFile(String arch, String branch) {
+ File mockSiteDefaultsFile = new File(mockConfDir, "site-defaults.cfg");
+ File mockLoggingFile = new File(mockConfDir, "logging.ini");
+ File mockConfigFile = new File(mockConfDir, getIdWithArch(arch)
+ + ".cfg");
+ try {
+ if (!mockSiteDefaultsFile.exists())
+ mockSiteDefaultsFile.createNewFile();
+ if (!mockLoggingFile.exists())
+ FileUtils.copyFile(new File(mockEtc + "/logging.ini"),
+ mockLoggingFile);
+
+ FileUtils.writeStringToFile(mockConfigFile,
+ generateMockConfigFile(arch, branch));
+ return mockConfigFile;
+ } catch (IOException e) {
+ throw new SlcException("Cannot write mock config file to "
+ + mockConfigFile, e);
+ }
+ }
+
+ /** Creates a yum config file. */
+ public File getYumRepoFile(String arch) {
+ File yumConfigFile = new File(yumConfDir, getIdWithArch(arch) + ".repo");
+ try {
+ FileUtils.writeStringToFile(yumConfigFile,
+ generateYumConfigFile(arch));
+ return yumConfigFile;
+ } catch (IOException e) {
+ throw new SlcException("Cannot write yum config file to "
+ + yumConfigFile, e);
+ }
+ }
+
+ public File getResultDir(String arch) {
+ return new File(mockVar + "/" + getIdWithArch(arch) + "/result");
+ }
+
+ public File getWorkspaceDir(String workspace) {
+ return new File(rpmBase + "/" + workspace);
+ }
+
+ public File getSourcesDir() {
+ return new File(distBase + "/" + stableWorkspace);
+ }
+
+ public String getMockConfig(String arch) {
+ return getIdWithArch(arch);
+ }
+
+ public String getIdWithArch(String arch) {
+ return id + "-" + arch;
+ }
+
+ public String getGitBaseUrl() {
+ return managedReposBase + gitWorkspace;
+ }
+
+ public void indexWorkspace(String workspace) {
+ Session session = null;
+ try {
+ session = rpmRepository.login(workspace);
+ session.getRootNode().accept(
+ new NodeIndexerVisitor(new RpmIndexer()));
+ if (log.isDebugEnabled())
+ log.debug("Indexed workspace " + workspace);
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot index workspace " + workspace, e);
+ } finally {
+ JcrUtils.logoutQuietly(session);
+ }
+ }
+
+ public Boolean isDeveloperInstance() {
+ return gitDevBaseUrl != null;
+ }
+
+ /** Write (topdir)/rpmmacros and (topdir)/rpmrc */
+ public void writeRpmbuildConfigFiles(File topdir) {
+ writeRpmbuildConfigFiles(topdir, new File(topdir, "rpmmacros"),
+ new File(topdir, "rpmrc"));
+ }
+
+ public void writeRpmbuildConfigFiles(File topdir, File rpmmacroFile,
+ File rpmrcFile) {
+ try {
+ List<String> macroLines = new ArrayList<String>();
+ macroLines.add("%_topdir " + topdir.getCanonicalPath());
+ for (String macroKey : rpmmacros.keySet()) {
+ macroLines.add(macroKey + " " + rpmmacros.get(macroKey));
+ }
+ FileUtils.writeLines(rpmmacroFile, macroLines);
+
+ List<String> rpmrcLines = new ArrayList<String>();
+ rpmrcLines.add("include: /usr/lib/rpm/rpmrc");
+ rpmrcLines.add("macrofiles: " + defaultMacroFiles + ":"
+ + rpmmacroFile.getCanonicalPath());
+ FileUtils.writeLines(rpmrcFile, rpmrcLines);
+ } catch (IOException e) {
+ throw new SlcException("Cannot write rpmbuild config files", e);
+ }
+
+ }
+
+ public Map<String, String> getRpmmacros() {
+ return rpmmacros;
+ }
+
+ public void setRpmmacros(Map<String, String> rpmmacros) {
+ this.rpmmacros = rpmmacros;
+ }
+
+ public String getDefaultMacroFiles() {
+ return defaultMacroFiles;
+ }
+
+ public void setDefaultMacroFiles(String defaultMacroFiles) {
+ this.defaultMacroFiles = defaultMacroFiles;
+ }
+
+ public void setArchs(List<String> archs) {
+ this.archs = archs;
+ }
+
+ public List<String> getArchs() {
+ return archs;
+ }
+
+ public void setRpmBase(String stagingBase) {
+ this.rpmBase = stagingBase;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setMockVar(String mockVar) {
+ this.mockVar = mockVar;
+ }
+
+ public void setRpmRepository(Repository rpmRepository) {
+ this.rpmRepository = rpmRepository;
+ }
+
+ public void setDistRepository(Repository distRepository) {
+ this.distRepository = distRepository;
+ }
+
+ public void setLocalUrlBase(String localUrlBase) {
+ this.localUrlBase = localUrlBase;
+ }
+
+ public void setYumConfigMainSection(String yumConfigMainSection) {
+ this.yumConfigMainSection = yumConfigMainSection;
+ }
+
+ public void setRepositories(List<RpmRepository> repositories) {
+ this.repositories = repositories;
+ }
+
+ public void setRpmFactoryBaseDir(File rpmFactoryBaseDir) {
+ this.rpmFactoryBaseDir = rpmFactoryBaseDir;
+ }
+
+ public String getStagingWorkspace() {
+ return stagingWorkspace;
+ }
+
+ public String getTestingWorkspace() {
+ return testingWorkspace;
+ }
+
+ public String getStableWorkspace() {
+ return stableWorkspace;
+ }
+
+ public void setWithTestingRepository(Boolean withTestingRepository) {
+ this.withTestingRepository = withTestingRepository;
+ }
+
+ public void setGitDevBaseUrl(String gitBaseUrl) {
+ this.gitDevBaseUrl = gitBaseUrl;
+ }
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import static org.redline_rpm.header.Header.HeaderTag.HEADERIMMUTABLE;
+import static org.redline_rpm.header.Signature.SignatureTag.SIGNATURES;
+
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.io.FilenameUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.NodeIndexer;
+import org.redline_rpm.ChannelWrapper.Key;
+import org.redline_rpm.ReadableChannelWrapper;
+import org.redline_rpm.header.AbstractHeader;
+import org.redline_rpm.header.Format;
+import org.redline_rpm.header.Header;
+
+/** Indexes an RPM file. */
+public class RpmIndexer implements NodeIndexer, SlcNames {
+ private Boolean force = false;
+
+ @Override
+ public Boolean support(String path) {
+ return FilenameUtils.getExtension(path).equals("rpm");
+ }
+
+ @Override
+ public void index(Node node) {
+ try {
+ if (!support(node.getPath()))
+ return;
+
+ // Already indexed
+ if (!force && node.isNodeType(SlcTypes.SLC_RPM))
+ return;
+
+ if (!node.isNodeType(NodeType.NT_FILE))
+ return;
+
+ InputStream in = node.getNode(Node.JCR_CONTENT)
+ .getProperty(Property.JCR_DATA).getBinary().getStream();
+ ReadableChannelWrapper channel = new ReadableChannelWrapper(
+ Channels.newChannel(in));
+ Format format = readRpmInfo(channel);
+
+ node.addMixin(SlcTypes.SLC_RPM);
+ node.setProperty(SLC_NAME, readTag(format, Header.HeaderTag.NAME));
+ String rpmVersion = readTag(format, Header.HeaderTag.VERSION);
+ String rpmRelease = readTag(format, Header.HeaderTag.RELEASE);
+ node.setProperty(SLC_RPM_VERSION, rpmVersion);
+ node.setProperty(SLC_RPM_RELEASE, rpmRelease);
+ node.setProperty(SLC_VERSION, rpmVersion + "-" + rpmRelease);
+
+ String arch = readTag(format, Header.HeaderTag.ARCH);
+ if (arch != null)
+ node.setProperty(SLC_RPM_ARCH, arch);
+
+ String archiveSize = readTag(format, Header.HeaderTag.ARCHIVESIZE);
+ if (archiveSize != null)
+ node.setProperty(SLC_RPM_ARCHIVE_SIZE,
+ Long.parseLong(archiveSize));
+
+ node.getSession().save();
+ } catch (Exception e) {
+ throw new SlcException("Cannot index " + node, e);
+ }
+
+ }
+
+ @SuppressWarnings("unused")
+ public Format readRpmInfo(ReadableChannelWrapper channel) throws Exception {
+ Format format = new Format();
+
+ Key<Integer> lead = channel.start();
+ format.getLead().read(channel);
+ // System.out.println( "Lead ended at '" + in.finish( lead) + "'.");
+
+ Key<Integer> signature = channel.start();
+ int count = format.getSignature().read(channel);
+ int expected = ByteBuffer
+ .wrap((byte[]) format.getSignature().getEntry(SIGNATURES)
+ .getValues(), 8, 4).getInt()
+ / -16;
+ // System.out.println( "Signature ended at '" + in.finish( signature) +
+ // "' and contained '" + count + "' headers (expected '" + expected +
+ // "').");
+
+ Key<Integer> header = channel.start();
+ count = format.getHeader().read(channel);
+ expected = ByteBuffer.wrap(
+ (byte[]) format.getHeader().getEntry(HEADERIMMUTABLE)
+ .getValues(), 8, 4).getInt()
+ / -16;
+ // System.out.println( "Header ended at '" + in.finish( header) +
+ // " and contained '" + count + "' headers (expected '" + expected +
+ // "').");
+
+ return format;
+ }
+
+ private String readTag(Format format, Header.HeaderTag tag) {
+ AbstractHeader.Entry<?> entry = format.getHeader().getEntry(tag);
+ if (entry == null)
+ return null;
+ if (entry.getValues() == null)
+ return null;
+ Object[] values = (Object[]) entry.getValues();
+ return values[0].toString().trim();
+ }
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+/** Set of RPM packages */
+public interface RpmPackageSet {
+ public Boolean contains(String rpmPackage);
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.security.AccessControlException;
+
+import org.argeo.api.cms.CmsLog;
+import org.argeo.cms.ArgeoNames;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.proxy.AbstractUrlProxy;
+import org.argeo.slc.SlcConstants;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.repo.RepoConstants;
+import org.argeo.slc.rpmfactory.RpmProxyService;
+import org.argeo.slc.rpmfactory.RpmRepository;
+
+/** Synchronises the node repository with remote Maven repositories */
+public class RpmProxyServiceImpl extends AbstractUrlProxy implements
+ RpmProxyService, ArgeoNames, SlcNames {
+ private final static CmsLog log = CmsLog.getLog(RpmProxyServiceImpl.class);
+
+ private Set<RpmRepository> defaultRepositories = new HashSet<RpmRepository>();
+
+ @Override
+ protected void beforeInitSessionSave(Session session)
+ throws RepositoryException {
+ JcrUtils.addPrivilege(session, "/", "anonymous", "jcr:read");
+ try {
+ JcrUtils.addPrivilege(session, "/", SlcConstants.ROLE_SLC,
+ "jcr:all");
+ } catch (AccessControlException e) {
+ if (log.isTraceEnabled())
+ log.trace("Cannot give jcr:all privileges to "+SlcConstants.ROLE_SLC);
+ }
+
+ JcrUtils.mkdirsSafe(session, RepoConstants.PROXIED_REPOSITORIES);
+ }
+
+ /**
+ * Retrieve and add this file to the repository
+ */
+ @Override
+ protected Node retrieve(Session session, String path) {
+ StringBuilder relativePathBuilder = new StringBuilder();
+ String repoId = extractRepoId(path, relativePathBuilder);
+ // remove starting '/'
+ String relativePath = relativePathBuilder.toString().substring(1);
+
+ RpmRepository sourceRepo = null;
+ for (Iterator<RpmRepository> reposIt = defaultRepositories.iterator(); reposIt
+ .hasNext();) {
+ RpmRepository rpmRepo = reposIt.next();
+ if (rpmRepo.getId().equals(repoId)) {
+ sourceRepo = rpmRepo;
+ break;
+ }
+ }
+
+ if (sourceRepo == null)
+ throw new SlcException("No RPM repository found for " + path);
+
+ try {
+ String baseUrl = sourceRepo.getUrl();
+ String remoteUrl = baseUrl + relativePath;
+ Node node = proxyUrl(session, remoteUrl, path);
+ if (node != null) {
+ registerSource(sourceRepo, node, remoteUrl);
+ if (log.isDebugEnabled())
+ log.debug("Imported " + remoteUrl + " to " + node);
+ return node;
+ }
+ } catch (Exception e) {
+ throw new SlcException("Cannot proxy " + path, e);
+ }
+ JcrUtils.discardQuietly(session);
+ throw new SlcException("No proxy found for " + path);
+ }
+
+ protected void registerSource(RpmRepository sourceRepo, Node node,
+ String remoteUrl) throws RepositoryException {
+ node.addMixin(SlcTypes.SLC_KNOWN_ORIGIN);
+ Node origin;
+ if (!node.hasNode(SLC_ORIGIN))
+ origin = node.addNode(SLC_ORIGIN, SlcTypes.SLC_PROXIED);
+ else
+ origin = node.getNode(SLC_ORIGIN);
+
+ // proxied repository
+ Node proxiedRepository;
+ String proxiedRepositoryPath = RepoConstants.PROXIED_REPOSITORIES + '/'
+ + sourceRepo.getId();
+ Session session = node.getSession();
+ if (session.itemExists(proxiedRepositoryPath)) {
+ proxiedRepository = session.getNode(proxiedRepositoryPath);
+ } else {
+ proxiedRepository = session.getNode(
+ RepoConstants.PROXIED_REPOSITORIES).addNode(
+ sourceRepo.getId());
+ proxiedRepository.addMixin(NodeType.MIX_REFERENCEABLE);
+ JcrUtils.urlToAddressProperties(proxiedRepository,
+ sourceRepo.getUrl());
+ proxiedRepository.setProperty(SLC_URL, sourceRepo.getUrl());
+ }
+
+ origin.setProperty(SLC_PROXY, proxiedRepository);
+ JcrUtils.urlToAddressProperties(origin, remoteUrl);
+ }
+
+ /** Returns the first token of the path */
+ protected String extractRepoId(String path, StringBuilder relativePath) {
+ StringBuilder workspace = new StringBuilder();
+ StringBuilder buf = workspace;
+ for (int i = 1; i < path.length(); i++) {
+ char c = path.charAt(i);
+ if (c == '/') {
+ buf = relativePath;
+ }
+ buf.append(c);
+ }
+ return workspace.toString();
+ }
+
+ @Override
+ protected Boolean shouldUpdate(Session clientSession, String nodePath) {
+ // if (nodePath.contains("/repodata/"))
+ // return true;
+ return super.shouldUpdate(clientSession, nodePath);
+ }
+
+ public void setDefaultRepositories(Set<RpmRepository> defaultRepositories) {
+ this.defaultRepositories = defaultRepositories;
+ }
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class RpmSpecFile {
+ private Path specFile;
+
+ private String name;
+ private String version;
+ private String release;
+ private Map<String, String> sources = new HashMap<String, String>();
+ private Map<String, String> patches = new HashMap<String, String>();
+
+ public RpmSpecFile(Path specFile) {
+ this.specFile = specFile;
+ parseSpecFile();
+ }
+
+ public void init() {
+ parseSpecFile();
+ }
+
+ protected void parseSpecFile() {
+ try {
+ List<String> lines = (List<String>) Files.readAllLines(specFile);
+
+ lines: for (String line : lines) {
+ int indexSemiColon = line.indexOf(':');
+ if (indexSemiColon <= 0)
+ continue lines;
+ String directive = line.substring(0, indexSemiColon).trim();
+ String value = line.substring(indexSemiColon + 1).trim();
+ if ("name".equals(directive.toLowerCase()))
+ name = value;
+ else if ("version".equals(directive.toLowerCase()))
+ version = value;
+ else if ("release".equals(directive.toLowerCase()))
+ release = value;
+ else if (directive.toLowerCase().startsWith("source"))
+ sources.put(directive, interpret(value));
+ else if (directive.toLowerCase().startsWith("patch"))
+ patches.put(directive, interpret(value));
+ }
+
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot parse spec file " + specFile, e);
+ }
+ }
+
+ protected String interpret(String value) {
+ StringBuffer buf = new StringBuffer(value.length());
+ StringBuffer currKey = null;
+ boolean mayBeKey = false;
+ chars: for (char c : value.toCharArray()) {
+ if (c == '%')
+ mayBeKey = true;
+ else if (c == '{') {
+ if (mayBeKey)
+ currKey = new StringBuffer();
+ } else if (c == '}') {
+ if (currKey == null)
+ continue chars;
+ String key = currKey.toString();
+ if ("name".equals(key.toLowerCase()))
+ buf.append(name);
+ else if ("version".equals(key.toLowerCase()))
+ buf.append(version);
+ else
+ buf.append("%{").append(key).append('}');
+ currKey = null;
+ } else {
+ if (currKey != null)
+ currKey.append(c);
+ else
+ buf.append(c);
+ }
+ }
+ return buf.toString();
+ }
+
+ public Path getSpecFile() {
+ return specFile;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public String getRelease() {
+ return release;
+ }
+
+ public Map<String, String> getSources() {
+ return sources;
+ }
+
+ public Map<String, String> getPatches() {
+ return patches;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+/** Local build repository, used only for builds. */
+public class StagingRpmRepository extends AbstractRpmRepository {
+
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+/**
+ * A repository of third party RPMs used for the build. RPM used by the builds
+ * will be cached within the system.
+ */
+public class ThirdPartyRpmRepository extends AbstractRpmRepository {
+ private String yumConf;
+
+ public String getYumConf() {
+ return yumConf;
+ }
+
+ public void setYumConf(String yumConf) {
+ this.yumConf = yumConf;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.rpmfactory.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.LineIterator;
+import org.argeo.api.cms.CmsLog;
+import org.argeo.slc.SlcException;
+
+/**
+ * Reads the output of a 'yum list all' command and interpret the list of
+ * packages.
+ */
+public class YumListParser implements RpmPackageSet {
+ private final static CmsLog log = CmsLog.getLog(YumListParser.class);
+
+ private Set<String> installed = new TreeSet<String>();
+ /** Not installed but available */
+ private Set<String> installable = new TreeSet<String>();
+
+ private Path yumListOutput;
+
+ public void init() {
+ if (yumListOutput != null) {
+ try (InputStream in = Files.newInputStream(yumListOutput)) {
+ load(in);
+ if (log.isDebugEnabled())
+ log.debug(installed.size() + " installed, " + installable.size() + " installable, from "
+ + yumListOutput);
+ } catch (IOException e) {
+ throw new SlcException("Cannot initialize yum list parser", e);
+ }
+ }
+ }
+
+ public Boolean contains(String packageName) {
+ if (installed.contains(packageName))
+ return true;
+ else
+ return installable.contains(packageName);
+ }
+
+ protected void load(InputStream in) throws IOException {
+ Boolean readingInstalled = false;
+ Boolean readingAvailable = false;
+ LineIterator it = IOUtils.lineIterator(in, "UTF-8");
+ while (it.hasNext()) {
+ String line = it.nextLine();
+ if (line.trim().equals("Installed Packages")) {
+ readingInstalled = true;
+ } else if (line.trim().equals("Available Packages")) {
+ readingAvailable = true;
+ readingInstalled = false;
+ } else if (readingAvailable) {
+ if (Character.isLetterOrDigit(line.charAt(0))) {
+ installable.add(extractRpmName(line));
+ }
+ } else if (readingInstalled) {
+ if (Character.isLetterOrDigit(line.charAt(0))) {
+ installed.add(extractRpmName(line));
+ }
+ }
+ }
+ }
+
+ protected String extractRpmName(String line) {
+ StringTokenizer st = new StringTokenizer(line, " \t");
+ String packageName = st.nextToken();
+ // consider the arch as an extension
+ return FilenameUtils.getBaseName(packageName);
+ // return packageName.split("\\.")[0];
+ }
+
+ public Set<String> getInstalled() {
+ return installed;
+ }
+
+ public Set<String> getInstallable() {
+ return installable;
+ }
+
+ public void setYumListOutput(Path yumListOutput) {
+ this.yumListOutput = yumListOutput;
+ }
+
+}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
+ <attributes>
+ <attribute name="module" value="true"/>
+ </attributes>
+ </classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="ext/test"/>
<classpathentry kind="output" path="bin"/>
</classpath>
--- /dev/null
+package org.argeo.fs;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.argeo.slc.sync.FsSyncUtils;
+
+/** {@link FsUtils} tests. */
+public class FsUtilsTest {
+ final static String FILE00 = "file00";
+ final static String FILE01 = "file01";
+ final static String SUB_DIR = "subDir";
+
+ public void testDelete() throws IOException {
+ Path dir = createDir00();
+ assert Files.exists(dir);
+ FsSyncUtils.delete(dir);
+ assert !Files.exists(dir);
+ }
+
+ public void testSync() throws IOException {
+ Path source = createDir00();
+ Path target = Files.createTempDirectory(getClass().getName());
+ FsSyncUtils.sync(source, target);
+ assert Files.exists(target.resolve(FILE00));
+ assert Files.exists(target.resolve(SUB_DIR));
+ assert Files.exists(target.resolve(SUB_DIR + File.separator + FILE01));
+ FsSyncUtils.delete(source.resolve(SUB_DIR));
+ FsSyncUtils.sync(source, target, true);
+ assert Files.exists(target.resolve(FILE00));
+ assert !Files.exists(target.resolve(SUB_DIR));
+ assert !Files.exists(target.resolve(SUB_DIR + File.separator + FILE01));
+
+ // clean up
+ FsSyncUtils.delete(source);
+ FsSyncUtils.delete(target);
+
+ }
+
+ Path createDir00() throws IOException {
+ Path base = Files.createTempDirectory(getClass().getName());
+ base.toFile().deleteOnExit();
+ Files.createFile(base.resolve(FILE00)).toFile().deleteOnExit();
+ Path subDir = Files.createDirectories(base.resolve(SUB_DIR));
+ subDir.toFile().deleteOnExit();
+ Files.createFile(subDir.resolve(FILE01)).toFile().deleteOnExit();
+ return base;
+ }
+}
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.runtime</artifactId>
- <name>SLC Runtime</name>
- <dependencies>
- <!-- SLC -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.api</artifactId>
- <version>2.1-SNAPSHOT</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.cli;
+
+public class CommandArgsException extends IllegalArgumentException {
+ private static final long serialVersionUID = -7271050747105253935L;
+ private String commandName;
+ private volatile CommandsCli commandsCli;
+
+ public CommandArgsException(Exception cause) {
+ super(cause.getMessage(), cause);
+ }
+
+ public CommandArgsException(String message) {
+ super(message);
+ }
+
+ public String getCommandName() {
+ return commandName;
+ }
+
+ public void setCommandName(String commandName) {
+ this.commandName = commandName;
+ }
+
+ public CommandsCli getCommandsCli() {
+ return commandsCli;
+ }
+
+ public void setCommandsCli(CommandsCli commandsCli) {
+ this.commandsCli = commandsCli;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.cli;
+
+import java.util.List;
+
+/** {@link RuntimeException} referring during a command run. */
+public class CommandRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = 5595999301269377128L;
+
+ private final DescribedCommand<?> command;
+ private final List<String> arguments;
+
+ public CommandRuntimeException(Throwable e, DescribedCommand<?> command, List<String> arguments) {
+ this(null, e, command, arguments);
+ }
+
+ public CommandRuntimeException(String message, DescribedCommand<?> command, List<String> arguments) {
+ this(message, null, command, arguments);
+ }
+
+ public CommandRuntimeException(String message, Throwable e, DescribedCommand<?> command, List<String> arguments) {
+ super(message == null ? "(" + command.getClass().getName() + " " + arguments.toString() + ")"
+ : message + " (" + command.getClass().getName() + " " + arguments.toString() + ")", e);
+ this.command = command;
+ this.arguments = arguments;
+ }
+
+ public DescribedCommand<?> getCommand() {
+ return command;
+ }
+
+ public List<String> getArguments() {
+ return arguments;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.cli;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.function.Function;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+/** Base class for a CLI managing sub commands. */
+public abstract class CommandsCli implements DescribedCommand<Object> {
+ public final static String HELP = "help";
+
+ private final String commandName;
+ private Map<String, Function<List<String>, ?>> commands = new TreeMap<>();
+
+ protected final Options options = new Options();
+
+ public CommandsCli(String commandName) {
+ this.commandName = commandName;
+ }
+
+ @Override
+ public Object apply(List<String> args) {
+ String cmd = null;
+ List<String> newArgs = new ArrayList<>();
+ try {
+ CommandLineParser clParser = new DefaultParser();
+ CommandLine commonCl = clParser.parse(getOptions(), args.toArray(new String[args.size()]), true);
+ List<String> leftOvers = commonCl.getArgList();
+ for (String arg : leftOvers) {
+ if (!arg.startsWith("-") && cmd == null) {
+ cmd = arg;
+ } else {
+ newArgs.add(arg);
+ }
+ }
+ } catch (ParseException e) {
+ CommandArgsException cae = new CommandArgsException(e);
+ throw cae;
+ }
+
+ Function<List<String>, ?> function = cmd != null ? getCommand(cmd) : getDefaultCommand();
+ if (function == null)
+ throw new IllegalArgumentException("Uknown command " + cmd);
+ try {
+ return function.apply(newArgs).toString();
+ } catch (CommandArgsException e) {
+ if (e.getCommandName() == null) {
+ e.setCommandName(cmd);
+ e.setCommandsCli(this);
+ }
+ throw e;
+ } catch (IllegalArgumentException e) {
+ CommandArgsException cae = new CommandArgsException(e);
+ cae.setCommandName(cmd);
+ throw cae;
+ }
+ }
+
+ @Override
+ public Options getOptions() {
+ return options;
+ }
+
+ protected void addCommand(String cmd, Function<List<String>, ?> function) {
+ commands.put(cmd, function);
+
+ }
+
+ @Override
+ public String getUsage() {
+ return "[command]";
+ }
+
+ protected void addCommandsCli(CommandsCli commandsCli) {
+ addCommand(commandsCli.getCommandName(), commandsCli);
+ commandsCli.addCommand(HELP, new HelpCommand(this, commandsCli));
+ }
+
+ public String getCommandName() {
+ return commandName;
+ }
+
+ public Set<String> getSubCommands() {
+ return commands.keySet();
+ }
+
+ public Function<List<String>, ?> getCommand(String command) {
+ return commands.get(command);
+ }
+
+ public HelpCommand getHelpCommand() {
+ return (HelpCommand) getCommand(HELP);
+ }
+
+ public Function<List<String>, String> getDefaultCommand() {
+ return getHelpCommand();
+ }
+
+ /** In order to implement quickly a main method. */
+ public static void mainImpl(CommandsCli cli, String[] args) {
+ try {
+ cli.addCommand(CommandsCli.HELP, new HelpCommand(null, cli));
+ Object output = cli.apply(Arrays.asList(args));
+ System.out.println(output);
+ System.exit(0);
+ } catch (CommandArgsException e) {
+ System.err.println("Wrong arguments " + Arrays.toString(args) + ": " + e.getMessage());
+ if (e.getCommandName() != null) {
+ StringWriter out = new StringWriter();
+ HelpCommand.printHelp(e.getCommandsCli(), e.getCommandName(), out);
+ System.err.println(out.toString());
+ } else {
+ e.printStackTrace();
+ }
+ System.exit(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+}
--- /dev/null
+package org.argeo.slc.cli;
+
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+/** A command that can be described. */
+public interface DescribedCommand<T> extends Function<List<String>, T> {
+ default Options getOptions() {
+ return new Options();
+ }
+
+ String getDescription();
+
+ default String getUsage() {
+ return null;
+ }
+
+ default String getExamples() {
+ return null;
+ }
+
+ default CommandLine toCommandLine(List<String> args) {
+ try {
+ DefaultParser parser = new DefaultParser();
+ return parser.parse(getOptions(), args.toArray(new String[args.size()]));
+ } catch (ParseException e) {
+ throw new CommandArgsException(e);
+ }
+ }
+
+ /** In order to implement quickly a main method. */
+ public static void mainImpl(DescribedCommand<?> command, String[] args) {
+ try {
+ Object output = command.apply(Arrays.asList(args));
+ System.out.println(output);
+ System.exit(0);
+ } catch (IllegalArgumentException e) {
+ StringWriter out = new StringWriter();
+ HelpCommand.printHelp(command, out);
+ System.err.println(out.toString());
+ System.exit(1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+}
--- /dev/null
+package org.argeo.slc.cli;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.function.Function;
+
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+
+/** A special command that can describe {@link DescribedCommand}. */
+public class HelpCommand implements DescribedCommand<String> {
+ private CommandsCli commandsCli;
+ private CommandsCli parentCommandsCli;
+
+ // Help formatting
+ private static int helpWidth = 80;
+ private static int helpLeftPad = 4;
+ private static int helpDescPad = 20;
+
+ public HelpCommand(CommandsCli parentCommandsCli, CommandsCli commandsCli) {
+ super();
+ this.parentCommandsCli = parentCommandsCli;
+ this.commandsCli = commandsCli;
+ }
+
+ @Override
+ public String apply(List<String> args) {
+ StringWriter out = new StringWriter();
+
+ if (args.size() == 0) {// overview
+ printHelp(commandsCli, out);
+ } else {
+ String cmd = args.get(0);
+ Function<List<String>, ?> function = commandsCli.getCommand(cmd);
+ if (function == null)
+ return "Command " + cmd + " not found.";
+ Options options;
+ String examples;
+ DescribedCommand<?> command = null;
+ if (function instanceof DescribedCommand) {
+ command = (DescribedCommand<?>) function;
+ options = command.getOptions();
+ examples = command.getExamples();
+ } else {
+ options = new Options();
+ examples = null;
+ }
+ String description = getShortDescription(function);
+ String commandCall = getCommandUsage(cmd, command);
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp(new PrintWriter(out), helpWidth, commandCall, description, options, helpLeftPad,
+ helpDescPad, examples, false);
+ }
+ return out.toString();
+ }
+
+ private static String getShortDescription(Function<List<String>, ?> function) {
+ if (function instanceof DescribedCommand) {
+ return ((DescribedCommand<?>) function).getDescription();
+ } else {
+ return function.toString();
+ }
+ }
+
+ public String getCommandUsage(String cmd, DescribedCommand<?> command) {
+ String commandCall = getCommandCall(commandsCli) + " " + cmd;
+ assert command != null;
+ if (command != null && command.getUsage() != null) {
+ commandCall = commandCall + " " + command.getUsage();
+ }
+ return commandCall;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Shows this help or describes a command";
+ }
+
+ @Override
+ public String getUsage() {
+ return "[command]";
+ }
+
+ public CommandsCli getParentCommandsCli() {
+ return parentCommandsCli;
+ }
+
+ protected String getCommandCall(CommandsCli commandsCli) {
+ HelpCommand hc = commandsCli.getHelpCommand();
+ if (hc.getParentCommandsCli() != null) {
+ return getCommandCall(hc.getParentCommandsCli()) + " " + commandsCli.getCommandName();
+ } else {
+ return commandsCli.getCommandName();
+ }
+ }
+
+ public static void printHelp(DescribedCommand<?> command, StringWriter out) {
+ String usage = "java " + command.getClass().getName()
+ + (command.getUsage() != null ? " " + command.getUsage() : "");
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp(new PrintWriter(out), helpWidth, usage, command.getDescription(), command.getOptions(),
+ helpLeftPad, helpDescPad, command.getExamples(), false);
+
+ }
+
+ public static void printHelp(CommandsCli commandsCli, String commandName, StringWriter out) {
+ DescribedCommand<?> command = (DescribedCommand<?>) commandsCli.getCommand(commandName);
+ String usage = commandsCli.getHelpCommand().getCommandUsage(commandName, command);
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp(new PrintWriter(out), helpWidth, usage, command.getDescription(), command.getOptions(),
+ helpLeftPad, helpDescPad, command.getExamples(), false);
+
+ }
+
+ public static void printHelp(CommandsCli commandsCli, StringWriter out) {
+ out.append(commandsCli.getDescription()).append('\n');
+ String leftPad = spaces(helpLeftPad);
+ for (String cmd : commandsCli.getSubCommands()) {
+ Function<List<String>, ?> function = commandsCli.getCommand(cmd);
+ assert function != null;
+ out.append(leftPad);
+ out.append(cmd);
+ // TODO deal with long commands
+ out.append(spaces(helpDescPad - cmd.length()));
+ out.append(getShortDescription(function));
+ out.append('\n');
+ }
+ }
+
+ private static String spaces(int count) {
+ // Java 11
+ // return " ".repeat(count);
+ if (count <= 0)
+ return "";
+ else {
+ StringBuilder sb = new StringBuilder(count);
+ for (int i = 0; i < count; i++)
+ sb.append(' ');
+ return sb.toString();
+ }
+ }
+}
--- /dev/null
+package org.argeo.slc.cli.fs;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.argeo.slc.cli.CommandArgsException;
+import org.argeo.slc.cli.DescribedCommand;
+import org.argeo.slc.sync.SyncResult;
+
+public class FileSync implements DescribedCommand<SyncResult<Path>> {
+ final static Option deleteOption = Option.builder().longOpt("delete").desc("delete from target").build();
+ final static Option recursiveOption = Option.builder("r").longOpt("recursive").desc("recurse into directories")
+ .build();
+ final static Option progressOption = Option.builder().longOpt("progress").hasArg(false).desc("show progress")
+ .build();
+
+ @Override
+ public SyncResult<Path> apply(List<String> t) {
+ try {
+ CommandLine line = toCommandLine(t);
+ List<String> remaining = line.getArgList();
+ if (remaining.size() == 0) {
+ throw new CommandArgsException("There must be at least one argument");
+ }
+ URI sourceUri = new URI(remaining.get(0));
+ URI targetUri;
+ if (remaining.size() == 1) {
+ targetUri = Paths.get(System.getProperty("user.dir")).toUri();
+ } else {
+ targetUri = new URI(remaining.get(1));
+ }
+ boolean delete = line.hasOption(deleteOption.getLongOpt());
+ boolean recursive = line.hasOption(recursiveOption.getLongOpt());
+ PathSync pathSync = new PathSync(sourceUri, targetUri, delete, recursive);
+ return pathSync.call();
+ } catch (URISyntaxException e) {
+ throw new CommandArgsException(e);
+ }
+ }
+
+ @Override
+ public Options getOptions() {
+ Options options = new Options();
+ options.addOption(recursiveOption);
+ options.addOption(deleteOption);
+ options.addOption(progressOption);
+ return options;
+ }
+
+ @Override
+ public String getUsage() {
+ return "[source URI] [target URI]";
+ }
+
+ public static void main(String[] args) {
+ DescribedCommand.mainImpl(new FileSync(), args);
+// Options options = new Options();
+// options.addOption("r", "recursive", false, "recurse into directories");
+// options.addOption(Option.builder().longOpt("progress").hasArg(false).desc("show progress").build());
+//
+// CommandLineParser parser = new DefaultParser();
+// try {
+// CommandLine line = parser.parse(options, args);
+// List<String> remaining = line.getArgList();
+// if (remaining.size() == 0) {
+// System.err.println("There must be at least one argument");
+// printHelp(options);
+// System.exit(1);
+// }
+// URI sourceUri = new URI(remaining.get(0));
+// URI targetUri;
+// if (remaining.size() == 1) {
+// targetUri = Paths.get(System.getProperty("user.dir")).toUri();
+// } else {
+// targetUri = new URI(remaining.get(1));
+// }
+// PathSync pathSync = new PathSync(sourceUri, targetUri);
+// pathSync.run();
+// } catch (Exception exp) {
+// exp.printStackTrace();
+// printHelp(options);
+// System.exit(1);
+// }
+ }
+
+// public static void printHelp(Options options) {
+// HelpFormatter formatter = new HelpFormatter();
+// formatter.printHelp("sync SRC [DEST]", options, true);
+// }
+
+ @Override
+ public String getDescription() {
+ return "Synchronises files";
+ }
+
+}
--- /dev/null
+package org.argeo.slc.cli.fs;
+
+import org.argeo.slc.cli.CommandsCli;
+
+/** File utilities. */
+public class FsCommands extends CommandsCli {
+
+ public FsCommands(String commandName) {
+ super(commandName);
+ addCommand("sync", new FileSync());
+ }
+
+ @Override
+ public String getDescription() {
+ return "Utilities around files and file systems";
+ }
+
+}
--- /dev/null
+package org.argeo.slc.cli.fs;
+
+import java.net.URI;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.spi.FileSystemProvider;
+import java.util.concurrent.Callable;
+
+import org.argeo.slc.sync.SyncResult;
+
+/** Synchronises two paths. */
+public class PathSync implements Callable<SyncResult<Path>> {
+ private final URI sourceUri, targetUri;
+ private final boolean delete;
+ private final boolean recursive;
+
+ public PathSync(URI sourceUri, URI targetUri) {
+ this(sourceUri, targetUri, false, false);
+ }
+
+ public PathSync(URI sourceUri, URI targetUri, boolean delete, boolean recursive) {
+ this.sourceUri = sourceUri;
+ this.targetUri = targetUri;
+ this.delete = delete;
+ this.recursive = recursive;
+ }
+
+ @Override
+ public SyncResult<Path> call() {
+ try {
+ Path sourceBasePath = createPath(sourceUri);
+ Path targetBasePath = createPath(targetUri);
+ SyncFileVisitor syncFileVisitor = new SyncFileVisitor(sourceBasePath, targetBasePath, delete, recursive);
+ Files.walkFileTree(sourceBasePath, syncFileVisitor);
+ return syncFileVisitor.getSyncResult();
+ } catch (Exception e) {
+ throw new IllegalStateException("Cannot sync " + sourceUri + " to " + targetUri, e);
+ }
+ }
+
+ private Path createPath(URI uri) {
+ Path path;
+ if (uri.getScheme() == null) {
+ path = Paths.get(uri.getPath());
+ } else if (uri.getScheme().equals("file")) {
+ FileSystemProvider fsProvider = FileSystems.getDefault().provider();
+ path = fsProvider.getPath(uri);
+ } else if (uri.getScheme().equals("davex")) {
+ throw new UnsupportedOperationException();
+// FileSystemProvider fsProvider = new DavexFsProvider();
+// path = fsProvider.getPath(uri);
+// } else if (uri.getScheme().equals("sftp")) {
+// Sftp sftp = new Sftp(uri);
+// path = sftp.getBasePath();
+ } else
+ throw new IllegalArgumentException("URI scheme not supported for " + uri);
+ return path;
+ }
+}
--- /dev/null
+package org.argeo.slc.cli.fs;
+
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
+import java.nio.file.Path;
+import java.util.Objects;
+
+import org.argeo.slc.sync.BasicSyncFileVisitor;
+
+/** Synchronises two directory structures. */
+public class SyncFileVisitor extends BasicSyncFileVisitor {
+ private final static Logger logger = System.getLogger(SyncFileVisitor.class.getName());
+
+ public SyncFileVisitor(Path sourceBasePath, Path targetBasePath, boolean delete, boolean recursive) {
+ super(sourceBasePath, targetBasePath, delete, recursive);
+ }
+
+ @Override
+ protected void error(Object obj, Throwable e) {
+ logger.log(Level.ERROR, Objects.toString(obj), e);
+ }
+
+ @Override
+ protected boolean isTraceEnabled() {
+ return logger.isLoggable(Level.TRACE);
+ }
+
+ @Override
+ protected void trace(Object obj) {
+ logger.log(Level.TRACE, Objects.toString(obj));
+ }
+}
--- /dev/null
+/** File system CLI commands. */
+package org.argeo.slc.cli.fs;
\ No newline at end of file
--- /dev/null
+/** Command line API. */
+package org.argeo.slc.cli;
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.cli.posix;
+
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.argeo.slc.cli.DescribedCommand;
+
+public class Echo implements DescribedCommand<String> {
+
+ @Override
+ public Options getOptions() {
+ Options options = new Options();
+ options.addOption(Option.builder("n").desc("do not output the trailing newline").build());
+ return options;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Display a line of text";
+ }
+
+ @Override
+ public String getUsage() {
+ return "[STRING]...";
+ }
+
+ @Override
+ public String apply(List<String> args) {
+ CommandLine cl = toCommandLine(args);
+
+ StringBuffer sb = new StringBuffer();
+ for (String s : cl.getArgList()) {
+ sb.append(s).append(' ');
+ }
+
+ if (cl.hasOption('n')) {
+ sb.deleteCharAt(sb.length() - 1);
+ } else {
+ sb.setCharAt(sb.length() - 1, '\n');
+ }
+ return sb.toString();
+ }
+
+}
--- /dev/null
+package org.argeo.slc.cli.posix;
+
+import org.argeo.slc.cli.CommandsCli;
+
+/** POSIX commands. */
+public class PosixCommands extends CommandsCli {
+
+ public PosixCommands(String commandName) {
+ super(commandName);
+ addCommand("echo", new Echo());
+ }
+
+ @Override
+ public String getDescription() {
+ return "Reimplementation of some POSIX commands in plain Java";
+ }
+
+ public static void main(String[] args) {
+ mainImpl(new PosixCommands("argeo-posix"), args);
+ }
+}
--- /dev/null
+/** Posix CLI commands. */
+package org.argeo.slc.cli.posix;
\ No newline at end of file
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.execution.ExecutionContext;
import org.argeo.slc.execution.ExecutionFlow;
import org.argeo.slc.execution.ExecutionFlowDescriptorConverter;
/** Provides the base feature of an execution module manager. */
public abstract class AbstractExecutionModulesManager implements
ExecutionModulesManager {
- private final static Log log = LogFactory
- .getLog(AbstractExecutionModulesManager.class);
// private List<FilteredNotifier> filteredNotifiers = Collections
// .synchronizedList(new ArrayList<FilteredNotifier>());
String moduleName, String moduleVersion);
public void execute(RealizedFlow realizedFlow) {
- if (log.isTraceEnabled())
- log.trace("Executing " + realizedFlow);
-
String moduleName = realizedFlow.getModuleName();
String moduleVersion = realizedFlow.getModuleVersion();
--- /dev/null
+package org.argeo.slc.runtime;
+
+import org.apache.commons.cli.Option;
+import org.argeo.slc.cli.CommandsCli;
+import org.argeo.slc.cli.fs.FsCommands;
+import org.argeo.slc.cli.posix.PosixCommands;
+
+/** Argeo command line tools. */
+public class ArgeoCli extends CommandsCli {
+
+ public ArgeoCli(String commandName) {
+ super(commandName);
+ // Common options
+ options.addOption(Option.builder("v").hasArg().argName("verbose").desc("verbosity").build());
+ options.addOption(
+ Option.builder("D").hasArgs().argName("property=value").desc("use value for given property").build());
+
+ addCommandsCli(new PosixCommands("posix"));
+ addCommandsCli(new FsCommands("fs"));
+// addCommandsCli(new JcrCommands("jcr"));
+ }
+
+ @Override
+ public String getDescription() {
+ return "Argeo command line utilities";
+ }
+
+ public static void main(String[] args) {
+ mainImpl(new ArgeoCli("argeo"), args);
+ }
+
+}
/** Implements the base methods of an SLC agent. */
public class DefaultAgent implements SlcAgent {
- // private final static Log log = LogFactory.getLog(DefaultAgent.class);
+ // private final static CmsLog log = CmsLog.getLog(DefaultAgent.class);
/** UTF-8 charset for encoding. */
private final static String UTF8 = "UTF-8";
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.DefaultNameVersion;
import org.argeo.slc.NameVersion;
import org.argeo.slc.SlcException;
* Reference implementation of args to URIs algorithm.
*/
public class DefaultAgentCli implements SlcAgentCli {
- private final static Log log = LogFactory.getLog(DefaultAgentCli.class);
-
private final static String UTF8 = "UTF-8";
private SlcAgent agent;
// private AuthenticationManager authenticationManager;
if (args.length > 0 && args[0].equals("help")) {
StringBuilder buf = new StringBuilder();
help(args, buf);
- log.info("\n" + buf);
+// log.info("\n" + buf);
return buf.toString();
} else {
List<URI> uris = asURIs(args);
package org.argeo.slc.runtime;
+import static java.lang.System.Logger.Level.ERROR;
+import static java.lang.System.Logger.Level.WARNING;
+
+import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
import org.argeo.slc.execution.ExecutionContext;
import org.argeo.slc.execution.ExecutionFlow;
/** Default implementation of an execution flow. */
public class DefaultExecutionFlow implements ExecutionFlow {
- private final static Log log = LogFactory.getLog(DefaultExecutionFlow.class);
+ private final static System.Logger logger = System.getLogger(DefaultExecutionFlow.class.getName());
private final ExecutionSpec executionSpec;
private String name = null;
try {
for (Runnable executable : executables) {
if (Thread.interrupted()) {
- log.error("Flow '" + getName() + "' killed before '" + executable + "'");
+ logger.log(ERROR, "Flow '" + getName() + "' killed before '" + executable + "'");
Thread.currentThread().interrupt();
return;
// throw new ThreadDeath();
}
} catch (RuntimeException e) {
if (Thread.interrupted()) {
- log.error("Flow '" + getName() + "' killed while receiving an unrelated exception", e);
+ logger.log(ERROR, "Flow '" + getName() + "' killed while receiving an unrelated exception", e);
Thread.currentThread().interrupt();
return;
// throw new ThreadDeath();
if (failOnError)
throw e;
else {
- log.error("Execution flow failed," + " but process did not fail" + " because failOnError property"
- + " is set to false: " + e);
- if (log.isTraceEnabled())
+ logger.log(ERROR, "Execution flow failed," + " but process did not fail"
+ + " because failOnError property" + " is set to false: " + e);
+ if (logger.isLoggable(Level.TRACE))
e.printStackTrace();
}
}
DefaultExecutionFlow flow = (DefaultExecutionFlow) executable;
String newPath = path + '/' + flow.getName();
flow.setPath(newPath);
- log.warn(newPath + " was forcibly set on " + flow);
+ logger.log(WARNING, newPath + " was forcibly set on " + flow);
}
}
}
import java.util.Stack;
import java.util.UUID;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
import org.argeo.slc.execution.ExecutionFlow;
import org.argeo.slc.execution.ExecutionSpecAttribute;
/** Canonical implementation of an execution stack. */
public class DefaultExecutionStack implements ExecutionStack {
-
- private final static Log log = LogFactory
- .getLog(DefaultExecutionStack.class);
-
private final Stack<ExecutionFlowRuntime> stack = new Stack<ExecutionFlowRuntime>();
public synchronized void enterFlow(ExecutionFlow executionFlow) {
ExecutionFlowRuntime runtime = new ExecutionFlowRuntime(executionFlow);
stack.push(runtime);
- Map<String, ExecutionSpecAttribute> specAttrs = executionFlow
- .getExecutionSpec().getAttributes();
+ Map<String, ExecutionSpecAttribute> specAttrs = executionFlow.getExecutionSpec().getAttributes();
for (String key : specAttrs.keySet()) {
if (executionFlow.isSetAsParameter(key)) {
- runtime.getLocalVariables().put(key,
- executionFlow.getParameter(key));
+ runtime.getLocalVariables().put(key, executionFlow.getParameter(key));
}
}
}
public synchronized void leaveFlow(ExecutionFlow executionFlow) {
ExecutionFlowRuntime leftEf = stack.pop();
- if (!leftEf.getExecutionFlow().getName()
- .equals(executionFlow.getName()))
- throw new SlcException("Asked to leave " + executionFlow
- + " but last is " + leftEf);
+ if (!leftEf.getExecutionFlow().getName().equals(executionFlow.getName()))
+ throw new SlcException("Asked to leave " + executionFlow + " but last is " + leftEf);
leftEf.getScopedObjects().clear();
leftEf.getLocalVariables().clear();
public synchronized void addScopedObject(String name, Object obj) {
ExecutionFlowRuntime runtime = stack.peek();
// TODO: check that the object is not set yet ?
- if (log.isDebugEnabled()) {
- Object existing = findScopedObject(name);
- if (existing != null)
- log.warn("Scoped object " + name + " of type " + obj.getClass()
- + " already registered in " + runtime);
- }
+// if (log.isDebugEnabled()) {
+// Object existing = findScopedObject(name);
+// if (existing != null)
+// log.warn("Scoped object " + name + " of type " + obj.getClass()
+// + " already registered in " + runtime);
+// }
runtime.getScopedObjects().put(name, obj);
}
package org.argeo.slc.runtime;
+import static java.lang.System.Logger.Level.ERROR;
+import static java.lang.System.Logger.Level.WARNING;
+
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import javax.security.auth.Subject;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.execution.ExecutionFlowDescriptor;
import org.argeo.slc.execution.ExecutionModulesManager;
import org.argeo.slc.execution.ExecutionStep;
/** Thread of a single execution */
public class ExecutionThread extends Thread {
public final static String SYSPROP_EXECUTION_AUTO_UPGRADE = "slc.execution.autoupgrade";
- private final static Log log = LogFactory.getLog(ExecutionThread.class);
+ private final static System.Logger logger = System.getLogger(ExecutionThread.class.getName());
private ExecutionModulesManager executionModulesManager;
private final RealizedFlow realizedFlow;
}
} catch (FlowConfigurationException e) {
String msg = "Configuration problem with flow " + flowName + ":\n" + e.getMessage();
- log.error(msg);
+ logger.log(ERROR, msg);
getProcessThreadGroup().dispatchAddStep(
new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.ERROR, msg + " " + e.getMessage()));
} catch (Exception e) {
// TODO: re-throw exception ?
String msg = "Execution of flow " + flowName + " failed.";
- log.error(msg, e);
+ logger.log(ERROR, msg, e);
getProcessThreadGroup().dispatchAddStep(
new ExecutionStep(realizedFlow.getModuleName(), ExecutionStep.ERROR, msg + " " + e.getMessage()));
} finally {
try {
destructionCallbacks.get(i).run();
} catch (Exception e) {
- log.warn("Could not process destruction callback " + i + " in thread " + getName(), e);
+ logger.log(WARNING, "Could not process destruction callback " + i + " in thread " + getName(), e);
}
}
}
/**
- * Gather object destruction callback to be called in reverse order at the
- * end of the thread
+ * Gather object destruction callback to be called in reverse order at the end
+ * of the thread
*/
public synchronized void registerDestructionCallback(String name, Runnable callback) {
destructionCallbacks.add(callback);
package org.argeo.slc.runtime;
+import java.lang.System.Logger.Level;
import java.util.Stack;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
import org.argeo.slc.execution.ExecutionFlow;
import org.argeo.slc.execution.ExecutionSpecAttribute;
/** Manage parameters that need to be set during the instantiation of a flow */
public class InstantiationManager {
- private final static Log log = LogFactory
- .getLog(InstantiationManager.class);
+ private final static System.Logger logger = System.getLogger(InstantiationManager.class.getName());
private ThreadLocal<Stack<ExecutionFlow>> flowStack = new ThreadLocal<Stack<ExecutionFlow>>();
public Object createRef(String name) {
if ((flowStack.get() == null) || flowStack.get().empty()) {
- throw new SlcException("No flow is currently initializing."
- + " Declare ParameterRef as inner beans or prototypes.");
+ throw new SlcException(
+ "No flow is currently initializing." + " Declare ParameterRef as inner beans or prototypes.");
}
return getInitializingFlowParameter(name);
((DefaultExecutionFlow) flow).setName(flowName);
}
- if (log.isTraceEnabled())
- log.trace("Start initialization of " + flow.hashCode() + " ("
- + flow + " - " + flow.getClass() + ")");
+ logger.log(Level.TRACE,
+ () -> "Start initialization of " + flow.hashCode() + " (" + flow + " - " + flow.getClass() + ")");
// log.info("# flowInitializationStarted " + flowName);
// create a stack for this thread if there is none
}
public void flowInitializationFinished(ExecutionFlow flow, String flowName) {
- if (log.isTraceEnabled())
- log.trace("Finish initialization of " + flow.hashCode() + " ("
- + flow + " - " + flow.getClass() + ")");
+ logger.log(Level.TRACE,
+ () -> "Finish initialization of " + flow.hashCode() + " (" + flow + " - " + flow.getClass() + ")");
if (flowStack.get() != null) {
ExecutionFlow registeredFlow = flowStack.get().pop();
}
} else {
// happens for flows imported as services
- log.warn("flowInitializationFinished - Flow Stack is null");
+ logger.log(Level.WARNING, "flowInitializationFinished - Flow Stack is null");
}
}
return flowStack.get().elementAt(i);
}
}
- throw new SlcException("Key " + key + " is not set as parameter in "
- + flowStack.get().firstElement().toString() + " (stack size="
- + flowStack.get().size() + ")");
+ throw new SlcException("Key " + key + " is not set as parameter in " + flowStack.get().firstElement().toString()
+ + " (stack size=" + flowStack.get().size() + ")");
}
}
public Class<?> getInitializingFlowParameterClass(String key) {
- ExecutionSpecAttribute attr = findInitializingFlowWithParameter(key)
- .getExecutionSpec().getAttributes().get(key);
+ ExecutionSpecAttribute attr = findInitializingFlowWithParameter(key).getExecutionSpec().getAttributes()
+ .get(key);
if (attr instanceof RefSpecAttribute)
return ((RefSpecAttribute) attr).getTargetClass();
else if (attr instanceof PrimitiveSpecAttribute) {
String type = ((PrimitiveSpecAttribute) attr).getType();
Class<?> clss = PrimitiveUtils.typeAsClass(type);
if (clss == null)
- throw new SlcException("Cannot convert type " + type
- + " to class.");
+ throw new SlcException("Cannot convert type " + type + " to class.");
return clss;
} else
return null;
package org.argeo.slc.runtime;
+import java.lang.System.Logger.Level;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import javax.security.auth.Subject;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
import org.argeo.slc.execution.ExecutionModulesManager;
import org.argeo.slc.execution.ExecutionProcess;
* sequential {@link ExecutionThread}s.
*/
public class ProcessThread extends Thread {
- private final static Log log = LogFactory.getLog(ProcessThread.class);
+ private final static System.Logger logger = System.getLogger(ProcessThread.class.getName());
private final ExecutionModulesManager executionModulesManager;
private final ExecutionProcess process;
// throw new SlcException("Can only execute authenticated threads");
// SecurityContextHolder.getContext().setAuthentication(authentication);
- log.info("\n##\n## SLC Process #" + process.getUuid() + " STARTED\n##\n");
+ logger.log(Level.INFO, "\n##\n## SLC Process #" + process.getUuid() + " STARTED\n##\n");
// Start logging
new LoggingThread().start();
return;
} catch (Exception e) {
String msg = "Process " + getProcess().getUuid() + " failed unexpectedly.";
- log.error(msg, e);
+ logger.log(Level.ERROR, msg, e);
getProcessThreadGroup()
.dispatchAddStep(new ExecutionStep("Process", ExecutionStep.ERROR, msg + " " + e.getMessage()));
}
process.setStatus(ExecutionProcess.COMPLETED);
// executionModulesManager.dispatchUpdateStatus(process, oldStatus,
// process.getStatus());
- log.info("\n## SLC Process #" + process.getUuid() + " " + process.getStatus() + "\n");
+ logger.log(Level.INFO, "\n## SLC Process #" + process.getUuid() + " " + process.getStatus() + "\n");
}
/** Called when being killed */
try {
executionThread.interrupt();
} catch (Exception e) {
- log.error("Cannot interrupt " + executionThread);
+ logger.log(Level.ERROR, "Cannot interrupt " + executionThread);
}
}
processThreadGroup.interrupt();
import java.io.File;
import java.io.IOException;
+import java.lang.System.Logger;
+import java.lang.System.Logger.Level;
import java.nio.file.Path;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
public class Echo implements Runnable {
- private final static Log defaultLog = LogFactory.getLog(Echo.class);
+ private final static Logger defaultLogger = System.getLogger(Echo.class.getName());
private Path writeTo = null;
- private Log log;
+ private Logger log;
private Object message;
public void run() {
- log().info(message);
+ log().log(Level.INFO, message);
if (writeTo != null) {
try {
File file = writeTo.toFile();
- if (log().isDebugEnabled())
- log().debug("Write to " + file);
+
+ log().log(Level.DEBUG, () -> "Write to " + file);
if (message != null)
FileUtils.writeStringToFile(file, message.toString());
} catch (IOException e) {
}
}
- private Log log() {
- return log != null ? log : defaultLog;
+ private Logger log() {
+ return log != null ? log : defaultLogger;
}
public void setMessage(Object message) {
package org.argeo.slc.runtime.tasks;
+import static java.lang.System.Logger.Level.DEBUG;
+import static java.lang.System.Logger.Level.ERROR;
+import static java.lang.System.Logger.Level.INFO;
+import static java.lang.System.Logger.Level.TRACE;
+import static java.lang.System.Logger.Level.WARNING;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.Writer;
+import java.lang.System.Logger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import org.apache.commons.exec.ShutdownHookProcessDestroyer;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
import org.argeo.slc.UnsupportedException;
import org.argeo.slc.execution.ExecutionResources;
public class SystemCall implements Runnable {
public final static String LOG_STDOUT = "System.out";
- private final Log log = LogFactory.getLog(getClass());
+ private final Logger logger = System.getLogger(getClass().getName());
private String execDir;
throw new SlcException("Cannot open a stream for " + stdInFile, e2);
}
- if (log.isTraceEnabled()) {
- log.debug("os.name=" + System.getProperty("os.name"));
- log.debug("os.arch=" + System.getProperty("os.arch"));
- log.debug("os.version=" + System.getProperty("os.version"));
- }
+ logger.log(TRACE, () -> "os.name=" + System.getProperty("os.name"));
+ logger.log(TRACE, () -> "os.arch=" + System.getProperty("os.arch"));
+ logger.log(TRACE, () -> "os.version=" + System.getProperty("os.version"));
// Execution directory
File dir = new File(getExecDirToUse());
// Command line to use
final CommandLine commandLine = createCommandLine();
if (logCommand)
- log.info("Execute command:\n" + commandLine + "\n in working directory: \n" + dir + "\n");
+ logger.log(INFO, "Execute command:\n" + commandLine + "\n in working directory: \n" + dir + "\n");
// Env variables
Map<String, String> environmentVariablesToUse = null;
commandLine = new CommandLine(commandToUse.get(0).toString());
for (int i = 1; i < commandToUse.size(); i++) {
- if (log.isTraceEnabled())
- log.debug(commandToUse.get(i));
+ if (logger.isLoggable(TRACE))
+ logger.log(TRACE, commandToUse.get(i));
commandLine.addArgument(commandToUse.get(i).toString());
}
} else {
public void onProcessComplete(int exitValue) {
String msg = "System call '" + commandLine + "' properly completed.";
- if (log.isTraceEnabled())
- log.trace(msg);
+ logger.log(TRACE, () -> msg);
if (testResult != null) {
forwardPath(testResult);
testResult.addResultPart(new SimpleResultPart(TestStatus.PASSED, msg));
if (exceptionOnFailed)
throw new SlcException(msg, e);
else
- log.error(msg, e);
+ logger.log(ERROR, msg, e);
}
releaseWatchdog();
}
// }
if ("ERROR".equals(logLevel))
- log.error(line);
+ logger.log(ERROR, line);
else if ("WARN".equals(logLevel))
- log.warn(line);
+ logger.log(WARNING, line);
+ else if ("WARNING".equals(logLevel))
+ logger.log(WARNING, line);
else if ("INFO".equals(logLevel))
- log.info(line);
+ logger.log(INFO, line);
else if ("DEBUG".equals(logLevel))
- log.debug(line);
+ logger.log(DEBUG, line);
else if ("TRACE".equals(logLevel))
- log.trace(line);
+ logger.log(TRACE, line);
else if (LOG_STDOUT.equals(logLevel))
System.out.println(line);
else if ("System.err".equals(logLevel))
try {
writer.append(line).append('\n');
} catch (IOException e) {
- log.error("Cannot write to log file", e);
+ logger.log(ERROR, "Cannot write to log file", e);
}
}
file = target.toFile();
writer = new FileWriter(file, append);
} catch (IOException e) {
- log.error("Cannot get file for " + target, e);
+ logger.log(ERROR, "Cannot get file for " + target, e);
IOUtils.closeQuietly(writer);
}
return writer;
file = target.toFile();
out = new FileOutputStream(file, false);
} catch (IOException e) {
- log.error("Cannot get file for " + target, e);
+ logger.log(ERROR, "Cannot get file for " + target, e);
IOUtils.closeQuietly(out);
}
return out;
import java.util.Map;
import java.util.TreeMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.test.TestResult;
import org.argeo.slc.test.TestStatus;
import org.argeo.slc.test.context.ContextAware;
/** Utilities for comparing and synchronising contexts. */
public class ContextUtils {
- private final static Log log = LogFactory.getLog(ContextUtils.class);
-
- public static void compareReachedExpected(ContextAware contextAware,
- TestResult testResult) {
+ public static void compareReachedExpected(ContextAware contextAware, TestResult testResult) {
for (String key : contextAware.getExpectedValues().keySet()) {
// Compare expected values with reached ones
Object expectedValue = contextAware.getExpectedValues().get(key);
- if (expectedValue.toString().equals(
- contextAware.getContextSkipFlag())) {
- if (log.isDebugEnabled())
- log.debug("Skipped check for key '" + key + "'");
+ if (expectedValue.toString().equals(contextAware.getContextSkipFlag())) {
+// if (log.isDebugEnabled())
+// log.debug("Skipped check for key '" + key + "'");
continue;
}
Object reachedValue = contextAware.getValues().get(key);
if (expectedValue.equals(contextAware.getContextAnyFlag())) {
- testResult.addResultPart(new SimpleResultPart(
- TestStatus.PASSED, "Expected any value for key '"
- + key + "'"));
+ testResult.addResultPart(
+ new SimpleResultPart(TestStatus.PASSED, "Expected any value for key '" + key + "'"));
} else if (expectedValue.equals(reachedValue)) {
- testResult.addResultPart(new SimpleResultPart(
- TestStatus.PASSED, "Values matched for key '" + key
- + "'"));
+ testResult.addResultPart(
+ new SimpleResultPart(TestStatus.PASSED, "Values matched for key '" + key + "'"));
} else {
- testResult.addResultPart(new SimpleResultPart(
- TestStatus.FAILED, "Mismatch for key '" + key
- + "': expected '" + expectedValue
- + "' but reached '" + reachedValue + "'"));
+ testResult.addResultPart(new SimpleResultPart(TestStatus.FAILED, "Mismatch for key '" + key
+ + "': expected '" + expectedValue + "' but reached '" + reachedValue + "'"));
}
} else {
- testResult.addResultPart(new SimpleResultPart(
- TestStatus.FAILED, "No value reached for key '" + key
- + "'"));
+ testResult.addResultPart(
+ new SimpleResultPart(TestStatus.FAILED, "No value reached for key '" + key + "'"));
}
}
}
/**
- * Makes sure that all children and sub-children of parent share the same
- * maps for values and expected values.
+ * Makes sure that all children and sub-children of parent share the same maps
+ * for values and expected values.
*/
public static void synchronize(ParentContextAware parent) {
- Map<String, Object> expectedValuesCommon = new TreeMap<String, Object>(
- parent.getExpectedValues());
+ Map<String, Object> expectedValuesCommon = new TreeMap<String, Object>(parent.getExpectedValues());
synchronize(parent, expectedValuesCommon);
- if (log.isDebugEnabled())
- log.debug("Synchronized context " + parent);
+// if (log.isDebugEnabled())
+// log.debug("Synchronized context " + parent);
}
- private static void synchronize(ParentContextAware parent,
- Map<String, Object> expectedValuesCommon) {
+ private static void synchronize(ParentContextAware parent, Map<String, Object> expectedValuesCommon) {
for (ContextAware child : parent.getChildContexts()) {
// Values
putNotContained(parent.getValues(), child.getValues());
// Creates a new Map in order not to disturb other context using the
// same keys
- Map<String, Object> expectedValuesCommonChild = new TreeMap<String, Object>(
- expectedValuesCommon);
- putNotContained(expectedValuesCommonChild,
- child.getExpectedValues());
+ Map<String, Object> expectedValuesCommonChild = new TreeMap<String, Object>(expectedValuesCommon);
+ putNotContained(expectedValuesCommonChild, child.getExpectedValues());
if (child instanceof ParentContextAware) {
// Recursive sync
- synchronize((ParentContextAware) child,
- expectedValuesCommonChild);
+ synchronize((ParentContextAware) child, expectedValuesCommonChild);
}
}
}
/**
- * Put into common map the values from child map which are not already
- * defined in common map.
+ * Put into common map the values from child map which are not already defined
+ * in common map.
*/
- public static void putNotContained(Map<String, Object> commonMap,
- Map<String, Object> childMap) {
+ public static void putNotContained(Map<String, Object> commonMap, Map<String, Object> childMap) {
for (String key : childMap.keySet()) {
if (!commonMap.containsKey(key)) {
commonMap.put(key, childMap.get(key));
}
/** Overrides child map values with the values already set in common map */
- public static void overrideContained(Map<String, Object> commonMap,
- Map<String, Object> childMap) {
+ public static void overrideContained(Map<String, Object> commonMap, Map<String, Object> childMap) {
for (String key : childMap.keySet()) {
if (commonMap.containsKey(key)) {
childMap.put(key, commonMap.get(key));
import java.util.UUID;
import java.util.Vector;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
import org.argeo.slc.test.TestResult;
import org.argeo.slc.test.TestResultPart;
* Basic implementation of a test result containing only a list of result parts.
*/
public class SimpleTestResult implements TestResult {
- private static Log log = LogFactory.getLog(SimpleTestResult.class);
-
private String uuid;
private String currentTestRunUuid;
public void addResultPart(TestResultPart part) {
if (throwError && part.getStatus() == ERROR) {
- throw new SlcException(
- "There was an error in the underlying test: "
- + part.getExceptionMessage());
+ throw new SlcException("There was an error in the underlying test: " + part.getExceptionMessage());
}
parts.add(part);
- if (log.isDebugEnabled())
- log.debug(part);
+// if (log.isDebugEnabled())
+// log.debug(part);
}
public void close() {
--- /dev/null
+package org.argeo.slc.sync;
+
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileTime;
+
+/** Synchronises two directory structures. */
+public class BasicSyncFileVisitor extends SimpleFileVisitor<Path> {
+ // TODO make it configurable
+ private boolean trace = false;
+
+ private final Path sourceBasePath;
+ private final Path targetBasePath;
+ private final boolean delete;
+ private final boolean recursive;
+
+ private SyncResult<Path> syncResult = new SyncResult<>();
+
+ public BasicSyncFileVisitor(Path sourceBasePath, Path targetBasePath, boolean delete, boolean recursive) {
+ this.sourceBasePath = sourceBasePath;
+ this.targetBasePath = targetBasePath;
+ this.delete = delete;
+ this.recursive = recursive;
+ }
+
+ @Override
+ public FileVisitResult preVisitDirectory(Path sourceDir, BasicFileAttributes attrs) throws IOException {
+ if (!recursive && !sourceDir.equals(sourceBasePath))
+ return FileVisitResult.SKIP_SUBTREE;
+ Path targetDir = toTargetPath(sourceDir);
+ Files.createDirectories(targetDir);
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path sourceDir, IOException exc) throws IOException {
+ if (delete) {
+ Path targetDir = toTargetPath(sourceDir);
+ for (Path targetPath : Files.newDirectoryStream(targetDir)) {
+ Path sourcePath = sourceDir.resolve(targetPath.getFileName());
+ if (!Files.exists(sourcePath)) {
+ try {
+ FsSyncUtils.delete(targetPath);
+ deleted(targetPath);
+ } catch (Exception e) {
+ deleteFailed(targetPath, exc);
+ }
+ }
+ }
+ }
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path sourceFile, BasicFileAttributes attrs) throws IOException {
+ Path targetFile = toTargetPath(sourceFile);
+ try {
+ if (!Files.exists(targetFile)) {
+ Files.copy(sourceFile, targetFile);
+ added(sourceFile, targetFile);
+ } else {
+ if (shouldOverwrite(sourceFile, targetFile)) {
+ Files.copy(sourceFile, targetFile, StandardCopyOption.REPLACE_EXISTING);
+ }
+ }
+ } catch (Exception e) {
+ copyFailed(sourceFile, targetFile, e);
+ }
+ return FileVisitResult.CONTINUE;
+ }
+
+ protected boolean shouldOverwrite(Path sourceFile, Path targetFile) throws IOException {
+ long sourceSize = Files.size(sourceFile);
+ long targetSize = Files.size(targetFile);
+ if (sourceSize != targetSize) {
+ return true;
+ }
+ FileTime sourceLastModif = Files.getLastModifiedTime(sourceFile);
+ FileTime targetLastModif = Files.getLastModifiedTime(targetFile);
+ if (sourceLastModif.compareTo(targetLastModif) > 0)
+ return true;
+ return shouldOverwriteLaterSameSize(sourceFile, targetFile);
+ }
+
+ protected boolean shouldOverwriteLaterSameSize(Path sourceFile, Path targetFile) {
+ return false;
+ }
+
+// @Override
+// public FileVisitResult visitFileFailed(Path sourceFile, IOException exc) throws IOException {
+// error("Cannot sync " + sourceFile, exc);
+// return FileVisitResult.CONTINUE;
+// }
+
+ private Path toTargetPath(Path sourcePath) {
+ Path relativePath = sourceBasePath.relativize(sourcePath);
+ Path targetPath = targetBasePath.resolve(relativePath.toString());
+ return targetPath;
+ }
+
+ public Path getSourceBasePath() {
+ return sourceBasePath;
+ }
+
+ public Path getTargetBasePath() {
+ return targetBasePath;
+ }
+
+ protected void added(Path sourcePath, Path targetPath) {
+ syncResult.getAdded().add(targetPath);
+ if (isTraceEnabled())
+ trace("Added " + sourcePath + " as " + targetPath);
+ }
+
+ protected void modified(Path sourcePath, Path targetPath) {
+ syncResult.getModified().add(targetPath);
+ if (isTraceEnabled())
+ trace("Overwritten from " + sourcePath + " to " + targetPath);
+ }
+
+ protected void copyFailed(Path sourcePath, Path targetPath, Exception e) {
+ syncResult.addError(sourcePath, targetPath, e);
+ if (isTraceEnabled())
+ error("Cannot copy " + sourcePath + " to " + targetPath, e);
+ }
+
+ protected void deleted(Path targetPath) {
+ syncResult.getDeleted().add(targetPath);
+ if (isTraceEnabled())
+ trace("Deleted " + targetPath);
+ }
+
+ protected void deleteFailed(Path targetPath, Exception e) {
+ syncResult.addError(null, targetPath, e);
+ if (isTraceEnabled())
+ error("Cannot delete " + targetPath, e);
+ }
+
+ /** Log error. */
+ protected void error(Object obj, Throwable e) {
+ System.err.println(obj);
+ e.printStackTrace();
+ }
+
+ protected boolean isTraceEnabled() {
+ return trace;
+ }
+
+ protected void trace(Object obj) {
+ System.out.println(obj);
+ }
+
+ public SyncResult<Path> getSyncResult() {
+ return syncResult;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.sync;
+
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+public class FsSyncUtils {
+ /** Sync a source path with a target path. */
+ public static void sync(Path sourceBasePath, Path targetBasePath) {
+ sync(sourceBasePath, targetBasePath, false);
+ }
+
+ /** Sync a source path with a target path. */
+ public static void sync(Path sourceBasePath, Path targetBasePath, boolean delete) {
+ sync(new BasicSyncFileVisitor(sourceBasePath, targetBasePath, delete, true));
+ }
+
+ public static void sync(BasicSyncFileVisitor syncFileVisitor) {
+ try {
+ Files.walkFileTree(syncFileVisitor.getSourceBasePath(), syncFileVisitor);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot sync " + syncFileVisitor.getSourceBasePath() + " with "
+ + syncFileVisitor.getTargetBasePath(), e);
+ }
+ }
+
+ /**
+ * Deletes this path, recursively if needed. Does nothing if the path does not
+ * exist.
+ */
+ public static void delete(Path path) {
+ try {
+ if (!Files.exists(path))
+ return;
+ Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult postVisitDirectory(Path directory, IOException e) throws IOException {
+ if (e != null)
+ throw e;
+ Files.delete(directory);
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ Files.delete(file);
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot delete " + path, e);
+ }
+ }
+
+ /** Singleton. */
+ private FsSyncUtils() {
+
+ }
+}
--- /dev/null
+package org.argeo.slc.sync;
+
+import java.time.Instant;
+import java.util.Set;
+import java.util.TreeSet;
+
+/** Describes what happendend during a sync operation. */
+public class SyncResult<T> {
+ private final Set<T> added = new TreeSet<>();
+ private final Set<T> modified = new TreeSet<>();
+ private final Set<T> deleted = new TreeSet<>();
+ private final Set<Error> errors = new TreeSet<>();
+
+ public Set<T> getAdded() {
+ return added;
+ }
+
+ public Set<T> getModified() {
+ return modified;
+ }
+
+ public Set<T> getDeleted() {
+ return deleted;
+ }
+
+ public Set<Error> getErrors() {
+ return errors;
+ }
+
+ public void addError(T sourcePath, T targetPath, Exception e) {
+ Error error = new Error(sourcePath, targetPath, e);
+ errors.add(error);
+ }
+
+ public boolean noModification() {
+ return modified.isEmpty() && deleted.isEmpty() && added.isEmpty();
+ }
+
+ @Override
+ public String toString() {
+ if (noModification())
+ return "No modification.";
+ StringBuffer sb = new StringBuffer();
+ for (T p : modified)
+ sb.append("MOD ").append(p).append('\n');
+ for (T p : deleted)
+ sb.append("DEL ").append(p).append('\n');
+ for (T p : added)
+ sb.append("ADD ").append(p).append('\n');
+ for (Error error : errors)
+ sb.append(error).append('\n');
+ return sb.toString();
+ }
+
+ public class Error implements Comparable<Error> {
+ private final T sourcePath;// if null this is a failed delete
+ private final T targetPath;
+ private final Exception exception;
+ private final Instant timestamp = Instant.now();
+
+ public Error(T sourcePath, T targetPath, Exception e) {
+ super();
+ this.sourcePath = sourcePath;
+ this.targetPath = targetPath;
+ this.exception = e;
+ }
+
+ public T getSourcePath() {
+ return sourcePath;
+ }
+
+ public T getTargetPath() {
+ return targetPath;
+ }
+
+ public Exception getException() {
+ return exception;
+ }
+
+ public Instant getTimestamp() {
+ return timestamp;
+ }
+
+ @Override
+ public int compareTo(Error o) {
+ return timestamp.compareTo(o.timestamp);
+ }
+
+ @Override
+ public int hashCode() {
+ return timestamp.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "ERR " + timestamp + (sourcePath == null ? "Deletion failed" : "Copy failed " + sourcePath) + " "
+ + targetPath + " " + exception.getMessage();
+ }
+
+ }
+}
+++ /dev/null
-<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.maven</groupId>
- <artifactId>argeo-osgi-parent</artifactId>
- <version>2.1.7</version>
- </parent>
- <groupId>org.argeo.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <packaging>pom</packaging>
- <name>Argeo SLC</name>
- <version>2.1-SNAPSHOT</version>
- <properties>
- <version.context>testing</version.context>
- <version.argeo-tp>2.1.27</version.argeo-tp>
- <version.argeo-tp-extras>2.1.13</version.argeo-tp-extras>
- <version.argeo-commons>2.1-SNAPSHOT</version.argeo-commons>
-
- <developmentCycle.startDate>2015-02-12</developmentCycle.startDate>
- <developmentCycle.slc>2.1</developmentCycle.slc>
- <version.argeo-commons-legacy>2.1.104</version.argeo-commons-legacy>
- </properties>
- <modules>
- <!-- SLC framework -->
- <module>org.argeo.slc.api</module>
- <module>org.argeo.slc.runtime</module>
- <module>org.argeo.slc.jcr</module>
- <module>org.argeo.slc.repo</module>
- <module>org.argeo.slc.factory</module>
-
- <!-- CMS extensions -->
- <module>cms</module>
-
- <!-- Distribution -->
- <module>dep</module>
- <module>ide</module>
-
- <!-- Legacy -->
- <module>legacy</module>
- </modules>
- <url>http://projects.argeo.org/slc/</url>
- <scm>
- <connection>scm:git:http://git.argeo.org/lgpl/argeo-slc.git</connection>
- <url>http://git.argeo.org/?p=lgpl/argeo-slc.git;a=summary</url>
- <developerConnection>scm:git:https://code.argeo.org/git/lgpl/argeo-slc.git</developerConnection>
- <tag>HEAD</tag>
- </scm>
- <organization>
- <name>Argeo GmbH</name>
- </organization>
- <inceptionYear>2007</inceptionYear>
- <licenses>
- <license>
- <name>LGPL-3.0-or-later</name>
- <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <dependencies>
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp</artifactId>
- <version>${version.argeo-tp}</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>org.argeo.tp.apache</groupId>
- <artifactId>org.apache.xerces</artifactId>
- </exclusion>
- <!-- Avoid slf4j implementations lurking in the classpath. -->
- <exclusion>
- <groupId>org.argeo.tp.sdk</groupId>
- <artifactId>biz.aQute.bndlib</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.argeo.tp.misc</groupId>
- <artifactId>slf4j.osgi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp</artifactId>
- <version>${version.argeo-tp}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp</groupId>
- <artifactId>argeo-tp-rap-e4</artifactId>
- <version>${version.argeo-tp}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.argeo.tp.extras</groupId>
- <artifactId>argeo-tp-extras</artifactId>
- <version>${version.argeo-tp-extras}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <repositories>
- <repository>
- <id>argeo</id>
- <url>http://forge.argeo.org/data/java/argeo-2.1/</url>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>daily</updatePolicy>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>argeo-extras</id>
- <url>http://forge.argeo.org/data/java/argeo-extras-2.1/</url>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>daily</updatePolicy>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <!-- Disable Maven default repository -->
- <repository>
- <id>central</id>
- <url>http://repo1.maven.org/maven2</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
- <distributionManagement>
- <site>
- <id>staging</id>
- <url>file:///srv/docfactory/argeo-2.1/site/argeo-slc/</url>
- </site>
- </distributionManagement>
-</project>
--- /dev/null
+/exec/
+/target/
--- /dev/null
+grant {
+ permission java.security.AllPermission;
+};
\ No newline at end of file
--- /dev/null
+Subproject commit 086f450078ec980aa1fa616f21fa5289c35212b0
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?pde version="3.8"?>
+<target name="argeo-tp-rap">
+ <locations>
+ <location path="/usr/share/a2/org.argeo.tp" type="Directory"/>
+ <location path="/usr/share/a2/org.argeo.tp.apache" type="Directory"/>
+ <location path="/usr/share/a2/org.argeo.tp.eclipse.equinox" type="Directory"/>
+ <location path="/usr/share/a2/org.argeo.tp.eclipse.rap" type="Directory"/>
+ <location path="/usr/share/a2/org.argeo.tp.jetty" type="Directory"/>
+ <location path="/usr/share/a2/org.argeo.tp.sdk" type="Directory"/>
+ <location path="/usr/share/a2/org.argeo.tp.jcr" type="Directory"/>
+ </locations>
+</target>
\ No newline at end of file
--- /dev/null
+/krb5.keytab
+/krb5.keytab.old
+/*.p12
+/*.jks
\ No newline at end of file
--- /dev/null
+dn: cn=admin,ou=roles,ou=node
+objectClass: groupOfNames
+objectClass: top
+cn: admin
+member: uid=root,ou=People,dc=example,dc=com
+
+dn: cn=org.argeo.slc.user,ou=roles,ou=node
+objectClass: groupOfNames
+objectClass: top
+cn: org.argeo.slc.user
+member: uid=root,ou=People,dc=example,dc=com
+member: uid=demo,ou=People,dc=example,dc=com
+
+dn: cn=userAdmin,ou=roles,ou=node
+objectClass: groupOfNames
+objectClass: top
+member: cn=admin,ou=roles,ou=node
+cn: userAdmin
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?pde version="3.8"?>
+<target name="(output) argeo-tp-rap">
+ <locations>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.apache" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.eclipse.equinox" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.eclipse.rap" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.jetty" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.sdk" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.jcr" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp" type="Directory"/>
+ </locations>
+</target>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?pde version="3.8"?>
+<target name="(output) argeo-tp-rcp">
+ <locations>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.apache" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.eclipse.equinox" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.eclipse.rcp" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.jetty" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.sdk" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp.jcr" type="Directory"/>
+ <location path="${project_loc:argeo-slc}/../output/a2/org.argeo.tp" type="Directory"/>
+ </locations>
+</target>
\ No newline at end of file
--- /dev/null
+argeo.osgi.start=\
+org.eclipse.equinox.cm,\
+org.argeo.cms,\
+org.eclipse.gemini.blueprint.extender,\
+org.argeo.slc.agent,\
+org.argeo.slc.agent.jcr,\
+
+#org.argeo.slc.support.maven,\
+
+slc.executionModules=org.argeo.slc.demo.ant,\
+org.argeo.slc.demo.basic,\
+org.argeo.slc.demo.minimal,\
+
+argeo.node.repo.type=localfs
+
+log4j.configuration=file:../../log4j.properties
+
+org.osgi.framework.security=osgi
+java.security.policy=file:../../all.policy
--- /dev/null
+argeo.osgi.start.2.http=\
+org.eclipse.equinox.http.servlet,\
+org.eclipse.equinox.metatype,\
+org.eclipse.equinox.cm,\
+org.eclipse.equinox.ds,\
+org.eclipse.rap.rwt.osgi
+
+argeo.osgi.start.3.node=\
+org.argeo.cms,\
+org.argeo.cms.jcr
+
+argeo.osgi.start.4.apps=\
+org.eclipse.gemini.blueprint.extender
+
+argeo.osgi.start.4.workbench=\
+org.eclipse.equinox.http.registry,\
+
+argeo.osgi.start.5.slc=\
+org.argeo.slc.agent,\
+org.argeo.slc.agent.jcr,\
+org.argeo.slc.server.repo,\
+
+argeo.node.repo.type=localfs
+
+org.osgi.framework.security=osgi
+java.security.policy=file:../../all.policy
+
+org.osgi.service.http.port=7070
+org.eclipse.equinox.http.jetty.log.stderr.threshold=info
+
+log4j.configuration=file:../../log4j.properties
+org.eclipse.rap.workbenchAutostart=false
+
+slc.executionModules=org.argeo.slc.demo.ant,\
+org.argeo.slc.demo.basic,\
+org.argeo.slc.demo.minimal,\
+
+org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.dist.distributionPerspective
+
+#argeo.node.useradmin.uris="ipa:/// dc=example,dc=com.ldif"
+
+# override ports to run the demo as a server
+argeo.server.port.http=7070
+#argeo.server.port.https=9073
+
+# DON'T CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
+eclipse.ignoreApp=true
+osgi.noShutdown=true
+org.eclipse.equinox.http.jetty.autostart=false
+org.eclipse.rap.workbenchAutostart=false
+
+# Avoid errors logs (see https://issues.apache.org/jira/browse/JCR-2226)
+org.apache.jackrabbit.core.statementcache=false
+
+org.osgi.framework.bootdelegation=com.sun.jndi.ldap,\
+com.sun.jndi.ldap.sasl,\
+com.sun.security.jgss,\
+com.sun.jndi.dns,\
+com.sun.nio.file,\
+com.sun.nio.sctp,\
+com.sun.crypto.provider
\ No newline at end of file
--- /dev/null
+# SLC SERVICES
+#argeo.osgi.start.1.slc=\
+#org.argeo.server.ads.server,\
+
+argeo.osgi.start.2.slc=\
+org.argeo.slc.node.jackrabbit,\
+org.argeo.slc.support.maven,\
+org.argeo.slc.server.repo,\
+org.argeo.slc.agent,\
+org.argeo.slc.agent.jcr,\
+
+argeo.osgi.start.3.slc=\
+org.argeo.slc.server.repo.webapp,\
+
+# NODE SERVICES
+argeo.osgi.start.1.node=\
+org.springframework.osgi.extender,\
+
+argeo.osgi.start.2.node=\
+org.argeo.node.repo.jackrabbit,\
+org.argeo.security.dao.ldap,\
+
+argeo.osgi.start.3.node=\
+org.argeo.jackrabbit.webapp,\
+org.argeo.server.rap.webapp,\
+org.argeo.server.catalina.start,\
+org.eclipse.equinox.http.registry,\
+org.springframework.osgi.web.extender,\
+
+slc.repo.jcr.dbuser=argeo
+slc.repo.jcr.dbpassword=argeo
+slc.repo.jcr.configuration.java=osgibundle:repository-pg-java.xml
+
+org.argeo.security.ui.initialPerspective=org.argeo.security.ui.userHomePerspective
+
+# LDAP
+argeo.ldap.manager.userdn=uid=admin,ou=system
+argeo.ldap.manager.password=demodemo
+argeo.ldap.port=389
+
+log4j.configuration=file:../../log4j.properties
+
+# DON'T CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
+eclipse.ignoreApp=true
+osgi.noShutdown=true
+
+# Avoid errors logs (see https://issues.apache.org/jira/browse/JCR-2226)
+org.apache.jackrabbit.core.statementcache=false
\ No newline at end of file
--- /dev/null
+argeo.osgi.start=\
+org.eclipse.equinox.http.servlet,\
+org.eclipse.equinox.http.jetty,\
+org.eclipse.equinox.metatype,\
+org.eclipse.equinox.cm,\
+
+argeo.osgi.start.3.node=\
+org.argeo.cms
+
+argeo.osgi.start.4.apps=\
+org.eclipse.gemini.blueprint.extender
+
+argeo.osgi.start.5.slc=\
+org.argeo.slc.agent,\
+org.argeo.slc.agent.jcr,\
+
+argeo.node.repo.type=localfs
+
+slc.executionModules=org.argeo.slc.demo.ant,\
+org.argeo.slc.demo.basic,\
+org.argeo.slc.demo.minimal,\
+
+#Branding
+eclipse.application=org.argeo.slc.client.rcp.application
+org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.slcExecutionPerspective
+
+log4j.configuration=file:../../log4j.properties
+
+#argeo.server.tomcat.config=conf/default-server-ssl.xml
+
+sun.security.jgss.native=false
+org.osgi.framework.security=osgi
+java.security.policy=file:../../all.policy
+
+# DON'T CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
+org.eclipse.equinox.http.jetty.autostart=false
--- /dev/null
+argeo.osgi.start=\
+org.springframework.osgi.extender,\
+org.argeo.security.dao.jackrabbit,\
+org.argeo.slc.node.jackrabbit,\
+org.argeo.slc.agent,\
+org.argeo.slc.agent.jcr,\
+org.argeo.slc.support.maven,\
+
+slc.executionModules=org.argeo.slc.demo.ant,\
+org.argeo.slc.demo.basic,\
+org.argeo.slc.demo.minimal,\
+
+eclipse.application=org.argeo.slc.client.rcp.application
+org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.slcExecutionPerspective
+
+log4j.configuration=file:../../log4j.properties
+
+argeo.node.repo.uri=http://localhost:7070/data/jcr/node
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIF3zCCA8egAwIBAgIJALKBUni09meLMA0GCSqGSIb3DQEBBQUAMIGFMQswCQYD
+VQQGEwJERTEPMA0GA1UECAwGQmVybGluMQ8wDQYDVQQHDAZCZXJsaW4xFTATBgNV
+BAoMDEV4YW1wbGUgR21iSDEMMAoGA1UECwwDUiZEMRAwDgYDVQQDDAdEZW1vIENB
+MR0wGwYJKoZIhvcNAQkBFg5jYUBleGFtcGxlLm9yZzAeFw0xMzA1MjgxMTI0MTNa
+Fw0yMzA1MjYxMTI0MTNaMIGFMQswCQYDVQQGEwJERTEPMA0GA1UECAwGQmVybGlu
+MQ8wDQYDVQQHDAZCZXJsaW4xFTATBgNVBAoMDEV4YW1wbGUgR21iSDEMMAoGA1UE
+CwwDUiZEMRAwDgYDVQQDDAdEZW1vIENBMR0wGwYJKoZIhvcNAQkBFg5jYUBleGFt
+cGxlLm9yZzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKwB6jOoHk+e
+LjI8AqqR9VHG53KgQFwjVkTlMJ5QHgUgFFzZB7af9B0AtzbLPSjJH3rY/8itYQnB
+jL1D9Ijc0EAJOrDgtQjYV1jpL49mFI9mgZkCXJv8rehxm8IDIuyPgceW4/ZrogOB
+MJwmWAK8DfDQzuomw/mKhPvssFFq7zW9l1ae2kSniZ+m7pTqESuZ8gB+qvEi/bMC
+nWD4jp+Sr3e1FGlXJu7Ltc1Z+OWmFRa4VlxBF5wgsNVcL4JRx1Wwhu0I5qWxrpZ3
+KdqBiPivM0N8Aaszf2APsatE6BDYdYJsM4KGJ8aInZYjN8hnzmDSui7taI2/vjrx
+0nE2lhxpykyaUxKhXOnfPHxUOCc6XlfZkKA/fg9ZYz3ybqIjL8SU7DOHEjIT7xdc
+WA9ccSCrr8B6Lfk7P5ZM/zdLir59dyogAMJtHiot4Tn44lXe+2RXBDytGTbWNNlM
+Llxv7O0f5b3QUWQ1lybNDRNJBwTIBoJMW6v09S3zf65XyQ3/hrAnXxQ5T4/fqEBP
+15C4g6n6ANg5jCXqYPdnMzR//vDxJZzKQc01BVdKLsSb02yIb2LizOy0ezx9dEZa
+PexiztKD5dwnrzVxHu4DilBcJBTFOkgbMfDau7fLVuF0XXFTc/FSdsaJDDWI5N7N
+8vzHZGZZfm5qasrZryop2DwzSWfCDYTrAgMBAAGjUDBOMB0GA1UdDgQWBBRsDHcK
+aom/nG0ov6N0soe7SHn1kDAfBgNVHSMEGDAWgBRsDHcKaom/nG0ov6N0soe7SHn1
+kDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4ICAQAw1gp89iBwBSMEnwcc
+OQ6jJ4BEnrvwY31VJmbA/2EOhLoUyGr4hTYo3RYGQB0OeMfu7B/YkurVVkEcuR9q
+uwV3eRpPUTcGSsisEwvUbu9Iur9ygA7S9+IKZJ4KCS6ZDKpdHO2lOcLwtguky6W2
+PJEJLrKOmXqLQ2epjeHqGe9FXHyk3AY4YtXpZ6Mu/sYTiG+LZscXYFkvIM/MwBC8
+THX8J3dE/v1gPgFHaavW5vhsEI1izPj9KN7wyT7ljJgvnWA5Vbs+w1qW6fCtmTxl
+nY/DvhsVoOj+Zg2iMGByZusm6oP+vVVK6ZCst2RBpoZ059RRY71woRYjXa88LxLM
+rOuzcBxLC+X4o4PJwIVTVKnga2TpxyREjFqJehf8+N9aSuvEM+sY9l1ELQ99zk5v
+juX5kykKI+j28TNtwyDsJNWmzK7OFQAhKMBZZYVLj6Wm6roU7TZ93tLQC1uLRZ82
+DIRDebUbKhGHlqmcQFblUztDzqmCHYvEE0t2mjQNoLDwMzi1d5oSYL0NH5gtuosH
+wDCK0GbR0elYFBcxtX6kceyFnQqOGE5b52rB75OHxJ7iQtCn6Lt3ms9h9ODJjS2e
+Kafzg+RuwOpmIwUOGW140WxNO89e9DCwhR3Q4waRTwzmdLLNEhHhi5GNRHlT7Cem
+gZlju4Nu4PKD2RWyBihI4YF1AA==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,1E365E4A0FD2EC89
+
+7MkG03lkphw7WxvG8mc86m6oBdxVibv06X9AbUAZ4CWavS3mO13NYU5K1d4bY4JM
+RKoN3QRJSBaBFy6kCGOEpKnpvKN4fSf/AVYZ7PFbe/oEsi9GruY3sjz2LNc3NgvI
+pPsC1uSWq8vODABzBlh6SKBdznJx403PRPzhR2qXZ6P3893J7qlfgHa7SY7hvY9G
+U4cYyas0Tu67Ta0kxGx87oompsfb/L49iEfEZuuNQnT8rNloiTa3kQRSDiUsVek9
+gq0atye+qgeYRWj054FCV9BC8+cxwYam+f7Fa4Au89Ir8fwFbgihbtzWXoowghwW
+9QTCNqeFu5jb0PYJ9NNY/nWa3lWEve45WZSWgJyDSiYZs/Ei497meXaLiPqtubrv
+aCR1OFDRu++8zElUZsxWdAKohBCfqbkQYe5HfFeenAfX9QZoo+mf8q9Ebj8ojfWl
+wIY+8CyMxla0reG4afsCe4IHfQ7I7TJOBlBMFbMUVBYToWPAK10wIOu5S5v7/gGT
+LauiVPbXVSjZB1wiURBGYqxIcqLktPtAV36XSIGu5geRvb4rT73G+D573jO8QVHA
+Fqw5PKLFA0gPaYjO/D9toPQECut61eHpRw5y4av+H2f/guZAE3UMNcQceYphmhFy
+YxxVBsfoQIVHcE51loEPeWdRvxZWBPvaAP+CFuLDkxzSJ3l1Rjl1kxsc4LOLrKJA
++qzEGMb30T5sS78xo+WTQVXhQOkM+aVVuvZpBZQg2XacTS51Pl/5rpd8m+puTSFO
+Zky4lzpkJwofEwaQeiQxoHnIvniW4Xa0q+ufRPQA6QX8Od1uabS0nuyNS88ezt9d
+yo7kfI6uDxYw1dyqHHsKD/71r3w8oqdtJHzvewK4GMQJqbn7o+i0vVEZ5qL+ZaKl
+/eIFsjxQcqvd5/wGJOyU2jTIotFCHc6AqIlq9sXgRN7F0DpvJCMpdaPpixD46BF8
+3zfRanM6Hx4Mdx9V4zPjujLdNuHMSRR0OzhZsFXkpxUIGE0EnsjrTjzJW8A6dv0P
+LTt3XSe2m8Wkrs7bFCdm4ynZ1wf2ivcB1Np52jP3HUPq9Jeu/VcTY2KnJm0GRsui
+arblNpSqqqi0YSH9KL0VyFFfon2R9u55ZdetPtBUm4PBv3sGqgXwg+a3VqK0CENx
+u//0lI29tIJGzPCMiO5cb9pwsqNbdngeXx7EMfw+bFHb9VVEjctk2Cr4QFKH2+Uf
+c0OvDRdwQdly9zW8Zr8CzSwTLwrIjRoIbNwqhsoTwPN4EXZsicG5hv19sQ1aXs/5
+2IPm968iyqF/ZHAYBNNARK4Pqs+ifMIiCEMpv0ZIovUaHX4/iJZW+UMrq4BqwtPk
+rkI1ZxxbupGFqJEABW8OsZFE8tC5x4lvCntt4tPzQDZuvR3PGcmY+4M9yXkFeYZg
+ol/o6rybVoNRVB/qLjKRWkZNYZUdTp/4zsnBorLaMlIWpyCgTGPQs25Y/7OJI1g5
+l4sZitaW1ucWgsUquWIpqZZCFLZbDGPqKRCZh8k49a7DqEUNf9w+bN6pktRdQ1YR
+uCokQEwUbSZqr4lsBGyJCSfxdZ+A4RdiH5iot6mltUiuKxqYmLfctm002y8daWXh
+Scl9Gv8QtaGu31St67p8FDF6WAZcNXwaP93pC5I2owA17kEbSC65IbNrnU23xqHU
+lEY1hnQuTeiQEXuYIcHURFBLKisKBL4Z1DiSubCK8w3Y9n3LGdMm6lPprLxur7jj
+zvJvWK4ksV+bBzYfhaQ15YVB8R+0DTyGY6LbKtdJ72ZIJsR4zoB5Mtli9xYrdpuA
+SZeE2CSUDRRzaMjdf43gfAM8yAlhQSE2LaQwpGTVrIYLtTJSEVdAk9JYZ+Z8d9DQ
+YeHSm5XROyrqyfnCc50d9Tasaf+ZEzMsmCFnSKalG9g3B4i57TofB6jUyBO8Qob1
+6dDILeXHX4oQ++2HxYeJIMcakiiX/V3rBFJrb0O7swA41cyxu++1x9KYkozHlnkO
+XSspOx3JPadTkcl6BiXpemcqgyd5Xqzx7lit/Y/3lz5mlJr/EIv/qpYpUcFKp2gT
+aijMtflayKignnE8c+1ENq4E8qt8WEuvs8gZG+qu4G8lhaS4dLQNj57W9BeZyAYi
+LvzfFYEVLwUt7mv1zqHLXAGBdvLCZl/DjloXu9RvhF9zOgIR/uNEMFUSyF8v+xZE
+lAwiii2BARCqO+XLo2KkRPsL3fFIItxwEVbpqfTngbe+o/SF/HCXsW+S09y8LNDp
+3Bx2cNIp9+HrDwtRfnN4okjLURxTvki3l19m3rDnvtUgM9AhsA2nNKpEEWAaC5bB
+nPEetLDK7KVniccPro3oI08OwlMGZLM38NgDK66AhgSjkgKri20Wxq5LgG8qLyAE
+kA+g7jjvpaALgbU6PL8k0eLRBldl8NNbdLywZmFOeA27sWNBfblaAeo6MveIGoLY
+Openi1D6uYfLaP/xI0D1Yldmvjgex/P9SDAcRoaj9x5Jaty9oMdGSeSQ+TXA3hrf
+sBsgpn+WN1LR7qBtq+/NdRyu7EXzlgGwpGM3aDUnsFt7iKThwHxEBpyRKXvjL2KO
+jiRaDO9NRpZqj/M0czpGeSXoHNRI/qrqquTDysvYG84rNgxQpWYgYo9R455HPrlQ
+BLlJzr0Nr8H3dp4TDFV0Awpld02FA4XfQ3PUoAnr6ku7CA79GS4PMd2nr4p48GC0
+owtVpm/Bqkp2H1FsnYuBw9FCGEcCe/DTw880V5NiLonUB1L+MVeUhWr/ucJ8txJx
+iBUlg/mxSgfXY715NUgy08UEsTvPw7Ky080RxmEOCIWjxFEvAHE7dCJokHbL8jSO
+8tNlyVPQt9ccEzJbPdag8eMKkIsGIMh1F7HwyLNOrIuM2Cuz9ALTIKwEZ0CE+XBE
+oL5AOn1Cqlvh0fAWUQNP1/RAsT8XqdBXkui/+kvqeVNbZoGJg+wVrNm0sP1nDRqZ
+6oMdcE7tC20YyFl8rkcv2JG+5pJrNQKMosdtQmA2pJ/hS4yZss9vBizJhQHRI4l9
+I7nCHOrxCQvBoxyJb8qKO1cpynN5tttZ0s/njhYXVNtQDpoB2iWFm0/biP63jh4j
+DcqOsuOqMGFtsWPfHM+oMBQ2YT63g4hilMzzilQqUsJ8mBGiYFIcP9CRPUFRI2tQ
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIFfzCCA2cCAQQwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYTAkRFMQ8wDQYD
+VQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBH
+bWJIMQwwCgYDVQQLDANSJkQxEDAOBgNVBAMMB0RlbW8gQ0ExHTAbBgkqhkiG9w0B
+CQEWDmNhQGV4YW1wbGUub3JnMB4XDTEzMDUyODExMzAwNFoXDTIzMDUyNjExMzAw
+NFowgYQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJl
+cmxpbjEVMBMGA1UECgwMRXhhbXBsZSBHbWJIMQwwCgYDVQQLDANSJkQxDTALBgNV
+BAMMBGRlbW8xHzAdBgkqhkiG9w0BCQEWEGRlbW9AZXhhbXBsZS5vcmcwggIiMA0G
+CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDBuEqxINyrCP2IauWReizNWl6J+WgV
+pqTAViqlEtbSbGCzvHE4eF07uCazWmAwWRmXxwf2h4M3siC8Q382n7ri/eS4mijk
+kw7FxoQh1W/jLDFcZ2orY4bz+DoexL+ClVAf8AKBQ68NNbf1aZnUctnDx5Ymrzq/
+KHvgUAIsRmcRzhE5mjWxem33iAVibrQ6LhY5tNDw+VfXZ0IzvTl/ZHfKyOGq4NTl
+21C0iWqksj6sJtvYv88wSHmnzokOXb5rJo5q07HN5b5eHuoAM74SS36ScXpQixDS
+Z4tCjxzo/QwRqQdlWJBv9PSPEq4HNHlCu/zbWZNCbRVKmRf0qYq9dxjxunyj+HjT
+Dj4OfvpmOhTrX78x9ZDOfWmYV/PpoyQ+5PKDhXfFYRGAY97CN1UlQhccdnJCgM3o
+bYkQ+fDXXvgNQLazbOVmeRd5is4TXdcNJIN3LcXXdEOa+O6X8fVTwxzXMD8Uy7fo
+CRvhCrF6gqZZyt+pIJMucLzydiCJHqqDK0xjJ4wtfJNGEyIDJ82hUDEae9X4ao6m
+ti146PH1zbKWS2EYaoEFeXgIqDiU8dKIZNrTd+nflIGd/TLf3LgY43qGEwd/oWtd
+I1hICu173WGdPNnZWbvJtqb4nHag2ldd+jnYHFFF0jnH+neRq4lqW+CAFjWz7c8J
+NtCr+RBVS6bYjwIDAQABMA0GCSqGSIb3DQEBBQUAA4ICAQAO6FbFXoYrM1OvUHdF
+mul7cP7jVys3dRNfIdTcKF9tYf5sWS7/2PbFeQ+bjLGxQJcZhQ8BvK2J00/+kExo
+JMEFqQ5BZRorwdnrQxJNJcHrvrQ6ZTaiBhuyktbWGblCAWkuhqw6NLYxhcE1Wq6s
+6w978F/qHCvqGSi1QkVX+9WjVx48K2JqBRKR04THWlgf+llOJsuMv4Rk75iH385L
+FNsQAXIquQHqgBDqKjcSAR0VAQSXV0gnMadaUrHv7H+QqsYo0zp19cX/WF0HNti6
+GHk+mCnDeZh6Z2z7xii+9fQGIMgQ8YhAJwzOhbk72y8WMqfHtFqcY1KnZq52c7wz
+3+kMx+XJ6t6YiJnWAWs4M/mk7RVPOvNqOAh8y+pnd6tZEzdRcvuDiv+U/HwNS6TS
+nEsUHK0rwWD3Sjfwe9LO9TMxdSZkWePlY2v5oAL4YxJnJGfbeBo/OynUkIa0fRXf
+FtKdAENfpijpuNiN3O92q8FwXpLjr38aTHy0o5n2Zrlly7ydGwRXJ8P7FdbGRXj5
+UPaN6b808kysE9zS6BA0XMslLPqQrFgqZFK2fnv/QW87jyXQkTAAgTVrHODJXVsr
+YLIpWTmykOxyNFGYiT9BCxHXTO7LvlGdK3OqRwbzTcD+CHKZsUxALg/q7FbSBS6i
+OZrgJYlxzdsI061+rLsaW02FOA==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN CERTIFICATE REQUEST-----
+MIIEyjCCArICAQAwgYQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzAN
+BgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBHbWJIMQwwCgYDVQQLDANS
+JkQxDTALBgNVBAMMBGRlbW8xHzAdBgkqhkiG9w0BCQEWEGRlbW9AZXhhbXBsZS5v
+cmcwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDBuEqxINyrCP2IauWR
+eizNWl6J+WgVpqTAViqlEtbSbGCzvHE4eF07uCazWmAwWRmXxwf2h4M3siC8Q382
+n7ri/eS4mijkkw7FxoQh1W/jLDFcZ2orY4bz+DoexL+ClVAf8AKBQ68NNbf1aZnU
+ctnDx5Ymrzq/KHvgUAIsRmcRzhE5mjWxem33iAVibrQ6LhY5tNDw+VfXZ0IzvTl/
+ZHfKyOGq4NTl21C0iWqksj6sJtvYv88wSHmnzokOXb5rJo5q07HN5b5eHuoAM74S
+S36ScXpQixDSZ4tCjxzo/QwRqQdlWJBv9PSPEq4HNHlCu/zbWZNCbRVKmRf0qYq9
+dxjxunyj+HjTDj4OfvpmOhTrX78x9ZDOfWmYV/PpoyQ+5PKDhXfFYRGAY97CN1Ul
+QhccdnJCgM3obYkQ+fDXXvgNQLazbOVmeRd5is4TXdcNJIN3LcXXdEOa+O6X8fVT
+wxzXMD8Uy7foCRvhCrF6gqZZyt+pIJMucLzydiCJHqqDK0xjJ4wtfJNGEyIDJ82h
+UDEae9X4ao6mti146PH1zbKWS2EYaoEFeXgIqDiU8dKIZNrTd+nflIGd/TLf3LgY
+43qGEwd/oWtdI1hICu173WGdPNnZWbvJtqb4nHag2ldd+jnYHFFF0jnH+neRq4lq
+W+CAFjWz7c8JNtCr+RBVS6bYjwIDAQABoAAwDQYJKoZIhvcNAQEFBQADggIBAKYk
+c1LiB2iNqjJMPEjzJ0wpKizHoqv7Tt55Slz4Q9bTgTYmevt8SIpQCKK+ZtMxCPIy
+9tfqjsdYqBxahfXnhXUDQQOYEAKcffEZd/c3LX16kOupximycFOj0iqJDe5VZ/NJ
+7fRXlJqqkufoQQ3OqPYzS/G5mP61gadvReAkTh78StlWMNxwg6wYgQ3p4ZD1GKNI
+M7A1Z99HyJeRZcT+yx1wuyvX2MJY15Kg6m9xaM1N+q4BJ82+u76pNX+pTw6A12mB
+XhmIKqRh+KN7YGSVMtU4dBwHMlZD3CRiGUE9RFg/5aqJeXZgCVnLgzTzJUFQqRqZ
+OehYdizkI6TgTLl3xIJWHFqYc5GhY9NwghYn0BjiC/8xpOmj+soAG4hDkydejtf1
+8lFeTxW8Ga560zjvaUOqntQTLHiAnZai7lVFxE+o3/b284OYu5wWyAFh9j+eE7qP
+pnObCpeFanlsuTnQIXZD4KcojI33dmBXIVhCfe0cvtDEPLl2MYJNguO40tJwPCzL
+JBpdwqh+rBKQjX+pn56js3BgB4qrcQnWGEHWOb/Z+ooRkaIIliRLBTS5DbbnsQWp
+jyVKVhTVLNdp4L2oy94hGi9wJSCujXyBFXH4+e3HpYrZwGSJKrpnRPChm9XW520A
+EFgLzv2Oh0zXJiBJ+EtVwWfkDCImakD1u5QAHW7h
+-----END CERTIFICATE REQUEST-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,955EFD4E985DC326
+
+TXxk9gZOkjLsP4MZmg0HWADP97beNLBrHBLwNvWVzFGmNcuLrAb1r6+OlwIVR/Hl
+BAFwygYvwvo2IL68I2hM+pW9wLY6WAit2CvdWs5J+q0MMc6kXilF33PvmW6G0raB
+XurT0Q0w7TcIXmjMo2k6CCnHGCUxIsYjXIKF7LdC7ERR2wCRUgtuns33/Xf7kfIg
+AEpYC5+iJFT9/ZvXm8Ezod0qG3LZ0TmRMRkWjbBOpHqWVCgTwddHZ2hCF4kNubxC
+DYL0UlDru9JgrW9ezAAloyG0GaiqPyCCkUQGw652e99OllYsfCsGQaoRNPwk2ytA
+fss7GyjymlxtjEdwWnVxngUGr+u+cp9QDD7dkSDm0uMBCVjtSg4MGvk3betn+JIt
+MYbEst4Qr0llFV7jMWt5e/EBllErrPipthfpd2o6JUxv5PNCDEbeKRSU+TZ2KuT5
+4uj8MSA8nbixQf063Q8Nz5sd9Aq4Vc+J9Juyu4fbUAI/PAL71fR3HC0hou6plxev
+EXIk6cAZLhzRKBnmwW0Srh/fp7dAlK/btQHoHVtx4E+uT2Ct+5xm63wMJLE5Z+Gw
+6xr0L9CCrnCicekEUoVdED03+U0r+lfP7nOmk/CgfIYpTP+RqsBXTVcwe1tvZqMN
+RLbL7iDCxPrRFwRs51sM2MS5v/3S4r1yTJ/ijgErhrf4shtR+AO9cqkZkLwLtTmW
+wKgWbRVnt8ITRRqqyBRjwBpmOWNC2YfkJrlDcm3rzn1fWWGOOQHlYjDYjpgVJfte
+v/HEC9Z+J82QQ73tyMUrNyJqeiyKdjUHY9T4oS13goGe3T+UUJ7ReYojmwFKCSu9
+GYNC/+7B2kPTbXVwKG9fZ85W7GdjGzy7ci7IsT95znKbPD7gmrr/5L+iYPqLv+R5
+WD9zNsyPpMZvatJRxjH2EdhhWoqvhY+M/k53AdHiM45iG6MVzKxPOlMlEsD2aiMb
+3zGUINsOm4Js77klemGqfd0uEBynypqhIQOoYnTTHnpqguandGkeyAZ689CncP3o
+pg3u3bZVoH5PubxWAFzxqpmrkk71oPaflbT6AbXGGpm9sjSPVKGm67B1yVMRtJph
+GjXuwiDRqX1HwDIMqQZrJKZv0XcEUObruKODryHuxbAA5IWTfZQoGfVei1acn5/7
+Q7MNqzDN2Rzgk4hOWuTSj3IFWzy432qfA2KQFcU37E5cBKnKq/rZp1L9O2wHY095
+4bXLugJML3pQPGg+VSw5RMhmN0RHh71W0aSQVAbOAu/fhCbrOAA/jHf8RN6gH+v2
+pZp1FZU0Bw5So/E9B2ubaTmBEfsAAnPd56jTAsHsqL8x4omXza96WGOlzqQf7W9x
+I481If4hwNl6KEeRb0guiOp0PFq9cfnjvhkbRVAiD5PodjpttAd1ZTvnJA5BDvdx
+v4JaNgKJ286I/2R65njiWtfDREwiStQzX+RjkFQGAQno3FYQiVajYg+URl8yul32
+Sn1ovaVGoT4AzM4UM6xGiAr5mQgZp75/BIYoFk3eit6025mKNfVOsljFnFhS0Bw7
+oRtfKE32TuEMmIfEMP02Ppofk3vBoLQtsgBpYLCYNy3wzzteAsXEFaAOaIFtHDXv
+TI8aHif0hgEXr6gTpQ7uqk5Kmo/9AAM8/5bbDd83Fk0m6Woi1EA0Ac2nv2TSpTeV
+MHy4vk+QJEmaDcKYCn8BlpgJe5b3CJONdt5yXGpfZISxhRQaWpv1dCSFxfARPGSy
+TPZ9jHU5fS+iegOIcb25dr0bncYy5+UKCoaW05L/z1a8Fn3AmjS5YkZBYqmsI4AX
+tkfcRKlVRGuOe3A1borQvC4pB41wlv93GKxF9xltJ7D0G/kNz9BRLvIoF7xYhzBe
+Jyp8SXUwLkAW3H1zIAf8A1rQNyP60txHXcR7HC3GGx6Y/c11L3XBzniD3VhBVZLc
+Z5ndKINz6wrmi3z87GFsBEe0aRhvXanxgBN1vOD2jhWAwOtsXAP0Pz8VZq/rCnIQ
+BKff0VVwRPqpCasgknY4hs6PmteMvOSynTS3v85a2++LrL4vE0MRMHUusY9jIUJn
+plSF9VOsjMS9eeLbch2FNnmEhnn+Sq06uZEZxgweocapm5TvU9S3b5zXWht+4ECy
+Fbe+hKcsls7B9p/sI564ylWtfy/JOsJ4GfsLaLwytbo8tUU9Z4t6bjiBXRUYBS7D
+bVep0ukngR1xeiML/887MGqN0G4RHgBhbdGvBKX0RYArMl2PTNebysuaabdYy8VB
+mrlodPL+OPrly23IHws6/48EiIugUgqTn0JtzZlAiRhK85b9dUHbnqxP9q6DOum0
+GYBnVivo+LZm+rVOPTB9SMEkZezoZZbV9US495vNQF27c85ERAXMi+qnwEmJZeff
+HqN7KzeK21coUNKrxx/n80lk0mCDX8M0BL1qQEH2iiE0wA0JZYm4cOujpmRtBJs7
+g+0Gd4qU9oQWVjbsr28wdFCBzeKvVdwi5+PVEtliSyB95ZLEFNQbOsomU986VllM
+AVYHDPmLfXVl+eUXFfdVNjnw+pXYGKhpicgJQYOunXOukdjmwu6byB7mR3e9IU/9
+BbrgWopv1ZKq/s/xvRsWih05nvXHKSeITVXUAHE4Z78Ia0ZRAj4qicJ/8XvhnJX9
+17G2nOPtPJFrOE+y+KXanBR+ZPNV8kve8hGxSzxcfvz9divRg77DCB81Jyi4LTXa
+l+p0xoM0UUS4per09zHHg9g8lHfjtaq/rge4KgV2uQENNCFjskCc8BjB9U7TYWun
+K9BNQC49p1lDESvStTDrvnX3Ckw3wsvoR4d7fGMakuZcoNF9VAH2YOi7VFBwaySF
+HB+NosmrfrK7izewfNuE751mIWPBek/5mkMwjdMl2Uch+HchGLFPMTrZSGjl8tlJ
+wzbtVP026Iutm+CDXglZq9OV0pk5NR3zF7444m9xxuzHQypRvklDd2OGwdwMoMCJ
+k370YS4dvIlXtwlW39WPyYwWyGmqpfYO2Fj5Su4Pzwz4c/LD8mUVD1scNXeE7dgD
+n1leMfMX5O1elhs9/FgNFH2ntrU0gRGORbwyD+yjryYxv3KOHic7uVY+JsAlY/JA
+ciqvTgSc49XYari0dMCE/rBAwTpKnEKDKB4pI/o6A+ARPGdSj6UThGRS4538d7cB
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIFfzCCA2cCAQMwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYTAkRFMQ8wDQYD
+VQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBH
+bWJIMQwwCgYDVQQLDANSJkQxEDAOBgNVBAMMB0RlbW8gQ0ExHTAbBgkqhkiG9w0B
+CQEWDmNhQGV4YW1wbGUub3JnMB4XDTEzMDUyODExMjgyNVoXDTIzMDUyNjExMjgy
+NVowgYQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJl
+cmxpbjEVMBMGA1UECgwMRXhhbXBsZSBHbWJIMQwwCgYDVQQLDANSJkQxDTALBgNV
+BAMMBHJvb3QxHzAdBgkqhkiG9w0BCQEWEHJvb3RAZXhhbXBsZS5vcmcwggIiMA0G
+CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDjfJpz+c2ompElZtBWC5HUJ6NevhMm
+I7VCAZjMEa8l64cCXlULOyKYbEZ2oQupg5iqHVbEK1d4UJ7b2EWTFc8bZT+cQODL
+7x3hPJ2856PNSg2Rcsna40Vy/1jieRE1gpLVZBi/myFuCBU5uQkhja+VikgIltfX
+uvYilMEkcEVSQniFJCB91xaNPWPJwuyy5JEMoRXprCjHmChaE+MGnWOXyU5+nSp7
+FuLAOZDXbNi+I8J01q2W+iWVlqvIKAa5ogq5TYayo9foVX6ftnNlkoG14gJUGn8C
+CNSAx8ZGNR16952H1UGQycDXM7T3T1MMYT8gB9qDK90ko1EgvITy2UPyWGhTxh9U
+dKkwpenVgn+hDER5ObTlDmSucCooVKZCAITimb4TjJm1pRfupaJlZfKboFmnmx2Y
+4JvZdbM7sTcCmFRv6P0UEJ3MSptzl/GBqSYFyTKmsVWq1NaRzytUKkTQP3TDpf9c
+vtJKu/CPUWKVtamf2d4U+34MLKIQ2zDRkUWDmEypjHitW9y4PlBYVtZ2ks1rdLCl
+ei7cDgwG6uwLZ9FSjHQgy0BF0lVHKnefrR+c1HZ8/vg12pDtmLvP9tL3rxWQ+fGj
+PluaIgPh/moMEKAWDHH+EeAlJ5mmutIU6HS8cL9G/doV7wfqx7TNGhbCbRIawF+x
+jBYCwiRDmNocGwIDAQABMA0GCSqGSIb3DQEBBQUAA4ICAQCm+WvHykMS7opbbfDu
+reOEt+2i/jyWuPPJB51HheyCQtV5MXyuCRflZpJJdI8iWb3DtayKCI18oK7SakcN
+hVGY+3GJyr5yYVsoeRbyFUgz4apBLb2CeEC7rHbbC39hYVc+FxIUbGiP70dm1TJW
+dZEWeyINScR/YVLitx99g6AVByRjaTDpSDr+Rbw0HWZiuJ2Sb7DqCdwaH5nJqLqN
+N8Vx4+vCCDyOD7kH7cqF3eJ6qepBIYPHib8IAqyLFDcd1OXLMQHv3rrYcQ0WM34P
+NkF7wTO1I8gzpcFyrtOBLOyx/wkoxWhqVcWzYXQrgLbgwp8Z/bJz9MyBnqX2NWq0
+qrGoRBqyLkT4W6acJ2SkgCqMLXhMXfne6wziG+nFiYexeKL+cLEB/CkarxRMEta7
+Hyb/zfWLrXATznjeeXanbgBC9f32Xo2IttLw7hPTAkOqulm7/k/U72/n21g9dLdR
+EtmfzYuDZEOH2QdBqPkrwuqY20t4qvqJITomE8GDFqguJFF5T0h0BS04oSA24J/m
+pwuaccHKuo2j7wapWhqQWZj+3CwYqZDKxIsmWCXAsreUj0GmZEKCgdOI3zzNpAI3
+F6puzfejkHze2rE9Obu71c4q0ibmo8MPx7ovoD9yIZPAvHK8HLiQaRNYP9xvv3FL
+g2zA6bTCQMYERNb1YTBv5xeuOQ==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN CERTIFICATE REQUEST-----
+MIIEyjCCArICAQAwgYQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzAN
+BgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBHbWJIMQwwCgYDVQQLDANS
+JkQxDTALBgNVBAMMBHJvb3QxHzAdBgkqhkiG9w0BCQEWEHJvb3RAZXhhbXBsZS5v
+cmcwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDjfJpz+c2ompElZtBW
+C5HUJ6NevhMmI7VCAZjMEa8l64cCXlULOyKYbEZ2oQupg5iqHVbEK1d4UJ7b2EWT
+Fc8bZT+cQODL7x3hPJ2856PNSg2Rcsna40Vy/1jieRE1gpLVZBi/myFuCBU5uQkh
+ja+VikgIltfXuvYilMEkcEVSQniFJCB91xaNPWPJwuyy5JEMoRXprCjHmChaE+MG
+nWOXyU5+nSp7FuLAOZDXbNi+I8J01q2W+iWVlqvIKAa5ogq5TYayo9foVX6ftnNl
+koG14gJUGn8CCNSAx8ZGNR16952H1UGQycDXM7T3T1MMYT8gB9qDK90ko1EgvITy
+2UPyWGhTxh9UdKkwpenVgn+hDER5ObTlDmSucCooVKZCAITimb4TjJm1pRfupaJl
+ZfKboFmnmx2Y4JvZdbM7sTcCmFRv6P0UEJ3MSptzl/GBqSYFyTKmsVWq1NaRzytU
+KkTQP3TDpf9cvtJKu/CPUWKVtamf2d4U+34MLKIQ2zDRkUWDmEypjHitW9y4PlBY
+VtZ2ks1rdLClei7cDgwG6uwLZ9FSjHQgy0BF0lVHKnefrR+c1HZ8/vg12pDtmLvP
+9tL3rxWQ+fGjPluaIgPh/moMEKAWDHH+EeAlJ5mmutIU6HS8cL9G/doV7wfqx7TN
+GhbCbRIawF+xjBYCwiRDmNocGwIDAQABoAAwDQYJKoZIhvcNAQEFBQADggIBALIn
+S0EvEuPFs6Ap7Pvi4ahwlzNFyRYryeAn2qkqwUyMqM2tHywxPd03jlnCTbMbSANj
+YPXIviamosY3LScyL4BrZTsayuvs0I5VKIZq612cPrpn0+hw3gK/tmiHqjEv/XhZ
+JzSAiJMQqurANhbdwEpBICnY5LjjoKcvdG+Pcto9JmXadmSfLpM25t5ldQ/azPjs
+IctBeXkHExRvT0UV5iCAxLu+kr0jxUFX9fTzewWli/TV50uCJtn7zKvQ/9WbdpZW
+mDKQSFLd2j9bDxhfmDD4A1f9/2qC/ymw9jZAdLgbs9Aan436fzZG0/pYEBxNrl5g
+LJZT+E5oXmLxlJLdPNAHSUccNzpajAaKvrwwksppE2Fqw7x0WNzNiXrsfI5xAORG
+0HIACy2K/+2wmS4Jz/FuA0llunWRhoOV9BpYlvrRL7b0IAbD0iirtakAJ/LOY1RV
+6skID/icIuP68TOy97P154Q58sXp2ic9UegjTAD04+M8+iysfA2p9/z2yWFHqEed
+tOKSe9ZfGhxaDZPmKMWTmQbReP72HLsPp/LRakN0EmxkAaRF3GscurVF90a9fbmm
+R1hKg+F8KOELcp9sgMNNhN/DA6Qwjsg6SOCf7B6nvEGBW0MSTdttZtmuQw686+gU
+2ZFgKlcmTP7epZ38lPhwiSOcObqxLwVrvbvfoxhR
+-----END CERTIFICATE REQUEST-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,4A5FB12597A1CBF1
+
+U3bL1J33MP2KEW9+AWj3YZyjpfAuhYr2c/5Zukdy/kAYRnnK436xUsKJtF9OD6H4
+QTawsgtOFL6gEKvKirbQ8q/xpWBX1xwWUSCf10QogNeRb3pk4h0G0BxM2t2Svh/b
+1iW06CDAl4E/7VAQ2Izsm9Th7Gn7uJEhMJHedDyz6vivxOPFhMA6i4OW3vWdlENZ
+cerjsUe8hE3YkQQZuF9060z4+doV8GUt0chtRorRhkH288BAppXJgqxWFG0mDHve
+EhSTDjQMbxlpS/Amnw2LgRNpBWJtOINKovXy4KzxjZPXnYIzkLF3wFRcq0/R40ND
+Wqs/L+Cc62+XXyY6ZwSYjjoTjaGWnAKfT5oDUIONb6eOOiAxAP4CbGU9m1X7Ctgy
+v4n9ElkRBvzMCnXuneB82tBL6zsEv3IvG4yf7jnPP4HL9+Dp3DtrmW4KYUT1iriE
+iC2Eq+J8TXe+F9Cj8lr95Ou/bqJQcze+5TFAPaZY5UTUqPSbxQczW3yP+Zs6mFia
+JQyUIKkQJAb0FQZYSzgs7nH76Wx0aVzpqTSnv2zZ8zULp4o+8ED2ox2eSKDPbcUa
+y0MNXMj73VGNh22WhJ/ter731TEjXSuysgBIwNZf/8CzZJCN6vSihieED1dIwa75
+a3gi9412v/EWjBJPQjcnUP7H9GyBnqJXyJaqtKuP1eGudl1n/Ri+xTx1BLRmZ0xN
+1wZN2LZaphPBd0tIOOsKfVfMfkyyFP4ymUmi9l2i/350ZPyfhldWKksaN1oGMzXC
+uQwK2NAAGMgbZRHwUEgAiVe/gZN0UyF2JRakcDK4n6woSDSvvD1mRZftb3b5saol
+9krcveZL0PJgZpO1jbw4XiiNj+1SNvfDy0nMsB8LmCtmsFAoANUWlsGZyh0xD3ko
+NE8Red5oz3Ydbw1RZglO5F0qdrZsH+p4nPOrCDttD+E8apsWXY0L4b2TkSGho2Q9
+04FZE/heKywZw+wVP8XMHvF87FP5kvpOKQEh39V9iVyCYOALMYp+Zk+lmZV+1WtW
+W5DnAhOfdXC/kDRQQLWT0SGhHOOtGLrU+KhmKlNDGe1YwjKUeKRL82+eebFIsDWe
+TRg7D3K9U+G8RwRCtsaNXptRLeG/gGb5hnP31KlIVz8QfQ9yOVtuGiGhMVlpzRYO
+prn2emRblIKASQNdYqiEg1OTZ3Hg88NLcXWUkoby6jDmA2hwWIRgVfhPrY8F2JGV
+jy5U7mmcnouVYjzBhkwSj4hMDK6Z4r5eppbEKWulEaxNI+0j+TvSBZmDEPhbtlF2
+ZO9VuHUROtBSK8EhxHgb/s8sR8jBGRGlTYHtk/djDJPmxmEvaMmoTTrZ+IqOwoMg
+CRewUi3cWFt08tvXKbprWpwGEKY9mMysYD4EijLEQGx6+HFSZ6WRMOzHAgb3kjhA
+q86YaI1y8zN6aAnRaq/UYqO/GxJMaj3svQjUwQLYoUAOp+8efs9eUVcZq4QVmAJX
+BDSh+E9GH6pCRMZcT5sETIqXfWHuoWuZTeE4qRBLIT6qCIfIr871cXclQuPRS+sI
+HFxiw0gPT+iSyIGM7pzn8kMMgbiGoSdzN90oJXUJ3OH49Liox58iyOk55LUp842N
+TnKsGgyS10qZ31MnkOw1zNnHtb458FsIXg+FjgT54Nlyf8SA0A6+tpqhPhYNfus0
+U1mjrxt1bL/q7QcjSe7FKUNenQfKHltIAAKUBrlnh3UG9a93D0V7GC8k/u+hFdWN
+kL7o8uva3NCZAXENk/ofiOpXV+wyzrf7O14T2dwQjJC6jmzK07AFL3/8k8rAUFPt
+imZk12TiB2m0mlg8RXVwsxe2PaP6rObl32wqFohOkkINfbSnTso5665LHgMtcB8j
+O7xV4sO/JZaPTe57/fyoOdqNv5MvpZaqhe4EH2mBAp04NqmcrELaux0msnrYdQnF
+7GN3PrVzpvE4jn2tZ8XSPnvawJ+cc6IYXSZrlamRKboq85V3uqhdayNEKWLDXQJ5
+NJLXxDe/9HEuOoMCxNKxScPhulXAkKN4bBAgytIcwi/9DAqDFxH8czGDzoR6aYD2
+3BIAdRkzxygy5uKBkqDSe8wugtTQI1kxvTgz06kBtN619k4dZFukQxWiAkzEZbZQ
+j3ulktFe+1oMjjQhI7S3LByWGuSrYw5kIvZrjwcwkqauk9ThTHsLrNwhKW7Dh1Op
+vCmDzi1WwMZyj6MpTEArA4YOz4UrJZohpK+8n5bPEQfy3jOJpHTilr0dpVpbEnFa
+bkj57y4ltYu1AfSgjRHtVfcXGRgj5/xrmLicDRXLH32O1al9f8bYyNFV8hLTLHUP
+q4D5dFAmVVdoRBbGroaK9fMxjpNzNqM+rHH2qLk9nE33I5LoJrqTamfCOj6a3iBh
+hGxxxmI9yNrPv2duCthEnn52haclWfbx3EJf97iIkEMjmpKnqc0KASqlRYk1pGzn
+6YhtsC+h5I1tLf/ukWgB3smsjeAWYt8bFzvcMHm8MVv6KxEthxdOh0zY3hP7peRK
++NS6HV6L6b2ci6kUkQLRhFra0SkRkMOkydHEx6d6XuKHNLt8y6yRf+O3xAOEAEIi
+QTcCSsXuLLNJCI7ouLi/IxLD4NBFJkXv5nSWZLP4woOwCF8XAUeMGRjr8iZ97VwL
+Iv1bbKwR3Ad0qQJKo5pGsWgPNceYcVuT+Lrkk0385O8e3yWen4GPsticf43NVN81
+EkQphsCOUOcJlAr2xTm6PWtVGbKQiOVVv/Ny0ixfjk4JLPzNGIaWGbQk/ywqF1VI
+RvPIIVlbGGh1FzxTHaxcvSsuPm/r3yMt0tAb5bBIb/RVuU+3MqFZWfciNurUxu/L
+YfwIc3GYrroJC08n5rBXN3fZIjr0HyAgL3c8ZSa10lqHALcoeOBSoAe4y6wmEsS8
+W1c8qsospdKERHMX6yB4qzQoqssQYtHRaPvli6Cq36yNdqRvcwjOxvzINf3SLY8N
+Lbgp7RvWbSPtmUXeubYi5V9qk3ay6YK7hXeQ2jXrRZpX2D2PB5OgUWkHXcmpx5xA
+QB/nFrx1Mz9dNCCpnBNqIhPwlJLkFYqhIwVXfoJNQtRAjaXBxKNgi+9kgQmqAaOb
+l9OUXiwv7gyepT3T3oM9Nr98b1uhom5LsJ40K2QabRJCcewJCsNCGWkziBaJOtHf
+-----END RSA PRIVATE KEY-----
--- /dev/null
+# Password for all users and teh CA is 'demo'
+# Password for all key- and truststores is 'changeit'
+
+# Clean
+# rm server.*
+
+# Create CA
+openssl genrsa -des3 -out ca.key 4096
+openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
+
+# Create Keystore and Truststore and add CA to them
+keytool -import -keystore server.ts -file ca.crt -alias ArgeoDemoCA
+keytool -import -keystore server.ks -file ca.crt -alias ArgeoDemoCA
+
+# Tomcat Server
+# (we must use keytool)
+keytool -genkey -alias tomcat -keyalg RSA -keysize 4096 -keystore server.ks
+keytool -certreq -alias tomcat -keystore server.ks -file tomcat.csr
+openssl x509 -req -set_serial 02 -days 3650 -in tomcat.csr -CA ca.crt -CAkey ca.key -out tomcat.crt
+keytool -importcert -alias tomcat -keystore server.ks -file tomcat.crt
+
+# Root User
+openssl genrsa -des3 -out root@demo.key 4096
+openssl req -new -key root@demo.key -out root@demo.csr
+openssl x509 -req -set_serial 03 -days 3650 -in root@demo.csr -CA ca.crt -CAkey ca.key -out root@demo.crt
+openssl pkcs12 -export -out root@demo.p12 -inkey root@demo.key -in root@demo.crt -certfile ca.crt
+
+# Demo User
+openssl genrsa -des3 -out demo@demo.key 4096
+openssl req -new -key demo@demo.key -out demo@demo.csr
+openssl x509 -req -set_serial 04 -days 3650 -in demo@demo.csr -CA ca.crt -CAkey ca.key -out demo@demo.crt
+openssl pkcs12 -export -out demo@demo.p12 -inkey demo@demo.key -in demo@demo.crt -certfile ca.crt
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIFYjCCA0oCAQIwDQYJKoZIhvcNAQEFBQAwgYUxCzAJBgNVBAYTAkRFMQ8wDQYD
+VQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEVMBMGA1UECgwMRXhhbXBsZSBH
+bWJIMQwwCgYDVQQLDANSJkQxEDAOBgNVBAMMB0RlbW8gQ0ExHTAbBgkqhkiG9w0B
+CQEWDmNhQGV4YW1wbGUub3JnMB4XDTEzMDUyODExMjYwM1oXDTIzMDUyNjExMjYw
+M1owaDELMAkGA1UEBhMCREUxDzANBgNVBAgTBkJlcmxpbjEPMA0GA1UEBxMGQmVy
+bGluMRUwEwYDVQQKEwxFeGFtcGxlIEdtYkgxDDAKBgNVBAsMA1ImRDESMBAGA1UE
+AxMJbG9jYWxob3N0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAj0X1
+BD4zndTvh5i+ZI+/PJWNhRQYVh+JMFSc85z/APrqZNbwsOEg2mjyLk+bTUcxSZtA
+JLOBGUp7cwQTLD7VTtW7SEtbrcPdikRFQaTL4MNSZNysCPFTOnaPmkHTqnfrNDq2
+yMoaIDp/73dkefT2hoafy6Of1ZC+Sp8QvVORAsnyauRrSnrQSeQlRLm7i2H8FfXK
+zJm33v7LBoX+xJrpKE0fPvJgTsrUaMH76ytMVvDn+PYrW42lmjnAuWZmPJsCjRX7
+XwPggQ6Sdmzj7Z0XeEX3W2ZAMFP2qhbVVSzS4lOUir7/VwfSHmkfhjR8ElzOw6t+
+wG116OXX+yk0INsP/0pLoo8N7yagyrajYcIO5Il7hxVvG5ToHzwgGEn+rMDr1KrF
+f/4XX55Hx2uw7mzkmpyyUVHCyhkNQUwnEmAXKaRM6TH2k84t3TJD/TapiugOGy+a
+o4cKfqfrRDWg09dk4+l4t+BZdlQ2qs/3Umt1aUGar0CLgRhmQJUvFfYCbTFJH4N8
+TVUE1C1C+anIXlapSZCfe9Nfbj1l8yWZwhhMMKaAjsdcBw1upi+cvPuvNTgu1CUz
+uNuPrYTMVkUxbAvZXE0OClZK8uFhlKD+wPzQOOinH7+xXGpAWoAbs5SckuqD7vIz
+mFA9DcllDRT7eQO5xEdfT1jg/PawS1mY8yp1GysCAwEAATANBgkqhkiG9w0BAQUF
+AAOCAgEAQQJm0wDgnsU4caIYt6LGIvPZtuIUfeCy3ZkM0LJsv3JYj8ppb4ULVknM
+8LNPk3W3BAbnuIZR5E9dkByfu2PF/fNpqJRLpCR5zSN3oQsQjHrf9XAr5VeZ0E/w
+YR/udjTJoXQVm2YhtOhDGJ52TW1TZtNGXrn5kmnkWgqm6WSXIZSQ1viW6a6nklZC
+8Tt0o0l+KiiMapgvC9eNonx3CpM+EzSAASmqUz+uPUG0SIQQfuP0Fs5oYaI/I2F3
+j5WxLBdqjTaatwkrhBV22ZoXigWpTNTHcpc469djr23ie+iHlIO/YkL41DDOI5r9
+EsIKxQBKzO9addeys5gReAiEMhDTYGwflliWhdFMAM1mLB4YJjN1iSJEkWkDGg4G
+N+i/Ydx5fgExAws6tE2nUxTBt/F/6Qe+oWCURLE2YDID+t5z7/JQEFJgnboLsUoe
+epKbITPtzNCnnWRwsqsanlx/RbgtI6Flb6/CWGmzlg1y6XhQDO0D6/4amvjeeqVV
+a3vSVpL06K7/PxDFK8vnJmVcC8SqN5RBwsngMnMpPOjD6TNdXo6R45m7UMjQiFO+
+XLi7SSvngmNsaVOlX3adb77ql6DS4dNLZ0UNi6/fr3ADkdkk6yewNJBgVpFoyNPn
+yZdafIUvaRcrH6QXhRyrDLRhF6j9AJNIqUwDBQ1IhexYz/23r6o=
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN NEW CERTIFICATE REQUEST-----
+MIIErTCCApUCAQAwaDELMAkGA1UEBhMCREUxDzANBgNVBAgTBkJlcmxpbjEPMA0GA1UEBxMGQmVy
+bGluMRUwEwYDVQQKEwxFeGFtcGxlIEdtYkgxDDAKBgNVBAsMA1ImRDESMBAGA1UEAxMJbG9jYWxo
+b3N0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAj0X1BD4zndTvh5i+ZI+/PJWNhRQY
+Vh+JMFSc85z/APrqZNbwsOEg2mjyLk+bTUcxSZtAJLOBGUp7cwQTLD7VTtW7SEtbrcPdikRFQaTL
+4MNSZNysCPFTOnaPmkHTqnfrNDq2yMoaIDp/73dkefT2hoafy6Of1ZC+Sp8QvVORAsnyauRrSnrQ
+SeQlRLm7i2H8FfXKzJm33v7LBoX+xJrpKE0fPvJgTsrUaMH76ytMVvDn+PYrW42lmjnAuWZmPJsC
+jRX7XwPggQ6Sdmzj7Z0XeEX3W2ZAMFP2qhbVVSzS4lOUir7/VwfSHmkfhjR8ElzOw6t+wG116OXX
++yk0INsP/0pLoo8N7yagyrajYcIO5Il7hxVvG5ToHzwgGEn+rMDr1KrFf/4XX55Hx2uw7mzkmpyy
+UVHCyhkNQUwnEmAXKaRM6TH2k84t3TJD/TapiugOGy+ao4cKfqfrRDWg09dk4+l4t+BZdlQ2qs/3
+Umt1aUGar0CLgRhmQJUvFfYCbTFJH4N8TVUE1C1C+anIXlapSZCfe9Nfbj1l8yWZwhhMMKaAjsdc
+Bw1upi+cvPuvNTgu1CUzuNuPrYTMVkUxbAvZXE0OClZK8uFhlKD+wPzQOOinH7+xXGpAWoAbs5Sc
+kuqD7vIzmFA9DcllDRT7eQO5xEdfT1jg/PawS1mY8yp1GysCAwEAAaAAMA0GCSqGSIb3DQEBBQUA
+A4ICAQCORSPE6s/ogDnCwX4KDkk8srvdkuERiC3Hb6vTP0bVkLRwHdj77xGNwkXI7UasE52ykOze
+khMuk94onH8yyeDg57EXO4267AsqowV6Od94AGKTndx4Zosx2N+JOGGA0ZwCHvmoX1Wwe1KJ6QoI
+uMdpO+i9uo4ZYth76VV+Yn3mtyJAH0sdHeFkgevKLDURtC+m70XF77NKl+L7VuoNKxXaVCab3d/x
+aksTJpwLGt8QECR1Wq5FPNG/EQiFqQCd3WyzgsebGLDHYQgPEKkKKhMU3G/kIofutz/hNvxp8MRK
+EEEnyfZWiSpYxxmEPmelyinOkoOH5tqbkHzcPawSPFWDBR4pWAg9efdl7zdVAxzNkS5PqWtXrWvm
+jfMAPkTJoeQ6YWZZjHxpYrbBZfIgCr9VehGdzvhDVGbe8NeTDzwk/AItr5shIbFZpA0vIHB4+wEA
+QVl7d1ZM/0qEKGLeHG8TvF4TUIBE1C6RVpnP5jMB9pLQ4FEbgHaadGxQfGxh18GfyxlWmQy8RgDW
+BDJRPClofXm57665hD+py7Jw5F4ZgD5IKwU96kDe7mZRLkF66ZinoubZeyXZBX4N0p7lrWzd/mJj
+r3Yf69L/Ptct7Cr3c4z7Y1xqrBb88bKhVRCfJVtlvE9mSvMh6UUY1QlAGQaDmSQEB+eCO+8diaTa
+gEOeNw==
+-----END NEW CERTIFICATE REQUEST-----
--- /dev/null
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.argeo.slc.factory.A2Factory;
+
+class Make {
+ public static void main(String[] args) {
+ if(args.length < 1) {
+ System.err.println("Usage: <path to a2 output dir>");
+ System.exit(1);
+ }
+ Path a2Base = Paths.get(args[0]).toAbsolutePath().normalize();
+ A2Factory factory = new A2Factory(a2Base);
+
+ Path descriptorsBase = Paths.get("./tp").toAbsolutePath().normalize();
+
+// factory.processSingleM2ArtifactDistributionUnit(descriptorsBase.resolve("org.argeo.tp.apache").resolve("org.apache.xml.resolver.bnd"));
+// factory.processM2BasedDistributionUnit(descriptorsBase.resolve("org.argeo.tp/slf4j"));
+// System.exit(0);
+
+ // Eclipse
+ factory.processEclipseArchive(
+ descriptorsBase.resolve("org.argeo.tp.eclipse.equinox").resolve("eclipse-equinox"));
+ factory.processEclipseArchive(descriptorsBase.resolve("org.argeo.tp.eclipse.rap").resolve("eclipse-rap"));
+ factory.processEclipseArchive(descriptorsBase.resolve("org.argeo.tp.eclipse.rcp").resolve("eclipse-rcp"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.eclipse.rcp"));
+
+ // Maven
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.sdk"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.apache"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.jetty"));
+ factory.processCategory(descriptorsBase.resolve("org.argeo.tp.jcr"));
+ }
+
+}
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+SLC-Origin-M2: :2.5.1
\ No newline at end of file
--- /dev/null
+Bundle-SymbolicName: org.apache.sshd.cli
+SLC-Origin-M2: org.apache.sshd:sshd-cli
--- /dev/null
+Bundle-SymbolicName: org.apache.sshd.common
+Fragment-Host: org.apache.sshd.core
+Import-Package: org.bouncycastle.jce.provider;resolution:=optional,
+ net.i2p.crypto.eddsa;resolution:=optional,
+ *
+SLC-Origin-M2: org.apache.sshd:sshd-common
--- /dev/null
+Bundle-SymbolicName: org.apache.sshd.core
+SLC-Origin-M2: org.apache.sshd:sshd-core
+Import-Package: \
+org.apache.tomcat.jni.*;resolution:=optional,\
+*
\ No newline at end of file
--- /dev/null
+Bundle-SymbolicName: org.apache.sshd.git
+SLC-Origin-M2: org.apache.sshd:sshd-git
+Import-Package: \
+org.eclipse.jgit.pgm.*;resolution:=optional,\
+org.kohsuke.*;resolution:=optional,\
+*
\ No newline at end of file
--- /dev/null
+Bundle-SymbolicName: org.apache.sshd.putty
+SLC-Origin-M2: org.apache.sshd:sshd-putty
+Import-Package: \
+net.i2p.*;resolution:=optional,\
+*
\ No newline at end of file
--- /dev/null
+Bundle-SymbolicName: org.apache.sshd.scp
+SLC-Origin-M2: org.apache.sshd:sshd-scp
--- /dev/null
+Bundle-SymbolicName: org.apache.sshd.sftp
+SLC-Origin-M2: org.apache.sshd:sshd-sftp
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.cli
+SLC-Origin-M2: commons-cli:commons-cli:1.5.0
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.codec
+SLC-Origin-M2: commons-codec:commons-codec:1.15
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.exec
+SLC-Origin-M2: org.apache.commons:commons-exec:1.3
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.fileupload
+Import-Package: javax.portlet;resolution:=optional,\
+*
+SLC-Origin-M2: commons-fileupload:commons-fileupload:1.4
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.httpclient
+SLC-Origin-M2: commons-httpclient:commons-httpclient:3.1
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.io
+SLC-Origin-M2: commons-io:commons-io:2.11.0
+Import-Package: sun.*;resolution:=optional, *
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.vfs
+Import-Package: org.apache.tools.ant.*;resolution:=optional,
+*
+SLC-Origin-M2: org.apache.commons:commons-vfs2:2.9.0
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.httpcomponents.httpclient
+SLC-Origin-M2: org.apache.httpcomponents:httpclient:4.5.13
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.httpcomponents.httpcore
+SLC-Origin-M2: org.apache.httpcomponents:httpcore:4.4.15
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.httpcomponents.httpmime
+SLC-Origin-M2: org.apache.httpcomponents:httpmime:4.5.13
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.tika.core
+SLC-Origin-M2: org.apache.tika:tika-core:1.27
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-Activator: org.apache.tika.parser.internal.Activator
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.tika.parsers
+Import-Package: *;resolution:=optional
+SLC-Origin-M2: org.apache.tika:tika-parsers:1.27
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.xalan
+SLC-Origin-M2: xalan:xalan:2.7.2
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.xalan.serializer
+SLC-Origin-M2: xalan:serializer:2.7.2
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.xerces
+Import-Package: sun.*;resolution:=optional,
+*
+SLC-Origin-M2: xerces:xercesImpl:2.12.2
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.xml.resolver
+SLC-Origin-M2: xml-resolver:xml-resolver:1.2
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.xml.security
+SLC-Origin-M2: org.apache.santuario:xmlsec:2.1.2
+Export-Package: org.apache.*
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.xmlbeans
+DynamicImport-Package: *
+Import-Package: org.apache.tools.ant.*;resolution:=optional,
+net.sf.saxon.*;resolution:=optional,
+com.sun.*;resolution:=optional,
+*
+SLC-Origin-M2: org.apache.xmlbeans:xmlbeans:3.1.0
\ No newline at end of file
--- /dev/null
+Bundle-License: EPL-1.0
+SLC-Origin-ManifestNotModified: true
+SLC-Origin-URI: http://www.eclipse.org/downloads/equinox/drops/R-4.22-202111241800/equinox-SDK-4.22.zip
--- /dev/null
+plugins/org.eclipse.osgi_*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.osgi.source_*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.osgi.util*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.osgi.services*.jar=org.argeo.tp.eclipse.equinox
+plugins/jakarta.servlet-api*.jar=org.argeo.tp.javax
+plugins/org.apache.felix.gogo.*.jar=org.argeo.tp.apache.felix
+plugins/org.apache.felix.scr*.jar=org.argeo.tp.apache.felix
+plugins/org.eclipse.equinox.app*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.cm*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.common*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.console_*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.console.source_*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.ds*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.metatype*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.event*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.http.jetty*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.http.registry*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.http.servlet*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.http.servletbridge*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.preferences*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.registry*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.servletbridge*.jar=org.argeo.tp.eclipse.equinox
+plugins/org.eclipse.equinox.util*.jar=org.argeo.tp.eclipse.equinox
--- /dev/null
+Bundle-License: EPL-1.0
+SLC-Origin-ManifestNotModified: true
+SLC-Origin-URI: http://www.eclipse.org/downloads/rt/rap/3.19/e4/rap-e4-3.19.0-R-20211130-1934.zip
--- /dev/null
+plugins/javax.inject*.jar=org.argeo.tp.javax
+plugins/javax.annotation*.jar=org.argeo.tp.javax
+plugins/org.apache.commons.jxpath*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.core.*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.rwt_*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.rwt.source_*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.rwt.osgi_*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.rwt.osgi.source_*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.fileupload*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.filedialog*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.e4*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.emf*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.e4_*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.e4.source_*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.ui.workbench*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.ui_*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.ui.source_*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.ui.views*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.jface*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.ui.forms*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.help*.jar=org.argeo.tp.eclipse.rap
+plugins/org.eclipse.rap.nebula.*.jar=org.argeo.tp.eclipse.rap
+plugins/com.ibm.icu*.jar=org.argeo.tp.eclipse.rap
--- /dev/null
+Bundle-License: EPL-1.0
+SLC-Origin-ManifestNotModified: true
+SLC-Origin-URI: http://www.eclipse.org/downloads/eclipse/downloads/drops4/R-4.22-202111241800/org.eclipse.rcp.source-4.22.zip
--- /dev/null
+plugins/*.jar=org.argeo.tp.eclipse.rcp
--- /dev/null
+Bundle-License: EPEL-2.0
+SLC-Origin-M2: org.eclipse.emf:org.eclipse.emf.common:2.23.0
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: EPEL-2.0
+SLC-Origin-M2: org.eclipse.emf:org.eclipse.emf.ecore:2.25.0
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: EPEL-2.0
+SLC-Origin-M2: org.eclipse.emf:org.eclipse.emf.ecore.change:2.14.0
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: EPEL-2.0
+SLC-Origin-M2: org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.16.0
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-SymbolicName: javax.xml.bind
+Bundle-Version: 2.4.0
+SLC-Origin-M2: javax.xml.bind:jaxb-api:2.4.0-b180830.0359
+Export-Package: javax.*
\ No newline at end of file
--- /dev/null
+Bundle-License: Public Domain
+Bundle-SymbolicName: EDU.oswego.cs.dl.util.concurrent
+SLC-Origin-M2: concurrent:concurrent:1.3.4
\ No newline at end of file
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: com.google.guava
+Bundle-Version: 27.1.0.jre
+SLC-Origin-M2: com.google.guava:guava:27.1-jre
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: com.google.guava.failureaccess
+SLC-Origin-M2: com.google.guava:failureaccess:1.0.1
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: Apache-2.0
+SLC-Origin-M2: :2.20.4
\ No newline at end of file
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-api
+Bundle-SymbolicName: org.apache.jackrabbit.api
+Export-Package: org.apache.jackrabbit.*
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-core
+Bundle-SymbolicName: org.apache.jackrabbit.core
+Import-Package: org.apache.jackrabbit.test;resolution:=optional,\
+org.apache.derby.*;resolution:=optional,\
+org.h2;resolution:=optional,\
+org.postgresql;resolution:=optional,\
+oracle.jdbc;resolution:=optional,\
+org.gjt.mm.mysql;resolution:=optional,\
+com.mysql.jdbc;resolution:=optional,\
+com.microsoft.sqlserver.jdbc;resolution:=optional,\
+net.sourceforge.jtds.jdbc;resolution:=optional,\
+org.hsqldb;resolution:=optional,\
+*
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-data
+Bundle-SymbolicName: org.apache.jackrabbit.data
+Fragment-Host: org.apache.jackrabbit.core
+Import-Package: org.apache.jackrabbit.test;resolution:=optional,\
+org.apache.derby.*;resolution:=optional,\
+org.h2;resolution:=optional,\
+org.postgresql;resolution:=optional,\
+oracle.jdbc;resolution:=optional,\
+org.gjt.mm.mysql;resolution:=optional,\
+com.mysql.jdbc;resolution:=optional,\
+com.microsoft.sqlserver.jdbc;resolution:=optional,\
+net.sourceforge.jtds.jdbc;resolution:=optional,\
+org.hsqldb;resolution:=optional,\
+*
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-jcr-client
+Bundle-SymbolicName: org.apache.jackrabbit.jcr.client
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-jcr-commons
+Bundle-SymbolicName: org.apache.jackrabbit.jcr.commons
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-jcr2dav
+Bundle-SymbolicName: org.apache.jackrabbit.jcr2dav
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-jcr2spi
+Bundle-SymbolicName: org.apache.jackrabbit.jcr2spi
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-jcr-server
+Bundle-SymbolicName: org.apache.jackrabbit.server
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-jcr-servlet
+Bundle-SymbolicName: org.apache.jackrabbit.servlet
+Fragment-Host: org.apache.jackrabbit.core
+Import-Package: org.apache.jackrabbit.rmi.*;resolution:=optional,*
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-spi
+Bundle-SymbolicName: org.apache.jackrabbit.spi
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-spi-commons
+Bundle-SymbolicName: org.apache.jackrabbit.spi.commons
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-spi2dav
+Bundle-SymbolicName: org.apache.jackrabbit.spi2dav
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-spi2jcr
+Bundle-SymbolicName: org.apache.jackrabbit.spi2jcr
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:jackrabbit-webdav
+Bundle-SymbolicName: org.apache.jackrabbit.webdav
--- /dev/null
+Bundle-License: https://www.adobe.io/experience-manager/reference-materials/spec/jcr/2.0/license.html
+Bundle-SymbolicName: javax.jcr
+Bundle-Version: 2.0.0
+SLC-Origin-M2: javax.jcr:jcr:2.0
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: Apache-2.0
+SLC-Origin-M2: :1.40.0
\ No newline at end of file
--- /dev/null
+SLC-Origin-M2: org.apache.jackrabbit:oak-jackrabbit-api
+Bundle-SymbolicName: org.apache.jackrabbit.api
+Export-Package: org.apache.jackrabbit.*
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.collections
+SLC-Origin-M2: commons-collections:commons-collections:3.2.2
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.dbcp
+SLC-Origin-M2: commons-dbcp:commons-dbcp:1.4
+Import-Package: javax.transaction.*; resolution:="optional",\
+*
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.commons.pool
+SLC-Origin-M2: commons-pool:commons-pool:1.6
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.lucene
+SLC-Origin-M2: org.apache.lucene:lucene-core:3.6.2
\ No newline at end of file
--- /dev/null
+Bundle-SymbolicName: javax.websocket
+Bundle-License: GPL-2.0-only OR CDDL-1.1
+SLC-Origin-M2: javax.websocket:javax.websocket-api:1.1
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: Apache-2.0
+SLC-Origin-M2: :10.0.8
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-jetty-api
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.api
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-jetty-client
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.client
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-jetty-common
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.common
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-core-client
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.core.client
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-core-common
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.core.common
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-core-client
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.core.client
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-jakarta-client
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.jakarta.client
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-jakarta-common
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.jakarta.common
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-jakarta-server
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.jakarta.server
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-jetty-server
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.server
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty.websocket:websocket-servlet
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.websocket.servlet
--- /dev/null
+Bundle-License: Apache-2.0
+SLC-Origin-M2: :10.0.8
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-client
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.client
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-continuation
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.continuation
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-http
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.http
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-io
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.io
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-jmx
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.jmx
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-security
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.security
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-server
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.server
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-servlet
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.servlet
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-servlets
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.servlets
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-util-ajax
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.util.ajax
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-util
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.util
--- /dev/null
+SLC-Origin-M2: org.eclipse.jetty:jetty-xml
+SLC-Origin-ManifestNotModified: true
+Bundle-SymbolicName: org.eclipse.jetty.xml
--- /dev/null
+Bundle-License: Apache-2.0
+SLC-Origin-M2: biz.aQute.bnd:biz.aQute.bndlib:5.3.0
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: EPL-2.0
+SLC-Origin-M2: org.eclipse.jdt:ecj:3.28.0
+SLC-Origin-ManifestNotModified: true
+Main-Class: org.eclipse.jdt.internal.compiler.batch.Main
\ No newline at end of file
--- /dev/null
+Bundle-License: BSD-3-Clause
+SLC-Origin-M2: org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r
+Import-Package: \
+sun.*;resolution:=optional, \
+com.jcraft.jsch;resolution:=optional, \
+*
--- /dev/null
+Bundle-License: BSD-3-Clause
+Bundle-SymbolicName: org.hamcrest
+Bundle-Version: 2.1.0
+SLC-Origin-M2: org.hamcrest:hamcrest:2.2
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: EPL-1.0
+Bundle-SymbolicName: org.junit
+Bundle-Version: 4.12.0
+Import-Package: org.hamcrest;resolution:=optional,\
+org.hamcrest.core;resolution:=optional,\
+*
+SLC-Origin-M2: junit:junit:4.13.2
\ No newline at end of file
--- /dev/null
+Bundle-License: MIT
+Bundle-SymbolicName: org.redline-rpm
+Import-Package: sun.security.*;resolution:=optional,
+org.apache.tools.ant.*;resolution:=optional,
+org.apache.tools.zip;resolution:=optional,
+*
+SLC-Origin-M2: org.redline-rpm:redline:1.2.10
--- /dev/null
+Bundle-SymbolicName: bcpg
+SLC-Origin-ManifestNotModified: true
+SLC-Origin-M2: org.bouncycastle:bcpg-jdk15on
--- /dev/null
+Bundle-SymbolicName: bcpkix
+SLC-Origin-ManifestNotModified: true
+SLC-Origin-M2: org.bouncycastle:bcpkix-jdk15on
--- /dev/null
+Bundle-SymbolicName: bcprov
+SLC-Origin-ManifestNotModified: true
+SLC-Origin-M2: org.bouncycastle:bcprov-jdk15on
--- /dev/null
+Bundle-SymbolicName: bcutil
+SLC-Origin-ManifestNotModified: true
+SLC-Origin-M2: org.bouncycastle:bcutil-jdk15on
--- /dev/null
+Bundle-License: MIT
+SLC-Origin-M2: :1.70
--- /dev/null
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: com.googlecode.javaewah.JavaEWAH
+SLC-Origin-M2: com.googlecode.javaewah:JavaEWAH:1.1.13
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-SymbolicName: com.fasterxml.jackson.core.jackson-annotations
+SLC-Origin-M2: com.fasterxml.jackson.core:jackson-annotations
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-SymbolicName: com.fasterxml.jackson.core.jackson-core
+SLC-Origin-M2: com.fasterxml.jackson.core:jackson-core
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-SymbolicName: com.fasterxml.jackson.core.jackson-databind
+SLC-Origin-M2: com.fasterxml.jackson.core:jackson-databind
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: Apache-2.0
+SLC-Origin-M2: :2.13.1
--- /dev/null
+Bundle-License: MPL-2.0
+Bundle-SymbolicName: org.h2
+SLC-Origin-M2: com.h2database:h2:1.4.200
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: BSD-2-Clause
+Bundle-SymbolicName: org.postgresql.jdbc42
+SLC-Origin-M2: org.postgresql:postgresql:42.3.2
+SLC-Origin-ManifestNotModified: true
--- /dev/null
+Bundle-License: Apache-2.0
+SLC-Origin-M2: :1.7.36
--- /dev/null
+Bundle-SymbolicName: org.slf4j.api
+SLC-Origin-M2: org.slf4j:slf4j-api
--- /dev/null
+Bundle-SymbolicName: org.slf4j.commons.logging
+SLC-Origin-M2: org.slf4j:jcl-over-slf4j
+Export-Package: org.apache.commons.logging.*;version="1.2"
\ No newline at end of file