+/*
+ * 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.
+ */
package org.argeo.slc.repo.maven;
import java.io.ByteArrayInputStream;
import org.argeo.slc.aether.AetherTemplate;
import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.jcr.SlcTypes;
+import org.argeo.slc.repo.ArtifactIndexer;
import org.argeo.slc.repo.RepoConstants;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
private Session jcrSession;
private String artifactBasePath = RepoConstants.ARTIFACTS_BASE_PATH;
- private String distributionsBasePath = "/slc/repo/distributions";
+ private String distributionsBasePath = RepoConstants.DISTRIBUTIONS_BASE_PATH;
private String distributionName;
+ private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
+
public void run() {
log.debug(jcrSession.getUserID());
Set<Artifact> artifacts = resolveDistribution();
}
try {
- String parentPath = artifactBasePath + '/'
+ String parentPath = artifactBasePath
+ + (artifactBasePath.endsWith("/") ? "" : "/")
+ artifactParentPath(artifact);
Node parentNode;
if (!jcrSession.itemExists(parentPath)) {
} else {
fileNode = parentNode.getNode(file.getName());
}
- processArtifact(fileNode, artifact);
+
+ if (artifactIndexer.support(fileNode.getPath()))
+ artifactIndexer.index(fileNode);
if (fileNode.isNodeType(SlcTypes.SLC_JAR_FILE)) {
processOsgiBundle(fileNode);
}
}
}
- protected void processArtifact(Node fileNode, Artifact artifact) {
- try {
- fileNode.addMixin(SlcTypes.SLC_ARTIFACT);
- 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_CLASSIFIER,
- artifact.getClassifier());
- } catch (RepositoryException e) {
- throw new SlcException("Cannot process artifact " + artifact
- + " on node " + fileNode, e);
- }
-
- }
-
protected File artifactToFile(Artifact artifact) {
return new File(System.getProperty("user.home")
+ File.separator