You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2010/07/29 19:13:30 UTC
svn commit: r980513 [13/15] - in
/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server:
chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/dummy/
chemistry-opencmis-server-bindings/src/main/java/org/apach...
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseGrammar.g
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseGrammar.g?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseGrammar.g (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseGrammar.g Thu Jul 29 17:13:28 2010
@@ -1,253 +1,253 @@
-/*
- * 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.
- *
- * Authors:
- * Stefane Fermigier, Nuxeo
- * Florent Guillaume, Nuxeo
- */
-
-parser grammar CmisBaseGrammar;
-
-// Note: The following tokenVocab option generates a warning:
-// warning(160): CMISBaseGrammar.g:27:5: tokenVocab option ignored in imported gram
-// mar CMISBaseGrammar
-// If you omit this it results in compilation errors, may be a maven issue (not sure
-// of outside of maven this needs file needs to be compilable
-// options must have AST options otherwise
-
-options {
- tokenVocab = CmisQlStrictLexer;
- output = AST;
-}
-
-@rulecatch {
- catch (RecognitionException e) {
- throw e;
- }
-}
-
-query:
- SELECT select_list from_clause where_clause? order_by_clause?
- -> ^(SELECT select_list from_clause order_by_clause? where_clause?)
- ;
-
-select_list
- : STAR
- | select_sublist ( COMMA select_sublist )*
- -> ^(SEL_LIST select_sublist+)
- ;
-
-select_sublist
- : value_expression ( AS!? column_name )?
- | qualifier DOT STAR
- //| multi_valued_column_reference
- ;
-
-value_expression:
- column_reference
- | numeric_value_function
- ;
-
-column_reference:
- ( qualifier DOT )? column_name
- -> ^(COL qualifier? column_name)
- ;
-
-multi_valued_column_reference:
- ( qualifier DOT )? multi_valued_column_name
- -> ^(COL qualifier? multi_valued_column_name)
- ;
-
-numeric_value_function:
- SCORE LPAR RPAR -> ^(SCORE);
-
-qualifier:
- table_name
- //| correlation_name
- ;
-
-from_clause: FROM^ table_reference;
-
-table_reference:
- one_table table_join*
- ;
-
-table_join:
- join_kind one_table join_specification?
- -> ^(JOIN join_kind one_table join_specification?)
- ;
-
-one_table:
- LPAR! table_reference RPAR!
- | table_name
- -> ^(TABLE table_name)
- | table_name AS? correlation_name
- -> ^(TABLE table_name correlation_name)
- ;
-
-join_kind:
- JOIN
- -> INNER
- | INNER JOIN
- -> INNER
- | LEFT OUTER? JOIN
- -> LEFT
- | RIGHT OUTER? JOIN
- -> RIGHT
- ;
-
-join_specification:
- ON^ column_reference EQ column_reference
- ;
-
-///////////////////////////////////////////////////////////
-// Begin Where
-
-where_clause: WHERE^ search_condition;
-
-search_condition:
- boolean_term (OR^ boolean_term)*;
-
-boolean_term:
- boolean_factor (AND^ boolean_factor)*;
-
-boolean_factor:
- NOT^ boolean_test
- | boolean_test
- ;
-
-boolean_test:
- predicate
- | LPAR search_condition RPAR -> search_condition
- ;
-
-predicate:
- comparison_predicate
- | in_predicate
- | like_predicate
- | null_predicate
- | quantified_comparison_predicate
- | quantified_in_predicate
- | text_search_predicate
- | folder_predicate
- ;
-
-comparison_predicate:
- value_expression EQ literal
- -> ^(EQ value_expression literal)
- | value_expression NEQ literal
- -> ^(NEQ value_expression literal)
- | value_expression LT literal
- -> ^(LT value_expression literal)
- | value_expression GT literal
- -> ^(GT value_expression literal)
- | value_expression LTEQ literal
- -> ^(LTEQ value_expression literal)
- | value_expression GTEQ literal
- -> ^(GTEQ value_expression literal)
- ;
-
-literal:
- NUM_LIT
- | STRING_LIT
- | TIME_LIT
- | BOOL_LIT
- ;
-
-in_predicate:
- column_reference IN LPAR in_value_list RPAR
- -> ^(IN column_reference in_value_list)
- | column_reference NOT IN LPAR in_value_list RPAR
- -> ^(NOT_IN column_reference in_value_list)
- ;
-
-in_value_list:
- literal ( COMMA literal )*
- -> ^(IN_LIST literal+)
- ;
-
-like_predicate:
- column_reference LIKE STRING_LIT
- -> ^(LIKE column_reference STRING_LIT)
- | column_reference NOT LIKE STRING_LIT
- -> ^(NOT_LIKE column_reference STRING_LIT)
- ;
-
-null_predicate:
- // second alternative commented out to remove left recursion for now.
- //( column_reference | multi_valued_column_reference ) 'IS' 'NOT'? 'NULL';
- column_reference IS
- ( NOT NULL -> ^(IS_NOT_NULL column_reference)
- | NULL -> ^(IS_NULL column_reference)
- )
- ;
-
-quantified_comparison_predicate:
- literal EQ ANY multi_valued_column_reference
- -> ^(EQ_ANY literal multi_valued_column_reference)
- ;
-
-quantified_in_predicate:
- ANY multi_valued_column_reference
- ( NOT IN LPAR in_value_list RPAR
- -> ^(NOT_IN_ANY multi_valued_column_reference in_value_list )
- | IN LPAR in_value_list RPAR
- -> ^(IN_ANY multi_valued_column_reference in_value_list )
- )
- ;
-
-text_search_predicate:
- CONTAINS LPAR (qualifier COMMA)? text_search_expression RPAR
- -> ^(CONTAINS qualifier? text_search_expression)
- ;
-
-// end where
-/////////////////////////////////////////////////////////////////
-
-folder_predicate:
- ( f=IN_FOLDER | f=IN_TREE ) LPAR (qualifier COMMA)? folder_id RPAR
- -> ^($f qualifier? folder_id)
- ;
-
-order_by_clause:
- ORDER BY sort_specification ( COMMA sort_specification )*
- -> ^(ORDER_BY sort_specification+)
- ;
-
-sort_specification:
- column_reference -> column_reference ASC
- | column_reference ( ASC | DESC )
- ;
-
-correlation_name:
- ID;
-
-table_name:
- ID;
-
-column_name:
- ID;
-
-multi_valued_column_name:
- ID;
-
-folder_id:
- STRING_LIT;
-
-text_search_expression:
- STRING_LIT;
+/*
+ * 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.
+ *
+ * Authors:
+ * Stefane Fermigier, Nuxeo
+ * Florent Guillaume, Nuxeo
+ */
+
+parser grammar CmisBaseGrammar;
+
+// Note: The following tokenVocab option generates a warning:
+// warning(160): CMISBaseGrammar.g:27:5: tokenVocab option ignored in imported gram
+// mar CMISBaseGrammar
+// If you omit this it results in compilation errors, may be a maven issue (not sure
+// of outside of maven this needs file needs to be compilable
+// options must have AST options otherwise
+
+options {
+ tokenVocab = CmisQlStrictLexer;
+ output = AST;
+}
+
+@rulecatch {
+ catch (RecognitionException e) {
+ throw e;
+ }
+}
+
+query:
+ SELECT select_list from_clause where_clause? order_by_clause?
+ -> ^(SELECT select_list from_clause order_by_clause? where_clause?)
+ ;
+
+select_list
+ : STAR
+ | select_sublist ( COMMA select_sublist )*
+ -> ^(SEL_LIST select_sublist+)
+ ;
+
+select_sublist
+ : value_expression ( AS!? column_name )?
+ | qualifier DOT STAR
+ //| multi_valued_column_reference
+ ;
+
+value_expression:
+ column_reference
+ | numeric_value_function
+ ;
+
+column_reference:
+ ( qualifier DOT )? column_name
+ -> ^(COL qualifier? column_name)
+ ;
+
+multi_valued_column_reference:
+ ( qualifier DOT )? multi_valued_column_name
+ -> ^(COL qualifier? multi_valued_column_name)
+ ;
+
+numeric_value_function:
+ SCORE LPAR RPAR -> ^(SCORE);
+
+qualifier:
+ table_name
+ //| correlation_name
+ ;
+
+from_clause: FROM^ table_reference;
+
+table_reference:
+ one_table table_join*
+ ;
+
+table_join:
+ join_kind one_table join_specification?
+ -> ^(JOIN join_kind one_table join_specification?)
+ ;
+
+one_table:
+ LPAR! table_reference RPAR!
+ | table_name
+ -> ^(TABLE table_name)
+ | table_name AS? correlation_name
+ -> ^(TABLE table_name correlation_name)
+ ;
+
+join_kind:
+ JOIN
+ -> INNER
+ | INNER JOIN
+ -> INNER
+ | LEFT OUTER? JOIN
+ -> LEFT
+ | RIGHT OUTER? JOIN
+ -> RIGHT
+ ;
+
+join_specification:
+ ON^ column_reference EQ column_reference
+ ;
+
+///////////////////////////////////////////////////////////
+// Begin Where
+
+where_clause: WHERE^ search_condition;
+
+search_condition:
+ boolean_term (OR^ boolean_term)*;
+
+boolean_term:
+ boolean_factor (AND^ boolean_factor)*;
+
+boolean_factor:
+ NOT^ boolean_test
+ | boolean_test
+ ;
+
+boolean_test:
+ predicate
+ | LPAR search_condition RPAR -> search_condition
+ ;
+
+predicate:
+ comparison_predicate
+ | in_predicate
+ | like_predicate
+ | null_predicate
+ | quantified_comparison_predicate
+ | quantified_in_predicate
+ | text_search_predicate
+ | folder_predicate
+ ;
+
+comparison_predicate:
+ value_expression EQ literal
+ -> ^(EQ value_expression literal)
+ | value_expression NEQ literal
+ -> ^(NEQ value_expression literal)
+ | value_expression LT literal
+ -> ^(LT value_expression literal)
+ | value_expression GT literal
+ -> ^(GT value_expression literal)
+ | value_expression LTEQ literal
+ -> ^(LTEQ value_expression literal)
+ | value_expression GTEQ literal
+ -> ^(GTEQ value_expression literal)
+ ;
+
+literal:
+ NUM_LIT
+ | STRING_LIT
+ | TIME_LIT
+ | BOOL_LIT
+ ;
+
+in_predicate:
+ column_reference IN LPAR in_value_list RPAR
+ -> ^(IN column_reference in_value_list)
+ | column_reference NOT IN LPAR in_value_list RPAR
+ -> ^(NOT_IN column_reference in_value_list)
+ ;
+
+in_value_list:
+ literal ( COMMA literal )*
+ -> ^(IN_LIST literal+)
+ ;
+
+like_predicate:
+ column_reference LIKE STRING_LIT
+ -> ^(LIKE column_reference STRING_LIT)
+ | column_reference NOT LIKE STRING_LIT
+ -> ^(NOT_LIKE column_reference STRING_LIT)
+ ;
+
+null_predicate:
+ // second alternative commented out to remove left recursion for now.
+ //( column_reference | multi_valued_column_reference ) 'IS' 'NOT'? 'NULL';
+ column_reference IS
+ ( NOT NULL -> ^(IS_NOT_NULL column_reference)
+ | NULL -> ^(IS_NULL column_reference)
+ )
+ ;
+
+quantified_comparison_predicate:
+ literal EQ ANY multi_valued_column_reference
+ -> ^(EQ_ANY literal multi_valued_column_reference)
+ ;
+
+quantified_in_predicate:
+ ANY multi_valued_column_reference
+ ( NOT IN LPAR in_value_list RPAR
+ -> ^(NOT_IN_ANY multi_valued_column_reference in_value_list )
+ | IN LPAR in_value_list RPAR
+ -> ^(IN_ANY multi_valued_column_reference in_value_list )
+ )
+ ;
+
+text_search_predicate:
+ CONTAINS LPAR (qualifier COMMA)? text_search_expression RPAR
+ -> ^(CONTAINS qualifier? text_search_expression)
+ ;
+
+// end where
+/////////////////////////////////////////////////////////////////
+
+folder_predicate:
+ ( f=IN_FOLDER | f=IN_TREE ) LPAR (qualifier COMMA)? folder_id RPAR
+ -> ^($f qualifier? folder_id)
+ ;
+
+order_by_clause:
+ ORDER BY sort_specification ( COMMA sort_specification )*
+ -> ^(ORDER_BY sort_specification+)
+ ;
+
+sort_specification:
+ column_reference -> column_reference ASC
+ | column_reference ( ASC | DESC )
+ ;
+
+correlation_name:
+ ID;
+
+table_name:
+ ID;
+
+column_name:
+ ID;
+
+multi_valued_column_name:
+ ID;
+
+folder_id:
+ STRING_LIT;
+
+text_search_expression:
+ STRING_LIT;
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisBaseGrammar.g
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlExtParser.g
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictLexer.g
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictParser.g
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/CmisServiceWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeManager.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeManager.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeManager.java Thu Jul 29 17:13:28 2010
@@ -1,74 +1,74 @@
-/*
- * 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.
- */
-package org.apache.chemistry.opencmis.server.support;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
-
-public interface TypeManager {
-
- /**
- * return a type definition from the type definition id
- *
- * @param typeId
- * id of the type definition
- * @return type definition for this id
- */
- public abstract TypeDefinitionContainer getTypeById(String typeId);
-
- /**
- * return a type definition from the type query name or null if not found
- *
- * @param typeQueryName
- * query name of the type definition
- * @return type definition for this query name
- */
- public abstract TypeDefinition getTypeByQueryName(String typeQueryName);
-
- /**
- * return a list of all types known in this repository
- *
- * @return
- */
- public abstract Collection<TypeDefinitionContainer> getTypeDefinitionList();
-
- /**
- * return a list of the root types as defined in the CMIS spec (for
- * document, folder, policy and relationship
- *
- * @return
- */
- public abstract List<TypeDefinitionContainer> getRootTypes();
-
- /**
- * retrieve the property id from a type for a given property query name
- *
- * @param typeDefinition
- * type definition containing query name
- * @param propQueryName
- * query name of property
- * @return
- * property id of property or null if not found
- */
- public abstract String getPropertyIdForQueryName(TypeDefinition typeDefinition, String propQueryName);
-
+/*
+ * 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.
+ */
+package org.apache.chemistry.opencmis.server.support;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+
+public interface TypeManager {
+
+ /**
+ * return a type definition from the type definition id
+ *
+ * @param typeId
+ * id of the type definition
+ * @return type definition for this id
+ */
+ public abstract TypeDefinitionContainer getTypeById(String typeId);
+
+ /**
+ * return a type definition from the type query name or null if not found
+ *
+ * @param typeQueryName
+ * query name of the type definition
+ * @return type definition for this query name
+ */
+ public abstract TypeDefinition getTypeByQueryName(String typeQueryName);
+
+ /**
+ * return a list of all types known in this repository
+ *
+ * @return
+ */
+ public abstract Collection<TypeDefinitionContainer> getTypeDefinitionList();
+
+ /**
+ * return a list of the root types as defined in the CMIS spec (for
+ * document, folder, policy and relationship
+ *
+ * @return
+ */
+ public abstract List<TypeDefinitionContainer> getRootTypes();
+
+ /**
+ * retrieve the property id from a type for a given property query name
+ *
+ * @param typeDefinition
+ * type definition containing query name
+ * @param propQueryName
+ * query name of property
+ * @return
+ * property id of property or null if not found
+ */
+ public abstract String getPropertyIdForQueryName(TypeDefinition typeDefinition, String propQueryName);
+
}
\ No newline at end of file
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java Thu Jul 29 17:13:28 2010
@@ -1,424 +1,424 @@
-/*
- * 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.
- */
-package org.apache.chemistry.opencmis.server.support;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.data.PropertyData;
-import org.apache.chemistry.opencmis.commons.data.PropertyDecimal;
-import org.apache.chemistry.opencmis.commons.data.PropertyInteger;
-import org.apache.chemistry.opencmis.commons.definitions.Choice;
-import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDecimalDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyIntegerDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
-import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
-import org.apache.chemistry.opencmis.commons.enums.Cardinality;
-import org.apache.chemistry.opencmis.commons.enums.VersioningState;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
-
-/**
- * @author Jens
- */
-public class TypeValidator {
-
- public static void validateRequiredSystemProperties(Properties properties) {
- if (properties == null || properties.getProperties() == null)
- throw new RuntimeException("Cannot create object, no properties are given");
-
- if (!properties.getProperties().containsKey(PropertyIds.OBJECT_TYPE_ID))
- throw new RuntimeException("Cannot create object, type id is missing");
-
- }
-
- private static boolean isMandatorySystemProperty(String propertyId) {
- // TODO Auto-generated method stub
- return propertyId.equals(PropertyIds.OBJECT_TYPE_ID);
- }
-
- @SuppressWarnings("unchecked")
- static <T> PropertyValidator<T> createPropertyValidator(PropertyDefinition<?> propDef) {
- PropertyValidator<T> result = null;
- if (propDef instanceof PropertyIntegerDefinition) {
- result = (PropertyValidator<T>) new PropertyValidatorInteger();
- } else if (propDef instanceof PropertyDecimalDefinition) {
- result = (PropertyValidator<T>) new PropertyValidatorDecimal();
- } else if (propDef instanceof PropertyStringDefinition) {
- result = (PropertyValidator<T>) new PropertyValidatorString();
- } else {
- result = new PropertyValidator<T>();
- }
- return result;
- }
-
- /*
- * property validations: not readonly, all required are given, all are known
- * in type cardinality: no multi values for single value, def min max check
- * for Integer and Decimal, choices and in list Strings, max length set
- * default value for omitted properties
- */
- static class PropertyValidator<T> {
-
- public void validate(PropertyDefinition<T> propDef, PropertyData<T> prop) {
-
- // check general constraints for all property types
- if (propDef.getCardinality() == Cardinality.SINGLE && prop.getValues().size() > 1)
- throw new CmisConstraintException("The property with id " + propDef.getId()
- + " is single valued, but multiple values are passed " + prop.getValues());
-
- if (propDef.getChoices() != null && propDef.getChoices().size() > 0) {
- validateChoices(propDef, prop);
- }
- }
-
- private void validateChoices(PropertyDefinition<T> propDef, PropertyData<T> prop) {
- boolean isAllowedValue = true;
- boolean hasMultiValueChoiceLists = false;
- for (Choice<?> allowedValue : propDef.getChoices()) {
- if (allowedValue.getValue() != null && allowedValue.getValue().size() > 1)
- hasMultiValueChoiceLists = true;
- }
-
- // check if value is in list
- if (hasMultiValueChoiceLists) {
- // do a complex check if this combination of actual values is
- // allowed
- // check if value is in list
- isAllowedValue = false;
- List<?> actualValues = prop.getValues();
- for (Choice<?> allowedValue : propDef.getChoices()) {
- if (allowedValue.getValue().size() == actualValues.size()) {
- boolean listValuesAreEqual = true;
- Iterator<?> it = allowedValue.getValue().iterator();
- for (Object actualValue : actualValues) {
- if (!actualValue.equals(it.next())) {
- listValuesAreEqual = false;
- break;
- }
- }
- if (listValuesAreEqual) {
- isAllowedValue = true;
- }
- }
-
- if (isAllowedValue)
- break;
- }
-
- } else {
- List<T> allowedValues = getAllowedValues(propDef.getChoices());
- // do a simpler check if all values are choice elements
-
- for (Object actualValue : prop.getValues()) {
- if (!allowedValues.contains(actualValue)) {
- isAllowedValue = false;
- break;
- }
- }
- }
-
- if (!isAllowedValue)
- throw new CmisConstraintException("The property with id " + propDef.getId()
- + " has a fixed set of values. Value(s) " + prop.getValues() + " are not listed.");
- }
-
- /**
- * Calculate the list of allowed values for this property definition by
- * recursively collecting all choice values from property definition
- *
- * @param propDef
- * property definition
- * @return list of possible values in complete hierarchy
- */
- private List<T> getAllowedValues(List<Choice<T>> choices) {
- List<T> allowedValues = new ArrayList<T>(choices.size());
- for (Choice<T> choice : choices) {
- if (choice.getValue() != null)
- allowedValues.add(choice.getValue().get(0));
- if (choice.getChoice() != null) {
- List<Choice<T>> x = choice.getChoice();
- allowedValues.addAll(getAllowedValues(x));
- }
- }
- return allowedValues;
- }
- }
-
- static class PropertyValidatorInteger extends PropertyValidator<BigInteger> {
-
- public void validate(PropertyDefinition<BigInteger> propDef, PropertyData<BigInteger> property) {
-
- super.validate(propDef, property);
-
- BigInteger propVal = ((PropertyInteger) property).getFirstValue();
- BigInteger minVal = ((PropertyIntegerDefinition) propDef).getMinValue();
- BigInteger maxVal = ((PropertyIntegerDefinition) propDef).getMaxValue();
-
- // check min and max
- if (minVal != null && propVal != null && propVal.compareTo(minVal) == -1) {
- throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
- + " is less than the minimum value " + minVal);
- }
- if (maxVal != null && propVal != null && propVal.compareTo(maxVal) == 1) {
- throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
- + " is bigger than the maximum value " + maxVal);
- }
- }
- }
-
- static class PropertyValidatorDecimal extends PropertyValidator<BigDecimal> {
-
- public void validate(PropertyDefinition<BigDecimal> propDef, PropertyData<BigDecimal> property) {
-
- super.validate(propDef, property);
-
- BigDecimal propVal = ((PropertyDecimal) property).getFirstValue();
- BigDecimal minVal = ((PropertyDecimalDefinition) propDef).getMinValue();
- BigDecimal maxVal = ((PropertyDecimalDefinition) propDef).getMaxValue();
-
- // check min and max
- if (minVal != null && propVal != null && propVal.compareTo(minVal) == -1) {
- throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
- + " is less than the minimum value " + minVal);
- }
- if (maxVal != null && propVal != null && propVal.compareTo(maxVal) == 1) {
- throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
- + " is bigger than the maximum value " + maxVal);
- }
- }
- }
-
- static class PropertyValidatorString extends PropertyValidator<String> {
-
- public void validate(PropertyDefinition<String> propDef, PropertyData<String> property) {
-
- super.validate(propDef, property);
-
- long maxLen = ((PropertyStringDefinition) propDef).getMaxLength() == null ? -1
- : ((PropertyStringDefinition) propDef).getMaxLength().longValue();
- long len = ((PropertyData<String>) property).getFirstValue() == null ? -1
- : ((PropertyData<String>) property).getFirstValue().length();
-
- // check max length
- if (maxLen >= 0 && len >= 0 && maxLen < len) {
- throw new CmisConstraintException("For property with id " + propDef.getId() + " the length of " + len
- + "is bigger than the maximum allowed length " + maxLen);
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public static <T> void validateProperties(TypeDefinition typeDef, Properties properties, boolean checkMandatory) {
-
- List<String> propDefsRequired = getMandatoryPropDefs(typeDef.getPropertyDefinitions());
-
- for (PropertyData<?> prop : properties.getProperties().values()) {
- String propertyId = prop.getId();
- BaseTypeId baseTypeId = typeDef.getBaseTypeId();
-
- if (isSystemProperty(baseTypeId, propertyId))
- continue; // ignore system properties for validation
-
- // Check if all properties are known in the type
- if (!typeContainsProperty(typeDef, propertyId)) {
- throw new CmisConstraintException("Unknown property " + propertyId + " in type " + typeDef.getId());
- }
-
- // check that all mandatory attributes are present
- if (checkMandatory && propDefsRequired.contains(propertyId))
- propDefsRequired.remove(propertyId);
-
- // check all type specific constraints:
- PropertyDefinition<T> propDef = getPropertyDefinition(typeDef, propertyId);
- PropertyValidator<T> validator = createPropertyValidator(propDef);
- validator.validate(propDef, (PropertyData<T>) prop);
- }
-
- if (checkMandatory && !propDefsRequired.isEmpty())
- throw new CmisConstraintException("The following mandatory properties are missing: " + propDefsRequired);
- }
-
- public static void validateVersionStateForCreate(DocumentTypeDefinition typeDef, VersioningState verState) {
- if (null == verState)
- return;
- if (typeDef.isVersionable() && verState.equals(VersioningState.NONE) || !typeDef.isVersionable()
- && !verState.equals(VersioningState.NONE)) {
- throw new CmisConstraintException("The versioning state flag is imcompatible to the type definition.");
- }
-
- }
-
- public static void validateAllowedChildObjectTypes(TypeDefinition childTypeDef, List<String> allowedChildTypes) {
-
- if (null == allowedChildTypes)
- return; // all types are allowed
-
- for (String allowedChildType : allowedChildTypes) {
- if (allowedChildType.equals(childTypeDef.getId()))
- return;
- }
- throw new RuntimeException("The requested type " + childTypeDef.getId() + " is not allowed in this folder");
- }
-
- private static List<String> getMandatoryPropDefs(Map<String, PropertyDefinition<?>> propDefs) {
- List<String> res = new ArrayList<String>();
- if (null != propDefs) {
- for (PropertyDefinition<?> propDef : propDefs.values()) {
- if (propDef.isRequired() && !isMandatorySystemProperty(propDef.getId()))
- res.add(propDef.getId());
- }
- }
- return res;
- }
-
- public static boolean typeContainsProperty(TypeDefinition typeDef, String propertyId) {
-
- Map<String, PropertyDefinition<?>> propDefs = typeDef.getPropertyDefinitions();
- if (null == propDefs)
- return false;
-
- PropertyDefinition<?> propDef = propDefs.get(propertyId);
-
- if (null == propDef)
- return false; // unknown property id in this type
- else
- return true;
- }
-
- public static boolean typeContainsPropertyWithQueryName(TypeDefinition typeDef, String propertyQueryName) {
-
- Map<String, PropertyDefinition<?>> propDefs = typeDef.getPropertyDefinitions();
- if (null == propDefs)
- return false;
-
- for (PropertyDefinition<?> propDef : propDefs.values()) {
- if (propDef.getQueryName().equals(propertyQueryName))
- return true;
- }
-
- return false; // unknown property query name in this type
- }
-
- @SuppressWarnings("unchecked")
- private static <T> PropertyDefinition<T> getPropertyDefinition(TypeDefinition typeDef, String propertyId) {
-
- Map<String, PropertyDefinition<?>> propDefs = typeDef.getPropertyDefinitions();
- if (null == propDefs)
- return null;
-
- PropertyDefinition<?> propDef = propDefs.get(propertyId);
-
- if (null == propDef)
- return null; // not found
- else
- return (PropertyDefinition<T>) propDef;
- }
-
- private static boolean isSystemProperty(BaseTypeId baseTypeId, String propertyId) {
-
- if (propertyId.equals(PropertyIds.NAME)) {
- return true;
- } else if (propertyId.equals(PropertyIds.OBJECT_ID)) {
- return true;
- } else if (propertyId.equals(PropertyIds.OBJECT_TYPE_ID)) {
- return true;
- } else if (propertyId.equals(PropertyIds.BASE_TYPE_ID)) {
- return true;
- } else if (propertyId.equals(PropertyIds.CREATED_BY)) {
- return true;
- } else if (propertyId.equals(PropertyIds.CREATION_DATE)) {
- return true;
- } else if (propertyId.equals(PropertyIds.LAST_MODIFIED_BY)) {
- return true;
- } else if (propertyId.equals(PropertyIds.LAST_MODIFICATION_DATE)) {
- return true;
- } else if (propertyId.equals(PropertyIds.CHANGE_TOKEN)) {
- return true;
- }
-
- if (baseTypeId.equals(BaseTypeId.CMIS_DOCUMENT)) {
- if (propertyId.equals(PropertyIds.IS_IMMUTABLE)) {
- return true;
- } else if (propertyId.equals(PropertyIds.IS_LATEST_VERSION)) {
- return true;
- } else if (propertyId.equals(PropertyIds.IS_MAJOR_VERSION)) {
- return true;
- } else if (propertyId.equals(PropertyIds.VERSION_SERIES_ID)) {
- return true;
- } else if (propertyId.equals(PropertyIds.IS_LATEST_MAJOR_VERSION)) {
- return true;
- } else if (propertyId.equals(PropertyIds.VERSION_LABEL)) {
- return true;
- } else if (propertyId.equals(PropertyIds.VERSION_SERIES_ID)) {
- return true;
- } else if (propertyId.equals(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT)) {
- return true;
- } else if (propertyId.equals(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY)) {
- return true;
- } else if (propertyId.equals(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID)) {
- return true;
- } else if (propertyId.equals(PropertyIds.CHECKIN_COMMENT)) {
- return true;
- } else if (propertyId.equals(PropertyIds.CONTENT_STREAM_LENGTH)) {
- return true;
- } else if (propertyId.equals(PropertyIds.CONTENT_STREAM_MIME_TYPE)) {
- return true;
- } else if (propertyId.equals(PropertyIds.CONTENT_STREAM_FILE_NAME)) {
- return true;
- } else if (propertyId.equals(PropertyIds.CONTENT_STREAM_ID)) {
- return true;
- } else {
- return false;
- }
- } else if (baseTypeId.equals(BaseTypeId.CMIS_FOLDER)) {
- if (propertyId.equals(PropertyIds.PARENT_ID)) {
- return true;
- } else if (propertyId.equals(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS)) {
- return true;
- } else if (propertyId.equals(PropertyIds.PATH)) {
- return true;
- } else {
- return false;
- }
- } else if (baseTypeId.equals(BaseTypeId.CMIS_POLICY)) {
- if (propertyId.equals(PropertyIds.SOURCE_ID)) {
- return true;
- } else if (propertyId.equals(PropertyIds.TARGET_ID)) {
- return true;
- } else {
- return false;
- }
- } else { // relationship
- if (propertyId.equals(PropertyIds.POLICY_TEXT)) {
- return true;
- } else {
- return false;
- }
- }
- }
-}
+/*
+ * 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.
+ */
+package org.apache.chemistry.opencmis.server.support;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.PropertyDecimal;
+import org.apache.chemistry.opencmis.commons.data.PropertyInteger;
+import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDecimalDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyIntegerDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.Cardinality;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+
+/**
+ * @author Jens
+ */
+public class TypeValidator {
+
+ public static void validateRequiredSystemProperties(Properties properties) {
+ if (properties == null || properties.getProperties() == null)
+ throw new RuntimeException("Cannot create object, no properties are given");
+
+ if (!properties.getProperties().containsKey(PropertyIds.OBJECT_TYPE_ID))
+ throw new RuntimeException("Cannot create object, type id is missing");
+
+ }
+
+ private static boolean isMandatorySystemProperty(String propertyId) {
+ // TODO Auto-generated method stub
+ return propertyId.equals(PropertyIds.OBJECT_TYPE_ID);
+ }
+
+ @SuppressWarnings("unchecked")
+ static <T> PropertyValidator<T> createPropertyValidator(PropertyDefinition<?> propDef) {
+ PropertyValidator<T> result = null;
+ if (propDef instanceof PropertyIntegerDefinition) {
+ result = (PropertyValidator<T>) new PropertyValidatorInteger();
+ } else if (propDef instanceof PropertyDecimalDefinition) {
+ result = (PropertyValidator<T>) new PropertyValidatorDecimal();
+ } else if (propDef instanceof PropertyStringDefinition) {
+ result = (PropertyValidator<T>) new PropertyValidatorString();
+ } else {
+ result = new PropertyValidator<T>();
+ }
+ return result;
+ }
+
+ /*
+ * property validations: not readonly, all required are given, all are known
+ * in type cardinality: no multi values for single value, def min max check
+ * for Integer and Decimal, choices and in list Strings, max length set
+ * default value for omitted properties
+ */
+ static class PropertyValidator<T> {
+
+ public void validate(PropertyDefinition<T> propDef, PropertyData<T> prop) {
+
+ // check general constraints for all property types
+ if (propDef.getCardinality() == Cardinality.SINGLE && prop.getValues().size() > 1)
+ throw new CmisConstraintException("The property with id " + propDef.getId()
+ + " is single valued, but multiple values are passed " + prop.getValues());
+
+ if (propDef.getChoices() != null && propDef.getChoices().size() > 0) {
+ validateChoices(propDef, prop);
+ }
+ }
+
+ private void validateChoices(PropertyDefinition<T> propDef, PropertyData<T> prop) {
+ boolean isAllowedValue = true;
+ boolean hasMultiValueChoiceLists = false;
+ for (Choice<?> allowedValue : propDef.getChoices()) {
+ if (allowedValue.getValue() != null && allowedValue.getValue().size() > 1)
+ hasMultiValueChoiceLists = true;
+ }
+
+ // check if value is in list
+ if (hasMultiValueChoiceLists) {
+ // do a complex check if this combination of actual values is
+ // allowed
+ // check if value is in list
+ isAllowedValue = false;
+ List<?> actualValues = prop.getValues();
+ for (Choice<?> allowedValue : propDef.getChoices()) {
+ if (allowedValue.getValue().size() == actualValues.size()) {
+ boolean listValuesAreEqual = true;
+ Iterator<?> it = allowedValue.getValue().iterator();
+ for (Object actualValue : actualValues) {
+ if (!actualValue.equals(it.next())) {
+ listValuesAreEqual = false;
+ break;
+ }
+ }
+ if (listValuesAreEqual) {
+ isAllowedValue = true;
+ }
+ }
+
+ if (isAllowedValue)
+ break;
+ }
+
+ } else {
+ List<T> allowedValues = getAllowedValues(propDef.getChoices());
+ // do a simpler check if all values are choice elements
+
+ for (Object actualValue : prop.getValues()) {
+ if (!allowedValues.contains(actualValue)) {
+ isAllowedValue = false;
+ break;
+ }
+ }
+ }
+
+ if (!isAllowedValue)
+ throw new CmisConstraintException("The property with id " + propDef.getId()
+ + " has a fixed set of values. Value(s) " + prop.getValues() + " are not listed.");
+ }
+
+ /**
+ * Calculate the list of allowed values for this property definition by
+ * recursively collecting all choice values from property definition
+ *
+ * @param propDef
+ * property definition
+ * @return list of possible values in complete hierarchy
+ */
+ private List<T> getAllowedValues(List<Choice<T>> choices) {
+ List<T> allowedValues = new ArrayList<T>(choices.size());
+ for (Choice<T> choice : choices) {
+ if (choice.getValue() != null)
+ allowedValues.add(choice.getValue().get(0));
+ if (choice.getChoice() != null) {
+ List<Choice<T>> x = choice.getChoice();
+ allowedValues.addAll(getAllowedValues(x));
+ }
+ }
+ return allowedValues;
+ }
+ }
+
+ static class PropertyValidatorInteger extends PropertyValidator<BigInteger> {
+
+ public void validate(PropertyDefinition<BigInteger> propDef, PropertyData<BigInteger> property) {
+
+ super.validate(propDef, property);
+
+ BigInteger propVal = ((PropertyInteger) property).getFirstValue();
+ BigInteger minVal = ((PropertyIntegerDefinition) propDef).getMinValue();
+ BigInteger maxVal = ((PropertyIntegerDefinition) propDef).getMaxValue();
+
+ // check min and max
+ if (minVal != null && propVal != null && propVal.compareTo(minVal) == -1) {
+ throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
+ + " is less than the minimum value " + minVal);
+ }
+ if (maxVal != null && propVal != null && propVal.compareTo(maxVal) == 1) {
+ throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
+ + " is bigger than the maximum value " + maxVal);
+ }
+ }
+ }
+
+ static class PropertyValidatorDecimal extends PropertyValidator<BigDecimal> {
+
+ public void validate(PropertyDefinition<BigDecimal> propDef, PropertyData<BigDecimal> property) {
+
+ super.validate(propDef, property);
+
+ BigDecimal propVal = ((PropertyDecimal) property).getFirstValue();
+ BigDecimal minVal = ((PropertyDecimalDefinition) propDef).getMinValue();
+ BigDecimal maxVal = ((PropertyDecimalDefinition) propDef).getMaxValue();
+
+ // check min and max
+ if (minVal != null && propVal != null && propVal.compareTo(minVal) == -1) {
+ throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
+ + " is less than the minimum value " + minVal);
+ }
+ if (maxVal != null && propVal != null && propVal.compareTo(maxVal) == 1) {
+ throw new CmisConstraintException("For property with id " + propDef.getId() + " the value " + propVal
+ + " is bigger than the maximum value " + maxVal);
+ }
+ }
+ }
+
+ static class PropertyValidatorString extends PropertyValidator<String> {
+
+ public void validate(PropertyDefinition<String> propDef, PropertyData<String> property) {
+
+ super.validate(propDef, property);
+
+ long maxLen = ((PropertyStringDefinition) propDef).getMaxLength() == null ? -1
+ : ((PropertyStringDefinition) propDef).getMaxLength().longValue();
+ long len = ((PropertyData<String>) property).getFirstValue() == null ? -1
+ : ((PropertyData<String>) property).getFirstValue().length();
+
+ // check max length
+ if (maxLen >= 0 && len >= 0 && maxLen < len) {
+ throw new CmisConstraintException("For property with id " + propDef.getId() + " the length of " + len
+ + "is bigger than the maximum allowed length " + maxLen);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T> void validateProperties(TypeDefinition typeDef, Properties properties, boolean checkMandatory) {
+
+ List<String> propDefsRequired = getMandatoryPropDefs(typeDef.getPropertyDefinitions());
+
+ for (PropertyData<?> prop : properties.getProperties().values()) {
+ String propertyId = prop.getId();
+ BaseTypeId baseTypeId = typeDef.getBaseTypeId();
+
+ if (isSystemProperty(baseTypeId, propertyId))
+ continue; // ignore system properties for validation
+
+ // Check if all properties are known in the type
+ if (!typeContainsProperty(typeDef, propertyId)) {
+ throw new CmisConstraintException("Unknown property " + propertyId + " in type " + typeDef.getId());
+ }
+
+ // check that all mandatory attributes are present
+ if (checkMandatory && propDefsRequired.contains(propertyId))
+ propDefsRequired.remove(propertyId);
+
+ // check all type specific constraints:
+ PropertyDefinition<T> propDef = getPropertyDefinition(typeDef, propertyId);
+ PropertyValidator<T> validator = createPropertyValidator(propDef);
+ validator.validate(propDef, (PropertyData<T>) prop);
+ }
+
+ if (checkMandatory && !propDefsRequired.isEmpty())
+ throw new CmisConstraintException("The following mandatory properties are missing: " + propDefsRequired);
+ }
+
+ public static void validateVersionStateForCreate(DocumentTypeDefinition typeDef, VersioningState verState) {
+ if (null == verState)
+ return;
+ if (typeDef.isVersionable() && verState.equals(VersioningState.NONE) || !typeDef.isVersionable()
+ && !verState.equals(VersioningState.NONE)) {
+ throw new CmisConstraintException("The versioning state flag is imcompatible to the type definition.");
+ }
+
+ }
+
+ public static void validateAllowedChildObjectTypes(TypeDefinition childTypeDef, List<String> allowedChildTypes) {
+
+ if (null == allowedChildTypes)
+ return; // all types are allowed
+
+ for (String allowedChildType : allowedChildTypes) {
+ if (allowedChildType.equals(childTypeDef.getId()))
+ return;
+ }
+ throw new RuntimeException("The requested type " + childTypeDef.getId() + " is not allowed in this folder");
+ }
+
+ private static List<String> getMandatoryPropDefs(Map<String, PropertyDefinition<?>> propDefs) {
+ List<String> res = new ArrayList<String>();
+ if (null != propDefs) {
+ for (PropertyDefinition<?> propDef : propDefs.values()) {
+ if (propDef.isRequired() && !isMandatorySystemProperty(propDef.getId()))
+ res.add(propDef.getId());
+ }
+ }
+ return res;
+ }
+
+ public static boolean typeContainsProperty(TypeDefinition typeDef, String propertyId) {
+
+ Map<String, PropertyDefinition<?>> propDefs = typeDef.getPropertyDefinitions();
+ if (null == propDefs)
+ return false;
+
+ PropertyDefinition<?> propDef = propDefs.get(propertyId);
+
+ if (null == propDef)
+ return false; // unknown property id in this type
+ else
+ return true;
+ }
+
+ public static boolean typeContainsPropertyWithQueryName(TypeDefinition typeDef, String propertyQueryName) {
+
+ Map<String, PropertyDefinition<?>> propDefs = typeDef.getPropertyDefinitions();
+ if (null == propDefs)
+ return false;
+
+ for (PropertyDefinition<?> propDef : propDefs.values()) {
+ if (propDef.getQueryName().equals(propertyQueryName))
+ return true;
+ }
+
+ return false; // unknown property query name in this type
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T> PropertyDefinition<T> getPropertyDefinition(TypeDefinition typeDef, String propertyId) {
+
+ Map<String, PropertyDefinition<?>> propDefs = typeDef.getPropertyDefinitions();
+ if (null == propDefs)
+ return null;
+
+ PropertyDefinition<?> propDef = propDefs.get(propertyId);
+
+ if (null == propDef)
+ return null; // not found
+ else
+ return (PropertyDefinition<T>) propDef;
+ }
+
+ private static boolean isSystemProperty(BaseTypeId baseTypeId, String propertyId) {
+
+ if (propertyId.equals(PropertyIds.NAME)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.OBJECT_ID)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.OBJECT_TYPE_ID)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.BASE_TYPE_ID)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.CREATED_BY)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.CREATION_DATE)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.LAST_MODIFIED_BY)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.LAST_MODIFICATION_DATE)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.CHANGE_TOKEN)) {
+ return true;
+ }
+
+ if (baseTypeId.equals(BaseTypeId.CMIS_DOCUMENT)) {
+ if (propertyId.equals(PropertyIds.IS_IMMUTABLE)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.IS_LATEST_VERSION)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.IS_MAJOR_VERSION)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.VERSION_SERIES_ID)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.IS_LATEST_MAJOR_VERSION)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.VERSION_LABEL)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.VERSION_SERIES_ID)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.CHECKIN_COMMENT)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.CONTENT_STREAM_LENGTH)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.CONTENT_STREAM_MIME_TYPE)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.CONTENT_STREAM_FILE_NAME)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.CONTENT_STREAM_ID)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else if (baseTypeId.equals(BaseTypeId.CMIS_FOLDER)) {
+ if (propertyId.equals(PropertyIds.PARENT_ID)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.PATH)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else if (baseTypeId.equals(BaseTypeId.CMIS_POLICY)) {
+ if (propertyId.equals(PropertyIds.SOURCE_ID)) {
+ return true;
+ } else if (propertyId.equals(PropertyIds.TARGET_ID)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else { // relationship
+ if (propertyId.equals(PropertyIds.POLICY_TEXT)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/TypeValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractQueryConditionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractQueryConditionProcessor.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractQueryConditionProcessor.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractQueryConditionProcessor.java Thu Jul 29 17:13:28 2010
@@ -1,135 +1,135 @@
-/*
- * 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.
- */
-package org.apache.chemistry.opencmis.server.support.query;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.GregorianCalendar;
-import java.util.List;
-
-import org.antlr.runtime.ANTLRInputStream;
-import org.antlr.runtime.CharStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.TokenSource;
-import org.antlr.runtime.TokenStream;
-import org.antlr.runtime.tree.CommonTree;
-import org.antlr.runtime.tree.CommonTreeNodeStream;
-import org.antlr.runtime.tree.Tree;
-import org.apache.chemistry.opencmis.server.support.query.CmisQueryWalker;
-import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser_CmisBaseGrammar.query_return;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class AbstractQueryConditionProcessor implements QueryConditionProcessor {
-
- private static Log LOG = LogFactory.getLog(AbstractQueryConditionProcessor.class);
-
- abstract public void onStartProcessing(Tree whereNode);
- abstract public void onStopProcessing();
-
- // Compare operators
- abstract public void onEquals(Tree eqNode, Tree leftNode, Tree rightNode);
- abstract public void onNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
- abstract public void onGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
- abstract public void onGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
- abstract public void onLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
- abstract public void onLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
-
- // Boolean operators
- abstract public void onNot(Tree opNode, Tree leftNode);
- abstract public void onAnd(Tree opNode, Tree leftNode, Tree rightNode);
- abstract public void onOr(Tree opNode, Tree leftNode, Tree rightNode);
-
- // Multi-value:
- abstract public void onIn(Tree node, Tree colNode, Tree listNode);
- abstract public void onNotIn(Tree node, Tree colNode, Tree listNode);
- abstract public void onInAny(Tree node, Tree colNode, Tree listNode);
- abstract public void onNotInAny(Tree node, Tree colNode, Tree listNode);
- abstract public void onEqAny(Tree node, Tree literalNode, Tree colNode);
-
- // Null comparisons:
- abstract public void onIsNull(Tree nullNode, Tree colNode);
- abstract public void onIsNotNull(Tree notNullNode, Tree colNode);
-
- // String matching:
- abstract public void onIsLike(Tree node, Tree colNode, Tree stringNode);
- abstract public void onIsNotLike(Tree node, Tree colNode, Tree stringNode);
-
- // Functions:
- abstract public void onContains(Tree node, Tree colNode, Tree paramNode);
- abstract public void onInFolder(Tree node, Tree colNode, Tree paramNode);
- abstract public void onInTree(Tree node, Tree colNode, Tree paramNode);
- abstract public void onScore(Tree node, Tree paramNode);
-
- // convenience method because everybody needs this piece of code
- static public CmisQueryWalker getWalker(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
- CharStream input = new ANTLRInputStream(new ByteArrayInputStream(statement.getBytes("UTF-8")));
- TokenSource lexer = new CmisQlStrictLexer(input);
- TokenStream tokens = new CommonTokenStream(lexer);
- CmisQlStrictParser parser = new CmisQlStrictParser(tokens);
- CommonTree parserTree; // the ANTLR tree after parsing phase
-
- query_return parsedStatement = parser.query();
-// if (parser.errorMessage != null) {
-// throw new RuntimeException("Cannot parse query: " + statement + " (" + parser.errorMessage + ")");
-// }
- parserTree = (CommonTree) parsedStatement.getTree();
-
- CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
- nodes.setTokenStream(tokens);
- CmisQueryWalker walker = new CmisQueryWalker(nodes);
- return walker;
- }
-
- // helper functions that are needed by most query tree walkers
-
- protected Object onLiteral(Tree node) {
- int type = node.getType();
- String text = node.getText();
- switch (type) {
- case CmisQlStrictLexer.BOOL_LIT:
- return Boolean.parseBoolean(node.getText());
- case CmisQlStrictLexer.NUM_LIT:
- if (text.contains(".") || text.contains("e") || text.contains("E"))
- return Double.parseDouble(text);
- else
- return Long.parseLong(text);
- case CmisQlStrictLexer.STRING_LIT:
- return text.substring(1, text.length()-1);
- case CmisQlStrictLexer.TIME_LIT:
- GregorianCalendar gc = CalendarHelper.fromString(text.substring(text.indexOf('\'')+1, text.lastIndexOf('\'')));
- return gc;
- default:
- throw new RuntimeException("Unknown literal. " + node);
- }
- }
-
- protected List<Object> onLiteralList(Tree node) {
- List<Object> res = new ArrayList<Object>(node.getChildCount());
- for (int i=0; i<node.getChildCount(); i++) {
- Tree literal = node.getChild(i);
- res.add(onLiteral(literal));
- }
- return res;
- }
-
-}
+/*
+ * 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.
+ */
+package org.apache.chemistry.opencmis.server.support.query;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import org.antlr.runtime.ANTLRInputStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenSource;
+import org.antlr.runtime.TokenStream;
+import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.CommonTreeNodeStream;
+import org.antlr.runtime.tree.Tree;
+import org.apache.chemistry.opencmis.server.support.query.CmisQueryWalker;
+import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser_CmisBaseGrammar.query_return;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class AbstractQueryConditionProcessor implements QueryConditionProcessor {
+
+ private static Log LOG = LogFactory.getLog(AbstractQueryConditionProcessor.class);
+
+ abstract public void onStartProcessing(Tree whereNode);
+ abstract public void onStopProcessing();
+
+ // Compare operators
+ abstract public void onEquals(Tree eqNode, Tree leftNode, Tree rightNode);
+ abstract public void onNotEquals(Tree neNode, Tree leftNode, Tree rightNode);
+ abstract public void onGreaterThan(Tree gtNode, Tree leftNode, Tree rightNode);
+ abstract public void onGreaterOrEquals(Tree geNode, Tree leftNode, Tree rightNode);
+ abstract public void onLessThan(Tree ltNode, Tree leftNode, Tree rightNode);
+ abstract public void onLessOrEquals(Tree leqNode, Tree leftNode, Tree rightNode);
+
+ // Boolean operators
+ abstract public void onNot(Tree opNode, Tree leftNode);
+ abstract public void onAnd(Tree opNode, Tree leftNode, Tree rightNode);
+ abstract public void onOr(Tree opNode, Tree leftNode, Tree rightNode);
+
+ // Multi-value:
+ abstract public void onIn(Tree node, Tree colNode, Tree listNode);
+ abstract public void onNotIn(Tree node, Tree colNode, Tree listNode);
+ abstract public void onInAny(Tree node, Tree colNode, Tree listNode);
+ abstract public void onNotInAny(Tree node, Tree colNode, Tree listNode);
+ abstract public void onEqAny(Tree node, Tree literalNode, Tree colNode);
+
+ // Null comparisons:
+ abstract public void onIsNull(Tree nullNode, Tree colNode);
+ abstract public void onIsNotNull(Tree notNullNode, Tree colNode);
+
+ // String matching:
+ abstract public void onIsLike(Tree node, Tree colNode, Tree stringNode);
+ abstract public void onIsNotLike(Tree node, Tree colNode, Tree stringNode);
+
+ // Functions:
+ abstract public void onContains(Tree node, Tree colNode, Tree paramNode);
+ abstract public void onInFolder(Tree node, Tree colNode, Tree paramNode);
+ abstract public void onInTree(Tree node, Tree colNode, Tree paramNode);
+ abstract public void onScore(Tree node, Tree paramNode);
+
+ // convenience method because everybody needs this piece of code
+ static public CmisQueryWalker getWalker(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
+ CharStream input = new ANTLRInputStream(new ByteArrayInputStream(statement.getBytes("UTF-8")));
+ TokenSource lexer = new CmisQlStrictLexer(input);
+ TokenStream tokens = new CommonTokenStream(lexer);
+ CmisQlStrictParser parser = new CmisQlStrictParser(tokens);
+ CommonTree parserTree; // the ANTLR tree after parsing phase
+
+ query_return parsedStatement = parser.query();
+// if (parser.errorMessage != null) {
+// throw new RuntimeException("Cannot parse query: " + statement + " (" + parser.errorMessage + ")");
+// }
+ parserTree = (CommonTree) parsedStatement.getTree();
+
+ CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
+ nodes.setTokenStream(tokens);
+ CmisQueryWalker walker = new CmisQueryWalker(nodes);
+ return walker;
+ }
+
+ // helper functions that are needed by most query tree walkers
+
+ protected Object onLiteral(Tree node) {
+ int type = node.getType();
+ String text = node.getText();
+ switch (type) {
+ case CmisQlStrictLexer.BOOL_LIT:
+ return Boolean.parseBoolean(node.getText());
+ case CmisQlStrictLexer.NUM_LIT:
+ if (text.contains(".") || text.contains("e") || text.contains("E"))
+ return Double.parseDouble(text);
+ else
+ return Long.parseLong(text);
+ case CmisQlStrictLexer.STRING_LIT:
+ return text.substring(1, text.length()-1);
+ case CmisQlStrictLexer.TIME_LIT:
+ GregorianCalendar gc = CalendarHelper.fromString(text.substring(text.indexOf('\'')+1, text.lastIndexOf('\'')));
+ return gc;
+ default:
+ throw new RuntimeException("Unknown literal. " + node);
+ }
+ }
+
+ protected List<Object> onLiteralList(Tree node) {
+ List<Object> res = new ArrayList<Object>(node.getChildCount());
+ for (int i=0; i<node.getChildCount(); i++) {
+ Tree literal = node.getChild(i);
+ res.add(onLiteral(literal));
+ }
+ return res;
+ }
+
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/AbstractQueryConditionProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/CmisSelector.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/CmisSelector.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/CmisSelector.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/CmisSelector.java Thu Jul 29 17:13:28 2010
@@ -1,32 +1,32 @@
-/*
- * 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.
- */
-package org.apache.chemistry.opencmis.server.support.query;
-
-public abstract class CmisSelector {
- private String aliasName; // Alias name for a column (only in SELECT part set)
-
- public void setAliasName(String alias) {
- aliasName = alias;
- }
-
- public String getAliasName() {
- return aliasName;
- }
- public abstract String getName();
-}
+/*
+ * 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.
+ */
+package org.apache.chemistry.opencmis.server.support.query;
+
+public abstract class CmisSelector {
+ private String aliasName; // Alias name for a column (only in SELECT part set)
+
+ public void setAliasName(String alias) {
+ aliasName = alias;
+ }
+
+ public String getAliasName() {
+ return aliasName;
+ }
+ public abstract String getName();
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/CmisSelector.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/ColumnReference.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/ColumnReference.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/ColumnReference.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/ColumnReference.java Thu Jul 29 17:13:28 2010
@@ -1,71 +1,71 @@
-/*
- * 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.
- */
-package org.apache.chemistry.opencmis.server.support.query;
-
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
-
-public class ColumnReference extends CmisSelector {
-
- private String typeQueryName; // type query name coming from query statement
- private String propQueryName; // property query name coming from query statement
-
- // The following fields are set when the types are resolved:
- private String propertyId;
- private TypeDefinition typeDef;
-
- public ColumnReference(String typeQueryName, String propQueryName) {
- this.typeQueryName = typeQueryName;
- this.propQueryName = propQueryName;
- }
-
- public ColumnReference(String propQueryName) {
- this.typeQueryName = null;
- this.propQueryName = propQueryName;
- }
-
- public String getTypeQueryName() {
- return typeQueryName;
- }
-
- public String getPropertyQueryName() {
- return propQueryName;
- }
-
- @Override
- public String getName() {
- return propQueryName;
- }
-
- void setTypeDefinition(String propertyId, TypeDefinition typeDef) {
- this.typeDef = typeDef;
- this.propertyId = propertyId;
- }
-
- public TypeDefinition getTypeDefinition() {
- return typeDef;
- }
-
- public String getPropertyId() {
- return propertyId;
- }
-
- public String toString() {
- return "Column Reference for column " + propQueryName + " in type " + typeQueryName;
- }
-}
+/*
+ * 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.
+ */
+package org.apache.chemistry.opencmis.server.support.query;
+
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+
+public class ColumnReference extends CmisSelector {
+
+ private String typeQueryName; // type query name coming from query statement
+ private String propQueryName; // property query name coming from query statement
+
+ // The following fields are set when the types are resolved:
+ private String propertyId;
+ private TypeDefinition typeDef;
+
+ public ColumnReference(String typeQueryName, String propQueryName) {
+ this.typeQueryName = typeQueryName;
+ this.propQueryName = propQueryName;
+ }
+
+ public ColumnReference(String propQueryName) {
+ this.typeQueryName = null;
+ this.propQueryName = propQueryName;
+ }
+
+ public String getTypeQueryName() {
+ return typeQueryName;
+ }
+
+ public String getPropertyQueryName() {
+ return propQueryName;
+ }
+
+ @Override
+ public String getName() {
+ return propQueryName;
+ }
+
+ void setTypeDefinition(String propertyId, TypeDefinition typeDef) {
+ this.typeDef = typeDef;
+ this.propertyId = propertyId;
+ }
+
+ public TypeDefinition getTypeDefinition() {
+ return typeDef;
+ }
+
+ public String getPropertyId() {
+ return propertyId;
+ }
+
+ public String toString() {
+ return "Column Reference for column " + propQueryName + " in type " + typeQueryName;
+ }
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/ColumnReference.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java Thu Jul 29 17:13:28 2010
@@ -1,44 +1,44 @@
-/*
- * 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.
- */
-package org.apache.chemistry.opencmis.server.support.query;
-
-public class FunctionReference extends CmisSelector {
-
- public enum CmisQlFunction { SCORE, };
-
- private CmisQlFunction function;
-
- public FunctionReference(CmisQlFunction func) {
- this.function = func;
- }
-
- public CmisQlFunction getFunction() {
- return function;
- }
-
- public String toString() {
- return "FunctionReference for " + function.toString();
- }
-
- @Override
- public String getName() {
- return function.toString();
- }
-
-}
+/*
+ * 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.
+ */
+package org.apache.chemistry.opencmis.server.support.query;
+
+public class FunctionReference extends CmisSelector {
+
+ public enum CmisQlFunction { SCORE, };
+
+ private CmisQlFunction function;
+
+ public FunctionReference(CmisQlFunction func) {
+ this.function = func;
+ }
+
+ public CmisQlFunction getFunction() {
+ return function;
+ }
+
+ public String toString() {
+ return "FunctionReference for " + function.toString();
+ }
+
+ @Override
+ public String getName() {
+ return function.toString();
+ }
+
+}
Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/FunctionReference.java
------------------------------------------------------------------------------
svn:eol-style = native