/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
using System;
using System.Reflection;
namespace PortCMIS.Enums
{
///
/// Base Type ID.
///
public enum BaseTypeId
{
///
/// CMIS Document Type.
///
[CmisValue("cmis:document")]
CmisDocument,
///
/// CMIS Folder Type.
///
[CmisValue("cmis:folder")]
CmisFolder,
///
/// CMIS Relationship Type.
///
[CmisValue("cmis:relationship")]
CmisRelationship,
///
/// CMIS Policy Type.
///
[CmisValue("cmis:policy")]
CmisPolicy,
///
/// CMIS Item Type.
///
[CmisValue("cmis:item")]
CmisItem,
///
/// CMIS Secondary Type.
///
[CmisValue("cmis:secondary")]
CmisSecondary
}
///
/// Repository Capability: Content Stream Updates
///
public enum CapabilityContentStreamUpdates
{
///
/// Content can be updated at any time.
///
[CmisValue("anytime")]
Anyime,
///
/// Only the content on PWCs can be updated.
///
[CmisValue("pwconly")]
PWCOnly,
///
/// Content cannot be updated.
///
[CmisValue("none")]
None
}
///
/// Repository Capability: Content Changes.
///
public enum CapabilityChanges
{
///
/// Change log is not supported.
///
[CmisValue("none")]
None,
///
/// The change log only contains object IDs.
///
[CmisValue("objectidsonly")]
ObjectIdsOnly,
///
/// The change log only contains properties.
///
[CmisValue("properties")]
Properties,
///
/// The change log only contains everything.
///
[CmisValue("all")]
All
}
///
/// Repository Capability: Renditions.
///
public enum CapabilityRenditions
{
///
/// Renditions are not supported.
///
[CmisValue("none")]
None,
///
/// Renditions can be read.
///
[CmisValue("read")]
Read
}
///
/// Repository Capability: Query.
///
public enum CapabilityQuery
{
///
/// Query is not supported.
///
[CmisValue("none")]
None,
///
/// Only metadata queries are supported.
///
[CmisValue("metadataonly")]
MetadataOnly,
///
/// Only fulltext queries are supported.
///
[CmisValue("fulltextonly")]
FulltextOnly,
///
/// Metadata and fulltext queries are supported but only separately.
///
[CmisValue("bothseparate")]
BothSeparate,
///
/// Metadata and fulltext queries are supported.
///
[CmisValue("bothcombined")]
BothCombined
}
///
/// Repository Capability: Query Joins.
///
public enum CapabilityJoin
{
///
/// Joins are not supported.
///
[CmisValue("none")]
None,
///
/// Only inner joins are supported.
///
[CmisValue("inneronly")]
InnerOnly,
///
/// Inner and outer joins are supported.
///
[CmisValue("innerandouter")]
InnerAndOuter
}
///
/// Repository Capability: ACL.
///
public enum CapabilityAcl
{
///
/// ACLs are not supported.
///
[CmisValue("none")]
None,
///
/// ACLs can be discovered.
///
[CmisValue("discover")]
Discover,
///
/// ACLs can be managed.
///
[CmisValue("manage")]
Manage
}
///
/// Repository Capability: Order by.
///
public enum CapabilityOrderBy
{
///
/// Order by is not supported.
///
[CmisValue("none")]
None,
///
/// Order by is supported for common properties.
///
[CmisValue("common")]
Common,
///
/// Order by is supported for common and custom properties.
///
[CmisValue("custom")]
Custom
}
///
/// Supported Permissions.
///
public enum SupportedPermissions
{
///
/// Basic permissions.
///
[CmisValue("basic")]
Basic,
///
/// Repository specific permissions.
///
[CmisValue("repository")]
Repository,
///
/// Basic and repository specific permissions.
///
[CmisValue("both")]
Both
}
///
/// ACL Propagation flag.
///
public enum AclPropagation
{
///
/// Repository determines the objects to change.
///
[CmisValue("repositorydetermined")]
RepositoryDetermined,
///
/// ACL is only changed for this object.
///
[CmisValue("objectonly")]
ObjectOnly,
///
/// ACL is changed for this object and propagated to related objects.
///
[CmisValue("propagate")]
Propagate
}
///
/// Content Stream Allowed flag.
///
public enum ContentStreamAllowed
{
///
/// Documents cannot have content.
///
[CmisValue("notallowed")]
NotAllowed,
///
/// Documents can have content.
///
[CmisValue("allowed")]
Allowed,
///
/// Documents must have content.
///
[CmisValue("required")]
Required
}
///
/// Property Data Type.
///
public enum PropertyType
{
///
/// Boolean.
///
[CmisValue("boolean")]
Boolean,
///
/// ID.
///
[CmisValue("id")]
Id,
///
/// Integer.
///
[CmisValue("integer")]
Integer,
///
/// DateTime.
///
[CmisValue("datetime")]
DateTime,
///
/// Decimal.
///
[CmisValue("decimal")]
Decimal,
///
/// HTML.
///
[CmisValue("html")]
Html,
///
/// String.
///
[CmisValue("string")]
String,
///
/// URI.
///
[CmisValue("uri")]
Uri
}
///
/// Property Cardinality.
///
public enum Cardinality
{
///
/// Single value property.
///
[CmisValue("single")]
Single,
///
/// Multivalue property.
///
[CmisValue("multi")]
Multi
}
///
/// Property Updatability.
///
public enum Updatability
{
///
/// Read-only property set by repository.
///
[CmisValue("readonly")]
ReadOnly,
///
/// Read-write property.
///
[CmisValue("readwrite")]
ReadWrite,
///
/// Property that can only be set if the document is checked out.
///
[CmisValue("whencheckedout")]
WhenCheckedOut,
///
/// Property that can only be set at object creation.
///
[CmisValue("oncreate")]
OnCreate
}
///
/// DateTime Property Resolution.
///
public enum DateTimeResolution
{
///
/// Years only.
///
[CmisValue("year")]
Year,
///
/// Date.
///
[CmisValue("date")]
Date,
///
/// Date and time.
///
[CmisValue("time")]
Time
}
///
/// Decimal Property Precision.
///
public enum DecimalPrecision
{
///
/// 32 bit precision. ("single" as specified in IEEE-754-1985).
///
[CmisValue("32")]
Bits32,
///
/// 64 bit precision. ("double" as specified in IEEE-754-1985).
///
[CmisValue("64")]
Bits64
}
///
/// Include Relationships flag.
///
public enum IncludeRelationships
{
///
/// Include no relationships.
///
[CmisValue("none")]
None,
///
/// Only relationships in which the objects returned are the source must be returned.
///
[CmisValue("source")]
Source,
///
/// Only relationships in which the objects returned are the target must be returned.
///
[CmisValue("target")]
Target,
///
/// Include all relationships.
///
[CmisValue("both")]
Both
}
///
/// Versioning State flag.
///
public enum VersioningState
{
///
/// No version.
///
[CmisValue("none")]
None,
///
/// Major version.
///
[CmisValue("major")]
Major,
///
/// Minor version.
///
[CmisValue("minor")]
Minor,
///
/// Checked out (PWC).
///
[CmisValue("checkedout")]
CheckedOut
}
///
/// Unfile Object flag.
///
public enum UnfileObject
{
///
/// Unfile all objects.
///
[CmisValue("unfile")]
Unfile,
///
/// Delete single filed object, unfile all others.
///
[CmisValue("deletesinglefiled")]
DeleteSinglefiled,
///
/// Delete all objects.
///
[CmisValue("delete")]
Delete
}
///
/// Relationship Direction flag.
///
public enum RelationshipDirection
{
///
/// Only relationship objects where the specified object is the source object.
///
[CmisValue("source")]
Source,
///
/// Only relationship objects where the specified object is the target object
///
[CmisValue("target")]
Target,
///
/// All relationships.
///
[CmisValue("either")]
Either
}
///
/// Return Version flag.
///
public enum ReturnVersion
{
///
/// Return this version.
///
[CmisValue("this")]
This,
///
/// Return latest version.
///
[CmisValue("latest")]
Latest,
///
/// Return latest major version.
///
[CmisValue("latestmajor")]
LatestMajor
}
///
/// Change Type in change logs.
///
public enum ChangeType
{
///
/// Object has been created.
///
[CmisValue("created")]
Created,
///
/// Object has been updated.
///
[CmisValue("updated")]
Updated,
///
/// Object has been deleted.
///
[CmisValue("deleted")]
Deleted,
///
/// Permissions (ACL, policies) have been changed.
///
[CmisValue("security")]
Security
}
///
/// Browser Binding DateTime Format.
///
public enum DateTimeFormat
{
///
/// Simple format (milliseconds).
///
[CmisValue("simple")]
Simple,
///
/// Extended format (ISO format).
///
[CmisValue("extended")]
Extended
}
///
/// Allowable Actions.
///
public enum Action
{
///
/// User can delete this object.
///
[CmisValue("canDeleteObject")]
CanDeleteObject,
///
/// Use can update properties of this object.
///
[CmisValue("canUpdateProperties")]
CanUpdateProperties,
///
/// User can get the folder tree of this folder.
///
[CmisValue("canGetFolderTree")]
CanGetFolderTree,
///
/// User can get the properties of this object.
///
[CmisValue("canGetProperties")]
CanGetProperties,
///
/// User can get the relationships of this object.
///
[CmisValue("canGetObjectRelationships")]
CanGetObjectRelationships,
///
/// User can get the parents of this object.
///
[CmisValue("canGetObjectParents")]
CanGetObjectParents,
///
/// User can get the parent of this folder.
///
[CmisValue("canGetFolderParent")]
CanGetFolderParent,
///
/// User can get the descendants of this folder.
///
[CmisValue("canGetDescendants")]
CanGetDescendants,
///
/// User can move this object.
///
[CmisValue("canMoveObject")]
CanMoveObject,
///
/// User can delete the content stream of this document.
///
[CmisValue("canDeleteContentStream")]
CanDeleteContentStream,
///
/// User can checkout this document.
///
[CmisValue("canCheckOut")]
CanCheckOut,
///
/// User can cancel the check out of this PWC.
///
[CmisValue("canCancelCheckOut")]
CanCancelCheckOut,
///
/// User can check in this PWC.
///
[CmisValue("canCheckIn")]
CanCheckIn,
///
/// User can set a content stream of this document.
///
[CmisValue("canSetContentStream")]
CanSetContentStream,
///
/// User can get the versions of this document.
///
[CmisValue("canGetAllVersions")]
CanGetAllVersions,
///
/// User can add thi object to a folder.
///
[CmisValue("canAddObjectToFolder")]
CanAddObjectToFolder,
///
/// User can remove this object form a folder.
///
[CmisValue("canRemoveObjectFromFolder")]
CanRemoveObjectFromFolder,
///
/// User can get the content stream of this document.
///
[CmisValue("canGetContentStream")]
CanGetContentStream,
///
/// User can apply policies to this object.
///
[CmisValue("canApplyPolicy")]
CanApplyPolicy,
///
/// User can get the policies applied to this object.
///
[CmisValue("canGetAppliedPolicies")]
CanGetAppliedPolicies,
///
/// User can remove policies from this object.
///
[CmisValue("canRemovePolicy")]
CanRemovePolicy,
///
/// User can get the children of this object.
///
[CmisValue("canGetChildren")]
CanGetChildren,
///
/// User can create documents in this folder.
///
[CmisValue("canCreateDocument")]
CanCreateDocument,
///
/// User can create folders in this folder.
///
[CmisValue("canCreateFolder")]
CanCreateFolder,
///
/// USer can create relationships from and to this object.
///
[CmisValue("canCreateRelationship")]
CanCreateRelationship,
///
/// User can create items in this folder.
///
[CmisValue("canCreateItem")]
CanCreateItem,
///
/// User can delete this folder and all descendants.
///
[CmisValue("canDeleteTree")]
CanDeleteTree,
///
/// User can get the renditions of this object.
///
[CmisValue("canGetRenditions")]
CanGetRenditions,
///
/// User can get the ACL of this object.
///
[CmisValue("canGetAcl")]
CanGetAcl,
///
/// User can apply an ACL to this object.
///
[CmisValue("canApplyAcl")]
CanApplyAcl
}
///
/// CMIS Version.
///
public enum CmisVersion
{
///
/// CMIS 1.0
///
[CmisValue("1.0")]
Cmis_1_0,
///
/// CMIS 1.1
///
[CmisValue("1.1")]
Cmis_1_1
}
// --- attribute class ---
[AttributeUsage(AttributeTargets.Field)]
internal sealed class CmisValueAttribute : System.Attribute
{
public CmisValueAttribute(string value)
{
Value = value;
}
public string Value
{
get;
private set;
}
}
///
/// Handles translations from Enums into CMIS values and vice versa.
///
internal static class CmisValue
{
///
/// Gets the CMIS value from an enum.
///
/// the enum
/// the CMIS value or null if no value can be determined
public static string GetCmisValue(this Enum value)
{
FieldInfo fieldInfo = value.GetType().GetRuntimeField(value.ToString());
CmisValueAttribute[] cmisValueAttr = fieldInfo.GetCustomAttributes(typeof(CmisValueAttribute), false) as CmisValueAttribute[];
return cmisValueAttr.Length > 0 ? cmisValueAttr[0].Value : null;
}
///
/// Gets an enum from a CMIS value.
///
/// the enum type
/// the CMIS value
/// the enum value
public static T GetCmisEnum(this string value)
{
Type type = typeof(T);
Type underlyingType = Nullable.GetUnderlyingType(type);
if (underlyingType != null)
{
type = underlyingType;
}
foreach (FieldInfo fieldInfo in type.GetRuntimeFields())
{
CmisValueAttribute[] cmisValueAttr = fieldInfo.GetCustomAttributes(typeof(CmisValueAttribute), false) as CmisValueAttribute[];
if (cmisValueAttr != null && cmisValueAttr.Length > 0 && cmisValueAttr[0].Value == value)
{
return (T)Enum.Parse(type, fieldInfo.Name);
}
}
return default(T);
}
}
}