1 package org
.argeo
.slc
.repo
.osgi
;
3 import java
.util
.Iterator
;
5 import javax
.jcr
.RepositoryException
;
6 import javax
.jcr
.Session
;
8 import org
.apache
.commons
.logging
.Log
;
9 import org
.apache
.commons
.logging
.LogFactory
;
10 import org
.argeo
.jcr
.JcrUtils
;
11 import org
.argeo
.slc
.CategorizedNameVersion
;
12 import org
.argeo
.slc
.NameVersion
;
13 import org
.argeo
.slc
.SlcException
;
14 import org
.argeo
.slc
.repo
.OsgiFactory
;
15 import org
.argeo
.slc
.repo
.maven
.MavenConventionsUtils
;
16 import org
.sonatype
.aether
.artifact
.Artifact
;
17 import org
.sonatype
.aether
.util
.artifact
.DefaultArtifact
;
19 public class ProcessDistribution
implements Runnable
{
20 private final static Log log
= LogFactory
.getLog(ProcessDistribution
.class);
22 private ArgeoOsgiDistribution osgiDistribution
;
23 private OsgiFactory osgiFactory
;
26 Session javaSession
= null;
28 javaSession
= osgiFactory
.openJavaSession();
30 Iterator
<NameVersion
> it
= osgiDistribution
.nameVersions();
31 while (it
.hasNext()) {
32 NameVersion t
= it
.next();
33 if (log
.isDebugEnabled())
34 log
.debug("Check " + t
+ "...");
35 if (!(t
instanceof CategorizedNameVersion
))
36 throw new SlcException("Unsupported type " + t
.getClass());
37 CategorizedNameVersion nv
= (CategorizedNameVersion
) t
;
38 Artifact artifact
= new DefaultArtifact(nv
.getCategory(),
39 nv
.getName(), "jar", nv
.getVersion());
40 String path
= MavenConventionsUtils
.artifactPath("/", artifact
);
41 if (!javaSession
.itemExists(path
)) {
42 if (nv
instanceof Runnable
) {
43 if (log
.isDebugEnabled())
44 log
.debug("Run " + nv
+ "...");
45 ((Runnable
) nv
).run();
47 log
.warn("Skipped unsupported " + nv
);
51 } catch (RepositoryException e
) {
52 throw new SlcException("Cannot process distribution "
53 + osgiDistribution
, e
);
55 JcrUtils
.logoutQuietly(javaSession
);
59 public void setOsgiDistribution(ArgeoOsgiDistribution osgiDistribution
) {
60 this.osgiDistribution
= osgiDistribution
;
63 public void setOsgiFactory(OsgiFactory osgiFactory
) {
64 this.osgiFactory
= osgiFactory
;