Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common.db')
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/.settings/org.eclipse.jdt.ui.prefs240
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/build.properties42
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/copyright.txt14
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/plugin.properties22
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/db/CDOCommonDBUtil.java108
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractDBAccessor.java80
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractQueryStatement.java108
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractUpdateStatement.java108
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/DBRevisionCacheUtil.java92
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/bundle/OM.java84
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCache.java1660
-rw-r--r--plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCacheSchema.java158
12 files changed, 1358 insertions, 1358 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common.db/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.emf.cdo.common.db/.settings/org.eclipse.jdt.ui.prefs
index aaef0ccba1..6726e7034a 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/.settings/org.eclipse.jdt.ui.prefs
+++ b/plugins/org.eclipse.emf.cdo.common.db/.settings/org.eclipse.jdt.ui.prefs
@@ -1,120 +1,120 @@
-#Thu Feb 04 09:44:24 CET 2010
-cleanup.add_default_serial_version_id=true
-cleanup.add_generated_serial_version_id=false
-cleanup.add_missing_annotations=true
-cleanup.add_missing_deprecated_annotations=true
-cleanup.add_missing_methods=false
-cleanup.add_missing_nls_tags=false
-cleanup.add_missing_override_annotations=true
-cleanup.add_missing_override_annotations_interface_methods=true
-cleanup.add_serial_version_id=true
-cleanup.always_use_blocks=true
-cleanup.always_use_parentheses_in_expressions=false
-cleanup.always_use_this_for_non_static_field_access=false
-cleanup.always_use_this_for_non_static_method_access=false
-cleanup.convert_to_enhanced_for_loop=false
-cleanup.correct_indentation=true
-cleanup.format_source_code=true
-cleanup.format_source_code_changes_only=false
-cleanup.make_local_variable_final=true
-cleanup.make_parameters_final=false
-cleanup.make_private_fields_final=true
-cleanup.make_type_abstract_if_missing_method=false
-cleanup.make_variable_declarations_final=false
-cleanup.never_use_blocks=false
-cleanup.never_use_parentheses_in_expressions=true
-cleanup.organize_imports=true
-cleanup.qualify_static_field_accesses_with_declaring_class=false
-cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-cleanup.qualify_static_member_accesses_with_declaring_class=false
-cleanup.qualify_static_method_accesses_with_declaring_class=false
-cleanup.remove_private_constructors=true
-cleanup.remove_trailing_whitespaces=true
-cleanup.remove_trailing_whitespaces_all=true
-cleanup.remove_trailing_whitespaces_ignore_empty=false
-cleanup.remove_unnecessary_casts=true
-cleanup.remove_unnecessary_nls_tags=true
-cleanup.remove_unused_imports=true
-cleanup.remove_unused_local_variables=false
-cleanup.remove_unused_private_fields=true
-cleanup.remove_unused_private_members=false
-cleanup.remove_unused_private_methods=true
-cleanup.remove_unused_private_types=true
-cleanup.sort_members=false
-cleanup.sort_members_all=false
-cleanup.use_blocks=true
-cleanup.use_blocks_only_for_return_and_throw=false
-cleanup.use_parentheses_in_expressions=true
-cleanup.use_this_for_non_static_field_access=true
-cleanup.use_this_for_non_static_field_access_only_if_necessary=true
-cleanup.use_this_for_non_static_method_access=true
-cleanup.use_this_for_non_static_method_access_only_if_necessary=true
-cleanup_profile=_EMFT
-cleanup_settings_version=2
-eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-formatter_profile=_EMFT
-formatter_settings_version=11
-org.eclipse.jdt.ui.exception.name=ex
-org.eclipse.jdt.ui.gettersetter.use.is=true
-org.eclipse.jdt.ui.ignorelowercasenames=true
-org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java;
-org.eclipse.jdt.ui.javadoc=true
-org.eclipse.jdt.ui.keywordthis=false
-org.eclipse.jdt.ui.ondemandthreshold=99
-org.eclipse.jdt.ui.overrideannotation=true
-org.eclipse.jdt.ui.staticondemandthreshold=99
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
-sp_cleanup.add_default_serial_version_id=true
-sp_cleanup.add_generated_serial_version_id=false
-sp_cleanup.add_missing_annotations=true
-sp_cleanup.add_missing_deprecated_annotations=true
-sp_cleanup.add_missing_methods=false
-sp_cleanup.add_missing_nls_tags=false
-sp_cleanup.add_missing_override_annotations=true
-sp_cleanup.add_missing_override_annotations_interface_methods=false
-sp_cleanup.add_serial_version_id=false
-sp_cleanup.always_use_blocks=true
-sp_cleanup.always_use_parentheses_in_expressions=false
-sp_cleanup.always_use_this_for_non_static_field_access=false
-sp_cleanup.always_use_this_for_non_static_method_access=false
-sp_cleanup.convert_to_enhanced_for_loop=false
-sp_cleanup.correct_indentation=true
-sp_cleanup.format_source_code=true
-sp_cleanup.format_source_code_changes_only=false
-sp_cleanup.make_local_variable_final=false
-sp_cleanup.make_parameters_final=false
-sp_cleanup.make_private_fields_final=true
-sp_cleanup.make_type_abstract_if_missing_method=false
-sp_cleanup.make_variable_declarations_final=false
-sp_cleanup.never_use_blocks=false
-sp_cleanup.never_use_parentheses_in_expressions=true
-sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=true
-sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
-sp_cleanup.remove_private_constructors=true
-sp_cleanup.remove_trailing_whitespaces=true
-sp_cleanup.remove_trailing_whitespaces_all=true
-sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
-sp_cleanup.remove_unnecessary_casts=true
-sp_cleanup.remove_unnecessary_nls_tags=true
-sp_cleanup.remove_unused_imports=true
-sp_cleanup.remove_unused_local_variables=false
-sp_cleanup.remove_unused_private_fields=true
-sp_cleanup.remove_unused_private_members=false
-sp_cleanup.remove_unused_private_methods=true
-sp_cleanup.remove_unused_private_types=true
-sp_cleanup.sort_members=false
-sp_cleanup.sort_members_all=false
-sp_cleanup.use_blocks=true
-sp_cleanup.use_blocks_only_for_return_and_throw=false
-sp_cleanup.use_parentheses_in_expressions=true
-sp_cleanup.use_this_for_non_static_field_access=true
-sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
-sp_cleanup.use_this_for_non_static_method_access=true
-sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+#Thu Feb 04 09:44:24 CET 2010
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=true
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_methods=false
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_missing_override_annotations_interface_methods=true
+cleanup.add_serial_version_id=true
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=false
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.correct_indentation=true
+cleanup.format_source_code=true
+cleanup.format_source_code_changes_only=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=true
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=false
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_trailing_whitespaces=true
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=false
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=false
+cleanup.sort_members_all=false
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=true
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=true
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_EMFT
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_EMFT
+formatter_settings_version=11
+org.eclipse.jdt.ui.exception.name=ex
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java;
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.ondemandthreshold=99
+org.eclipse.jdt.ui.overrideannotation=true
+org.eclipse.jdt.ui.staticondemandthreshold=99
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=false
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=true
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=true
+sp_cleanup.use_this_for_non_static_field_access=true
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=true
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/plugins/org.eclipse.emf.cdo.common.db/build.properties b/plugins/org.eclipse.emf.cdo.common.db/build.properties
index d6cd99e548..a23538dd08 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/build.properties
+++ b/plugins/org.eclipse.emf.cdo.common.db/build.properties
@@ -1,21 +1,21 @@
-# Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Eike Stepper - initial API and implementation
-
-# NLS_MESSAGEFORMAT_VAR
-
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- about.html,\
- copyright.txt,\
- plugin.properties,\
- .options
-src.includes = about.html,\
- copyright.txt
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Eike Stepper - initial API and implementation
+
+# NLS_MESSAGEFORMAT_VAR
+
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ copyright.txt,\
+ plugin.properties,\
+ .options
+src.includes = about.html,\
+ copyright.txt
diff --git a/plugins/org.eclipse.emf.cdo.common.db/copyright.txt b/plugins/org.eclipse.emf.cdo.common.db/copyright.txt
index e921242cf0..8f6328980e 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/copyright.txt
+++ b/plugins/org.eclipse.emf.cdo.common.db/copyright.txt
@@ -1,8 +1,8 @@
-Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
+Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
Eike Stepper - initial API and implementation \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.common.db/plugin.properties b/plugins/org.eclipse.emf.cdo.common.db/plugin.properties
index 96578d978a..68ecb903c5 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/plugin.properties
+++ b/plugins/org.eclipse.emf.cdo.common.db/plugin.properties
@@ -1,11 +1,11 @@
-# Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Eike Stepper - initial API and implementation
-
-pluginName = CDO Model Repository Common DB Support
-providerName = Eclipse Modeling Project
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Eike Stepper - initial API and implementation
+
+pluginName = CDO Model Repository Common DB Support
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/db/CDOCommonDBUtil.java b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/db/CDOCommonDBUtil.java
index fc2a47f8b6..3f1660838c 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/db/CDOCommonDBUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/db/CDOCommonDBUtil.java
@@ -1,54 +1,54 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Andre Dietisheim - further implementations
- */
-package org.eclipse.emf.cdo.common.db;
-
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.internal.db.cache.DBRevisionCache;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public final class CDOCommonDBUtil
-{
- private CDOCommonDBUtil()
- {
- }
-
- /**
- * Creates and returns a new JDBC-based revision cache.
- * <p>
- * TODO Add all config parameters!
- */
- public static CDORevisionCache createDBCache(IDBAdapter dbAdapter, IDBConnectionProvider dbConnectionProvider,
- CDOListFactory listFactory, CDOPackageRegistry packageRegistry, CDORevisionFactory revisionFactory)
- {
- DBRevisionCache cache = new DBRevisionCache();
- cache.setDBAdapter(dbAdapter);
- cache.setDBConnectionProvider(dbConnectionProvider);
- cache.setListFactory(listFactory);
- cache.setPackageRegistry(packageRegistry);
- cache.setRevisionFactory(revisionFactory);
-
- // TODO Remove after branch "redesign-dangling" has been merged!
- cache.setIDProvider(CDOIDProvider.NOOP);
-
- return cache;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ * Andre Dietisheim - further implementations
+ */
+package org.eclipse.emf.cdo.common.db;
+
+import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+import org.eclipse.emf.cdo.common.internal.db.cache.DBRevisionCache;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.revision.CDOListFactory;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
+import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
+
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+
+/**
+ * @author Eike Stepper
+ * @since 3.0
+ */
+public final class CDOCommonDBUtil
+{
+ private CDOCommonDBUtil()
+ {
+ }
+
+ /**
+ * Creates and returns a new JDBC-based revision cache.
+ * <p>
+ * TODO Add all config parameters!
+ */
+ public static CDORevisionCache createDBCache(IDBAdapter dbAdapter, IDBConnectionProvider dbConnectionProvider,
+ CDOListFactory listFactory, CDOPackageRegistry packageRegistry, CDORevisionFactory revisionFactory)
+ {
+ DBRevisionCache cache = new DBRevisionCache();
+ cache.setDBAdapter(dbAdapter);
+ cache.setDBConnectionProvider(dbConnectionProvider);
+ cache.setListFactory(listFactory);
+ cache.setPackageRegistry(packageRegistry);
+ cache.setRevisionFactory(revisionFactory);
+
+ // TODO Remove after branch "redesign-dangling" has been merged!
+ cache.setIDProvider(CDOIDProvider.NOOP);
+
+ return cache;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractDBAccessor.java b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractDBAccessor.java
index 589e2ef2d1..6386d85d9d 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractDBAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractDBAccessor.java
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.common.internal.db;
-
-import org.eclipse.emf.cdo.common.internal.db.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-/**
- * @author Andre Dietisheim
- */
-public abstract class AbstractDBAccessor
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AbstractDBAccessor.class);
-
- protected PreparedStatement getPreparedStatement(Connection connection) throws Exception
- {
- PreparedStatement preparedStatement = connection.prepareStatement(getSQL());
- setParameters(preparedStatement);
- TRACER.trace(getSQL());
- return preparedStatement;
- }
-
- public abstract String getSQL();
-
- protected abstract void setParameters(PreparedStatement statement) throws SQLException, Exception;
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.internal.db;
+
+import org.eclipse.emf.cdo.common.internal.db.bundle.OM;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+/**
+ * @author Andre Dietisheim
+ */
+public abstract class AbstractDBAccessor
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, AbstractDBAccessor.class);
+
+ protected PreparedStatement getPreparedStatement(Connection connection) throws Exception
+ {
+ PreparedStatement preparedStatement = connection.prepareStatement(getSQL());
+ setParameters(preparedStatement);
+ TRACER.trace(getSQL());
+ return preparedStatement;
+ }
+
+ public abstract String getSQL();
+
+ protected abstract void setParameters(PreparedStatement statement) throws SQLException, Exception;
+}
diff --git a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractQueryStatement.java b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractQueryStatement.java
index f07e07089a..d66120adf4 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractQueryStatement.java
+++ b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractQueryStatement.java
@@ -1,54 +1,54 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.common.internal.db;
-
-import org.eclipse.net4j.db.DBUtil;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-
-/**
- * @author Andre Dietisheim
- */
-public abstract class AbstractQueryStatement<Result> extends AbstractDBAccessor
-{
- public AbstractQueryStatement()
- {
- }
-
- public Result query(Connection connection) throws Exception
- {
- PreparedStatement preparedStatement = null;
-
- try
- {
- preparedStatement = getPreparedStatement(connection);
- ResultSet resultSet = preparedStatement.executeQuery();
- connection.commit();
- if (resultSet.next())
- {
- Result result = getResult(resultSet);
- resultSet.close();
- return result;
- }
-
- return null;
- }
- finally
- {
- DBUtil.close(preparedStatement);
- }
- }
-
- protected abstract Result getResult(ResultSet resultSet) throws Exception;
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.internal.db;
+
+import org.eclipse.net4j.db.DBUtil;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+/**
+ * @author Andre Dietisheim
+ */
+public abstract class AbstractQueryStatement<Result> extends AbstractDBAccessor
+{
+ public AbstractQueryStatement()
+ {
+ }
+
+ public Result query(Connection connection) throws Exception
+ {
+ PreparedStatement preparedStatement = null;
+
+ try
+ {
+ preparedStatement = getPreparedStatement(connection);
+ ResultSet resultSet = preparedStatement.executeQuery();
+ connection.commit();
+ if (resultSet.next())
+ {
+ Result result = getResult(resultSet);
+ resultSet.close();
+ return result;
+ }
+
+ return null;
+ }
+ finally
+ {
+ DBUtil.close(preparedStatement);
+ }
+ }
+
+ protected abstract Result getResult(ResultSet resultSet) throws Exception;
+}
diff --git a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractUpdateStatement.java b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractUpdateStatement.java
index 97ccc13108..a5ea2bdaa9 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractUpdateStatement.java
+++ b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/AbstractUpdateStatement.java
@@ -1,54 +1,54 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.common.internal.db;
-
-import org.eclipse.net4j.db.DBException;
-import org.eclipse.net4j.db.DBUtil;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.text.MessageFormat;
-
-/**
- * @author Andre Dietisheim
- */
-public abstract class AbstractUpdateStatement extends AbstractDBAccessor
-{
- public AbstractUpdateStatement()
- {
- }
-
- public void update(Connection connection) throws Exception
- {
- PreparedStatement preparedStatement = null;
- try
- {
- preparedStatement = getPreparedStatement(connection);
- preparedStatement.executeUpdate();
- if (preparedStatement.getUpdateCount() == 0)
- {
- throw new DBException(MessageFormat.format("No row inserted by statement \"{0}\"", getSQL()));
- }
-
- connection.commit();
- }
- finally
- {
- DBUtil.close(preparedStatement);
- }
- }
-
- @Override
- protected void setParameters(PreparedStatement preparedStatement) throws Exception
- {
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.internal.db;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.text.MessageFormat;
+
+/**
+ * @author Andre Dietisheim
+ */
+public abstract class AbstractUpdateStatement extends AbstractDBAccessor
+{
+ public AbstractUpdateStatement()
+ {
+ }
+
+ public void update(Connection connection) throws Exception
+ {
+ PreparedStatement preparedStatement = null;
+ try
+ {
+ preparedStatement = getPreparedStatement(connection);
+ preparedStatement.executeUpdate();
+ if (preparedStatement.getUpdateCount() == 0)
+ {
+ throw new DBException(MessageFormat.format("No row inserted by statement \"{0}\"", getSQL()));
+ }
+
+ connection.commit();
+ }
+ finally
+ {
+ DBUtil.close(preparedStatement);
+ }
+ }
+
+ @Override
+ protected void setParameters(PreparedStatement preparedStatement) throws Exception
+ {
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/DBRevisionCacheUtil.java b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/DBRevisionCacheUtil.java
index 342baf748e..d958e04573 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/DBRevisionCacheUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/DBRevisionCacheUtil.java
@@ -1,46 +1,46 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.common.internal.db;
-
-import org.eclipse.emf.cdo.common.model.CDOModelConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.CheckUtil;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author Andre Dietisheim
- */
-public class DBRevisionCacheUtil
-{
- /**
- * Gets the name of a revision of a CDOResourceNode.
- * <p>
- * See bug 279817
- *
- * @param revision
- * the revision
- * @return the resource node name
- */
- // TODO: this should be refactored and put in a place, that's more generic
- // than this class. The same snippet's used in LRURevisionCache and
- // MemRevisionCache
- public static String getResourceNodeName(CDORevision revision)
- {
- CheckUtil.checkArg(revision.isResourceNode(), "The revision is not a resource node!");
- EStructuralFeature feature = revision.getEClass().getEStructuralFeature(
- CDOModelConstants.RESOURCE_NODE_NAME_ATTRIBUTE);
- return (String)((InternalCDORevision)revision).getValue(feature);
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.internal.db;
+
+import org.eclipse.emf.cdo.common.model.CDOModelConstants;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.net4j.util.CheckUtil;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class DBRevisionCacheUtil
+{
+ /**
+ * Gets the name of a revision of a CDOResourceNode.
+ * <p>
+ * See bug 279817
+ *
+ * @param revision
+ * the revision
+ * @return the resource node name
+ */
+ // TODO: this should be refactored and put in a place, that's more generic
+ // than this class. The same snippet's used in LRURevisionCache and
+ // MemRevisionCache
+ public static String getResourceNodeName(CDORevision revision)
+ {
+ CheckUtil.checkArg(revision.isResourceNode(), "The revision is not a resource node!");
+ EStructuralFeature feature = revision.getEClass().getEStructuralFeature(
+ CDOModelConstants.RESOURCE_NODE_NAME_ATTRIBUTE);
+ return (String)((InternalCDORevision)revision).getValue(feature);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/bundle/OM.java b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/bundle/OM.java
index 1a96bf06d5..b7562f0b30 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/bundle/OM.java
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.common.internal.db.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Andre Dietisheim
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.common.db"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.internal.db.bundle;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Andre Dietisheim
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.emf.cdo.common.db"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCache.java b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCache.java
index f871a2d5ed..4b8adba7d1 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCache.java
+++ b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCache.java
@@ -1,830 +1,830 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.common.internal.db.cache;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.internal.db.AbstractQueryStatement;
-import org.eclipse.emf.cdo.common.internal.db.AbstractUpdateStatement;
-import org.eclipse.emf.cdo.common.internal.db.DBRevisionCacheUtil;
-import org.eclipse.emf.cdo.common.lob.CDOLobStore;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.db.DBException;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.sql.Blob;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A JDBC-based {@link CDORevisionCache}.
- *
- * @author Andre Dietisheim
- */
-public class DBRevisionCache extends Lifecycle implements InternalCDORevisionCache
-{
- private CDOIDProvider idProvider;
-
- private CDOListFactory listFactory;
-
- private CDOPackageRegistry packageRegistry;
-
- private CDORevisionFactory revisionFactory;
-
- private IDBAdapter dbAdapter;
-
- private IDBConnectionProvider dbConnectionProvider;
-
- public DBRevisionCache()
- {
- }
-
- public InternalCDORevisionCache instantiate(CDORevision revision)
- {
- // TODO: Support branches directly
- throw new UnsupportedOperationException();
- }
-
- public CDOIDProvider getIDProvider()
- {
- return idProvider;
- }
-
- public void setIDProvider(CDOIDProvider idProvider)
- {
- this.idProvider = idProvider;
- }
-
- public CDOListFactory getListFactory()
- {
- return listFactory;
- }
-
- public void setListFactory(CDOListFactory listFactory)
- {
- this.listFactory = listFactory;
- }
-
- public CDOPackageRegistry getPackageRegistry()
- {
- return packageRegistry;
- }
-
- public void setPackageRegistry(CDOPackageRegistry packageRegistry)
- {
- this.packageRegistry = packageRegistry;
- }
-
- public CDORevisionFactory getRevisionFactory()
- {
- return revisionFactory;
- }
-
- public void setRevisionFactory(CDORevisionFactory revisionFactory)
- {
- this.revisionFactory = revisionFactory;
- }
-
- public IDBAdapter getDBAdapter()
- {
- return dbAdapter;
- }
-
- public void setDBAdapter(IDBAdapter dbAdapter)
- {
- this.dbAdapter = dbAdapter;
- }
-
- public IDBConnectionProvider getDBConnectionProvider()
- {
- return dbConnectionProvider;
- }
-
- public void setDBConnectionProvider(IDBConnectionProvider dbConnectionProvider)
- {
- this.dbConnectionProvider = dbConnectionProvider;
- }
-
- public EClass getObjectType(CDOID id)
- {
- return null;
- }
-
- /**
- * Gets the revision with the highest version for a given {@link CDOID}.
- *
- * @param id
- * the id to match
- * @return the revision that was found
- */
- public InternalCDORevision getRevision(final CDOID id)
- {
- Connection connection = null;
- String sql = null;
-
- try
- {
- connection = getConnection();
- AbstractQueryStatement<InternalCDORevision> query = createGetRevisionByIDStatement(id);
- sql = query.getSQL();
- return query.query(connection);
- }
- catch (Exception e)
- {
- throw new DBException("Error while retrieving the revision from the database", e, sql); //$NON-NLS-1$
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-
- private AbstractQueryStatement<InternalCDORevision> createGetRevisionByIDStatement(final CDOID id)
- {
- return new AbstractQueryStatement<InternalCDORevision>()
- {
- @Override
- public String getSQL()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("SELECT "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append(" FROM "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS);
- builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_ID);
- builder.append("=? AND "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append("="); //$NON-NLS-1$
- builder.append(CDORevision.UNSPECIFIED_DATE);
- return builder.toString();
- }
-
- @Override
- protected void setParameters(PreparedStatement preparedStatement) throws SQLException
- {
- preparedStatement.setString(1, id.toURIFragment());
- }
-
- @Override
- protected InternalCDORevision getResult(ResultSet resultSet) throws Exception
- {
- long revised = resultSet.getLong(2);
- Blob blob = resultSet.getBlob(1);
- return toRevision(blob, revised);
- }
- };
- }
-
- /**
- * Gets an {@link InternalCDORevision} that matches the given timestamp (it is >= created timestamp AND <= revised
- * timestamp of the revision).
- *
- * @param id
- * the id
- * @return the revision by time
- */
- public InternalCDORevision getRevision(final CDOID id, final CDOBranchPoint branchPoint)
- {
- Connection connection = null;
- String sql = null;
-
- try
- {
- connection = getConnection();
- AbstractQueryStatement<InternalCDORevision> statement = new AbstractQueryStatement<InternalCDORevision>()
- {
- @Override
- public String getSQL()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("SELECT "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append(" FROM "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS);
- builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_ID);
- builder.append("=? AND "); //$NON-NLS-1$
- appendTimestampCondition(builder);
- return builder.toString();
- }
-
- @Override
- protected void setParameters(PreparedStatement preparedStatement) throws SQLException
- {
- long timeStamp = branchPoint.getTimeStamp();
- preparedStatement.setString(1, id.toURIFragment());
- preparedStatement.setLong(2, timeStamp);
- preparedStatement.setLong(3, timeStamp);
- }
-
- @Override
- protected InternalCDORevision getResult(ResultSet resultSet) throws Exception
- {
- long revised = resultSet.getLong(2);
- Blob blob = resultSet.getBlob(1);
- return toRevision(blob, revised);
- }
- };
-
- sql = statement.getSQL();
- return statement.query(connection);
- }
- catch (Exception e)
- {
- throw new DBException("Error while retrieving a revision by timestamp from the database", e, sql); //$NON-NLS-1$
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-
- /**
- * Gets a {@link InternalCDORevision} by a given id and version.
- *
- * @param id
- * the id to match the revision against
- * @return the revision by version
- */
- public InternalCDORevision getRevisionByVersion(final CDOID id, final CDOBranchVersion branchVersion)
- {
- Connection connection = null;
- String sql = null;
-
- try
- {
- connection = getConnection();
- AbstractQueryStatement<InternalCDORevision> statement = new AbstractQueryStatement<InternalCDORevision>()
- {
- @Override
- public String getSQL()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("SELECT "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append(" FROM "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS);
- builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_ID);
- builder.append("=? AND "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_VERSION);
- builder.append("=?"); //$NON-NLS-1$
- return builder.toString();
- }
-
- @Override
- protected void setParameters(PreparedStatement preparedStatement) throws SQLException
- {
- preparedStatement.setString(1, id.toURIFragment());
- preparedStatement.setInt(2, branchVersion.getVersion());
- }
-
- @Override
- protected InternalCDORevision getResult(ResultSet resultSet) throws Exception
- {
- long revised = resultSet.getLong(2);
- Blob blob = resultSet.getBlob(1);
- return toRevision(blob, revised);
- }
- };
-
- sql = statement.getSQL();
- return statement.query(connection);
- }
- catch (Exception e)
- {
- throw new DBException("Error while retrieving a revision by version from the database", e, sql); //$NON-NLS-1$
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-
- /**
- * Gets the latest revisions of all persisted model versions.
- *
- * @return the revisions
- */
- public List<CDORevision> getCurrentRevisions()
- {
- Connection connection = null;
- String sql = null;
-
- try
- {
- connection = getConnection();
- AbstractQueryStatement<List<CDORevision>> query = new AbstractQueryStatement<List<CDORevision>>()
- {
- @Override
- public String getSQL()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("SELECT "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append(" FROM "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS);
- builder.append(" WHERE "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append("="); //$NON-NLS-1$
- builder.append(CDORevision.UNSPECIFIED_DATE);
- return builder.toString();
- }
-
- @Override
- protected void setParameters(PreparedStatement preparedStatement) throws SQLException
- {
- }
-
- @Override
- protected List<CDORevision> getResult(ResultSet resultSet) throws Exception
- {
- final List<CDORevision> revisionList = new ArrayList<CDORevision>();
-
- do
- {
- long revised = resultSet.getLong(2);
- Blob blob = resultSet.getBlob(1);
- revisionList.add(toRevision(blob, revised));
- } while (resultSet.next());
-
- return revisionList;
- }
- };
-
- sql = query.getSQL();
- return query.query(connection);
- }
- catch (Exception e)
- {
- throw new DBException("Error while retrieving a revision by version from the database", e, sql); //$NON-NLS-1$
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-
- /**
- * Adds a given revision to this cache. It furthermore updates the revised timestamp of the latest (before inserting
- * the new one) revision
- *
- * @param revision
- * the revision to add to this cache
- */
- public void addRevision(CDORevision revision)
- {
- CheckUtil.checkArg(revision, "revision");
- Connection connection = null;
- String sql = null;
-
- try
- {
- connection = getConnection();
- AbstractUpdateStatement update = createAddRevisionStatement((InternalCDORevision)revision);
- sql = update.getSQL();
- update.update(connection);
-
- if (revision.getVersion() > CDORevision.FIRST_VERSION)
- {
- // Update former latest revision
- update = createUpdateRevisedStatement((InternalCDORevision)revision);
- update.update(connection);
- }
- }
- catch (DBException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new DBException("Error while retrieving the revision from the database", e, sql); //$NON-NLS-1$
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-
- private AbstractUpdateStatement createUpdateRevisedStatement(final InternalCDORevision revision)
- {
- return new AbstractUpdateStatement()
- {
- @Override
- public String getSQL()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("UPDATE "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS);
- builder.append(" SET "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append(" =? WHERE "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_ID);
- builder.append(" =? AND "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_VERSION);
- builder.append(" =?"); //$NON-NLS-1$
- return builder.toString();
- }
-
- @Override
- protected void setParameters(PreparedStatement preparedStatement) throws SQLException
- {
- preparedStatement.setLong(1, revision.getTimeStamp() - 1);
- preparedStatement.setString(2, revision.getID().toURIFragment());
- preparedStatement.setInt(3, revision.getVersion() - 1);
- }
- };
- }
-
- private AbstractUpdateStatement createAddRevisionStatement(final InternalCDORevision revision)
- {
- return new AbstractUpdateStatement()
- {
- @Override
- public String getSQL()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("INSERT INTO "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS);
- builder.append(" ("); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_ID);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_VERSION);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_CREATED);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_RESOURCENODE_NAME);
- builder.append(", "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_CONTAINERID);
- builder.append(") "); //$NON-NLS-1$
- builder.append(" VALUES (?, ?, ?, ?, ?, ? ,?)"); //$NON-NLS-1$
- return builder.toString();
- }
-
- @Override
- protected void setParameters(PreparedStatement preparedStatement) throws Exception
- {
- preparedStatement.setString(1, revision.getID().toURIFragment());
- preparedStatement.setInt(2, revision.getVersion());
- preparedStatement.setLong(3, revision.getTimeStamp());
- preparedStatement.setLong(4, revision.getRevised());
- preparedStatement.setBytes(5, toBytes(revision));
- setResourceNodeValues(revision, preparedStatement);
- }
-
- /**
- * Sets the values in the prepared statment, that are related to the given revision. If the revision is a resource
- * node, the values are set otherwise the fields are set to <tt>null</tt>
- *
- * @param revision
- * the revision
- * @param preparedStatement
- * the prepared statement
- * @throws SQLException
- * the SQL exception
- */
- private void setResourceNodeValues(InternalCDORevision revision, PreparedStatement preparedStatement)
- throws SQLException
- {
- if (revision.isResourceNode())
- {
- preparedStatement.setString(6, DBRevisionCacheUtil.getResourceNodeName(revision));
- CDOID containerID = (CDOID)revision.getContainerID();
- preparedStatement.setString(7, containerID.toURIFragment());
- }
- else
- {
- preparedStatement.setNull(6, Types.VARCHAR);
- preparedStatement.setNull(7, Types.INTEGER);
- }
- }
- };
- }
-
- /**
- * Removes a revision by its Id and version. If the given revision does not exist <tt>null</tt> is returned. Otherwise
- * the {@link InternalCDORevision}, that was removed is returned
- *
- * @param id
- * the id of the revision to remove
- * @return the {@link InternalCDORevision} that was removed, <tt>null</tt> otherwise
- */
- public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
- {
- Connection connection = null;
- String sql = null;
-
- try
- {
- final InternalCDORevision revision = getRevisionByVersion(id, branchVersion);
- if (revision != null)
- {
- connection = getConnection();
- AbstractUpdateStatement statement = new AbstractUpdateStatement()
- {
- @Override
- public String getSQL()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("DELETE FROM "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS);
- builder.append(" WHERE ID =? AND VERSION =?"); //$NON-NLS-1$
- return builder.toString();
- }
-
- @Override
- protected void setParameters(PreparedStatement preparedStatement) throws Exception
- {
- preparedStatement.setString(1, revision.getID().toURIFragment());
- preparedStatement.setInt(2, revision.getVersion());
- }
- };
-
- sql = statement.getSQL();
- statement.update(connection);
- }
-
- return revision;
- }
- catch (Exception e)
- {
- throw new DBException("Error while removing a revision from the database", e, sql); //$NON-NLS-1$
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-
- /**
- * Removes all revisions from this cache (and its database).
- */
- public void clear()
- {
- Connection connection = null;
- String sql = null;
-
- try
- {
- connection = getConnection();
- AbstractUpdateStatement update = new AbstractUpdateStatement()
- {
- @Override
- public String getSQL()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("DELETE FROM "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS);
- return builder.toString();
- }
- };
-
- sql = update.getSQL();
- update.update(connection);
- }
- catch (Exception e)
- {
- throw new DBException("Error while clearing the database", e, sql);
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-
- public Map<CDOBranch, List<CDORevision>> getAllRevisions()
- {
- throw new UnsupportedOperationException();
- }
-
- public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- checkState(idProvider, "idProvider"); //$NON-NLS-1$
- checkState(listFactory, "listFactory");//$NON-NLS-1$
- checkState(packageRegistry, "packageRegistry"); //$NON-NLS-1$
- checkState(revisionFactory, "revisionFactory"); //$NON-NLS-1$
- checkState(dbAdapter, "dbAdapter"); //$NON-NLS-1$
- checkState(dbConnectionProvider, "dbConnectionProvider"); //$NON-NLS-1$
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- createTable();
- }
-
- /**
- * Creates the (single) table that's used to store the cached revisions.
- *
- * @throws SQLException
- * Signals that an error has occured while getting the connection or committing the transaction
- */
- private void createTable() throws SQLException
- {
- Connection connection = null;
-
- try
- {
- connection = getConnection();
- DBRevisionCacheSchema.INSTANCE.create(dbAdapter, connection);
- connection.commit();
- }
- finally
- {
- DBUtil.close(connection);
- }
- }
-
- private static StringBuilder appendTimestampCondition(StringBuilder builder)
- {
- builder.append(DBRevisionCacheSchema.REVISIONS_CREATED);
- builder.append("<=? AND ("); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append(">=? OR "); //$NON-NLS-1$
- builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
- builder.append("="); //$NON-NLS-1$
- builder.append(CDORevision.UNSPECIFIED_DATE);
- builder.append(")"); //$NON-NLS-1$
- return builder;
- }
-
- /**
- * Converts the given Objects to an {@link InternalCDORevision}. The object is deserialized to an instance of the
- * correct type and the revised timestamp is set separatley. Whe you insert a new revision into this cache, the former
- * latest revision gets a new revised timestamp. This timestamp's only updated in the database column 'revised', not
- * in the blob that holds the serialized instance. Therefore the revised timestamp has to be set separately
- *
- * @param revisedTimestamp
- * the revised timestamp to set to the revision
- * @param blob
- * the blob that holds the revision
- * @return the revision
- * @throws IOException
- * Signals that an error has occurred while reading the revision from the blob.
- * @throws SQLException
- * Signals that an error hass occured while getting the binary stream from the blob
- */
- private InternalCDORevision toRevision(Blob blob, long revisedTimestamp) throws IOException, SQLException
- {
- CDODataInput dataInput = getCDODataInput(ExtendedDataInputStream.wrap(blob.getBinaryStream()));
- InternalCDORevision revision = (InternalCDORevision)dataInput.readCDORevision();
- // Revised timestamp's updated in the revised column only (not in the blob)
- revision.setRevised(revisedTimestamp);
- return revision;
- }
-
- private CDODataInput getCDODataInput(ExtendedDataInputStream inputStream) throws IOException
- {
- return new CDODataInputImpl(inputStream)
- {
- @Override
- protected CDOPackageRegistry getPackageRegistry()
- {
- return packageRegistry;
- }
-
- @Override
- protected CDOBranchManager getBranchManager()
- {
- return null;
- }
-
- @Override
- protected CDOCommitInfoManager getCommitInfoManager()
- {
- return null;
- }
-
- @Override
- protected CDORevisionFactory getRevisionFactory()
- {
- return revisionFactory;
- }
-
- @Override
- protected CDOListFactory getListFactory()
- {
- return listFactory;
- }
-
- @Override
- protected CDOLobStore getLobStore()
- {
- return null;
- }
- };
- }
-
- /**
- * Converts a given {@link CDORevision} to a byte array.
- *
- * @param revision
- * the revision
- * @return the array of bytes for the given revision
- * @throws IOException
- * Signals an error has occurred while writing the revision to the byte array.
- */
- private byte[] toBytes(InternalCDORevision revision) throws IOException
- {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- CDODataOutput dataOutput = getCDODataOutput(ExtendedDataOutputStream.wrap(byteArrayOutputStream));
- dataOutput.writeCDORevision(revision, CDORevision.UNCHUNKED);
- return byteArrayOutputStream.toByteArray();
- }
-
- private CDODataOutput getCDODataOutput(ExtendedDataOutput extendedDataOutputStream)
- {
- return new CDODataOutputImpl(extendedDataOutputStream)
- {
- @Override
- public CDOPackageRegistry getPackageRegistry()
- {
- return packageRegistry;
- }
-
- @Override
- public CDOIDProvider getIDProvider()
- {
- return idProvider;
- }
- };
- }
-
- /**
- * Gets a connection from the {@link IDBConnectionProvider} within this cache. The Connection is set not to auto
- * commit transactions.
- *
- * @return the connection
- * @throws SQLException
- * Signals that an error occured while getting the connection from the connection provider
- */
- private Connection getConnection() throws SQLException
- {
- Connection connection = dbConnectionProvider.getConnection();
- connection.setAutoCommit(false);
- return connection;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.internal.db.cache;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+import org.eclipse.emf.cdo.common.internal.db.AbstractQueryStatement;
+import org.eclipse.emf.cdo.common.internal.db.AbstractUpdateStatement;
+import org.eclipse.emf.cdo.common.internal.db.DBRevisionCacheUtil;
+import org.eclipse.emf.cdo.common.lob.CDOLobStore;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDOListFactory;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
+import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
+import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
+import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.sql.Blob;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A JDBC-based {@link CDORevisionCache}.
+ *
+ * @author Andre Dietisheim
+ */
+public class DBRevisionCache extends Lifecycle implements InternalCDORevisionCache
+{
+ private CDOIDProvider idProvider;
+
+ private CDOListFactory listFactory;
+
+ private CDOPackageRegistry packageRegistry;
+
+ private CDORevisionFactory revisionFactory;
+
+ private IDBAdapter dbAdapter;
+
+ private IDBConnectionProvider dbConnectionProvider;
+
+ public DBRevisionCache()
+ {
+ }
+
+ public InternalCDORevisionCache instantiate(CDORevision revision)
+ {
+ // TODO: Support branches directly
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOIDProvider getIDProvider()
+ {
+ return idProvider;
+ }
+
+ public void setIDProvider(CDOIDProvider idProvider)
+ {
+ this.idProvider = idProvider;
+ }
+
+ public CDOListFactory getListFactory()
+ {
+ return listFactory;
+ }
+
+ public void setListFactory(CDOListFactory listFactory)
+ {
+ this.listFactory = listFactory;
+ }
+
+ public CDOPackageRegistry getPackageRegistry()
+ {
+ return packageRegistry;
+ }
+
+ public void setPackageRegistry(CDOPackageRegistry packageRegistry)
+ {
+ this.packageRegistry = packageRegistry;
+ }
+
+ public CDORevisionFactory getRevisionFactory()
+ {
+ return revisionFactory;
+ }
+
+ public void setRevisionFactory(CDORevisionFactory revisionFactory)
+ {
+ this.revisionFactory = revisionFactory;
+ }
+
+ public IDBAdapter getDBAdapter()
+ {
+ return dbAdapter;
+ }
+
+ public void setDBAdapter(IDBAdapter dbAdapter)
+ {
+ this.dbAdapter = dbAdapter;
+ }
+
+ public IDBConnectionProvider getDBConnectionProvider()
+ {
+ return dbConnectionProvider;
+ }
+
+ public void setDBConnectionProvider(IDBConnectionProvider dbConnectionProvider)
+ {
+ this.dbConnectionProvider = dbConnectionProvider;
+ }
+
+ public EClass getObjectType(CDOID id)
+ {
+ return null;
+ }
+
+ /**
+ * Gets the revision with the highest version for a given {@link CDOID}.
+ *
+ * @param id
+ * the id to match
+ * @return the revision that was found
+ */
+ public InternalCDORevision getRevision(final CDOID id)
+ {
+ Connection connection = null;
+ String sql = null;
+
+ try
+ {
+ connection = getConnection();
+ AbstractQueryStatement<InternalCDORevision> query = createGetRevisionByIDStatement(id);
+ sql = query.getSQL();
+ return query.query(connection);
+ }
+ catch (Exception e)
+ {
+ throw new DBException("Error while retrieving the revision from the database", e, sql); //$NON-NLS-1$
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ private AbstractQueryStatement<InternalCDORevision> createGetRevisionByIDStatement(final CDOID id)
+ {
+ return new AbstractQueryStatement<InternalCDORevision>()
+ {
+ @Override
+ public String getSQL()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SELECT "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append(" FROM "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS);
+ builder.append(" WHERE "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_ID);
+ builder.append("=? AND "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append("="); //$NON-NLS-1$
+ builder.append(CDORevision.UNSPECIFIED_DATE);
+ return builder.toString();
+ }
+
+ @Override
+ protected void setParameters(PreparedStatement preparedStatement) throws SQLException
+ {
+ preparedStatement.setString(1, id.toURIFragment());
+ }
+
+ @Override
+ protected InternalCDORevision getResult(ResultSet resultSet) throws Exception
+ {
+ long revised = resultSet.getLong(2);
+ Blob blob = resultSet.getBlob(1);
+ return toRevision(blob, revised);
+ }
+ };
+ }
+
+ /**
+ * Gets an {@link InternalCDORevision} that matches the given timestamp (it is >= created timestamp AND <= revised
+ * timestamp of the revision).
+ *
+ * @param id
+ * the id
+ * @return the revision by time
+ */
+ public InternalCDORevision getRevision(final CDOID id, final CDOBranchPoint branchPoint)
+ {
+ Connection connection = null;
+ String sql = null;
+
+ try
+ {
+ connection = getConnection();
+ AbstractQueryStatement<InternalCDORevision> statement = new AbstractQueryStatement<InternalCDORevision>()
+ {
+ @Override
+ public String getSQL()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SELECT "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append(" FROM "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS);
+ builder.append(" WHERE "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_ID);
+ builder.append("=? AND "); //$NON-NLS-1$
+ appendTimestampCondition(builder);
+ return builder.toString();
+ }
+
+ @Override
+ protected void setParameters(PreparedStatement preparedStatement) throws SQLException
+ {
+ long timeStamp = branchPoint.getTimeStamp();
+ preparedStatement.setString(1, id.toURIFragment());
+ preparedStatement.setLong(2, timeStamp);
+ preparedStatement.setLong(3, timeStamp);
+ }
+
+ @Override
+ protected InternalCDORevision getResult(ResultSet resultSet) throws Exception
+ {
+ long revised = resultSet.getLong(2);
+ Blob blob = resultSet.getBlob(1);
+ return toRevision(blob, revised);
+ }
+ };
+
+ sql = statement.getSQL();
+ return statement.query(connection);
+ }
+ catch (Exception e)
+ {
+ throw new DBException("Error while retrieving a revision by timestamp from the database", e, sql); //$NON-NLS-1$
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ /**
+ * Gets a {@link InternalCDORevision} by a given id and version.
+ *
+ * @param id
+ * the id to match the revision against
+ * @return the revision by version
+ */
+ public InternalCDORevision getRevisionByVersion(final CDOID id, final CDOBranchVersion branchVersion)
+ {
+ Connection connection = null;
+ String sql = null;
+
+ try
+ {
+ connection = getConnection();
+ AbstractQueryStatement<InternalCDORevision> statement = new AbstractQueryStatement<InternalCDORevision>()
+ {
+ @Override
+ public String getSQL()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SELECT "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append(" FROM "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS);
+ builder.append(" WHERE "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_ID);
+ builder.append("=? AND "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_VERSION);
+ builder.append("=?"); //$NON-NLS-1$
+ return builder.toString();
+ }
+
+ @Override
+ protected void setParameters(PreparedStatement preparedStatement) throws SQLException
+ {
+ preparedStatement.setString(1, id.toURIFragment());
+ preparedStatement.setInt(2, branchVersion.getVersion());
+ }
+
+ @Override
+ protected InternalCDORevision getResult(ResultSet resultSet) throws Exception
+ {
+ long revised = resultSet.getLong(2);
+ Blob blob = resultSet.getBlob(1);
+ return toRevision(blob, revised);
+ }
+ };
+
+ sql = statement.getSQL();
+ return statement.query(connection);
+ }
+ catch (Exception e)
+ {
+ throw new DBException("Error while retrieving a revision by version from the database", e, sql); //$NON-NLS-1$
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ /**
+ * Gets the latest revisions of all persisted model versions.
+ *
+ * @return the revisions
+ */
+ public List<CDORevision> getCurrentRevisions()
+ {
+ Connection connection = null;
+ String sql = null;
+
+ try
+ {
+ connection = getConnection();
+ AbstractQueryStatement<List<CDORevision>> query = new AbstractQueryStatement<List<CDORevision>>()
+ {
+ @Override
+ public String getSQL()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SELECT "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append(" FROM "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS);
+ builder.append(" WHERE "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append("="); //$NON-NLS-1$
+ builder.append(CDORevision.UNSPECIFIED_DATE);
+ return builder.toString();
+ }
+
+ @Override
+ protected void setParameters(PreparedStatement preparedStatement) throws SQLException
+ {
+ }
+
+ @Override
+ protected List<CDORevision> getResult(ResultSet resultSet) throws Exception
+ {
+ final List<CDORevision> revisionList = new ArrayList<CDORevision>();
+
+ do
+ {
+ long revised = resultSet.getLong(2);
+ Blob blob = resultSet.getBlob(1);
+ revisionList.add(toRevision(blob, revised));
+ } while (resultSet.next());
+
+ return revisionList;
+ }
+ };
+
+ sql = query.getSQL();
+ return query.query(connection);
+ }
+ catch (Exception e)
+ {
+ throw new DBException("Error while retrieving a revision by version from the database", e, sql); //$NON-NLS-1$
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ /**
+ * Adds a given revision to this cache. It furthermore updates the revised timestamp of the latest (before inserting
+ * the new one) revision
+ *
+ * @param revision
+ * the revision to add to this cache
+ */
+ public void addRevision(CDORevision revision)
+ {
+ CheckUtil.checkArg(revision, "revision");
+ Connection connection = null;
+ String sql = null;
+
+ try
+ {
+ connection = getConnection();
+ AbstractUpdateStatement update = createAddRevisionStatement((InternalCDORevision)revision);
+ sql = update.getSQL();
+ update.update(connection);
+
+ if (revision.getVersion() > CDORevision.FIRST_VERSION)
+ {
+ // Update former latest revision
+ update = createUpdateRevisedStatement((InternalCDORevision)revision);
+ update.update(connection);
+ }
+ }
+ catch (DBException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new DBException("Error while retrieving the revision from the database", e, sql); //$NON-NLS-1$
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ private AbstractUpdateStatement createUpdateRevisedStatement(final InternalCDORevision revision)
+ {
+ return new AbstractUpdateStatement()
+ {
+ @Override
+ public String getSQL()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("UPDATE "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS);
+ builder.append(" SET "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append(" =? WHERE "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_ID);
+ builder.append(" =? AND "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_VERSION);
+ builder.append(" =?"); //$NON-NLS-1$
+ return builder.toString();
+ }
+
+ @Override
+ protected void setParameters(PreparedStatement preparedStatement) throws SQLException
+ {
+ preparedStatement.setLong(1, revision.getTimeStamp() - 1);
+ preparedStatement.setString(2, revision.getID().toURIFragment());
+ preparedStatement.setInt(3, revision.getVersion() - 1);
+ }
+ };
+ }
+
+ private AbstractUpdateStatement createAddRevisionStatement(final InternalCDORevision revision)
+ {
+ return new AbstractUpdateStatement()
+ {
+ @Override
+ public String getSQL()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("INSERT INTO "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS);
+ builder.append(" ("); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_ID);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_VERSION);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_CREATED);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_CDOREVISION);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_RESOURCENODE_NAME);
+ builder.append(", "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_CONTAINERID);
+ builder.append(") "); //$NON-NLS-1$
+ builder.append(" VALUES (?, ?, ?, ?, ?, ? ,?)"); //$NON-NLS-1$
+ return builder.toString();
+ }
+
+ @Override
+ protected void setParameters(PreparedStatement preparedStatement) throws Exception
+ {
+ preparedStatement.setString(1, revision.getID().toURIFragment());
+ preparedStatement.setInt(2, revision.getVersion());
+ preparedStatement.setLong(3, revision.getTimeStamp());
+ preparedStatement.setLong(4, revision.getRevised());
+ preparedStatement.setBytes(5, toBytes(revision));
+ setResourceNodeValues(revision, preparedStatement);
+ }
+
+ /**
+ * Sets the values in the prepared statment, that are related to the given revision. If the revision is a resource
+ * node, the values are set otherwise the fields are set to <tt>null</tt>
+ *
+ * @param revision
+ * the revision
+ * @param preparedStatement
+ * the prepared statement
+ * @throws SQLException
+ * the SQL exception
+ */
+ private void setResourceNodeValues(InternalCDORevision revision, PreparedStatement preparedStatement)
+ throws SQLException
+ {
+ if (revision.isResourceNode())
+ {
+ preparedStatement.setString(6, DBRevisionCacheUtil.getResourceNodeName(revision));
+ CDOID containerID = (CDOID)revision.getContainerID();
+ preparedStatement.setString(7, containerID.toURIFragment());
+ }
+ else
+ {
+ preparedStatement.setNull(6, Types.VARCHAR);
+ preparedStatement.setNull(7, Types.INTEGER);
+ }
+ }
+ };
+ }
+
+ /**
+ * Removes a revision by its Id and version. If the given revision does not exist <tt>null</tt> is returned. Otherwise
+ * the {@link InternalCDORevision}, that was removed is returned
+ *
+ * @param id
+ * the id of the revision to remove
+ * @return the {@link InternalCDORevision} that was removed, <tt>null</tt> otherwise
+ */
+ public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
+ {
+ Connection connection = null;
+ String sql = null;
+
+ try
+ {
+ final InternalCDORevision revision = getRevisionByVersion(id, branchVersion);
+ if (revision != null)
+ {
+ connection = getConnection();
+ AbstractUpdateStatement statement = new AbstractUpdateStatement()
+ {
+ @Override
+ public String getSQL()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("DELETE FROM "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS);
+ builder.append(" WHERE ID =? AND VERSION =?"); //$NON-NLS-1$
+ return builder.toString();
+ }
+
+ @Override
+ protected void setParameters(PreparedStatement preparedStatement) throws Exception
+ {
+ preparedStatement.setString(1, revision.getID().toURIFragment());
+ preparedStatement.setInt(2, revision.getVersion());
+ }
+ };
+
+ sql = statement.getSQL();
+ statement.update(connection);
+ }
+
+ return revision;
+ }
+ catch (Exception e)
+ {
+ throw new DBException("Error while removing a revision from the database", e, sql); //$NON-NLS-1$
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ /**
+ * Removes all revisions from this cache (and its database).
+ */
+ public void clear()
+ {
+ Connection connection = null;
+ String sql = null;
+
+ try
+ {
+ connection = getConnection();
+ AbstractUpdateStatement update = new AbstractUpdateStatement()
+ {
+ @Override
+ public String getSQL()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("DELETE FROM "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS);
+ return builder.toString();
+ }
+ };
+
+ sql = update.getSQL();
+ update.update(connection);
+ }
+ catch (Exception e)
+ {
+ throw new DBException("Error while clearing the database", e, sql);
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ public Map<CDOBranch, List<CDORevision>> getAllRevisions()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ checkState(idProvider, "idProvider"); //$NON-NLS-1$
+ checkState(listFactory, "listFactory");//$NON-NLS-1$
+ checkState(packageRegistry, "packageRegistry"); //$NON-NLS-1$
+ checkState(revisionFactory, "revisionFactory"); //$NON-NLS-1$
+ checkState(dbAdapter, "dbAdapter"); //$NON-NLS-1$
+ checkState(dbConnectionProvider, "dbConnectionProvider"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ createTable();
+ }
+
+ /**
+ * Creates the (single) table that's used to store the cached revisions.
+ *
+ * @throws SQLException
+ * Signals that an error has occured while getting the connection or committing the transaction
+ */
+ private void createTable() throws SQLException
+ {
+ Connection connection = null;
+
+ try
+ {
+ connection = getConnection();
+ DBRevisionCacheSchema.INSTANCE.create(dbAdapter, connection);
+ connection.commit();
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
+ }
+
+ private static StringBuilder appendTimestampCondition(StringBuilder builder)
+ {
+ builder.append(DBRevisionCacheSchema.REVISIONS_CREATED);
+ builder.append("<=? AND ("); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append(">=? OR "); //$NON-NLS-1$
+ builder.append(DBRevisionCacheSchema.REVISIONS_REVISED);
+ builder.append("="); //$NON-NLS-1$
+ builder.append(CDORevision.UNSPECIFIED_DATE);
+ builder.append(")"); //$NON-NLS-1$
+ return builder;
+ }
+
+ /**
+ * Converts the given Objects to an {@link InternalCDORevision}. The object is deserialized to an instance of the
+ * correct type and the revised timestamp is set separatley. Whe you insert a new revision into this cache, the former
+ * latest revision gets a new revised timestamp. This timestamp's only updated in the database column 'revised', not
+ * in the blob that holds the serialized instance. Therefore the revised timestamp has to be set separately
+ *
+ * @param revisedTimestamp
+ * the revised timestamp to set to the revision
+ * @param blob
+ * the blob that holds the revision
+ * @return the revision
+ * @throws IOException
+ * Signals that an error has occurred while reading the revision from the blob.
+ * @throws SQLException
+ * Signals that an error hass occured while getting the binary stream from the blob
+ */
+ private InternalCDORevision toRevision(Blob blob, long revisedTimestamp) throws IOException, SQLException
+ {
+ CDODataInput dataInput = getCDODataInput(ExtendedDataInputStream.wrap(blob.getBinaryStream()));
+ InternalCDORevision revision = (InternalCDORevision)dataInput.readCDORevision();
+ // Revised timestamp's updated in the revised column only (not in the blob)
+ revision.setRevised(revisedTimestamp);
+ return revision;
+ }
+
+ private CDODataInput getCDODataInput(ExtendedDataInputStream inputStream) throws IOException
+ {
+ return new CDODataInputImpl(inputStream)
+ {
+ @Override
+ protected CDOPackageRegistry getPackageRegistry()
+ {
+ return packageRegistry;
+ }
+
+ @Override
+ protected CDOBranchManager getBranchManager()
+ {
+ return null;
+ }
+
+ @Override
+ protected CDOCommitInfoManager getCommitInfoManager()
+ {
+ return null;
+ }
+
+ @Override
+ protected CDORevisionFactory getRevisionFactory()
+ {
+ return revisionFactory;
+ }
+
+ @Override
+ protected CDOListFactory getListFactory()
+ {
+ return listFactory;
+ }
+
+ @Override
+ protected CDOLobStore getLobStore()
+ {
+ return null;
+ }
+ };
+ }
+
+ /**
+ * Converts a given {@link CDORevision} to a byte array.
+ *
+ * @param revision
+ * the revision
+ * @return the array of bytes for the given revision
+ * @throws IOException
+ * Signals an error has occurred while writing the revision to the byte array.
+ */
+ private byte[] toBytes(InternalCDORevision revision) throws IOException
+ {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ CDODataOutput dataOutput = getCDODataOutput(ExtendedDataOutputStream.wrap(byteArrayOutputStream));
+ dataOutput.writeCDORevision(revision, CDORevision.UNCHUNKED);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ private CDODataOutput getCDODataOutput(ExtendedDataOutput extendedDataOutputStream)
+ {
+ return new CDODataOutputImpl(extendedDataOutputStream)
+ {
+ @Override
+ public CDOPackageRegistry getPackageRegistry()
+ {
+ return packageRegistry;
+ }
+
+ @Override
+ public CDOIDProvider getIDProvider()
+ {
+ return idProvider;
+ }
+ };
+ }
+
+ /**
+ * Gets a connection from the {@link IDBConnectionProvider} within this cache. The Connection is set not to auto
+ * commit transactions.
+ *
+ * @return the connection
+ * @throws SQLException
+ * Signals that an error occured while getting the connection from the connection provider
+ */
+ private Connection getConnection() throws SQLException
+ {
+ Connection connection = dbConnectionProvider.getConnection();
+ connection.setAutoCommit(false);
+ return connection;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCacheSchema.java b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCacheSchema.java
index 0f8f500db9..c1011b0e92 100644
--- a/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCacheSchema.java
+++ b/plugins/org.eclipse.emf.cdo.common.db/src/org/eclipse/emf/cdo/common/internal/db/cache/DBRevisionCacheSchema.java
@@ -1,79 +1,79 @@
-/*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andre Dietisheim - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.common.internal.db.cache;
-
-import org.eclipse.net4j.db.DBType;
-import org.eclipse.net4j.db.ddl.IDBField;
-import org.eclipse.net4j.db.ddl.IDBIndex;
-import org.eclipse.net4j.db.ddl.IDBTable;
-import org.eclipse.net4j.spi.db.DBSchema;
-
-/**
- * @author Andre Dietisheim
- */
-public class DBRevisionCacheSchema extends DBSchema
-{
- public static final DBRevisionCacheSchema INSTANCE = new DBRevisionCacheSchema();
-
- /**
- * DBTable dbrevisioncache_revisions.
- * <p>
- * TODO Make name configurable!
- */
- public static final IDBTable REVISIONS = INSTANCE.addTable("dbrevisioncache_revisions");
-
- public static final IDBField REVISIONS_ID = //
- REVISIONS.addField("id", DBType.VARCHAR, 254);
-
- public static final IDBField REVISIONS_VERSION = //
- REVISIONS.addField("version", DBType.INTEGER);
-
- public static final IDBField REVISIONS_CREATED = //
- REVISIONS.addField("created", DBType.BIGINT);
-
- public static final IDBField REVISIONS_REVISED = //
- REVISIONS.addField("revised", DBType.BIGINT);
-
- public static final IDBField REVISIONS_CDOREVISION = //
- REVISIONS.addField("revision", DBType.BLOB);
-
- public static final IDBField REVISIONS_RESOURCENODE_NAME = //
- REVISIONS.addField("resourcenode_name", DBType.VARCHAR, false);
-
- public static final IDBField REVISIONS_CONTAINERID = //
- REVISIONS.addField("container_id", DBType.BIGINT, false);
-
- public static final IDBIndex INDEX_REVISIONS_RESOURCENODENAME = //
- REVISIONS.addIndex(IDBIndex.Type.NON_UNIQUE, REVISIONS_RESOURCENODE_NAME);
-
- public static final IDBIndex INDEX_REVISIONS_ID = //
- REVISIONS.addIndex(IDBIndex.Type.NON_UNIQUE, REVISIONS_ID);
-
- public static final IDBIndex INDEX_REVISIONS_VERSION = //
- REVISIONS.addIndex(IDBIndex.Type.NON_UNIQUE, REVISIONS_VERSION);
-
- public static final IDBIndex INDEX_REVISIONS_PK = //
- REVISIONS.addIndex(IDBIndex.Type.PRIMARY_KEY, REVISIONS_ID, REVISIONS_VERSION);
-
- public static final IDBIndex INDEX_REVISIONS_CONTAINERID = //
- REVISIONS.addIndex(IDBIndex.Type.NON_UNIQUE, REVISIONS_CONTAINERID);
-
- private DBRevisionCacheSchema()
- {
- super("DBRevisionCache");
- }
-
- static
- {
- INSTANCE.lock();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Dietisheim - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.internal.db.cache;
+
+import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBIndex;
+import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.spi.db.DBSchema;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class DBRevisionCacheSchema extends DBSchema
+{
+ public static final DBRevisionCacheSchema INSTANCE = new DBRevisionCacheSchema();
+
+ /**
+ * DBTable dbrevisioncache_revisions.
+ * <p>
+ * TODO Make name configurable!
+ */
+ public static final IDBTable REVISIONS = INSTANCE.addTable("dbrevisioncache_revisions");
+
+ public static final IDBField REVISIONS_ID = //
+ REVISIONS.addField("id", DBType.VARCHAR, 254);
+
+ public static final IDBField REVISIONS_VERSION = //
+ REVISIONS.addField("version", DBType.INTEGER);
+
+ public static final IDBField REVISIONS_CREATED = //
+ REVISIONS.addField("created", DBType.BIGINT);
+
+ public static final IDBField REVISIONS_REVISED = //
+ REVISIONS.addField("revised", DBType.BIGINT);
+
+ public static final IDBField REVISIONS_CDOREVISION = //
+ REVISIONS.addField("revision", DBType.BLOB);
+
+ public static final IDBField REVISIONS_RESOURCENODE_NAME = //
+ REVISIONS.addField("resourcenode_name", DBType.VARCHAR, false);
+
+ public static final IDBField REVISIONS_CONTAINERID = //
+ REVISIONS.addField("container_id", DBType.BIGINT, false);
+
+ public static final IDBIndex INDEX_REVISIONS_RESOURCENODENAME = //
+ REVISIONS.addIndex(IDBIndex.Type.NON_UNIQUE, REVISIONS_RESOURCENODE_NAME);
+
+ public static final IDBIndex INDEX_REVISIONS_ID = //
+ REVISIONS.addIndex(IDBIndex.Type.NON_UNIQUE, REVISIONS_ID);
+
+ public static final IDBIndex INDEX_REVISIONS_VERSION = //
+ REVISIONS.addIndex(IDBIndex.Type.NON_UNIQUE, REVISIONS_VERSION);
+
+ public static final IDBIndex INDEX_REVISIONS_PK = //
+ REVISIONS.addIndex(IDBIndex.Type.PRIMARY_KEY, REVISIONS_ID, REVISIONS_VERSION);
+
+ public static final IDBIndex INDEX_REVISIONS_CONTAINERID = //
+ REVISIONS.addIndex(IDBIndex.Type.NON_UNIQUE, REVISIONS_CONTAINERID);
+
+ private DBRevisionCacheSchema()
+ {
+ super("DBRevisionCache");
+ }
+
+ static
+ {
+ INSTANCE.lock();
+ }
+}

Back to the top