mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
- Incorporate JCR project into Repository project
- Single configuration entry point for JCR and non-JCR clients (i.e. application-context.xml) - Addition of build-war, incremental-war build targets (no deploy) - Remove build of JCR TCK war file by default git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2777 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* 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.alfresco.jcr.item.property;
|
||||
|
||||
import javax.jcr.RepositoryException;
|
||||
|
||||
import org.alfresco.jcr.dictionary.JCRNamespace;
|
||||
import org.alfresco.jcr.item.NodeImpl;
|
||||
import org.alfresco.jcr.item.PropertyImpl;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Implementation for mix:lockable lockIsDeep property
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class JCRLockIsDeepProperty extends PropertyImpl
|
||||
{
|
||||
public static QName PROPERTY_NAME = QName.createQName(JCRNamespace.JCR_URI, "lockIsDeep");
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
public JCRLockIsDeepProperty(NodeImpl node)
|
||||
{
|
||||
super(node, PROPERTY_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getPropertyValue() throws RepositoryException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* 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.alfresco.jcr.item.property;
|
||||
|
||||
import javax.jcr.RepositoryException;
|
||||
|
||||
import org.alfresco.jcr.dictionary.JCRNamespace;
|
||||
import org.alfresco.jcr.item.NodeImpl;
|
||||
import org.alfresco.jcr.item.PropertyImpl;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Implementation for mix:lockable lockOwner property
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class JCRLockOwnerProperty extends PropertyImpl
|
||||
{
|
||||
public static QName PROPERTY_NAME = QName.createQName(JCRNamespace.JCR_URI, "lockOwner");
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
public JCRLockOwnerProperty(NodeImpl node)
|
||||
{
|
||||
super(node, PROPERTY_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getPropertyValue() throws RepositoryException
|
||||
{
|
||||
NodeImpl nodeImpl = getNodeImpl();
|
||||
NodeService nodeService = nodeImpl.getSessionImpl().getRepositoryImpl().getServiceRegistry().getNodeService();
|
||||
String lockOwner = (String)nodeService.getProperty(nodeImpl.getNodeRef(), ContentModel.PROP_LOCK_OWNER);
|
||||
return lockOwner;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* 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.alfresco.jcr.item.property;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.jcr.RepositoryException;
|
||||
|
||||
import org.alfresco.jcr.dictionary.JCRNamespace;
|
||||
import org.alfresco.jcr.dictionary.NodeTypeImpl;
|
||||
import org.alfresco.jcr.item.NodeImpl;
|
||||
import org.alfresco.jcr.item.PropertyImpl;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Implementation for nt:base primaryType property
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class JCRMixinTypesProperty extends PropertyImpl
|
||||
{
|
||||
public static QName PROPERTY_NAME = QName.createQName(JCRNamespace.JCR_URI, "mixinTypes");
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
public JCRMixinTypesProperty(NodeImpl node)
|
||||
{
|
||||
super(node, PROPERTY_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getPropertyValue() throws RepositoryException
|
||||
{
|
||||
// get aspects from node
|
||||
NodeImpl nodeImpl = getNodeImpl();
|
||||
NodeService nodeService = nodeImpl.getSessionImpl().getRepositoryImpl().getServiceRegistry().getNodeService();
|
||||
Set<QName> aspects = nodeService.getAspects(nodeImpl.getNodeRef());
|
||||
|
||||
// resolve against session namespace prefix resolver
|
||||
List<String> aspectNames = new ArrayList<String>(aspects.size() + 1);
|
||||
for (QName aspect : aspects)
|
||||
{
|
||||
aspectNames.add(aspect.toPrefixString(nodeImpl.getSessionImpl().getNamespaceResolver()));
|
||||
}
|
||||
|
||||
// add JCR referenceable
|
||||
aspectNames.add(NodeTypeImpl.MIX_REFERENCEABLE.toPrefixString(nodeImpl.getSessionImpl().getNamespaceResolver()));
|
||||
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* 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.alfresco.jcr.item.property;
|
||||
|
||||
import javax.jcr.RepositoryException;
|
||||
|
||||
import org.alfresco.jcr.dictionary.JCRNamespace;
|
||||
import org.alfresco.jcr.item.NodeImpl;
|
||||
import org.alfresco.jcr.item.PropertyImpl;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Implementation for nt:base primaryType property
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class JCRPrimaryTypeProperty extends PropertyImpl
|
||||
{
|
||||
public static QName PROPERTY_NAME = QName.createQName(JCRNamespace.JCR_URI, "primaryType");
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
public JCRPrimaryTypeProperty(NodeImpl node)
|
||||
{
|
||||
super(node, PROPERTY_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getPropertyValue() throws RepositoryException
|
||||
{
|
||||
NodeImpl nodeImpl = getNodeImpl();
|
||||
NodeService nodeService = nodeImpl.getSessionImpl().getRepositoryImpl().getServiceRegistry().getNodeService();
|
||||
QName type = nodeService.getType(nodeImpl.getNodeRef());
|
||||
return type.toPrefixString(nodeImpl.getSessionImpl().getNamespaceResolver());
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* 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.alfresco.jcr.item.property;
|
||||
|
||||
import javax.jcr.RepositoryException;
|
||||
|
||||
import org.alfresco.jcr.dictionary.JCRNamespace;
|
||||
import org.alfresco.jcr.item.NodeImpl;
|
||||
import org.alfresco.jcr.item.PropertyImpl;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation for mix:referenceable uuid property
|
||||
|
||||
* @author David Caruana
|
||||
*
|
||||
*/
|
||||
public class JCRUUIDProperty extends PropertyImpl
|
||||
{
|
||||
public static QName PROPERTY_NAME = QName.createQName(JCRNamespace.JCR_URI, "uuid");
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
public JCRUUIDProperty(NodeImpl node)
|
||||
{
|
||||
super(node, PROPERTY_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getPropertyValue() throws RepositoryException
|
||||
{
|
||||
NodeImpl node = getNodeImpl();
|
||||
return node.getNodeRef().getId();
|
||||
}
|
||||
|
||||
}
|
204
source/java/org/alfresco/jcr/item/property/PropertyResolver.java
Normal file
204
source/java/org/alfresco/jcr/item/property/PropertyResolver.java
Normal file
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* 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.alfresco.jcr.item.property;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jcr.PathNotFoundException;
|
||||
|
||||
import org.alfresco.jcr.item.NodeImpl;
|
||||
import org.alfresco.jcr.item.PropertyImpl;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.QNamePattern;
|
||||
|
||||
|
||||
/**
|
||||
* Responsible for resolving properties on Nodes
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class PropertyResolver
|
||||
{
|
||||
|
||||
private static Map<QName, QName> virtualProperties = new HashMap<QName, QName>();
|
||||
static
|
||||
{
|
||||
virtualProperties.put(JCRUUIDProperty.PROPERTY_NAME, null);
|
||||
virtualProperties.put(JCRPrimaryTypeProperty.PROPERTY_NAME, null);
|
||||
virtualProperties.put(JCRMixinTypesProperty.PROPERTY_NAME, null);
|
||||
virtualProperties.put(JCRLockOwnerProperty.PROPERTY_NAME, ContentModel.ASPECT_LOCKABLE);
|
||||
virtualProperties.put(JCRLockIsDeepProperty.PROPERTY_NAME, ContentModel.ASPECT_LOCKABLE);
|
||||
|
||||
// TODO: mix:versionable
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create Property List for all properties of this node
|
||||
*
|
||||
* @return list of properties (null properties are filtered)
|
||||
*/
|
||||
public static List<PropertyImpl> createProperties(NodeImpl node, QNamePattern pattern)
|
||||
{
|
||||
// Create list of properties from node itself
|
||||
NodeService nodeService = node.getSessionImpl().getRepositoryImpl().getServiceRegistry().getNodeService();
|
||||
Map<QName, Serializable> properties = nodeService.getProperties(node.getNodeRef());
|
||||
List<PropertyImpl> propertyList = new ArrayList<PropertyImpl>(properties.size());
|
||||
for (Map.Entry<QName, Serializable> entry : properties.entrySet())
|
||||
{
|
||||
QName propertyName = entry.getKey();
|
||||
if (pattern == null || pattern.isMatch(propertyName))
|
||||
{
|
||||
Serializable value = entry.getValue();
|
||||
if (value != null)
|
||||
{
|
||||
PropertyImpl property = new PropertyImpl(node, propertyName);
|
||||
propertyList.add(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add JCR properties
|
||||
for (Map.Entry<QName, QName> virtualProperty : virtualProperties.entrySet())
|
||||
{
|
||||
boolean addJCRProperty = false;
|
||||
if (virtualProperty.getValue() == null)
|
||||
{
|
||||
addJCRProperty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
addJCRProperty = nodeService.hasAspect(node.getNodeRef(), virtualProperty.getValue());
|
||||
}
|
||||
|
||||
if (addJCRProperty && (pattern == null || pattern.isMatch(virtualProperty.getKey())))
|
||||
{
|
||||
propertyList.add(createVirtualProperty(node, virtualProperty.getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
return propertyList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create property for the given named property
|
||||
*
|
||||
* @param node
|
||||
* @param propertyName
|
||||
* @return
|
||||
* @throws PathNotFoundException
|
||||
*/
|
||||
public static PropertyImpl createProperty(NodeImpl node, QName propertyName)
|
||||
throws PathNotFoundException
|
||||
{
|
||||
// has a JCR property been requested that is not persisted in Alfresco repository?
|
||||
if (hasVirtualProperty(node, propertyName))
|
||||
{
|
||||
return createVirtualProperty(node, propertyName);
|
||||
}
|
||||
|
||||
// has a property been requested that actually exists?
|
||||
NodeService nodeService = node.getSessionImpl().getRepositoryImpl().getServiceRegistry().getNodeService();
|
||||
Serializable value = nodeService.getProperty(node.getNodeRef(), propertyName);
|
||||
if (value == null)
|
||||
{
|
||||
throw new PathNotFoundException("Property path " + propertyName + " not found from node " + node.getNodeRef());
|
||||
}
|
||||
|
||||
// construct property wrapper
|
||||
PropertyImpl propertyImpl = new PropertyImpl(node, propertyName);
|
||||
return propertyImpl;
|
||||
}
|
||||
|
||||
|
||||
private static PropertyImpl createVirtualProperty(NodeImpl node, QName propertyName)
|
||||
{
|
||||
if (propertyName.equals(JCRUUIDProperty.PROPERTY_NAME))
|
||||
{
|
||||
return new JCRUUIDProperty(node);
|
||||
}
|
||||
if (propertyName.equals(JCRPrimaryTypeProperty.PROPERTY_NAME))
|
||||
{
|
||||
return new JCRPrimaryTypeProperty(node);
|
||||
}
|
||||
if (propertyName.equals(JCRMixinTypesProperty.PROPERTY_NAME))
|
||||
{
|
||||
return new JCRMixinTypesProperty(node);
|
||||
}
|
||||
if (propertyName.equals(JCRLockOwnerProperty.PROPERTY_NAME))
|
||||
{
|
||||
return new JCRLockOwnerProperty(node);
|
||||
}
|
||||
if (propertyName.equals(JCRLockIsDeepProperty.PROPERTY_NAME))
|
||||
{
|
||||
return new JCRLockIsDeepProperty(node);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for existence of Property on specified Node
|
||||
*
|
||||
* @param node
|
||||
* @param propertyName
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasProperty(NodeImpl node, QName propertyName)
|
||||
{
|
||||
if (hasVirtualProperty(node, propertyName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
NodeService nodeService = node.getSessionImpl().getRepositoryImpl().getServiceRegistry().getNodeService();
|
||||
Serializable value = nodeService.getProperty(node.getNodeRef(), propertyName);
|
||||
return value != null;
|
||||
}
|
||||
|
||||
|
||||
private static boolean hasVirtualProperty(NodeImpl node, QName propertyName)
|
||||
{
|
||||
// is this a virtual property
|
||||
if (virtualProperties.containsKey(propertyName))
|
||||
{
|
||||
// is this a virtual property attached to a specific aspect
|
||||
QName aspect = virtualProperties.get(propertyName);
|
||||
if (aspect == null)
|
||||
{
|
||||
// it's supported on all types
|
||||
return true;
|
||||
}
|
||||
|
||||
// is the aspect attached to the node
|
||||
NodeService nodeService = node.getSessionImpl().getRepositoryImpl().getServiceRegistry().getNodeService();
|
||||
return nodeService.hasAspect(node.getNodeRef(), aspect);
|
||||
}
|
||||
|
||||
// no, it's not even a virtual property
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user