mirror of https://github.com/apache/archiva.git
Migrating to JCR primary types
This commit is contained in:
parent
81be348796
commit
a2dd2a16b8
|
@ -21,16 +21,10 @@ package org.apache.archiva.metadata.model;
|
|||
|
||||
import org.apache.archiva.checksum.ChecksumAlgorithm;
|
||||
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
|
||||
import sun.reflect.generics.repository.MethodRepository;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
|
@ -924,7 +924,7 @@ public abstract class AbstractMetadataRepositoryTest
|
|||
for (int i=0; i<10; i++) {
|
||||
assertEquals(TEST_NAME + "/" + String.format("%03d",i), result.get(i).getName());
|
||||
}
|
||||
}, 3, 500 );
|
||||
}, 5, 500 );
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -952,7 +952,7 @@ public abstract class AbstractMetadataRepositoryTest
|
|||
for (int i=0; i<10; i++) {
|
||||
assertEquals(TEST_NAME + "/" + String.format("%03d",i+5), result.get(i).getName());
|
||||
}
|
||||
}, 3, 500 );
|
||||
}, 5, 500 );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,9 @@ public interface JcrConstants
|
|||
String MIXIN_META_MAILINGLIST = "archiva:meta_mailinglist";
|
||||
String DEPENDENCY_NODE_TYPE = "archiva:dependency";
|
||||
String CHECKSUM_NODE_TYPE = "archiva:checksum";
|
||||
String CHECKSUMS_FOLDER_TYPE = "archiva:checksums";
|
||||
String FACETS_FOLDER_TYPE = "archiva:facets";
|
||||
String FACET_ID_CONTAINER_TYPE = "archiva:facetIdContainer";
|
||||
|
||||
// Must be alphabetically ordered!
|
||||
String[] PROJECT_VERSION_VERSION_PROPERTIES = {"ci.system","ci.url", "description", "incomplete", "issue.system","issue.url", "name", "org.name", "org.url", "url", "scm.connection", "scm.developerConnection", "scm.url"};
|
||||
|
|
|
@ -202,7 +202,7 @@ public class JcrMetadataRepository
|
|||
node.setProperty( "size", artifactMeta.getSize() );
|
||||
|
||||
int idx=0;
|
||||
Node cslistNode = getOrAddNodeByPath( node, "checksums" );
|
||||
Node cslistNode = getOrAddNodeByPath( node, "checksums", CHECKSUMS_FOLDER_TYPE, true );
|
||||
NodeIterator nit = cslistNode.getNodes("*");
|
||||
while (nit.hasNext()) {
|
||||
Node csNode = nit.nextNode();
|
||||
|
@ -234,8 +234,7 @@ public class JcrMetadataRepository
|
|||
if ( metadataFacet != null )
|
||||
{
|
||||
// recreate, to ensure properties are removed
|
||||
Node n = node.addNode( facetId);
|
||||
n.addMixin( FACET_NODE_TYPE );
|
||||
Node n = node.addNode( facetId, FACET_NODE_TYPE);
|
||||
n.setProperty( "facetId", facetId );
|
||||
|
||||
for ( Map.Entry<String, String> entry : metadataFacet.toProperties().entrySet() )
|
||||
|
@ -368,8 +367,7 @@ public class JcrMetadataRepository
|
|||
{
|
||||
versionNode.getNode( facet.getFacetId() ).remove();
|
||||
}
|
||||
Node n = versionNode.addNode( facet.getFacetId() );
|
||||
n.addMixin( FACET_NODE_TYPE );
|
||||
Node n = versionNode.addNode( facet.getFacetId(), FACET_NODE_TYPE );
|
||||
|
||||
for ( Map.Entry<String, String> entry : facet.toProperties().entrySet() )
|
||||
{
|
||||
|
@ -673,15 +671,17 @@ public class JcrMetadataRepository
|
|||
try
|
||||
{
|
||||
Node repo = getOrAddRepositoryNode( jcrSession, repositoryId );
|
||||
Node facets = JcrUtils.getOrAddNode( repo, "facets" );
|
||||
Node facets = JcrUtils.getOrAddNode( repo, "facets", FACETS_FOLDER_TYPE);
|
||||
|
||||
String id = metadataFacet.getFacetId();
|
||||
Node facetNode = JcrUtils.getOrAddNode( facets, id );
|
||||
Node facetNode = JcrUtils.getOrAddNode( facets, id, FACET_ID_CONTAINER_TYPE );
|
||||
if (!facetNode.hasProperty("id")) {
|
||||
facetNode.setProperty("id", id);
|
||||
}
|
||||
|
||||
Node facetInstance = getOrAddNodeByPath( facetNode, metadataFacet.getName() );
|
||||
if (!facetInstance.isNodeType( FACET_NODE_TYPE ))
|
||||
Node facetInstance = getOrAddNodeByPath( facetNode, metadataFacet.getName(), FACET_NODE_TYPE, true );
|
||||
if (!facetInstance.hasProperty( "archiva:facetId"))
|
||||
{
|
||||
facetInstance.addMixin( FACET_NODE_TYPE );
|
||||
facetInstance.setProperty( "archiva:facetId", id );
|
||||
facetInstance.setProperty( "archiva:name", metadataFacet.getName( ) );
|
||||
}
|
||||
|
@ -1796,17 +1796,25 @@ public class JcrMetadataRepository
|
|||
return getOrAddNodeByPath( baseNode, name, null );
|
||||
}
|
||||
|
||||
private Node getOrAddNodeByPath( Node baseNode, String name, String nodeType )
|
||||
private Node getOrAddNodeByPath( Node baseNode, String name, String nodeType ) throws RepositoryException {
|
||||
return getOrAddNodeByPath(baseNode, name, nodeType, false);
|
||||
}
|
||||
|
||||
private Node getOrAddNodeByPath( Node baseNode, String name, String nodeType, boolean primaryType )
|
||||
throws RepositoryException
|
||||
{
|
||||
log.debug( "getOrAddNodeByPath " + baseNode + " " + name + " " + nodeType );
|
||||
Node node = baseNode;
|
||||
for ( String n : name.split( "/" ) )
|
||||
{
|
||||
node = JcrUtils.getOrAddNode( node, n );
|
||||
if ( nodeType != null && !node.isNodeType( nodeType ))
|
||||
{
|
||||
node.addMixin( nodeType );
|
||||
if (nodeType!=null && primaryType) {
|
||||
node = JcrUtils.getOrAddNode( node, n, nodeType );
|
||||
} else {
|
||||
node = JcrUtils.getOrAddNode( node, n);
|
||||
if ( nodeType != null && !node.isNodeType( nodeType ))
|
||||
{
|
||||
node.addMixin( nodeType );
|
||||
}
|
||||
}
|
||||
if (!node.hasProperty( "id" )) {
|
||||
node.setProperty( "id", n );
|
||||
|
@ -1892,11 +1900,7 @@ public class JcrMetadataRepository
|
|||
throws RepositoryException
|
||||
{
|
||||
Node versionNode = getOrAddProjectVersionNode( jcrSession, repositoryId, namespace, projectId, projectVersion );
|
||||
Node node = JcrUtils.getOrAddNode( versionNode, id);
|
||||
if (!node.isNodeType( ARTIFACT_NODE_TYPE ))
|
||||
{
|
||||
node.addMixin( ARTIFACT_NODE_TYPE );
|
||||
}
|
||||
Node node = JcrUtils.getOrAddNode( versionNode, id, ARTIFACT_NODE_TYPE);
|
||||
if (!node.hasProperty( "id" )) {
|
||||
node.setProperty( "id", id );
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JCR OAK does not support same name siblings. Which means we have to
|
||||
* setup unique keys for list entries.
|
||||
*/
|
||||
<archiva = 'http://archiva.apache.org/jcr'>
|
||||
[archiva:base] abstract mixin
|
||||
- id (string)
|
||||
|
@ -24,6 +28,7 @@
|
|||
|
||||
[archiva:repository] > archiva:base mixin
|
||||
+ content (archiva:content) primary
|
||||
+ facets (nt:hierarchyNode)
|
||||
|
||||
[archiva:content] > archiva:base mixin
|
||||
+ * (archiva:namespace)
|
||||
|
@ -81,7 +86,8 @@
|
|||
[archiva:dependencies] mixin
|
||||
+ * (archiva:dependency)
|
||||
|
||||
[archiva:checksums]
|
||||
[archiva:checksums] > nt:hierarchyNode
|
||||
- id (string)
|
||||
+ * (archiva:checksum)
|
||||
|
||||
[archiva:checksum]
|
||||
|
@ -99,13 +105,23 @@
|
|||
+ * (archiva:dependencies)
|
||||
+ * (archiva:facet)
|
||||
|
||||
[archiva:artifact] > archiva:base mixin
|
||||
|
||||
|
||||
[archiva:artifact] > archiva:base
|
||||
- whenGathered (date)
|
||||
- size (long)
|
||||
- version (string)
|
||||
+ * (archiva:checksum)
|
||||
+ checksums (archiva:checksums)
|
||||
+ * (archiva:facet)
|
||||
|
||||
[archiva:facet] > archiva:base mixin
|
||||
[archiva:facets] > nt:hierarchyNode
|
||||
+ * (archiva:facetIdContainer)
|
||||
|
||||
[archiva:facetIdContainer] > archiva:base
|
||||
+ * (archiva:facet)
|
||||
|
||||
[archiva:facet] > archiva:base
|
||||
- archiva:facetId
|
||||
- archiva:name
|
||||
- archiva:name
|
||||
- * (string)
|
||||
+ * (archiva:facet)
|
||||
|
|
Loading…
Reference in New Issue