mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge from SEAMIST3
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10735 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,6 +26,8 @@ package org.apache.abdera.ext.cmis;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.apache.abdera.util.Constants;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Namespace definitions for the Abdera ATOM library.
|
||||
@@ -41,10 +43,22 @@ import javax.xml.namespace.QName;
|
||||
*/
|
||||
public interface CMISConstants
|
||||
{
|
||||
// Namespace
|
||||
public static final String CMIS_200805_NS = "http://www.cmis.org/2008/05";
|
||||
|
||||
// Mimetypes
|
||||
public static final String MIMETYPE_QUERY = "application/cmisquery+xml";
|
||||
public static final String MIMETYPE_ALLOWABLEACTIONS = "application/cmisallowableactions+xml";
|
||||
|
||||
// CMIS Service Document
|
||||
public static final QName COLLECTION_TYPE = new QName(CMIS_200805_NS, "collectionType");
|
||||
public static final String COLLECTION_ROOT_CHILDREN = "root-children";
|
||||
public static final String COLLECTION_ROOT_DESCENDANTS = "root-descendants";
|
||||
public static final String COLLECTION_CHECKEDOUT = "checkedout";
|
||||
public static final String COLLECTION_UNFILED = "unfiled";
|
||||
public static final String COLLECTION_TYPES_CHILDREN = "types-children";
|
||||
public static final String COLLECTION_TYPES_DESCENDANTS = "types-descendants";
|
||||
public static final String COLLECTION_QUERY = "query";
|
||||
|
||||
// CMIS Repository Info
|
||||
public static final QName REPOSITORY_INFO = new QName(CMIS_200805_NS, "repositoryInfo");
|
||||
@@ -67,35 +81,60 @@ public interface CMISConstants
|
||||
public static final QName CAPABILITY_JOIN = new QName(CMIS_200805_NS, "capabilityJoin");
|
||||
public static final QName CAPABILITY_FULLTEXT = new QName(CMIS_200805_NS, "capabilityFullText");
|
||||
|
||||
// CMIS Schema
|
||||
// CMIS Object
|
||||
public static final QName OBJECT = new QName(CMIS_200805_NS, "object");
|
||||
public static final QName PROPERTIES = new QName(CMIS_200805_NS, "properties");
|
||||
public static final QName PROPERTY_STRING = new QName(CMIS_200805_NS, "propertyString");
|
||||
public static final QName PROPERTY_ID = new QName(CMIS_200805_NS, "propertyID");
|
||||
public static final QName PROPERTY_BOOLEAN = new QName(CMIS_200805_NS, "propertyBoolean");
|
||||
public static final QName PROPERTY_NAME = new QName(CMIS_200805_NS, "name");
|
||||
|
||||
// CMIS Properties
|
||||
public static final String PROP_NAME = "name";
|
||||
public static final String PROP_OBJECT_ID = "objectId";
|
||||
public static final String PROP_BASETYPE = "baseType";
|
||||
public static final String PROP_OBJECT_TYPE = "objectType";
|
||||
public static final String PROP_IS_IMMUTABLE = "isImmutable";
|
||||
public static final String PROP_IS_LATEST_VERSION = "isLatestVersion";
|
||||
public static final String PROP_IS_MAJOR_VERSION = "isMajorVersion";
|
||||
public static final String PROP_IS_LATEST_MAJOR_VERSION = "isLatestMajorVersion";
|
||||
public static final String PROP_VERSION_LABEL = "versionLabel";
|
||||
public static final String PROP_VERSION_SERIES_ID = "versionSeriesID";
|
||||
public static final String PROP_VERSION_SERIES_IS_CHECKED_OUT = "isVersionSeriesCheckedOut";
|
||||
public static final String PROP_VERSION_SERIES_CHECKED_OUT_BY = "versionSeriesCheckedOutBy";
|
||||
public static final String PROP_VERSION_SERIES_CHECKED_OUT_ID = "versionSeriesCheckedOutID";
|
||||
public static final String PROP_CHECKIN_COMMENT = "checkinComment";
|
||||
|
||||
public static final QName PROPERTY_VALUE = new QName(CMIS_200805_NS, "value");
|
||||
public static final QName PROPERTY_STRING = new QName(CMIS_200805_NS, "propertyString");
|
||||
public static final QName PROPERTY_DECIMAL = new QName(CMIS_200805_NS, "propertyDecimal");
|
||||
public static final QName PROPERTY_INTEGER = new QName(CMIS_200805_NS, "propertyInteger");
|
||||
public static final QName PROPERTY_BOOLEAN = new QName(CMIS_200805_NS, "propertyBoolean");
|
||||
public static final QName PROPERTY_DATETIME = new QName(CMIS_200805_NS, "propertyDateTime");
|
||||
public static final QName PROPERTY_URI = new QName(CMIS_200805_NS, "propertyUri");
|
||||
public static final QName PROPERTY_ID = new QName(CMIS_200805_NS, "propertyId");
|
||||
public static final QName PROPERTY_XML = new QName(CMIS_200805_NS, "propertyXml");
|
||||
public static final QName PROPERTY_HTML = new QName(CMIS_200805_NS, "propertyHtml");
|
||||
|
||||
// CMIS Relationships
|
||||
public static final String REL_CHILDREN = "cmis-children";
|
||||
public static final String REL_DESCENDANTS = "cmis-descendants";
|
||||
public static final String REL_PARENT = "cmis-parent";
|
||||
public static final String REL_FOLDERPARENT = "cmis-folderparent";
|
||||
public static final String REL_PARENTS = "cmis-parents";
|
||||
public static final String REL_ALLVERSIONS = "cmis-allversions";
|
||||
public static final String REL_TYPE = "cmis-type";
|
||||
public static final String REL_SOURCE = "cmis-source";
|
||||
|
||||
// CMIS Nested Entry
|
||||
public static final QName NESTED_ENTRY = Constants.ENTRY;
|
||||
|
||||
|
||||
// CMIS Properties Names
|
||||
public static final String PROP_NAME = "Name";
|
||||
public static final String PROP_OBJECT_ID = "ObjectId";
|
||||
public static final String PROP_BASETYPE = "BaseType";
|
||||
public static final String PROP_OBJECT_TYPE_ID = "ObjectTypeId";
|
||||
public static final String PROP_IS_IMMUTABLE = "IsImmutable";
|
||||
public static final String PROP_IS_LATEST_VERSION = "IsLatestVersion";
|
||||
public static final String PROP_IS_MAJOR_VERSION = "IsMajorVersion";
|
||||
public static final String PROP_IS_LATEST_MAJOR_VERSION = "IsLatestMajorVersion";
|
||||
public static final String PROP_VERSION_LABEL = "VersionLabel";
|
||||
public static final String PROP_VERSION_SERIES_ID = "VersionSeriesId";
|
||||
public static final String PROP_IS_VERSION_SERIES_CHECKED_OUT = "IsVersionSeriesCheckedOut";
|
||||
public static final String PROP_VERSION_SERIES_CHECKED_OUT_BY = "VersionSeriesCheckedOutBy";
|
||||
public static final String PROP_VERSION_SERIES_CHECKED_OUT_ID = "VersionSeriesCheckedOutId";
|
||||
public static final String PROP_CHECKIN_COMMENT = "CheckinComment";
|
||||
|
||||
// CMIS Property Types
|
||||
public static final String PROP_TYPE_STRING = "string";
|
||||
public static final String PROP_TYPE_DECIMAL = "decimal";
|
||||
public static final String PROP_TYPE_INTEGER = "integer";
|
||||
public static final String PROP_TYPE_BOOLEAN = "boolean";
|
||||
public static final String PROP_TYPE_DATETIME = "datetime";
|
||||
public static final String PROP_TYPE_URI = "uri";
|
||||
public static final String PROP_TYPE_ID = "id";
|
||||
public static final String PROP_TYPE_XML = "xml";
|
||||
public static final String PROP_TYPE_HTML = "html";
|
||||
|
||||
}
|
||||
|
@@ -24,6 +24,15 @@
|
||||
*/
|
||||
package org.apache.abdera.ext.cmis;
|
||||
|
||||
import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyBoolean;
|
||||
import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyDateTime;
|
||||
import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyDecimal;
|
||||
import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyHtml;
|
||||
import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyId;
|
||||
import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyInteger;
|
||||
import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString;
|
||||
import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyUri;
|
||||
import org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyXml;
|
||||
import org.apache.abdera.util.AbstractExtensionFactory;
|
||||
|
||||
|
||||
@@ -48,7 +57,17 @@ public class CMISExtensionFactory extends AbstractExtensionFactory
|
||||
super(CMIS_200805_NS);
|
||||
addImpl(REPOSITORY_INFO, CMISRepositoryInfo.class);
|
||||
addImpl(CAPABILITIES, CMISCapabilities.class);
|
||||
addImpl(OBJECT, CMISObject.class);
|
||||
addImpl(PROPERTIES, CMISProperties.class);
|
||||
addImpl(PROPERTY_STRING, CMISPropertyString.class);
|
||||
addImpl(PROPERTY_DECIMAL, CMISPropertyDecimal.class);
|
||||
addImpl(PROPERTY_INTEGER, CMISPropertyInteger.class);
|
||||
addImpl(PROPERTY_BOOLEAN, CMISPropertyBoolean.class);
|
||||
addImpl(PROPERTY_DATETIME, CMISPropertyDateTime.class);
|
||||
addImpl(PROPERTY_URI, CMISPropertyUri.class);
|
||||
addImpl(PROPERTY_ID, CMISPropertyId.class);
|
||||
addImpl(PROPERTY_XML, CMISPropertyXml.class);
|
||||
addImpl(PROPERTY_HTML, CMISPropertyHtml.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
217
source/java/org/apache/abdera/ext/cmis/CMISObject.java
Normal file
217
source/java/org/apache/abdera/ext/cmis/CMISObject.java
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.apache.abdera.ext.cmis;
|
||||
|
||||
import org.apache.abdera.factory.Factory;
|
||||
import org.apache.abdera.model.Element;
|
||||
import org.apache.abdera.model.ExtensibleElementWrapper;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Object for the Abdera ATOM library.
|
||||
*
|
||||
* Encapsulates access and modification of CMIS extension values to CMIS
|
||||
* Object.
|
||||
*
|
||||
* NOTE: Potentially, this extension can be contributed to Abdera upon
|
||||
* publication of CMIS. This is why it is organised under a
|
||||
* non-Alfresco Java package. It follows the conventions of all
|
||||
* other Abdera extensions.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISObject extends ExtensibleElementWrapper
|
||||
{
|
||||
/**
|
||||
* @param internal
|
||||
*/
|
||||
public CMISObject(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param factory
|
||||
*/
|
||||
public CMISObject(Factory factory)
|
||||
{
|
||||
super(factory, CMISConstants.OBJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all Properties for this CMIS Object
|
||||
*
|
||||
* @return properties
|
||||
*/
|
||||
public CMISProperties getProperties()
|
||||
{
|
||||
Element child = getFirstChild(CMISConstants.PROPERTIES);
|
||||
if (child == null)
|
||||
{
|
||||
child = addExtension(CMISConstants.PROPERTIES);
|
||||
}
|
||||
return (CMISProperties)child;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name
|
||||
*
|
||||
* @return name property
|
||||
*/
|
||||
public CMISProperty getName()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets id
|
||||
*
|
||||
* @return id property
|
||||
*/
|
||||
public CMISProperty getObjectId()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_OBJECT_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets base type
|
||||
*
|
||||
* @return base type property
|
||||
*/
|
||||
public CMISProperty getBaseType()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_BASETYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets object type
|
||||
*
|
||||
* @return object type property
|
||||
*/
|
||||
public CMISProperty getObjectTypeId()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_OBJECT_TYPE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is immutable?
|
||||
*
|
||||
* @return isImmutable property
|
||||
*/
|
||||
public CMISProperty isImmutable()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_IS_IMMUTABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Latest Version
|
||||
*
|
||||
* @return latest version property
|
||||
*/
|
||||
public CMISProperty isLatestVersion()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_IS_LATEST_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Major Version?
|
||||
*
|
||||
* @return is major version property
|
||||
*/
|
||||
public CMISProperty isMajorVersion()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_IS_MAJOR_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Latest Major Version?
|
||||
*
|
||||
* @return is latest major version property
|
||||
*/
|
||||
public CMISProperty isLatestMajorVersion()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_IS_LATEST_MAJOR_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version label
|
||||
*
|
||||
* @return version label property
|
||||
*/
|
||||
public CMISProperty getVersionLabel()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_VERSION_LABEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version series id
|
||||
*
|
||||
* @return version series id property
|
||||
*/
|
||||
public CMISProperty getVersionSeriesId()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_VERSION_SERIES_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version Series Checked Out
|
||||
*
|
||||
* @return version series checked out property
|
||||
*/
|
||||
public CMISProperty isVersionSeriesCheckedOut()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_IS_VERSION_SERIES_CHECKED_OUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version Series Checked Out By
|
||||
*
|
||||
* @return version series checked out by property
|
||||
*/
|
||||
public CMISProperty getVersionSeriesCheckedOutBy()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_BY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version Series Checked Out Id
|
||||
*
|
||||
* @return version series checked out id property
|
||||
*/
|
||||
public CMISProperty getVersionSeriesCheckedOutId()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkin Comment
|
||||
*
|
||||
* @return checkin comment property
|
||||
*/
|
||||
public CMISProperty getCheckinComment()
|
||||
{
|
||||
return getProperties().find(CMISConstants.PROP_CHECKIN_COMMENT);
|
||||
}
|
||||
}
|
@@ -24,13 +24,16 @@
|
||||
*/
|
||||
package org.apache.abdera.ext.cmis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.abdera.factory.Factory;
|
||||
import org.apache.abdera.model.Element;
|
||||
import org.apache.abdera.model.ElementWrapper;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Object Element Wrapper for the Abdera ATOM library.
|
||||
* CMIS Properties Element Wrapper for the Abdera ATOM library.
|
||||
*
|
||||
* Encapsulates access and modification of CMIS extension values to ATOM.
|
||||
*
|
||||
@@ -43,128 +46,59 @@ import org.apache.abdera.model.ElementWrapper;
|
||||
*/
|
||||
public class CMISProperties extends ElementWrapper
|
||||
{
|
||||
/**
|
||||
* @param internal
|
||||
*/
|
||||
public CMISProperties(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param factory
|
||||
*/
|
||||
public CMISProperties(Factory factory)
|
||||
{
|
||||
super(factory, CMISConstants.PROPERTIES);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
/**
|
||||
* Gets all property names
|
||||
*
|
||||
* @return list of property names
|
||||
*/
|
||||
public List<String> getNames()
|
||||
{
|
||||
return findPropertyString(CMISConstants.PROP_NAME);
|
||||
}
|
||||
|
||||
public String getObjectId()
|
||||
{
|
||||
return findPropertyID(CMISConstants.PROP_OBJECT_ID);
|
||||
}
|
||||
|
||||
public String getBaseType()
|
||||
{
|
||||
return findPropertyString(CMISConstants.PROP_BASETYPE);
|
||||
}
|
||||
|
||||
public String getObjectType()
|
||||
{
|
||||
return findPropertyString(CMISConstants.PROP_OBJECT_TYPE);
|
||||
}
|
||||
|
||||
public boolean isImmutable()
|
||||
{
|
||||
return findPropertyBoolean(CMISConstants.PROP_IS_IMMUTABLE);
|
||||
}
|
||||
|
||||
public boolean isLatestVersion()
|
||||
{
|
||||
return findPropertyBoolean(CMISConstants.PROP_IS_LATEST_VERSION);
|
||||
}
|
||||
|
||||
public boolean isMajorVersion()
|
||||
{
|
||||
return findPropertyBoolean(CMISConstants.PROP_IS_MAJOR_VERSION);
|
||||
}
|
||||
|
||||
public boolean isLatestMajorVersion()
|
||||
{
|
||||
return findPropertyBoolean(CMISConstants.PROP_IS_LATEST_MAJOR_VERSION);
|
||||
}
|
||||
|
||||
public String getVersionLabel()
|
||||
{
|
||||
return findPropertyString(CMISConstants.PROP_VERSION_LABEL);
|
||||
}
|
||||
|
||||
public String getVersionSeriesId()
|
||||
{
|
||||
return findPropertyID(CMISConstants.PROP_VERSION_SERIES_ID);
|
||||
}
|
||||
|
||||
public boolean isVersionSeriesCheckedOut()
|
||||
{
|
||||
return findPropertyBoolean(CMISConstants.PROP_VERSION_SERIES_IS_CHECKED_OUT);
|
||||
}
|
||||
|
||||
public String getVersionSeriesCheckedOutBy()
|
||||
{
|
||||
return findPropertyString(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_BY);
|
||||
}
|
||||
|
||||
public String getVersionSeriesCheckedOutId()
|
||||
{
|
||||
return findPropertyID(CMISConstants.PROP_VERSION_SERIES_CHECKED_OUT_ID);
|
||||
}
|
||||
|
||||
public String getCheckinComment()
|
||||
{
|
||||
return findPropertyString(CMISConstants.PROP_CHECKIN_COMMENT);
|
||||
}
|
||||
|
||||
|
||||
public String findPropertyString(String name)
|
||||
{
|
||||
Element child = getFirstChild(CMISConstants.PROPERTY_STRING);
|
||||
while(child != null)
|
||||
List<CMISProperty> props = getElements();
|
||||
List<String> names = new ArrayList<String>(props.size());
|
||||
for (CMISProperty prop : props)
|
||||
{
|
||||
if (name.equals(child.getAttributeValue(CMISConstants.PROPERTY_NAME)))
|
||||
names.add(prop.getName());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds property by name
|
||||
*
|
||||
* @param name property name
|
||||
* @return property
|
||||
*/
|
||||
public CMISProperty find(String name)
|
||||
{
|
||||
List<Element> elements = getElements();
|
||||
for (Element element : elements)
|
||||
{
|
||||
if (element instanceof CMISProperty)
|
||||
{
|
||||
return child.getText();
|
||||
CMISProperty prop = (CMISProperty)element;
|
||||
if (prop.getName().equals(name))
|
||||
{
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling(CMISConstants.PROPERTY_STRING);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String findPropertyID(String name)
|
||||
{
|
||||
Element child = getFirstChild(CMISConstants.PROPERTY_ID);
|
||||
while(child != null)
|
||||
{
|
||||
if (name.equals(child.getAttributeValue(CMISConstants.PROPERTY_NAME)))
|
||||
{
|
||||
return child.getText();
|
||||
}
|
||||
child = child.getNextSibling(CMISConstants.PROPERTY_ID);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean findPropertyBoolean(String name)
|
||||
{
|
||||
Element child = getFirstChild(CMISConstants.PROPERTY_BOOLEAN);
|
||||
while(child != null)
|
||||
{
|
||||
if (name.equals(child.getAttributeValue(CMISConstants.PROPERTY_NAME)))
|
||||
{
|
||||
return Boolean.valueOf(child.getText());
|
||||
}
|
||||
child = child.getNextSibling(CMISConstants.PROPERTY_BOOLEAN);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
387
source/java/org/apache/abdera/ext/cmis/CMISProperty.java
Normal file
387
source/java/org/apache/abdera/ext/cmis/CMISProperty.java
Normal file
@@ -0,0 +1,387 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.apache.abdera.ext.cmis;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.apache.abdera.factory.Factory;
|
||||
import org.apache.abdera.model.Element;
|
||||
import org.apache.abdera.model.ElementWrapper;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Property for the Abdera ATOM library.
|
||||
*
|
||||
* Encapsulates access and modification of CMIS extension values to CMIS
|
||||
* Property.
|
||||
*
|
||||
* NOTE: Potentially, this extension can be contributed to Abdera upon
|
||||
* publication of CMIS. This is why it is organised under a
|
||||
* non-Alfresco Java package. It follows the conventions of all
|
||||
* other Abdera extensions.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public abstract class CMISProperty extends ElementWrapper
|
||||
{
|
||||
/**
|
||||
* @param internal
|
||||
*/
|
||||
public CMISProperty(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param factory
|
||||
* @param qname
|
||||
*/
|
||||
public CMISProperty(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property type
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public abstract String getType();
|
||||
|
||||
/**
|
||||
* Gets the property name
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getAttributeValue(CMISConstants.PROPERTY_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is property value null?
|
||||
*
|
||||
* @return true => null
|
||||
*/
|
||||
public boolean isNull()
|
||||
{
|
||||
return getFirstChild(CMISConstants.PROPERTY_VALUE) == null ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets property value (as String)
|
||||
*
|
||||
* @return property value (or null, if not specified)
|
||||
*/
|
||||
public String getValue()
|
||||
{
|
||||
Element child = getFirstChild(CMISConstants.PROPERTY_VALUE);
|
||||
if (child != null)
|
||||
{
|
||||
return child.getText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets String value
|
||||
*
|
||||
* @return string value
|
||||
*/
|
||||
public String getStringValue()
|
||||
{
|
||||
return getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Decimal value
|
||||
*
|
||||
* @return decimal value
|
||||
*/
|
||||
public BigDecimal getDecimalValue()
|
||||
{
|
||||
return new BigDecimal(getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Integer value
|
||||
*
|
||||
* @return integer value
|
||||
*/
|
||||
public int getIntegerValue()
|
||||
{
|
||||
return new Integer(getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Boolean value
|
||||
*
|
||||
* @return boolean value
|
||||
*/
|
||||
public boolean getBooleanValue()
|
||||
{
|
||||
return Boolean.valueOf(getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Date value
|
||||
*
|
||||
* @return date value
|
||||
*/
|
||||
public Date getDateValue()
|
||||
{
|
||||
// TODO:
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* String Property
|
||||
*/
|
||||
public static class CMISPropertyString extends CMISProperty
|
||||
{
|
||||
public CMISPropertyString(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
public CMISPropertyString(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.abdera.ext.cmis.CMISProperty#getType()
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return CMISConstants.PROP_TYPE_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decimal Property
|
||||
*/
|
||||
public static class CMISPropertyDecimal extends CMISProperty
|
||||
{
|
||||
public CMISPropertyDecimal(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
public CMISPropertyDecimal(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.abdera.ext.cmis.CMISProperty#getType()
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return CMISConstants.PROP_TYPE_DECIMAL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Integer Property
|
||||
*/
|
||||
public static class CMISPropertyInteger extends CMISProperty
|
||||
{
|
||||
public CMISPropertyInteger(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
public CMISPropertyInteger(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.abdera.ext.cmis.CMISProperty#getType()
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return CMISConstants.PROP_TYPE_INTEGER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Boolean Property
|
||||
*/
|
||||
public static class CMISPropertyBoolean extends CMISProperty
|
||||
{
|
||||
public CMISPropertyBoolean(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
public CMISPropertyBoolean(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.abdera.ext.cmis.CMISProperty#getType()
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return CMISConstants.PROP_TYPE_BOOLEAN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DateTime Property
|
||||
*/
|
||||
public static class CMISPropertyDateTime extends CMISProperty
|
||||
{
|
||||
public CMISPropertyDateTime(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
public CMISPropertyDateTime(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.abdera.ext.cmis.CMISProperty#getType()
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return CMISConstants.PROP_TYPE_DATETIME;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* URI Property
|
||||
*/
|
||||
public static class CMISPropertyUri extends CMISPropertyString
|
||||
{
|
||||
public CMISPropertyUri(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
public CMISPropertyUri(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString#getType()
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return CMISConstants.PROP_TYPE_URI;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ID Property
|
||||
*/
|
||||
public static class CMISPropertyId extends CMISPropertyString
|
||||
{
|
||||
public CMISPropertyId(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
public CMISPropertyId(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString#getType()
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return CMISConstants.PROP_TYPE_ID;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* XML Property
|
||||
*/
|
||||
public static class CMISPropertyXml extends CMISPropertyString
|
||||
{
|
||||
public CMISPropertyXml(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
public CMISPropertyXml(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString#getType()
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return CMISConstants.PROP_TYPE_XML;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML Property
|
||||
*/
|
||||
public static class CMISPropertyHtml extends CMISPropertyString
|
||||
{
|
||||
public CMISPropertyHtml(Element internal)
|
||||
{
|
||||
super(internal);
|
||||
}
|
||||
|
||||
public CMISPropertyHtml(Factory factory, QName qname)
|
||||
{
|
||||
super(factory, qname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.abdera.ext.cmis.CMISProperty.CMISPropertyString#getType()
|
||||
*/
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return CMISConstants.PROP_TYPE_HTML;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user