X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.repo%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Frepo%2Fmaven%2FMigration_01_03.java;h=9e37f7592516e5de8b0aa099f7c57050516615b1;hb=44c43b9c874d7c6edd4327f180d5506b3e9c99e6;hp=b93831cc191c8bf0f071791030b84cba30e4582d;hpb=418a82cb85b477af9f2b8d850ca14c8512546643;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/Migration_01_03.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/Migration_01_03.java index b93831cc1..9e37f7592 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/Migration_01_03.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/Migration_01_03.java @@ -24,6 +24,7 @@ import javax.jcr.query.qom.Selector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.jcr.JcrUtils; +import org.argeo.slc.NameVersion; import org.argeo.slc.SlcException; import org.argeo.slc.jcr.SlcNames; import org.argeo.slc.jcr.SlcTypes; @@ -254,6 +255,54 @@ public class Migration_01_03 implements Runnable, SlcNames { jarFileIndexer.index(targetJarNode); targetSession.save(); + + // sources + 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", + origArtifact.getVersion()); + 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); + JcrUtils.closeQuietly(origBinary); + } else {// just copy + targetSession.getWorkspace().copy(sourceWorkspace, + origSourceJarNode.getPath(), targetSourceJarPath); + } + targetSession.save(); + + // reindex + Node targetSourceJarNode = targetSession + .getNode(targetSourceJarPath); + artifactIndexer.index(targetSourceJarNode); + jarFileIndexer.index(targetSourceJarNode); + + targetSession.save(); + } } /*