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();
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() )
{
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() )
{
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( ) );
}
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 );
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 );
}
* 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)
[archiva:repository] > archiva:base mixin
+ content (archiva:content) primary
+ + facets (nt:hierarchyNode)
[archiva:content] > archiva:base mixin
+ * (archiva:namespace)
[archiva:dependencies] mixin
+ * (archiva:dependency)
-[archiva:checksums]
+[archiva:checksums] > nt:hierarchyNode
+ - id (string)
+ * (archiva:checksum)
[archiva:checksum]
+ * (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
\ No newline at end of file
+ - archiva:name
+ - * (string)
+ + * (archiva:facet)