diff options
author | Eike Stepper | 2012-01-14 10:27:01 +0000 |
---|---|---|
committer | Eike Stepper | 2012-01-14 10:27:01 +0000 |
commit | 0266166cb9ff9535c150250073ea1e57b42d2693 (patch) | |
tree | c006a3bc0ba1f6e1d8a2bc032eedc346f71eab0d /plugins/org.eclipse.emf.cdo.workspace | |
parent | 7416443692cdda72d1f704ea4fc5ececcc669df7 (diff) | |
download | cdo-0266166cb9ff9535c150250073ea1e57b42d2693.tar.gz cdo-0266166cb9ff9535c150250073ea1e57b42d2693.tar.xz cdo-0266166cb9ff9535c150250073ea1e57b42d2693.zip |
Adjusted copyrights to 2012
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.workspace')
18 files changed, 2184 insertions, 2184 deletions
diff --git a/plugins/org.eclipse.emf.cdo.workspace/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.emf.cdo.workspace/.settings/org.eclipse.jdt.ui.prefs index aaef0ccba1..6726e7034a 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/.settings/org.eclipse.jdt.ui.prefs +++ b/plugins/org.eclipse.emf.cdo.workspace/.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.workspace/build.properties b/plugins/org.eclipse.emf.cdo.workspace/build.properties index 7aaa05eb68..b9909b26f5 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/build.properties +++ b/plugins/org.eclipse.emf.cdo.workspace/build.properties @@ -1,22 +1,22 @@ -# 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/,\ - .,\ - .options,\ - about.html,\ - copyright.txt,\ - plugin.properties,\ - plugin.xml -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/,\
+ .,\
+ .options,\
+ about.html,\
+ copyright.txt,\
+ plugin.properties,\
+ plugin.xml
+src.includes = about.html,\
+ copyright.txt
diff --git a/plugins/org.eclipse.emf.cdo.workspace/copyright.txt b/plugins/org.eclipse.emf.cdo.workspace/copyright.txt index e921242cf0..8f6328980e 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/copyright.txt +++ b/plugins/org.eclipse.emf.cdo.workspace/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.workspace/plugin.properties b/plugins/org.eclipse.emf.cdo.workspace/plugin.properties index 6fac9ae921..2a3e62871c 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.workspace/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 Client Workspace -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 Client Workspace
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.cdo.workspace/plugin.xml b/plugins/org.eclipse.emf.cdo.workspace/plugin.xml index fe6b8a99f7..924f4e4ea8 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.workspace/plugin.xml @@ -1,33 +1,33 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.4"?> -<!-- - 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 ---> - -<plugin> - - <extension - point="org.eclipse.net4j.util.factories"> - <factory - class="org.eclipse.emf.cdo.internal.workspace.FolderCDOWorkspaceBase$Factory" - productGroup="org.eclipse.emf.cdo.workspace.bases" - type="folder"/> - </extension> - - <extension point="org.eclipse.core.expressions.propertyTesters"> - <propertyTester - id="org.eclipse.emf.cdo.workspace.properties" - type="org.eclipse.emf.cdo.workspace.CDOWorkspace" - namespace="org.eclipse.emf.cdo.workspace" - properties="open,branchPath,timeStamp,fixed,dirty,idGenerationLocation,base,local,remote" - class="org.eclipse.emf.cdo.internal.workspace.WorkspaceProperties$Tester"/> - </extension> - -</plugin> +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ 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
+-->
+
+<plugin>
+
+ <extension
+ point="org.eclipse.net4j.util.factories">
+ <factory
+ class="org.eclipse.emf.cdo.internal.workspace.FolderCDOWorkspaceBase$Factory"
+ productGroup="org.eclipse.emf.cdo.workspace.bases"
+ type="folder"/>
+ </extension>
+
+ <extension point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ id="org.eclipse.emf.cdo.workspace.properties"
+ type="org.eclipse.emf.cdo.workspace.CDOWorkspace"
+ namespace="org.eclipse.emf.cdo.workspace"
+ properties="open,branchPath,timeStamp,fixed,dirty,idGenerationLocation,base,local,remote"
+ class="org.eclipse.emf.cdo.internal.workspace.WorkspaceProperties$Tester"/>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java index 2cd3783535..e0a3e47902 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java @@ -1,139 +1,139 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.internal.workspace; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDProvider; -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.CDORevisionFactory; -import org.eclipse.emf.cdo.common.util.CDOCommonUtil; -import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; -import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace; -import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspaceBase; -import org.eclipse.emf.cdo.transaction.CDOTransaction; - -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public abstract class AbstractCDOWorkspaceBase implements InternalCDOWorkspaceBase -{ - private InternalCDOWorkspace workspace; - - private Set<CDOID> ids; - - protected AbstractCDOWorkspaceBase() - { - } - - public void init(InternalCDOWorkspace workspace) - { - this.workspace = workspace; - } - - public final InternalCDOWorkspace getWorkspace() - { - return workspace; - } - - public final synchronized Set<CDOID> getIDs() - { - if (ids == null) - { - ids = doGetIDs(); - } - - return ids; - } - - @Deprecated - public final void updateAfterCommit(CDOTransaction transaction) - { - throw new UnsupportedOperationException(); - } - - public final synchronized void registerChangedOrDetachedObject(InternalCDORevision revision) - { - getIDs().add(revision.getID()); - doRegisterChangedOrDetachedObject(revision); - } - - public final synchronized void registerAddedObject(CDOID id) - { - getIDs().add(id); - doRegisterAddedObject(id); - } - - public final synchronized void deregisterObject(CDOID id) - { - if (ids != null) - { - ids.remove(id); - } - - doDeregisterObject(id); - } - - public final synchronized void clear() - { - ids = new HashSet<CDOID>(); - doClear(); - } - - public final synchronized boolean isEmpty() - { - return getIDs().isEmpty(); - } - - public final synchronized boolean containsID(CDOID id) - { - return getIDs().contains(id); - } - - protected CDODataInput createCDODataInput(ExtendedDataInputStream edis) throws IOException - { - InternalCDOPackageRegistry packageRegistry = workspace.getLocalRepository().getPackageRegistry(false); - InternalCDOBranchManager branchManager = workspace.getLocalRepository().getBranchManager(); - CDORevisionFactory revisionFactory = CDORevisionFactory.DEFAULT; - CDOListFactory listFactory = CDOListFactory.DEFAULT; - - return CDOCommonUtil.createCDODataInput(edis, packageRegistry, branchManager, null, revisionFactory, listFactory, - null); - } - - protected CDODataOutput createCDODataOutput(ExtendedDataOutputStream edos) - { - InternalCDOPackageRegistry packageRegistry = workspace.getLocalRepository().getPackageRegistry(false); - CDOIDProvider idProvider = CDOIDProvider.NOOP; - - return CDOCommonUtil.createCDODataOutput(edos, packageRegistry, idProvider); - } - - protected abstract void doClear(); - - protected abstract Set<CDOID> doGetIDs(); - - protected abstract void doRegisterChangedOrDetachedObject(InternalCDORevision revision); - - protected abstract void doRegisterAddedObject(CDOID id); - - protected abstract void doDeregisterObject(CDOID id); -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.internal.workspace;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+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.CDORevisionFactory;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace;
+import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspaceBase;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractCDOWorkspaceBase implements InternalCDOWorkspaceBase
+{
+ private InternalCDOWorkspace workspace;
+
+ private Set<CDOID> ids;
+
+ protected AbstractCDOWorkspaceBase()
+ {
+ }
+
+ public void init(InternalCDOWorkspace workspace)
+ {
+ this.workspace = workspace;
+ }
+
+ public final InternalCDOWorkspace getWorkspace()
+ {
+ return workspace;
+ }
+
+ public final synchronized Set<CDOID> getIDs()
+ {
+ if (ids == null)
+ {
+ ids = doGetIDs();
+ }
+
+ return ids;
+ }
+
+ @Deprecated
+ public final void updateAfterCommit(CDOTransaction transaction)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public final synchronized void registerChangedOrDetachedObject(InternalCDORevision revision)
+ {
+ getIDs().add(revision.getID());
+ doRegisterChangedOrDetachedObject(revision);
+ }
+
+ public final synchronized void registerAddedObject(CDOID id)
+ {
+ getIDs().add(id);
+ doRegisterAddedObject(id);
+ }
+
+ public final synchronized void deregisterObject(CDOID id)
+ {
+ if (ids != null)
+ {
+ ids.remove(id);
+ }
+
+ doDeregisterObject(id);
+ }
+
+ public final synchronized void clear()
+ {
+ ids = new HashSet<CDOID>();
+ doClear();
+ }
+
+ public final synchronized boolean isEmpty()
+ {
+ return getIDs().isEmpty();
+ }
+
+ public final synchronized boolean containsID(CDOID id)
+ {
+ return getIDs().contains(id);
+ }
+
+ protected CDODataInput createCDODataInput(ExtendedDataInputStream edis) throws IOException
+ {
+ InternalCDOPackageRegistry packageRegistry = workspace.getLocalRepository().getPackageRegistry(false);
+ InternalCDOBranchManager branchManager = workspace.getLocalRepository().getBranchManager();
+ CDORevisionFactory revisionFactory = CDORevisionFactory.DEFAULT;
+ CDOListFactory listFactory = CDOListFactory.DEFAULT;
+
+ return CDOCommonUtil.createCDODataInput(edis, packageRegistry, branchManager, null, revisionFactory, listFactory,
+ null);
+ }
+
+ protected CDODataOutput createCDODataOutput(ExtendedDataOutputStream edos)
+ {
+ InternalCDOPackageRegistry packageRegistry = workspace.getLocalRepository().getPackageRegistry(false);
+ CDOIDProvider idProvider = CDOIDProvider.NOOP;
+
+ return CDOCommonUtil.createCDODataOutput(edos, packageRegistry, idProvider);
+ }
+
+ protected abstract void doClear();
+
+ protected abstract Set<CDOID> doGetIDs();
+
+ protected abstract void doRegisterChangedOrDetachedObject(InternalCDORevision revision);
+
+ protected abstract void doRegisterAddedObject(CDOID id);
+
+ protected abstract void doDeregisterObject(CDOID id);
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceConfigurationImpl.java index 3d01cab6f1..17b9892bb6 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceConfigurationImpl.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceConfigurationImpl.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * 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
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java index b34fb8225a..26284b9ad3 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java @@ -1,961 +1,961 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.internal.workspace; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange; -import org.eclipse.emf.cdo.common.commit.CDOChangeSet; -import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDGenerator; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.common.revision.CDORevisionCache; -import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; -import org.eclipse.emf.cdo.common.revision.CDORevisionManager; -import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; -import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; -import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; -import org.eclipse.emf.cdo.internal.server.Repository; -import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration; -import org.eclipse.emf.cdo.net4j.CDONet4jUtil; -import org.eclipse.emf.cdo.server.CDOServerUtil; -import org.eclipse.emf.cdo.server.IRepository.Props; -import org.eclipse.emf.cdo.server.ISession; -import org.eclipse.emf.cdo.server.IStore; -import org.eclipse.emf.cdo.server.IStoreAccessor; -import org.eclipse.emf.cdo.server.ITransaction; -import org.eclipse.emf.cdo.server.StoreThreadLocal; -import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil; -import org.eclipse.emf.cdo.session.CDORepositoryInfo; -import org.eclipse.emf.cdo.session.CDOSessionConfiguration; -import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory; -import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil; -import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; -import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; -import org.eclipse.emf.cdo.spi.common.revision.CDOIDMapper; -import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; -import org.eclipse.emf.cdo.spi.common.revision.ManagedRevisionProvider; -import org.eclipse.emf.cdo.spi.server.InternalRepository; -import org.eclipse.emf.cdo.spi.server.InternalStore; -import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace; -import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspaceBase; -import org.eclipse.emf.cdo.transaction.CDOCommitContext; -import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler1; -import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler2; -import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler3; -import org.eclipse.emf.cdo.transaction.CDOMerger; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent; -import org.eclipse.emf.cdo.util.CommitException; -import org.eclipse.emf.cdo.util.ReadOnlyException; -import org.eclipse.emf.cdo.view.CDOView; -import org.eclipse.emf.cdo.workspace.CDOWorkspace; - -import org.eclipse.net4j.Net4jUtil; -import org.eclipse.net4j.jvm.IJVMAcceptor; -import org.eclipse.net4j.jvm.IJVMConnector; -import org.eclipse.net4j.jvm.JVMUtil; -import org.eclipse.net4j.signal.ISignalProtocol; -import org.eclipse.net4j.util.StringUtil; -import org.eclipse.net4j.util.container.ContainerUtil; -import org.eclipse.net4j.util.container.IManagedContainer; -import org.eclipse.net4j.util.event.Event; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.event.Notifier; -import org.eclipse.net4j.util.lifecycle.ILifecycle; -import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter; -import org.eclipse.net4j.util.lifecycle.LifecycleUtil; -import org.eclipse.net4j.util.om.monitor.Monitor; -import org.eclipse.net4j.util.om.monitor.OMMonitor; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.spi.cdo.InternalCDOSession; -import org.eclipse.emf.spi.cdo.InternalCDOSessionConfiguration; -import org.eclipse.emf.spi.cdo.InternalCDOTransaction; -import org.eclipse.emf.spi.cdo.InternalCDOTransaction.ApplyChangeSetResult; -import org.eclipse.emf.spi.cdo.InternalCDOTransaction.ChangeSetOutdatedException; -import org.eclipse.emf.spi.cdo.InternalCDOView; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace -{ - private static final String PROP_BRANCH_PATH = "org.eclipse.emf.cdo.workspace.branchPath"; //$NON-NLS-1$ - - private static final String PROP_TIME_STAMP = "org.eclipse.emf.cdo.workspace.timeStamp"; //$NON-NLS-1$ - - private static final String PROP_FIXED = "org.eclipse.emf.cdo.workspace.fixed"; //$NON-NLS-1$ - - private IManagedContainer container; - - private InternalCDOWorkspaceBase base; - - private IDGenerationLocation idGenerationLocation; - - private CDOIDGenerator idGenerator; - - private InternalRepository localRepository; - - private InternalCDOSession localSession; - - private CDOBranchPoint head; - - private String branchPath; - - private long timeStamp; - - private boolean fixed; - - private boolean dirty; - - private CDOSessionConfigurationFactory remoteSessionConfigurationFactory; - - private Set<InternalCDOView> views = new HashSet<InternalCDOView>(); - - public CDOWorkspaceImpl(String localRepositoryName, IStore local, IDGenerationLocation idGenerationLocation, - CDOIDGenerator idGenerator, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote, - String branchPath, long timeStamp) - { - init(localRepositoryName, local, idGenerationLocation, idGenerator, base, remote); - - this.branchPath = StringUtil.isEmpty(branchPath) ? CDOBranch.MAIN_BRANCH_NAME : branchPath; - this.timeStamp = timeStamp; - fixed = timeStamp != CDOBranchPoint.UNSPECIFIED_DATE; - - checkout(); - saveProperties(); - } - - public CDOWorkspaceImpl(String localRepositoryName, IStore local, IDGenerationLocation idGenerationLocation, - CDOIDGenerator idGenerator, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote) - { - init(localRepositoryName, local, idGenerationLocation, idGenerator, base, remote); - loadProperties(); - } - - protected void init(String localRepositoryName, IStore local, IDGenerationLocation idGenerationLocation, - CDOIDGenerator idGenerator, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote) - { - this.idGenerationLocation = idGenerationLocation; - this.idGenerator = idGenerator; - - container = createContainer(local); - remoteSessionConfigurationFactory = remote; - - localRepository = createLocalRepository(localRepositoryName, local); - - this.base = base; - this.base.init(this); - setDirtyFromBase(); - } - - private void setDirtyFromBase() - { - setDirty(!base.isEmpty()); - } - - protected void checkout() - { - final OMMonitor monitor = new Monitor(); - final IStoreAccessor.Raw accessor = (IStoreAccessor.Raw)localRepository.getStore().getWriter(null); - StoreThreadLocal.setAccessor(accessor); - - try - { - InternalCDOSession remoteSession = openRemoteSession(); - - try - { - localRepository.setRootResourceID(remoteSession.getRepositoryInfo().getRootResourceID()); - - InternalCDOPackageUnit[] packageUnits = remoteSession.getPackageRegistry().getPackageUnits(false); - localRepository.getPackageRegistry(false).putPackageUnits(packageUnits, CDOPackageUnit.State.LOADED); - accessor.rawStore(packageUnits, monitor); - - CDORevisionHandler handler = new CDORevisionHandler() - { - public boolean handleRevision(CDORevision revision) - { - InternalCDORevision rev = (InternalCDORevision)revision; - accessor.rawStore(rev, monitor); - - long commitTime = revision.getTimeStamp(); - if (commitTime > timeStamp) - { - timeStamp = commitTime; - } - - return true; - } - }; - - CDOBranch branch = remoteSession.getBranchManager().getBranch(branchPath); - remoteSession.getSessionProtocol().handleRevisions(null, branch, false, timeStamp, false, handler); - } - finally - { - LifecycleUtil.deactivate(remoteSession); - } - - accessor.rawCommit(1, monitor); - } - finally - { - StoreThreadLocal.release(); - monitor.done(); - } - } - - public String getBranchPath() - { - return branchPath; - } - - public long getTimeStamp() - { - return timeStamp; - } - - public boolean isFixed() - { - return fixed; - } - - public boolean isDirty() - { - return dirty; - } - - protected void setDirty(boolean dirty) - { - if (this.dirty != dirty) - { - this.dirty = dirty; - fireEvent(new DirtyStateChangedEventImpl(this, dirty)); - } - } - - protected void clearBase() - { - base.clear(); - setDirty(false); - } - - public IDGenerationLocation getIDGenerationLocation() - { - return idGenerationLocation; - } - - public CDOIDGenerator getIDGenerator() - { - return idGenerator; - } - - public InternalCDOWorkspaceBase getBase() - { - return base; - } - - public InternalCDOView openView() - { - CDOView view = getLocalSession().openView(); - initView(view); - return (InternalCDOView)view; - } - - public InternalCDOView openView(ResourceSet resourceSet) - { - CDOView view = getLocalSession().openView(resourceSet); - initView(view); - return (InternalCDOView)view; - } - - public InternalCDOTransaction openTransaction() - { - CDOTransaction transaction = getLocalSession().openTransaction(); - initView(transaction); - initTransaction(transaction); - return (InternalCDOTransaction)transaction; - } - - public InternalCDOTransaction openTransaction(ResourceSet resourceSet) - { - CDOTransaction transaction = getLocalSession().openTransaction(resourceSet); - initView(transaction); - initTransaction(transaction); - return (InternalCDOTransaction)transaction; - } - - protected void initView(CDOView view) - { - synchronized (views) - { - views.add((InternalCDOView)view); - } - - view.addListener(new ViewAdapter()); - - if (view instanceof CDOTransaction) - { - if (fixed) - { - throw new ReadOnlyException("Workspace is fixed"); - } - - if (idGenerationLocation != IDGenerationLocation.CLIENT) - { - CDOTransaction transaction = (CDOTransaction)view; - transaction.addTransactionHandler(new CDODefaultTransactionHandler1() - { - @Override - public void attachingObject(CDOTransaction transaction, CDOObject object) - { - throw new IllegalStateException("Attaching new objects is only supported for IDGenerationLocation.CLIENT"); - } - }); - } - } - } - - protected void initTransaction(CDOTransaction transaction) - { - transaction.addTransactionHandler(new CDODefaultTransactionHandler2() - { - @Override - public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext) - { - InternalCDOTransaction tx = (InternalCDOTransaction)transaction; - Set<CDOID> dirtyObjects = tx.getDirtyObjects().keySet(); - Set<CDOID> detachedObjects = tx.getDetachedObjects().keySet(); - for (InternalCDORevision revision : tx.getCleanRevisions().values()) - { - CDOID id = revision.getID(); - boolean isDetached = detachedObjects.contains(id); - - if (isDetached && base.isAddedObject(id)) - { - base.deregisterObject(id); - } - - if (dirtyObjects.contains(id) || isDetached) - { - base.registerChangedOrDetachedObject(revision); - } - } - - // Don't use keySet() because only the values() are ID-mapped! - for (CDOObject object : tx.getNewObjects().values()) - { - CDOID id = object.cdoID(); - base.registerAddedObject(id); - } - - setDirtyFromBase(); - } - }); - } - - public InternalCDOTransaction update(CDOMerger merger) - { - return merge(merger, branchPath); - } - - public InternalCDOTransaction merge(CDOMerger merger, String branchPath) - { - return merge(merger, branchPath, CDOBranchPoint.UNSPECIFIED_DATE); - } - - public InternalCDOTransaction merge(CDOMerger merger, String branchPath, long timeStamp) - { - final InternalCDOSession remoteSession = openRemoteSession(); - if (timeStamp == CDOBranchPoint.UNSPECIFIED_DATE) - { - timeStamp = remoteSession.getLastUpdateTime(); - } - - final long newTimeStamp = timeStamp; - - final InternalCDOBranchManager branchManager = remoteSession.getBranchManager(); - final CDOBranchPoint basePoint = branchManager.getBranch(branchPath).getPoint(this.timeStamp); - final CDOBranchPoint remotePoint = branchManager.getBranch(branchPath).getPoint(newTimeStamp); - - final CDOBranchPointRange range = CDOBranchUtil.createRange(basePoint, remotePoint); - - final CDOChangeSetData remoteData = remoteSession.getSessionProtocol().loadChangeSets(range)[0]; - final CDOChangeSetData localData = getLocalChanges(); - final CDOChangeSetData result = getMergeResult(merger, basePoint, remotePoint, localData, remoteData); - - final InternalCDOTransaction transaction = (InternalCDOTransaction)getLocalSession().openTransaction(); - initView(transaction); - - transaction.applyChangeSet(result, new BaseRevisionProvider(), this, null, false); - transaction.addTransactionHandler(new CDODefaultTransactionHandler3() - { - @Override - public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext, CDOCommitInfo result) - { - try - { - Set<CDOID> affectedIDs = getAffectedIDs(commitContext, remoteData); - - CDORevisionProvider local = CDOWorkspaceImpl.this; - CDORevisionProvider remote = new ManagedRevisionProvider(remoteSession.getRevisionManager(), remotePoint); - - updateBase(affectedIDs, local, remote); - setTimeStamp(newTimeStamp); - } - finally - { - LifecycleUtil.deactivate(remoteSession); - } - } - - private void updateBase(Set<CDOID> affectedIDs, CDORevisionProvider local, CDORevisionProvider remote) - { - for (CDOID id : affectedIDs) - { - CDORevision localRevision = getRevision(id, local); - CDORevision remoteRevision = getRevision(id, remote); - if (localRevision == null) - { - if (remoteRevision == null) - { - // Unchanged - base.deregisterObject(id); - } - else - { - // Detached - base.registerChangedOrDetachedObject((InternalCDORevision)remoteRevision); - } - } - else - { - if (remoteRevision == null) - { - // Added - base.registerAddedObject(id); - } - else - { - CDORevisionDelta delta = localRevision.compare(remoteRevision); - if (delta.isEmpty()) - { - // Unchanged - base.deregisterObject(id); - } - else - { - // Changed - base.registerChangedOrDetachedObject((InternalCDORevision)remoteRevision); - } - } - } - } - } - - private Set<CDOID> getAffectedIDs(CDOCommitContext commitContext, final CDOChangeSetData remoteData) - { - Set<CDOID> affectedIDs = new HashSet<CDOID>(); - - // Base IDs - affectedIDs.addAll(base.getIDs()); - - // Remote IDs - affectedIDs.addAll(remoteData.getChangeKinds().keySet()); - - // Local IDs - affectedIDs.addAll(commitContext.getNewObjects().keySet()); - affectedIDs.addAll(commitContext.getDirtyObjects().keySet()); - affectedIDs.addAll(commitContext.getDetachedObjects().keySet()); - - return affectedIDs; - } - - private CDORevision getRevision(CDOID id, CDORevisionProvider revisionProvider) - { - CDORevision revision = revisionProvider.getRevision(id); - if (revision instanceof DetachedCDORevision) - { - revision = null; - } - - return revision; - } - }); - - return transaction; - } - - private CDOChangeSetData getMergeResult(CDOMerger merger, CDOBranchPoint basePoint, CDOBranchPoint remotePoint, - CDOChangeSetData localData, CDOChangeSetData remoteData) - { - if (localData.isEmpty()) - { - return remoteData; - } - - CDOChangeSet localChanges = CDORevisionUtil.createChangeSet(basePoint, null, localData); - CDOChangeSet remoteChanges = CDORevisionUtil.createChangeSet(basePoint, remotePoint, remoteData); - return merger.merge(localChanges, remoteChanges); - } - - public void revert() - { - // TODO: implement CDOWorkspaceImpl.revert() - throw new UnsupportedOperationException(); - } - - public void replace(String branchPath, long timeStamp) - { - // TODO: implement CDOWorkspaceImpl.replace(branchPath, timeStamp) - throw new UnsupportedOperationException(); - } - - public CDOCommitInfo checkin() throws CommitException - { - return checkin(null); - } - - public CDOCommitInfo checkin(String comment) throws CommitException - { - InternalCDOSession remoteSession = openRemoteSession(); - - try - { - InternalCDOBranch branch = remoteSession.getBranchManager().getBranch(branchPath); - InternalCDOTransaction transaction = (InternalCDOTransaction)remoteSession.openTransaction(branch); - - CDOChangeSetData changes = getLocalChanges(); - - try - { - ApplyChangeSetResult result = transaction.applyChangeSet(changes, base, this, head, true); - if (!result.getIDMappings().isEmpty()) - { - throw new IllegalStateException("Attaching new objects is only supported for IDGenerationLocation.CLIENT"); - } - } - catch (ChangeSetOutdatedException ex) - { - throw new CommitException(ex); - } - - transaction.setCommitComment(comment); - CDOCommitInfo info = transaction.commit(); - - clearBase(); - setTimeStamp(info.getTimeStamp()); - return info; - } - finally - { - LifecycleUtil.deactivate(remoteSession); - } - } - - /** - * @deprecated Attaching new objects is only supported for IDGenerationLocation.CLIENT - */ - @Deprecated - protected CDOIDMapper getIDMapper(InternalCDOTransaction transaction, final Map<CDOID, CDOID> idMappings) - { - if (idMappings.isEmpty()) - { - return null; - } - - transaction.addListener(new IListener() - { - public void notifyEvent(IEvent event) - { - if (event instanceof CDOTransactionFinishedEvent) - { - CDOTransactionFinishedEvent e = (CDOTransactionFinishedEvent)event; - Map<CDOID, CDOID> remoteMappings = e.getIDMappings(); - for (Entry<CDOID, CDOID> entry : idMappings.entrySet()) - { - CDOID tempID = entry.getValue(); - CDOID newID = remoteMappings.get(tempID); - entry.setValue(newID); - } - } - } - }); - - return new CDOIDMapper(idMappings); - } - - /** - * @deprecated Attaching new objects is only supported for IDGenerationLocation.CLIENT - */ - @Deprecated - protected void adjustLocalIDs(CDOIDMapper idMapper, List<CDOID> adjustedObjects) - { - Map<CDOID, CDOID> idMappings = idMapper.getIDMappings(); - if (!idMappings.isEmpty()) - { - CDOTransaction transaction = null; - OMMonitor monitor = new Monitor(); - - try - { - transaction = localSession.openTransaction(); - ISession repoSession = localRepository.getSessionManager().getSession(localSession.getSessionID()); - ITransaction repoTransaction = (ITransaction)repoSession.getView(transaction.getViewID()); - - IStoreAccessor.Raw accessor = (IStoreAccessor.Raw)localRepository.getStore().getWriter(repoTransaction); - StoreThreadLocal.setAccessor(accessor); - - monitor.begin(idMappings.size() * 2 + adjustedObjects.size() * 2 + 10); - - for (Entry<CDOID, CDOID> entry : idMappings.entrySet()) - { - CDOID id = entry.getKey(); - - InternalCDORevision revision = accessor.readRevision(id, head, CDORevision.UNCHUNKED, null); - int version = revision.getVersion(); - CDOBranch branch = revision.getBranch(); - EClass eClass = revision.getEClass(); - - CDOID newID = entry.getValue(); - revision.setID(newID); - revision.setVersion(CDORevision.FIRST_VERSION); - - accessor.rawDelete(id, version, branch, eClass, monitor.fork()); - revision.adjustReferences(idMapper); - accessor.rawStore(revision, monitor.fork()); - } - - for (CDOID id : adjustedObjects) - { - InternalCDORevision revision = accessor.readRevision(id, head, CDORevision.UNCHUNKED, null); - int version = revision.getVersion(); - CDOBranch branch = revision.getBranch(); - EClass eClass = revision.getEClass(); - - // TODO DBStoreAccessor.rawDelete() creates a new row with -(version+1)!!! - accessor.rawDelete(id, version, branch, eClass, monitor.fork()); - revision.adjustReferences(idMapper); - accessor.rawStore(revision, monitor.fork()); - } - - accessor.rawCommit(1, monitor.fork(10)); - } - finally - { - monitor.done(); - StoreThreadLocal.release(); - - if (transaction != null) - { - transaction.close(); - } - } - } - } - - public CDOChangeSetData compare(String branchPath) - { - return compare(branchPath, CDOBranchPoint.UNSPECIFIED_DATE); - } - - public CDOChangeSetData compare(String branchPath, long timeStamp) - { - // TODO: implement CDOWorkspaceImpl.compare(branchPath, timeStamp) - throw new UnsupportedOperationException(); - } - - public synchronized void close() - { - LifecycleUtil.deactivate(localSession); - localSession = null; - - LifecycleUtil.deactivate(localRepository); - localRepository = null; - - LifecycleUtil.deactivate(container); - container = null; - } - - public synchronized boolean isClosed() - { - return container == null; - } - - public CDORevision getRevision(CDOID id) - { - InternalCDOSession session = getLocalSession(); - CDORevisionManager revisionManager = session.getRevisionManager(); - return revisionManager.getRevision(id, head, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, true); - } - - public InternalRepository getLocalRepository() - { - return localRepository; - } - - public synchronized InternalCDOSession getLocalSession() - { - if (localSession == null) - { - localSession = openLocalSession(); - } - - return localSession; - } - - public CDOChangeSetData getLocalChanges() - { - Set<CDOID> ids = base.getIDs(); - return CDORevisionUtil.createChangeSetData(ids, base, this, true); - } - - public CDOSessionConfigurationFactory getRemoteSessionConfigurationFactory() - { - return remoteSessionConfigurationFactory; - } - - protected IManagedContainer createContainer(IStore local) - { - IManagedContainer container = ContainerUtil.createContainer(); - Net4jUtil.prepareContainer(container); - JVMUtil.prepareContainer(container); - CDONet4jServerUtil.prepareContainer(container); - container.activate(); - return container; - } - - protected IManagedContainer getContainer() - { - return container; - } - - protected String getLocalAcceptorName() - { - return "acceptor-for-" + localRepository.getUUID(); - } - - protected IJVMAcceptor getLocalAcceptor() - { - String localAcceptorName = getLocalAcceptorName(); - return JVMUtil.getAcceptor(container, localAcceptorName); - } - - protected IJVMConnector getLocalConnector() - { - String localAcceptorName = getLocalAcceptorName(); - return JVMUtil.getConnector(container, localAcceptorName); - } - - protected InternalRepository createLocalRepository(String localRepositoryName, IStore store) - { - Map<String, String> props = new HashMap<String, String>(); - props.put(Props.OVERRIDE_UUID, ""); // UUID := name !!! - props.put(Props.SUPPORTING_AUDITS, "false"); - props.put(Props.SUPPORTING_BRANCHES, "false"); - props.put(Props.ID_GENERATION_LOCATION, idGenerationLocation.toString()); - - Repository repository = new Repository.Default() - { - @Override - public void initMainBranch(InternalCDOBranchManager branchManager, long timeStamp) - { - if (idGenerationLocation == IDGenerationLocation.STORE) - { - // Mark the main branch local so that new objects get local IDs - branchManager.initMainBranch(true, timeStamp); - } - else - { - super.initMainBranch(branchManager, timeStamp); - } - } - - @Override - protected void initRootResource() - { - // Don't create the root resource as it will be checked out - setState(State.INITIAL); - } - }; - - repository.setName(localRepositoryName); - repository.setStore((InternalStore)store); - repository.setProperties(props); - - CDOServerUtil.addRepository(container, repository); - return repository; - } - - protected InternalCDOSession openLocalSession() - { - getLocalAcceptor(); - - IJVMConnector connector = getLocalConnector(); - String repositoryName = localRepository.getName(); - - CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration(); - configuration.setConnector(connector); - configuration.setRepositoryName(repositoryName); - configuration.setIDGenerator(idGenerator); - configuration.setRevisionManager(CDORevisionUtil.createRevisionManager(CDORevisionCache.NOOP)); // Use repo's cache - - if (idGenerationLocation == IDGenerationLocation.STORE) - { - ((InternalCDOSessionConfiguration)configuration).setMainBranchLocal(true); - } - - InternalCDOSession session = (InternalCDOSession)configuration.openNet4jSession(); - ((ISignalProtocol<?>)session.getSessionProtocol()).setTimeout(ISignalProtocol.NO_TIMEOUT); - session.setPackageRegistry(localRepository.getPackageRegistry(false)); // Use repo's registry - - head = session.getBranchManager().getMainBranch().getHead(); - return session; - } - - protected InternalCDOView[] getViews() - { - synchronized (views) - { - return views.toArray(new InternalCDOView[views.size()]); - } - } - - protected InternalCDOSession openRemoteSession() - { - CDOSessionConfiguration configuration = remoteSessionConfigurationFactory.createSessionConfiguration(); - InternalCDOSession session = (InternalCDOSession)configuration.openSession(); - - CDORepositoryInfo repositoryInfo = session.getRepositoryInfo(); - if (!repositoryInfo.isSupportingAudits()) - { - session.close(); - throw new IllegalStateException("Remote repository does not support auditing"); - } - - IDGenerationLocation remoteLocation = repositoryInfo.getIDGenerationLocation(); - if (!remoteLocation.equals(idGenerationLocation)) - { - session.close(); - throw new IllegalStateException("Remote repository uses different ID generation location: " + remoteLocation); - } - - return session; - } - - protected void setTimeStamp(long timeStamp) - { - Map<String, String> props = new HashMap<String, String>(); - props.put(PROP_TIME_STAMP, String.valueOf(timeStamp)); - localRepository.getStore().setPersistentProperties(props); - - this.timeStamp = timeStamp; - } - - protected void saveProperties() - { - Map<String, String> props = new HashMap<String, String>(); - props.put(PROP_BRANCH_PATH, branchPath); - props.put(PROP_TIME_STAMP, String.valueOf(timeStamp)); - props.put(PROP_FIXED, String.valueOf(fixed)); - localRepository.getStore().setPersistentProperties(props); - } - - protected void loadProperties() - { - Set<String> names = new HashSet<String>(Arrays.asList(PROP_BRANCH_PATH, PROP_TIME_STAMP, PROP_FIXED)); - Map<String, String> props = localRepository.getStore().getPersistentProperties(names); - branchPath = props.get(PROP_BRANCH_PATH); - timeStamp = Long.parseLong(props.get(PROP_TIME_STAMP)); - fixed = Boolean.parseBoolean(props.get(PROP_FIXED)); - } - - /** - * @author Eike Stepper - */ - private class BaseRevisionProvider implements CDORevisionProvider - { - public CDORevision getRevision(CDOID id) - { - CDORevision revision = base.getRevision(id); - if (revision == null) - { - revision = CDOWorkspaceImpl.this.getRevision(id); - } - - return revision; - } - } - - /** - * @author Eike Stepper - */ - public final class ViewAdapter extends LifecycleEventAdapter - { - public ViewAdapter() - { - } - - public CDOWorkspace getWorkspace() - { - return CDOWorkspaceImpl.this; - } - - @Override - protected void onDeactivated(ILifecycle view) - { - synchronized (views) - { - views.remove(view); - } - } - } - - /** - * @author Eike Stepper - */ - private static final class DirtyStateChangedEventImpl extends Event implements DirtyStateChangedEvent - { - private static final long serialVersionUID = 1L; - - private boolean dirty; - - public DirtyStateChangedEventImpl(CDOWorkspace workspace, boolean dirty) - { - super(workspace); - this.dirty = dirty; - } - - public boolean isDirty() - { - return dirty; - } - } -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.internal.workspace;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
+import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
+import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.internal.server.Repository;
+import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
+import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
+import org.eclipse.emf.cdo.server.CDOServerUtil;
+import org.eclipse.emf.cdo.server.IRepository.Props;
+import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreAccessor;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.server.StoreThreadLocal;
+import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
+import org.eclipse.emf.cdo.session.CDORepositoryInfo;
+import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
+import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+import org.eclipse.emf.cdo.spi.common.revision.CDOIDMapper;
+import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.ManagedRevisionProvider;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalStore;
+import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace;
+import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspaceBase;
+import org.eclipse.emf.cdo.transaction.CDOCommitContext;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler1;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler2;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler3;
+import org.eclipse.emf.cdo.transaction.CDOMerger;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.ReadOnlyException;
+import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.workspace.CDOWorkspace;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.jvm.IJVMAcceptor;
+import org.eclipse.net4j.jvm.IJVMConnector;
+import org.eclipse.net4j.jvm.JVMUtil;
+import org.eclipse.net4j.signal.ISignalProtocol;
+import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.container.ContainerUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.event.Notifier;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.om.monitor.Monitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
+import org.eclipse.emf.spi.cdo.InternalCDOSessionConfiguration;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.ApplyChangeSetResult;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.ChangeSetOutdatedException;
+import org.eclipse.emf.spi.cdo.InternalCDOView;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
+{
+ private static final String PROP_BRANCH_PATH = "org.eclipse.emf.cdo.workspace.branchPath"; //$NON-NLS-1$
+
+ private static final String PROP_TIME_STAMP = "org.eclipse.emf.cdo.workspace.timeStamp"; //$NON-NLS-1$
+
+ private static final String PROP_FIXED = "org.eclipse.emf.cdo.workspace.fixed"; //$NON-NLS-1$
+
+ private IManagedContainer container;
+
+ private InternalCDOWorkspaceBase base;
+
+ private IDGenerationLocation idGenerationLocation;
+
+ private CDOIDGenerator idGenerator;
+
+ private InternalRepository localRepository;
+
+ private InternalCDOSession localSession;
+
+ private CDOBranchPoint head;
+
+ private String branchPath;
+
+ private long timeStamp;
+
+ private boolean fixed;
+
+ private boolean dirty;
+
+ private CDOSessionConfigurationFactory remoteSessionConfigurationFactory;
+
+ private Set<InternalCDOView> views = new HashSet<InternalCDOView>();
+
+ public CDOWorkspaceImpl(String localRepositoryName, IStore local, IDGenerationLocation idGenerationLocation,
+ CDOIDGenerator idGenerator, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote,
+ String branchPath, long timeStamp)
+ {
+ init(localRepositoryName, local, idGenerationLocation, idGenerator, base, remote);
+
+ this.branchPath = StringUtil.isEmpty(branchPath) ? CDOBranch.MAIN_BRANCH_NAME : branchPath;
+ this.timeStamp = timeStamp;
+ fixed = timeStamp != CDOBranchPoint.UNSPECIFIED_DATE;
+
+ checkout();
+ saveProperties();
+ }
+
+ public CDOWorkspaceImpl(String localRepositoryName, IStore local, IDGenerationLocation idGenerationLocation,
+ CDOIDGenerator idGenerator, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
+ {
+ init(localRepositoryName, local, idGenerationLocation, idGenerator, base, remote);
+ loadProperties();
+ }
+
+ protected void init(String localRepositoryName, IStore local, IDGenerationLocation idGenerationLocation,
+ CDOIDGenerator idGenerator, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
+ {
+ this.idGenerationLocation = idGenerationLocation;
+ this.idGenerator = idGenerator;
+
+ container = createContainer(local);
+ remoteSessionConfigurationFactory = remote;
+
+ localRepository = createLocalRepository(localRepositoryName, local);
+
+ this.base = base;
+ this.base.init(this);
+ setDirtyFromBase();
+ }
+
+ private void setDirtyFromBase()
+ {
+ setDirty(!base.isEmpty());
+ }
+
+ protected void checkout()
+ {
+ final OMMonitor monitor = new Monitor();
+ final IStoreAccessor.Raw accessor = (IStoreAccessor.Raw)localRepository.getStore().getWriter(null);
+ StoreThreadLocal.setAccessor(accessor);
+
+ try
+ {
+ InternalCDOSession remoteSession = openRemoteSession();
+
+ try
+ {
+ localRepository.setRootResourceID(remoteSession.getRepositoryInfo().getRootResourceID());
+
+ InternalCDOPackageUnit[] packageUnits = remoteSession.getPackageRegistry().getPackageUnits(false);
+ localRepository.getPackageRegistry(false).putPackageUnits(packageUnits, CDOPackageUnit.State.LOADED);
+ accessor.rawStore(packageUnits, monitor);
+
+ CDORevisionHandler handler = new CDORevisionHandler()
+ {
+ public boolean handleRevision(CDORevision revision)
+ {
+ InternalCDORevision rev = (InternalCDORevision)revision;
+ accessor.rawStore(rev, monitor);
+
+ long commitTime = revision.getTimeStamp();
+ if (commitTime > timeStamp)
+ {
+ timeStamp = commitTime;
+ }
+
+ return true;
+ }
+ };
+
+ CDOBranch branch = remoteSession.getBranchManager().getBranch(branchPath);
+ remoteSession.getSessionProtocol().handleRevisions(null, branch, false, timeStamp, false, handler);
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(remoteSession);
+ }
+
+ accessor.rawCommit(1, monitor);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ monitor.done();
+ }
+ }
+
+ public String getBranchPath()
+ {
+ return branchPath;
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ public boolean isFixed()
+ {
+ return fixed;
+ }
+
+ public boolean isDirty()
+ {
+ return dirty;
+ }
+
+ protected void setDirty(boolean dirty)
+ {
+ if (this.dirty != dirty)
+ {
+ this.dirty = dirty;
+ fireEvent(new DirtyStateChangedEventImpl(this, dirty));
+ }
+ }
+
+ protected void clearBase()
+ {
+ base.clear();
+ setDirty(false);
+ }
+
+ public IDGenerationLocation getIDGenerationLocation()
+ {
+ return idGenerationLocation;
+ }
+
+ public CDOIDGenerator getIDGenerator()
+ {
+ return idGenerator;
+ }
+
+ public InternalCDOWorkspaceBase getBase()
+ {
+ return base;
+ }
+
+ public InternalCDOView openView()
+ {
+ CDOView view = getLocalSession().openView();
+ initView(view);
+ return (InternalCDOView)view;
+ }
+
+ public InternalCDOView openView(ResourceSet resourceSet)
+ {
+ CDOView view = getLocalSession().openView(resourceSet);
+ initView(view);
+ return (InternalCDOView)view;
+ }
+
+ public InternalCDOTransaction openTransaction()
+ {
+ CDOTransaction transaction = getLocalSession().openTransaction();
+ initView(transaction);
+ initTransaction(transaction);
+ return (InternalCDOTransaction)transaction;
+ }
+
+ public InternalCDOTransaction openTransaction(ResourceSet resourceSet)
+ {
+ CDOTransaction transaction = getLocalSession().openTransaction(resourceSet);
+ initView(transaction);
+ initTransaction(transaction);
+ return (InternalCDOTransaction)transaction;
+ }
+
+ protected void initView(CDOView view)
+ {
+ synchronized (views)
+ {
+ views.add((InternalCDOView)view);
+ }
+
+ view.addListener(new ViewAdapter());
+
+ if (view instanceof CDOTransaction)
+ {
+ if (fixed)
+ {
+ throw new ReadOnlyException("Workspace is fixed");
+ }
+
+ if (idGenerationLocation != IDGenerationLocation.CLIENT)
+ {
+ CDOTransaction transaction = (CDOTransaction)view;
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler1()
+ {
+ @Override
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ throw new IllegalStateException("Attaching new objects is only supported for IDGenerationLocation.CLIENT");
+ }
+ });
+ }
+ }
+ }
+
+ protected void initTransaction(CDOTransaction transaction)
+ {
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler2()
+ {
+ @Override
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ InternalCDOTransaction tx = (InternalCDOTransaction)transaction;
+ Set<CDOID> dirtyObjects = tx.getDirtyObjects().keySet();
+ Set<CDOID> detachedObjects = tx.getDetachedObjects().keySet();
+ for (InternalCDORevision revision : tx.getCleanRevisions().values())
+ {
+ CDOID id = revision.getID();
+ boolean isDetached = detachedObjects.contains(id);
+
+ if (isDetached && base.isAddedObject(id))
+ {
+ base.deregisterObject(id);
+ }
+
+ if (dirtyObjects.contains(id) || isDetached)
+ {
+ base.registerChangedOrDetachedObject(revision);
+ }
+ }
+
+ // Don't use keySet() because only the values() are ID-mapped!
+ for (CDOObject object : tx.getNewObjects().values())
+ {
+ CDOID id = object.cdoID();
+ base.registerAddedObject(id);
+ }
+
+ setDirtyFromBase();
+ }
+ });
+ }
+
+ public InternalCDOTransaction update(CDOMerger merger)
+ {
+ return merge(merger, branchPath);
+ }
+
+ public InternalCDOTransaction merge(CDOMerger merger, String branchPath)
+ {
+ return merge(merger, branchPath, CDOBranchPoint.UNSPECIFIED_DATE);
+ }
+
+ public InternalCDOTransaction merge(CDOMerger merger, String branchPath, long timeStamp)
+ {
+ final InternalCDOSession remoteSession = openRemoteSession();
+ if (timeStamp == CDOBranchPoint.UNSPECIFIED_DATE)
+ {
+ timeStamp = remoteSession.getLastUpdateTime();
+ }
+
+ final long newTimeStamp = timeStamp;
+
+ final InternalCDOBranchManager branchManager = remoteSession.getBranchManager();
+ final CDOBranchPoint basePoint = branchManager.getBranch(branchPath).getPoint(this.timeStamp);
+ final CDOBranchPoint remotePoint = branchManager.getBranch(branchPath).getPoint(newTimeStamp);
+
+ final CDOBranchPointRange range = CDOBranchUtil.createRange(basePoint, remotePoint);
+
+ final CDOChangeSetData remoteData = remoteSession.getSessionProtocol().loadChangeSets(range)[0];
+ final CDOChangeSetData localData = getLocalChanges();
+ final CDOChangeSetData result = getMergeResult(merger, basePoint, remotePoint, localData, remoteData);
+
+ final InternalCDOTransaction transaction = (InternalCDOTransaction)getLocalSession().openTransaction();
+ initView(transaction);
+
+ transaction.applyChangeSet(result, new BaseRevisionProvider(), this, null, false);
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler3()
+ {
+ @Override
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext, CDOCommitInfo result)
+ {
+ try
+ {
+ Set<CDOID> affectedIDs = getAffectedIDs(commitContext, remoteData);
+
+ CDORevisionProvider local = CDOWorkspaceImpl.this;
+ CDORevisionProvider remote = new ManagedRevisionProvider(remoteSession.getRevisionManager(), remotePoint);
+
+ updateBase(affectedIDs, local, remote);
+ setTimeStamp(newTimeStamp);
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(remoteSession);
+ }
+ }
+
+ private void updateBase(Set<CDOID> affectedIDs, CDORevisionProvider local, CDORevisionProvider remote)
+ {
+ for (CDOID id : affectedIDs)
+ {
+ CDORevision localRevision = getRevision(id, local);
+ CDORevision remoteRevision = getRevision(id, remote);
+ if (localRevision == null)
+ {
+ if (remoteRevision == null)
+ {
+ // Unchanged
+ base.deregisterObject(id);
+ }
+ else
+ {
+ // Detached
+ base.registerChangedOrDetachedObject((InternalCDORevision)remoteRevision);
+ }
+ }
+ else
+ {
+ if (remoteRevision == null)
+ {
+ // Added
+ base.registerAddedObject(id);
+ }
+ else
+ {
+ CDORevisionDelta delta = localRevision.compare(remoteRevision);
+ if (delta.isEmpty())
+ {
+ // Unchanged
+ base.deregisterObject(id);
+ }
+ else
+ {
+ // Changed
+ base.registerChangedOrDetachedObject((InternalCDORevision)remoteRevision);
+ }
+ }
+ }
+ }
+ }
+
+ private Set<CDOID> getAffectedIDs(CDOCommitContext commitContext, final CDOChangeSetData remoteData)
+ {
+ Set<CDOID> affectedIDs = new HashSet<CDOID>();
+
+ // Base IDs
+ affectedIDs.addAll(base.getIDs());
+
+ // Remote IDs
+ affectedIDs.addAll(remoteData.getChangeKinds().keySet());
+
+ // Local IDs
+ affectedIDs.addAll(commitContext.getNewObjects().keySet());
+ affectedIDs.addAll(commitContext.getDirtyObjects().keySet());
+ affectedIDs.addAll(commitContext.getDetachedObjects().keySet());
+
+ return affectedIDs;
+ }
+
+ private CDORevision getRevision(CDOID id, CDORevisionProvider revisionProvider)
+ {
+ CDORevision revision = revisionProvider.getRevision(id);
+ if (revision instanceof DetachedCDORevision)
+ {
+ revision = null;
+ }
+
+ return revision;
+ }
+ });
+
+ return transaction;
+ }
+
+ private CDOChangeSetData getMergeResult(CDOMerger merger, CDOBranchPoint basePoint, CDOBranchPoint remotePoint,
+ CDOChangeSetData localData, CDOChangeSetData remoteData)
+ {
+ if (localData.isEmpty())
+ {
+ return remoteData;
+ }
+
+ CDOChangeSet localChanges = CDORevisionUtil.createChangeSet(basePoint, null, localData);
+ CDOChangeSet remoteChanges = CDORevisionUtil.createChangeSet(basePoint, remotePoint, remoteData);
+ return merger.merge(localChanges, remoteChanges);
+ }
+
+ public void revert()
+ {
+ // TODO: implement CDOWorkspaceImpl.revert()
+ throw new UnsupportedOperationException();
+ }
+
+ public void replace(String branchPath, long timeStamp)
+ {
+ // TODO: implement CDOWorkspaceImpl.replace(branchPath, timeStamp)
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOCommitInfo checkin() throws CommitException
+ {
+ return checkin(null);
+ }
+
+ public CDOCommitInfo checkin(String comment) throws CommitException
+ {
+ InternalCDOSession remoteSession = openRemoteSession();
+
+ try
+ {
+ InternalCDOBranch branch = remoteSession.getBranchManager().getBranch(branchPath);
+ InternalCDOTransaction transaction = (InternalCDOTransaction)remoteSession.openTransaction(branch);
+
+ CDOChangeSetData changes = getLocalChanges();
+
+ try
+ {
+ ApplyChangeSetResult result = transaction.applyChangeSet(changes, base, this, head, true);
+ if (!result.getIDMappings().isEmpty())
+ {
+ throw new IllegalStateException("Attaching new objects is only supported for IDGenerationLocation.CLIENT");
+ }
+ }
+ catch (ChangeSetOutdatedException ex)
+ {
+ throw new CommitException(ex);
+ }
+
+ transaction.setCommitComment(comment);
+ CDOCommitInfo info = transaction.commit();
+
+ clearBase();
+ setTimeStamp(info.getTimeStamp());
+ return info;
+ }
+ finally
+ {
+ LifecycleUtil.deactivate(remoteSession);
+ }
+ }
+
+ /**
+ * @deprecated Attaching new objects is only supported for IDGenerationLocation.CLIENT
+ */
+ @Deprecated
+ protected CDOIDMapper getIDMapper(InternalCDOTransaction transaction, final Map<CDOID, CDOID> idMappings)
+ {
+ if (idMappings.isEmpty())
+ {
+ return null;
+ }
+
+ transaction.addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOTransactionFinishedEvent)
+ {
+ CDOTransactionFinishedEvent e = (CDOTransactionFinishedEvent)event;
+ Map<CDOID, CDOID> remoteMappings = e.getIDMappings();
+ for (Entry<CDOID, CDOID> entry : idMappings.entrySet())
+ {
+ CDOID tempID = entry.getValue();
+ CDOID newID = remoteMappings.get(tempID);
+ entry.setValue(newID);
+ }
+ }
+ }
+ });
+
+ return new CDOIDMapper(idMappings);
+ }
+
+ /**
+ * @deprecated Attaching new objects is only supported for IDGenerationLocation.CLIENT
+ */
+ @Deprecated
+ protected void adjustLocalIDs(CDOIDMapper idMapper, List<CDOID> adjustedObjects)
+ {
+ Map<CDOID, CDOID> idMappings = idMapper.getIDMappings();
+ if (!idMappings.isEmpty())
+ {
+ CDOTransaction transaction = null;
+ OMMonitor monitor = new Monitor();
+
+ try
+ {
+ transaction = localSession.openTransaction();
+ ISession repoSession = localRepository.getSessionManager().getSession(localSession.getSessionID());
+ ITransaction repoTransaction = (ITransaction)repoSession.getView(transaction.getViewID());
+
+ IStoreAccessor.Raw accessor = (IStoreAccessor.Raw)localRepository.getStore().getWriter(repoTransaction);
+ StoreThreadLocal.setAccessor(accessor);
+
+ monitor.begin(idMappings.size() * 2 + adjustedObjects.size() * 2 + 10);
+
+ for (Entry<CDOID, CDOID> entry : idMappings.entrySet())
+ {
+ CDOID id = entry.getKey();
+
+ InternalCDORevision revision = accessor.readRevision(id, head, CDORevision.UNCHUNKED, null);
+ int version = revision.getVersion();
+ CDOBranch branch = revision.getBranch();
+ EClass eClass = revision.getEClass();
+
+ CDOID newID = entry.getValue();
+ revision.setID(newID);
+ revision.setVersion(CDORevision.FIRST_VERSION);
+
+ accessor.rawDelete(id, version, branch, eClass, monitor.fork());
+ revision.adjustReferences(idMapper);
+ accessor.rawStore(revision, monitor.fork());
+ }
+
+ for (CDOID id : adjustedObjects)
+ {
+ InternalCDORevision revision = accessor.readRevision(id, head, CDORevision.UNCHUNKED, null);
+ int version = revision.getVersion();
+ CDOBranch branch = revision.getBranch();
+ EClass eClass = revision.getEClass();
+
+ // TODO DBStoreAccessor.rawDelete() creates a new row with -(version+1)!!!
+ accessor.rawDelete(id, version, branch, eClass, monitor.fork());
+ revision.adjustReferences(idMapper);
+ accessor.rawStore(revision, monitor.fork());
+ }
+
+ accessor.rawCommit(1, monitor.fork(10));
+ }
+ finally
+ {
+ monitor.done();
+ StoreThreadLocal.release();
+
+ if (transaction != null)
+ {
+ transaction.close();
+ }
+ }
+ }
+ }
+
+ public CDOChangeSetData compare(String branchPath)
+ {
+ return compare(branchPath, CDOBranchPoint.UNSPECIFIED_DATE);
+ }
+
+ public CDOChangeSetData compare(String branchPath, long timeStamp)
+ {
+ // TODO: implement CDOWorkspaceImpl.compare(branchPath, timeStamp)
+ throw new UnsupportedOperationException();
+ }
+
+ public synchronized void close()
+ {
+ LifecycleUtil.deactivate(localSession);
+ localSession = null;
+
+ LifecycleUtil.deactivate(localRepository);
+ localRepository = null;
+
+ LifecycleUtil.deactivate(container);
+ container = null;
+ }
+
+ public synchronized boolean isClosed()
+ {
+ return container == null;
+ }
+
+ public CDORevision getRevision(CDOID id)
+ {
+ InternalCDOSession session = getLocalSession();
+ CDORevisionManager revisionManager = session.getRevisionManager();
+ return revisionManager.getRevision(id, head, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, true);
+ }
+
+ public InternalRepository getLocalRepository()
+ {
+ return localRepository;
+ }
+
+ public synchronized InternalCDOSession getLocalSession()
+ {
+ if (localSession == null)
+ {
+ localSession = openLocalSession();
+ }
+
+ return localSession;
+ }
+
+ public CDOChangeSetData getLocalChanges()
+ {
+ Set<CDOID> ids = base.getIDs();
+ return CDORevisionUtil.createChangeSetData(ids, base, this, true);
+ }
+
+ public CDOSessionConfigurationFactory getRemoteSessionConfigurationFactory()
+ {
+ return remoteSessionConfigurationFactory;
+ }
+
+ protected IManagedContainer createContainer(IStore local)
+ {
+ IManagedContainer container = ContainerUtil.createContainer();
+ Net4jUtil.prepareContainer(container);
+ JVMUtil.prepareContainer(container);
+ CDONet4jServerUtil.prepareContainer(container);
+ container.activate();
+ return container;
+ }
+
+ protected IManagedContainer getContainer()
+ {
+ return container;
+ }
+
+ protected String getLocalAcceptorName()
+ {
+ return "acceptor-for-" + localRepository.getUUID();
+ }
+
+ protected IJVMAcceptor getLocalAcceptor()
+ {
+ String localAcceptorName = getLocalAcceptorName();
+ return JVMUtil.getAcceptor(container, localAcceptorName);
+ }
+
+ protected IJVMConnector getLocalConnector()
+ {
+ String localAcceptorName = getLocalAcceptorName();
+ return JVMUtil.getConnector(container, localAcceptorName);
+ }
+
+ protected InternalRepository createLocalRepository(String localRepositoryName, IStore store)
+ {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(Props.OVERRIDE_UUID, ""); // UUID := name !!!
+ props.put(Props.SUPPORTING_AUDITS, "false");
+ props.put(Props.SUPPORTING_BRANCHES, "false");
+ props.put(Props.ID_GENERATION_LOCATION, idGenerationLocation.toString());
+
+ Repository repository = new Repository.Default()
+ {
+ @Override
+ public void initMainBranch(InternalCDOBranchManager branchManager, long timeStamp)
+ {
+ if (idGenerationLocation == IDGenerationLocation.STORE)
+ {
+ // Mark the main branch local so that new objects get local IDs
+ branchManager.initMainBranch(true, timeStamp);
+ }
+ else
+ {
+ super.initMainBranch(branchManager, timeStamp);
+ }
+ }
+
+ @Override
+ protected void initRootResource()
+ {
+ // Don't create the root resource as it will be checked out
+ setState(State.INITIAL);
+ }
+ };
+
+ repository.setName(localRepositoryName);
+ repository.setStore((InternalStore)store);
+ repository.setProperties(props);
+
+ CDOServerUtil.addRepository(container, repository);
+ return repository;
+ }
+
+ protected InternalCDOSession openLocalSession()
+ {
+ getLocalAcceptor();
+
+ IJVMConnector connector = getLocalConnector();
+ String repositoryName = localRepository.getName();
+
+ CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
+ configuration.setConnector(connector);
+ configuration.setRepositoryName(repositoryName);
+ configuration.setIDGenerator(idGenerator);
+ configuration.setRevisionManager(CDORevisionUtil.createRevisionManager(CDORevisionCache.NOOP)); // Use repo's cache
+
+ if (idGenerationLocation == IDGenerationLocation.STORE)
+ {
+ ((InternalCDOSessionConfiguration)configuration).setMainBranchLocal(true);
+ }
+
+ InternalCDOSession session = (InternalCDOSession)configuration.openNet4jSession();
+ ((ISignalProtocol<?>)session.getSessionProtocol()).setTimeout(ISignalProtocol.NO_TIMEOUT);
+ session.setPackageRegistry(localRepository.getPackageRegistry(false)); // Use repo's registry
+
+ head = session.getBranchManager().getMainBranch().getHead();
+ return session;
+ }
+
+ protected InternalCDOView[] getViews()
+ {
+ synchronized (views)
+ {
+ return views.toArray(new InternalCDOView[views.size()]);
+ }
+ }
+
+ protected InternalCDOSession openRemoteSession()
+ {
+ CDOSessionConfiguration configuration = remoteSessionConfigurationFactory.createSessionConfiguration();
+ InternalCDOSession session = (InternalCDOSession)configuration.openSession();
+
+ CDORepositoryInfo repositoryInfo = session.getRepositoryInfo();
+ if (!repositoryInfo.isSupportingAudits())
+ {
+ session.close();
+ throw new IllegalStateException("Remote repository does not support auditing");
+ }
+
+ IDGenerationLocation remoteLocation = repositoryInfo.getIDGenerationLocation();
+ if (!remoteLocation.equals(idGenerationLocation))
+ {
+ session.close();
+ throw new IllegalStateException("Remote repository uses different ID generation location: " + remoteLocation);
+ }
+
+ return session;
+ }
+
+ protected void setTimeStamp(long timeStamp)
+ {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(PROP_TIME_STAMP, String.valueOf(timeStamp));
+ localRepository.getStore().setPersistentProperties(props);
+
+ this.timeStamp = timeStamp;
+ }
+
+ protected void saveProperties()
+ {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(PROP_BRANCH_PATH, branchPath);
+ props.put(PROP_TIME_STAMP, String.valueOf(timeStamp));
+ props.put(PROP_FIXED, String.valueOf(fixed));
+ localRepository.getStore().setPersistentProperties(props);
+ }
+
+ protected void loadProperties()
+ {
+ Set<String> names = new HashSet<String>(Arrays.asList(PROP_BRANCH_PATH, PROP_TIME_STAMP, PROP_FIXED));
+ Map<String, String> props = localRepository.getStore().getPersistentProperties(names);
+ branchPath = props.get(PROP_BRANCH_PATH);
+ timeStamp = Long.parseLong(props.get(PROP_TIME_STAMP));
+ fixed = Boolean.parseBoolean(props.get(PROP_FIXED));
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private class BaseRevisionProvider implements CDORevisionProvider
+ {
+ public CDORevision getRevision(CDOID id)
+ {
+ CDORevision revision = base.getRevision(id);
+ if (revision == null)
+ {
+ revision = CDOWorkspaceImpl.this.getRevision(id);
+ }
+
+ return revision;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public final class ViewAdapter extends LifecycleEventAdapter
+ {
+ public ViewAdapter()
+ {
+ }
+
+ public CDOWorkspace getWorkspace()
+ {
+ return CDOWorkspaceImpl.this;
+ }
+
+ @Override
+ protected void onDeactivated(ILifecycle view)
+ {
+ synchronized (views)
+ {
+ views.remove(view);
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class DirtyStateChangedEventImpl extends Event implements DirtyStateChangedEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private boolean dirty;
+
+ public DirtyStateChangedEventImpl(CDOWorkspace workspace, boolean dirty)
+ {
+ super(workspace);
+ this.dirty = dirty;
+ }
+
+ public boolean isDirty()
+ {
+ return dirty;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java index 9080eaed7f..70565a65e5 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java @@ -1,242 +1,242 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.internal.workspace; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDUtil; -import org.eclipse.emf.cdo.common.protocol.CDODataInput; -import org.eclipse.emf.cdo.common.protocol.CDODataOutput; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; -import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspaceBase; -import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase; -import org.eclipse.emf.cdo.workspace.CDOWorkspaceUtil; - -import org.eclipse.net4j.util.factory.ProductCreationException; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; -import org.eclipse.net4j.util.io.IOUtil; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class FolderCDOWorkspaceBase extends AbstractCDOWorkspaceBase -{ - private File folder; - - public FolderCDOWorkspaceBase(File folder) - { - this.folder = folder; - } - - public File getFolder() - { - return folder; - } - - public final synchronized CDORevision getRevision(CDOID id) - { - File file = getFile(id); - if (!file.exists() || file.length() == 0) - { - return null; - } - - FileInputStream fis = null; - - try - { - fis = new FileInputStream(file); - ExtendedDataInputStream edis = new ExtendedDataInputStream(fis); - CDODataInput in = createCDODataInput(edis); - return in.readCDORevision(); - } - catch (Exception ex) - { - throw new IllegalStateException("Could not read from " + file.getAbsolutePath(), ex); - } - finally - { - IOUtil.close(fis); - } - } - - public boolean isAddedObject(CDOID id) - { - File file = getFile(id); - if (!file.exists()) - { - return false; - } - - return file.length() == 0; - } - - @Override - public String toString() - { - return "FolderBase[" + folder.getAbsolutePath() + "]"; - } - - @Override - protected void doClear() - { - IOUtil.delete(folder); - checkExists(folder, false); - createFolder(); - } - - @Override - protected Set<CDOID> doGetIDs() - { - Set<CDOID> ids = new HashSet<CDOID>(); - for (String key : folder.list()) - { - CDOID id = getCDOID(key); - ids.add(id); - } - - return ids; - } - - @Override - protected void doRegisterChangedOrDetachedObject(InternalCDORevision revision) - { - File file = getFile(revision.getID()); - if (file.exists()) - { - return; - } - - FileOutputStream fos = null; - - try - { - fos = new FileOutputStream(file); - ExtendedDataOutputStream edos = new ExtendedDataOutputStream(fos); - CDODataOutput out = createCDODataOutput(edos); - out.writeCDORevision(revision, CDORevision.UNCHUNKED); - edos.flush(); - } - catch (Exception ex) - { - throw new IllegalStateException("Could not create " + file.getAbsolutePath(), ex); - } - finally - { - IOUtil.close(fos); - } - } - - @Override - protected void doRegisterAddedObject(CDOID id) - { - File file = getFile(id); - if (file.exists()) - { - return; - } - - FileOutputStream fos = null; - - try - { - fos = new FileOutputStream(file); // Just create an empty marker file - } - catch (Exception ex) - { - throw new IllegalStateException("Could not create " + file.getAbsolutePath(), ex); - } - finally - { - IOUtil.close(fos); - } - } - - @Override - protected void doDeregisterObject(CDOID id) - { - File file = getFile(id); - file.delete(); - checkExists(file, false); - } - - protected CDOID getCDOID(String filename) - { - return CDOIDUtil.read(filename); - } - - protected String getKey(CDOID id) - { - StringBuilder builder = new StringBuilder(); - CDOIDUtil.write(builder, id); - return builder.toString(); - } - - protected File getFile(CDOID id) - { - String key = getKey(id); - return new File(folder, key); - } - - private void createFolder() - { - IOUtil.mkdirs(folder); - checkExists(folder, true); - } - - private void checkExists(File file, boolean exists) - { - if (exists) - { - if (!file.exists()) - { - throw new IllegalStateException("File does not exist: " + file.getAbsolutePath()); - } - } - else - { - if (file.exists()) - { - throw new IllegalStateException("File does still exist: " + file.getAbsolutePath()); - } - } - } - - /** - * @author Eike Stepper - */ - public static final class Factory extends org.eclipse.net4j.util.factory.Factory - { - public static final String TYPE = "folder"; - - public Factory() - { - super(InternalCDOWorkspaceBase.PRODUCT_GROUP, TYPE); - } - - public Factory(String productGroup, String type) - { - super(productGroup, type); - } - - public CDOWorkspaceBase create(String description) throws ProductCreationException - { - return CDOWorkspaceUtil.createFolderWorkspaceBase(new File(description)); - } - } -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.internal.workspace;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspaceBase;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceUtil;
+
+import org.eclipse.net4j.util.factory.ProductCreationException;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class FolderCDOWorkspaceBase extends AbstractCDOWorkspaceBase
+{
+ private File folder;
+
+ public FolderCDOWorkspaceBase(File folder)
+ {
+ this.folder = folder;
+ }
+
+ public File getFolder()
+ {
+ return folder;
+ }
+
+ public final synchronized CDORevision getRevision(CDOID id)
+ {
+ File file = getFile(id);
+ if (!file.exists() || file.length() == 0)
+ {
+ return null;
+ }
+
+ FileInputStream fis = null;
+
+ try
+ {
+ fis = new FileInputStream(file);
+ ExtendedDataInputStream edis = new ExtendedDataInputStream(fis);
+ CDODataInput in = createCDODataInput(edis);
+ return in.readCDORevision();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Could not read from " + file.getAbsolutePath(), ex);
+ }
+ finally
+ {
+ IOUtil.close(fis);
+ }
+ }
+
+ public boolean isAddedObject(CDOID id)
+ {
+ File file = getFile(id);
+ if (!file.exists())
+ {
+ return false;
+ }
+
+ return file.length() == 0;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "FolderBase[" + folder.getAbsolutePath() + "]";
+ }
+
+ @Override
+ protected void doClear()
+ {
+ IOUtil.delete(folder);
+ checkExists(folder, false);
+ createFolder();
+ }
+
+ @Override
+ protected Set<CDOID> doGetIDs()
+ {
+ Set<CDOID> ids = new HashSet<CDOID>();
+ for (String key : folder.list())
+ {
+ CDOID id = getCDOID(key);
+ ids.add(id);
+ }
+
+ return ids;
+ }
+
+ @Override
+ protected void doRegisterChangedOrDetachedObject(InternalCDORevision revision)
+ {
+ File file = getFile(revision.getID());
+ if (file.exists())
+ {
+ return;
+ }
+
+ FileOutputStream fos = null;
+
+ try
+ {
+ fos = new FileOutputStream(file);
+ ExtendedDataOutputStream edos = new ExtendedDataOutputStream(fos);
+ CDODataOutput out = createCDODataOutput(edos);
+ out.writeCDORevision(revision, CDORevision.UNCHUNKED);
+ edos.flush();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Could not create " + file.getAbsolutePath(), ex);
+ }
+ finally
+ {
+ IOUtil.close(fos);
+ }
+ }
+
+ @Override
+ protected void doRegisterAddedObject(CDOID id)
+ {
+ File file = getFile(id);
+ if (file.exists())
+ {
+ return;
+ }
+
+ FileOutputStream fos = null;
+
+ try
+ {
+ fos = new FileOutputStream(file); // Just create an empty marker file
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Could not create " + file.getAbsolutePath(), ex);
+ }
+ finally
+ {
+ IOUtil.close(fos);
+ }
+ }
+
+ @Override
+ protected void doDeregisterObject(CDOID id)
+ {
+ File file = getFile(id);
+ file.delete();
+ checkExists(file, false);
+ }
+
+ protected CDOID getCDOID(String filename)
+ {
+ return CDOIDUtil.read(filename);
+ }
+
+ protected String getKey(CDOID id)
+ {
+ StringBuilder builder = new StringBuilder();
+ CDOIDUtil.write(builder, id);
+ return builder.toString();
+ }
+
+ protected File getFile(CDOID id)
+ {
+ String key = getKey(id);
+ return new File(folder, key);
+ }
+
+ private void createFolder()
+ {
+ IOUtil.mkdirs(folder);
+ checkExists(folder, true);
+ }
+
+ private void checkExists(File file, boolean exists)
+ {
+ if (exists)
+ {
+ if (!file.exists())
+ {
+ throw new IllegalStateException("File does not exist: " + file.getAbsolutePath());
+ }
+ }
+ else
+ {
+ if (file.exists())
+ {
+ throw new IllegalStateException("File does still exist: " + file.getAbsolutePath());
+ }
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Factory extends org.eclipse.net4j.util.factory.Factory
+ {
+ public static final String TYPE = "folder";
+
+ public Factory()
+ {
+ super(InternalCDOWorkspaceBase.PRODUCT_GROUP, TYPE);
+ }
+
+ public Factory(String productGroup, String type)
+ {
+ super(productGroup, type);
+ }
+
+ public CDOWorkspaceBase create(String description) throws ProductCreationException
+ {
+ return CDOWorkspaceUtil.createFolderWorkspaceBase(new File(description));
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/WorkspaceProperties.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/WorkspaceProperties.java index c780699db7..54a7485204 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/WorkspaceProperties.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/WorkspaceProperties.java @@ -1,141 +1,141 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.internal.workspace; - -import org.eclipse.emf.cdo.common.util.CDOCommonUtil; -import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace; -import org.eclipse.emf.cdo.workspace.CDOWorkspace; - -import org.eclipse.net4j.util.properties.DefaultPropertyTester; -import org.eclipse.net4j.util.properties.IProperties; -import org.eclipse.net4j.util.properties.Properties; -import org.eclipse.net4j.util.properties.Property; - -/** - * @author Eike Stepper - */ -public class WorkspaceProperties extends Properties<CDOWorkspace> -{ - public static final IProperties<CDOWorkspace> INSTANCE = new WorkspaceProperties(); - - private WorkspaceProperties() - { - super(CDOWorkspace.class); - - add(new Property<CDOWorkspace>("open", //$NON-NLS-1$ - "Open", "Whether this workspace is open or not.") - { - @Override - protected Object eval(CDOWorkspace workspace) - { - return !workspace.isClosed(); - } - }); - - add(new Property<CDOWorkspace>("branchPath", //$NON-NLS-1$ - "Branch", "The remote branch of this workspace.") - { - @Override - protected Object eval(CDOWorkspace workspace) - { - return workspace.getBranchPath(); - } - }); - - add(new Property<CDOWorkspace>("timeStamp", //$NON-NLS-1$ - "Time Stamp", "The time stamp of this workspace.") - { - @Override - protected Object eval(CDOWorkspace workspace) - { - return CDOCommonUtil.formatTimeStamp(workspace.getTimeStamp()); - } - }); - - add(new Property<CDOWorkspace>("fixed", //$NON-NLS-1$ - "Fixed", "Whether this workspace is fixed to a specific remote time stamp or not.") - { - @Override - protected Object eval(CDOWorkspace workspace) - { - return workspace.isFixed(); - } - }); - - add(new Property<CDOWorkspace>("dirty", //$NON-NLS-1$ - "Dirty", "Whether this workspace is locally dirty or not.") - { - @Override - protected Object eval(CDOWorkspace workspace) - { - return workspace.isDirty(); - } - }); - - add(new Property<CDOWorkspace>("idGenerationLocation", //$NON-NLS-1$ - "ID Generation Location", "One of STORE, CLIENT.") - { - @Override - protected Object eval(CDOWorkspace workspace) - { - return ((InternalCDOWorkspace)workspace).getIDGenerationLocation(); - } - }); - - add(new Property<CDOWorkspace>("base", //$NON-NLS-1$ - "Base", "The base of this workspace.") - { - @Override - protected Object eval(CDOWorkspace workspace) - { - return ((InternalCDOWorkspace)workspace).getBase(); - } - }); - - add(new Property<CDOWorkspace>("local", //$NON-NLS-1$ - "Local", "The local repository of this workspace.") - { - @Override - protected Object eval(CDOWorkspace workspace) - { - return ((InternalCDOWorkspace)workspace).getLocalRepository(); - } - }); - - add(new Property<CDOWorkspace>("remote", //$NON-NLS-1$ - "Remote", "The remote repository of this workspace.") - { - @Override - protected Object eval(CDOWorkspace workspace) - { - return ((InternalCDOWorkspace)workspace).getRemoteSessionConfigurationFactory(); - } - }); - } - - public static void main(String[] args) - { - new Tester().dumpContributionMarkup(); - } - - /** - * @author Eike Stepper - */ - public static final class Tester extends DefaultPropertyTester<CDOWorkspace> - { - public static final String NAMESPACE = "org.eclipse.emf.cdo.workspace"; - - public Tester() - { - super(NAMESPACE, INSTANCE); - } - } -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.internal.workspace;
+
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace;
+import org.eclipse.emf.cdo.workspace.CDOWorkspace;
+
+import org.eclipse.net4j.util.properties.DefaultPropertyTester;
+import org.eclipse.net4j.util.properties.IProperties;
+import org.eclipse.net4j.util.properties.Properties;
+import org.eclipse.net4j.util.properties.Property;
+
+/**
+ * @author Eike Stepper
+ */
+public class WorkspaceProperties extends Properties<CDOWorkspace>
+{
+ public static final IProperties<CDOWorkspace> INSTANCE = new WorkspaceProperties();
+
+ private WorkspaceProperties()
+ {
+ super(CDOWorkspace.class);
+
+ add(new Property<CDOWorkspace>("open", //$NON-NLS-1$
+ "Open", "Whether this workspace is open or not.")
+ {
+ @Override
+ protected Object eval(CDOWorkspace workspace)
+ {
+ return !workspace.isClosed();
+ }
+ });
+
+ add(new Property<CDOWorkspace>("branchPath", //$NON-NLS-1$
+ "Branch", "The remote branch of this workspace.")
+ {
+ @Override
+ protected Object eval(CDOWorkspace workspace)
+ {
+ return workspace.getBranchPath();
+ }
+ });
+
+ add(new Property<CDOWorkspace>("timeStamp", //$NON-NLS-1$
+ "Time Stamp", "The time stamp of this workspace.")
+ {
+ @Override
+ protected Object eval(CDOWorkspace workspace)
+ {
+ return CDOCommonUtil.formatTimeStamp(workspace.getTimeStamp());
+ }
+ });
+
+ add(new Property<CDOWorkspace>("fixed", //$NON-NLS-1$
+ "Fixed", "Whether this workspace is fixed to a specific remote time stamp or not.")
+ {
+ @Override
+ protected Object eval(CDOWorkspace workspace)
+ {
+ return workspace.isFixed();
+ }
+ });
+
+ add(new Property<CDOWorkspace>("dirty", //$NON-NLS-1$
+ "Dirty", "Whether this workspace is locally dirty or not.")
+ {
+ @Override
+ protected Object eval(CDOWorkspace workspace)
+ {
+ return workspace.isDirty();
+ }
+ });
+
+ add(new Property<CDOWorkspace>("idGenerationLocation", //$NON-NLS-1$
+ "ID Generation Location", "One of STORE, CLIENT.")
+ {
+ @Override
+ protected Object eval(CDOWorkspace workspace)
+ {
+ return ((InternalCDOWorkspace)workspace).getIDGenerationLocation();
+ }
+ });
+
+ add(new Property<CDOWorkspace>("base", //$NON-NLS-1$
+ "Base", "The base of this workspace.")
+ {
+ @Override
+ protected Object eval(CDOWorkspace workspace)
+ {
+ return ((InternalCDOWorkspace)workspace).getBase();
+ }
+ });
+
+ add(new Property<CDOWorkspace>("local", //$NON-NLS-1$
+ "Local", "The local repository of this workspace.")
+ {
+ @Override
+ protected Object eval(CDOWorkspace workspace)
+ {
+ return ((InternalCDOWorkspace)workspace).getLocalRepository();
+ }
+ });
+
+ add(new Property<CDOWorkspace>("remote", //$NON-NLS-1$
+ "Remote", "The remote repository of this workspace.")
+ {
+ @Override
+ protected Object eval(CDOWorkspace workspace)
+ {
+ return ((InternalCDOWorkspace)workspace).getRemoteSessionConfigurationFactory();
+ }
+ });
+ }
+
+ public static void main(String[] args)
+ {
+ new Tester().dumpContributionMarkup();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Tester extends DefaultPropertyTester<CDOWorkspace>
+ {
+ public static final String NAMESPACE = "org.eclipse.emf.cdo.workspace";
+
+ public Tester()
+ {
+ super(NAMESPACE, INSTANCE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/bundle/OM.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/bundle/OM.java index 022755c595..56719a82bb 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/bundle/OM.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/bundle/OM.java @@ -1,44 +1,44 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.internal.workspace.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 Eike Stepper - */ -public abstract class OM -{ - public static final String BUNDLE_ID = "org.eclipse.emf.cdo.workspace"; //$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(); - - /** - * @author Eike Stepper - */ - 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.workspace.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 Eike Stepper
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.emf.cdo.workspace"; //$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();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspace.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspace.java index 9bae3fe39c..d48c6f35bd 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspace.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspace.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: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.spi.workspace; - -import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation; -import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory; -import org.eclipse.emf.cdo.spi.server.InternalRepository; -import org.eclipse.emf.cdo.workspace.CDOWorkspace; - -import org.eclipse.emf.spi.cdo.InternalCDOSession; - -/** - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface InternalCDOWorkspace extends CDOWorkspace -{ - /** - * @since 4.1 - */ - public IDGenerationLocation getIDGenerationLocation(); - - public InternalCDOWorkspaceBase getBase(); - - public InternalRepository getLocalRepository(); - - public InternalCDOSession getLocalSession(); - - /** - * @since 4.1 - */ - public CDOSessionConfigurationFactory getRemoteSessionConfigurationFactory(); -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.spi.workspace;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.workspace.CDOWorkspace;
+
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
+
+/**
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalCDOWorkspace extends CDOWorkspace
+{
+ /**
+ * @since 4.1
+ */
+ public IDGenerationLocation getIDGenerationLocation();
+
+ public InternalCDOWorkspaceBase getBase();
+
+ public InternalRepository getLocalRepository();
+
+ public InternalCDOSession getLocalSession();
+
+ /**
+ * @since 4.1
+ */
+ public CDOSessionConfigurationFactory getRemoteSessionConfigurationFactory();
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspaceBase.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspaceBase.java index daddbecf92..dc22cb23a9 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspaceBase.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspaceBase.java @@ -1,50 +1,50 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.spi.workspace; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase2; - -/** - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface InternalCDOWorkspaceBase extends CDOWorkspaceBase2 -{ - public static final String PRODUCT_GROUP = "org.eclipse.emf.cdo.workspace.bases"; - - public InternalCDOWorkspace getWorkspace(); - - public void init(InternalCDOWorkspace workspace); - - /** - * @since 4.1 - */ - public void registerChangedOrDetachedObject(InternalCDORevision revision); - - /** - * @since 4.1 - */ - public void registerAddedObject(CDOID id); - - /** - * @since 4.1 - */ - public void deregisterObject(CDOID id); - - @Deprecated - public void updateAfterCommit(CDOTransaction transaction); - - public void clear(); -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.spi.workspace;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase2;
+
+/**
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface InternalCDOWorkspaceBase extends CDOWorkspaceBase2
+{
+ public static final String PRODUCT_GROUP = "org.eclipse.emf.cdo.workspace.bases";
+
+ public InternalCDOWorkspace getWorkspace();
+
+ public void init(InternalCDOWorkspace workspace);
+
+ /**
+ * @since 4.1
+ */
+ public void registerChangedOrDetachedObject(InternalCDORevision revision);
+
+ /**
+ * @since 4.1
+ */
+ public void registerAddedObject(CDOID id);
+
+ /**
+ * @since 4.1
+ */
+ public void deregisterObject(CDOID id);
+
+ @Deprecated
+ public void updateAfterCommit(CDOTransaction transaction);
+
+ public void clear();
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspace.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspace.java index d3740dbb02..8d3d5a6b17 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspace.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspace.java @@ -1,85 +1,85 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.workspace; - -import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; -import org.eclipse.emf.cdo.transaction.CDOMerger; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.util.CommitException; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.net4j.util.collection.Closeable; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.INotifier; - -import org.eclipse.emf.ecore.resource.ResourceSet; - -/** - * Represents a local {@link CDOWorkspaceConfiguration#checkout() checkout} from a remote repository. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOWorkspace extends CDORevisionProvider, Closeable, INotifier -{ - public String getBranchPath(); - - public long getTimeStamp(); - - public boolean isFixed(); - - public CDOWorkspaceBase getBase(); - - public CDOView openView(); - - public CDOView openView(ResourceSet resourceSet); - - public CDOTransaction openTransaction(); - - public CDOTransaction openTransaction(ResourceSet resourceSet); - - public CDOTransaction update(CDOMerger merger); - - public CDOTransaction merge(CDOMerger merger, String branchPath); - - public CDOTransaction merge(CDOMerger merger, String branchPath, long timeStamp); - - public CDOCommitInfo checkin() throws CommitException; - - public CDOCommitInfo checkin(String comment) throws CommitException; - - public CDOChangeSetData compare(String branchPath); - - public CDOChangeSetData compare(String branchPath, long timeStamp); - - public CDOChangeSetData getLocalChanges(); - - public void replace(String branchPath, long timeStamp); - - public void revert(); - - /** - * @since 4.1 - */ - public boolean isDirty(); - - /** - * @author Eike Stepper - * @since 4.1 - */ - public interface DirtyStateChangedEvent extends IEvent - { - public boolean isDirty(); - } -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.workspace;
+
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
+import org.eclipse.emf.cdo.transaction.CDOMerger;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.collection.Closeable;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.INotifier;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+/**
+ * Represents a local {@link CDOWorkspaceConfiguration#checkout() checkout} from a remote repository.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOWorkspace extends CDORevisionProvider, Closeable, INotifier
+{
+ public String getBranchPath();
+
+ public long getTimeStamp();
+
+ public boolean isFixed();
+
+ public CDOWorkspaceBase getBase();
+
+ public CDOView openView();
+
+ public CDOView openView(ResourceSet resourceSet);
+
+ public CDOTransaction openTransaction();
+
+ public CDOTransaction openTransaction(ResourceSet resourceSet);
+
+ public CDOTransaction update(CDOMerger merger);
+
+ public CDOTransaction merge(CDOMerger merger, String branchPath);
+
+ public CDOTransaction merge(CDOMerger merger, String branchPath, long timeStamp);
+
+ public CDOCommitInfo checkin() throws CommitException;
+
+ public CDOCommitInfo checkin(String comment) throws CommitException;
+
+ public CDOChangeSetData compare(String branchPath);
+
+ public CDOChangeSetData compare(String branchPath, long timeStamp);
+
+ public CDOChangeSetData getLocalChanges();
+
+ public void replace(String branchPath, long timeStamp);
+
+ public void revert();
+
+ /**
+ * @since 4.1
+ */
+ public boolean isDirty();
+
+ /**
+ * @author Eike Stepper
+ * @since 4.1
+ */
+ public interface DirtyStateChangedEvent extends IEvent
+ {
+ public boolean isDirty();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase.java index 97a203d6c8..fc022910ed 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase.java @@ -1,31 +1,31 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.workspace; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; - -import java.util.Set; - -/** - * Represents the local state of a {@link CDOWorkspace workspace} directly after the initial - * {@link CDOWorkspaceConfiguration#checkout() checkout} operation or any subsequent - * {@link CDOWorkspace#update(org.eclipse.emf.cdo.transaction.CDOMerger) update} and - * {@link CDOWorkspace#replace(String, long) replace} operations. - * - * @author Eike Stepper - */ -public interface CDOWorkspaceBase extends CDORevisionProvider -{ - public CDOWorkspace getWorkspace(); - - public Set<CDOID> getIDs(); -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.workspace;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
+
+import java.util.Set;
+
+/**
+ * Represents the local state of a {@link CDOWorkspace workspace} directly after the initial
+ * {@link CDOWorkspaceConfiguration#checkout() checkout} operation or any subsequent
+ * {@link CDOWorkspace#update(org.eclipse.emf.cdo.transaction.CDOMerger) update} and
+ * {@link CDOWorkspace#replace(String, long) replace} operations.
+ *
+ * @author Eike Stepper
+ */
+public interface CDOWorkspaceBase extends CDORevisionProvider
+{
+ public CDOWorkspace getWorkspace();
+
+ public Set<CDOID> getIDs();
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase2.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase2.java index 9555b3fed6..5c8c5c6195 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase2.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase2.java @@ -1,31 +1,31 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.workspace; - -import org.eclipse.emf.cdo.common.id.CDOID; - -/** - * Adds {@link #isEmpty()} and {@link #containsID(CDOID)} methods. - * - * @author Eike Stepper - * @since 4.1 - */ -public interface CDOWorkspaceBase2 extends CDOWorkspaceBase -{ - public boolean isEmpty(); - - public boolean containsID(CDOID id); - - /** - * @since 4.1 - */ - public boolean isAddedObject(CDOID id); -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.workspace;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+/**
+ * Adds {@link #isEmpty()} and {@link #containsID(CDOID)} methods.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+public interface CDOWorkspaceBase2 extends CDOWorkspaceBase
+{
+ public boolean isEmpty();
+
+ public boolean containsID(CDOID id);
+
+ /**
+ * @since 4.1
+ */
+ public boolean isAddedObject(CDOID id);
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceConfiguration.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceConfiguration.java index a06f444e59..aeb185a810 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceConfiguration.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceConfiguration.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * 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
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java index a71da98f76..cedae49baf 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java @@ -1,223 +1,223 @@ -/* - * 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 - */ -package org.eclipse.emf.cdo.workspace; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.internal.workspace.FolderCDOWorkspaceBase; -import org.eclipse.emf.cdo.internal.workspace.WorkspaceProperties; -import org.eclipse.emf.cdo.server.IStore; -import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory; -import org.eclipse.emf.cdo.util.CDOUtil; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.properties.IProperties; - -import org.eclipse.emf.ecore.EObject; - -import java.io.File; -import java.util.Set; - -/** - * Various static helper methods for dealing with {@link CDOWorkspace workspaces}. - * - * @author Eike Stepper - */ -public final class CDOWorkspaceUtil -{ - private CDOWorkspaceUtil() - { - } - - /** - * @since 4.1 - */ - public static IProperties<CDOWorkspace> getProperties() - { - return WorkspaceProperties.INSTANCE; - } - - /** - * @since 4.1 - */ - public static CDOWorkspace getWorkspace(EObject object) - { - CDOView view = CDOUtil.getCDOObject(object).cdoView(); - if (view == null || view.isClosed()) - { - return null; - } - - IListener[] listeners = view.getListeners(); - if (listeners != null) - { - for (int i = 0; i < listeners.length; i++) - { - IListener listener = listeners[i]; - if (listener instanceof org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceImpl.ViewAdapter) - { - org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceImpl.ViewAdapter adapter = (org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceImpl.ViewAdapter)listener; - return adapter.getWorkspace(); - } - } - } - - return null; - } - - /** - * @since 4.1 - */ - public static boolean isDirty(EObject object) - { - CDOObject cdoObject = CDOUtil.getCDOObject(object); - if (object == null) - { - return false; - } - - CDOWorkspace workspace = getWorkspace(cdoObject); - CDOWorkspaceBase2 base = getWorkspaceBase2(workspace.getBase()); - return base.containsID(cdoObject.cdoID()); - } - - /** - * @since 4.1 - */ - public static CDOWorkspaceBase2 getWorkspaceBase2(final CDOWorkspaceBase base) - { - if (base instanceof CDOWorkspaceBase2) - { - return (CDOWorkspaceBase2)base; - } - - return new DelegatingWorkspaceBase2(base); - } - - public static CDOWorkspaceBase createFolderWorkspaceBase(File folder) - { - return new FolderCDOWorkspaceBase(folder); - } - - /** - * Returns a new configuration that can be used to checkout a new {@link CDOWorkspace} or open an existing one. - * - * @since 4.1 - */ - public static CDOWorkspaceConfiguration createWorkspaceConfiguration() - { - return new org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceConfigurationImpl(); - } - - /** - * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#open()} - */ - @Deprecated - public static CDOWorkspace open(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote) - { - CDOWorkspaceConfiguration config = createWorkspaceConfiguration(); - config.setStore(local); - config.setBase(base); - config.setRemote(remote); - return config.open(); - } - - /** - * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()} - */ - @Deprecated - public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote) - { - return checkout(local, base, remote, null); - } - - /** - * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()} - */ - @Deprecated - public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote, - String branchPath) - { - return checkout(local, base, remote, branchPath, CDOBranchPoint.UNSPECIFIED_DATE); - } - - /** - * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()} - */ - @Deprecated - public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote, - long timeStamp) - { - return checkout(local, base, remote, null, timeStamp); - } - - /** - * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()} - */ - @Deprecated - public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote, - String branchPath, long timeStamp) - { - CDOWorkspaceConfiguration config = createWorkspaceConfiguration(); - config.setStore(local); - config.setBase(base); - config.setRemote(remote); - config.setBranchPath(branchPath); - config.setTimeStamp(timeStamp); - return config.checkout(); - } - - /** - * @author Eike Stepper - */ - private static final class DelegatingWorkspaceBase2 implements CDOWorkspaceBase2 - { - private final CDOWorkspaceBase delegate; - - private DelegatingWorkspaceBase2(CDOWorkspaceBase base) - { - delegate = base; - } - - public CDOWorkspace getWorkspace() - { - return delegate.getWorkspace(); - } - - public Set<CDOID> getIDs() - { - return delegate.getIDs(); - } - - public CDORevision getRevision(CDOID id) - { - return delegate.getRevision(id); - } - - public boolean isEmpty() - { - return getIDs().isEmpty(); - } - - public boolean containsID(CDOID id) - { - return getIDs().contains(id); - } - - public boolean isAddedObject(CDOID id) - { - return containsID(id) && getRevision(id) == null; - } - } -} +/*
+ * 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
+ */
+package org.eclipse.emf.cdo.workspace;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.internal.workspace.FolderCDOWorkspaceBase;
+import org.eclipse.emf.cdo.internal.workspace.WorkspaceProperties;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.properties.IProperties;
+
+import org.eclipse.emf.ecore.EObject;
+
+import java.io.File;
+import java.util.Set;
+
+/**
+ * Various static helper methods for dealing with {@link CDOWorkspace workspaces}.
+ *
+ * @author Eike Stepper
+ */
+public final class CDOWorkspaceUtil
+{
+ private CDOWorkspaceUtil()
+ {
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static IProperties<CDOWorkspace> getProperties()
+ {
+ return WorkspaceProperties.INSTANCE;
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static CDOWorkspace getWorkspace(EObject object)
+ {
+ CDOView view = CDOUtil.getCDOObject(object).cdoView();
+ if (view == null || view.isClosed())
+ {
+ return null;
+ }
+
+ IListener[] listeners = view.getListeners();
+ if (listeners != null)
+ {
+ for (int i = 0; i < listeners.length; i++)
+ {
+ IListener listener = listeners[i];
+ if (listener instanceof org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceImpl.ViewAdapter)
+ {
+ org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceImpl.ViewAdapter adapter = (org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceImpl.ViewAdapter)listener;
+ return adapter.getWorkspace();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static boolean isDirty(EObject object)
+ {
+ CDOObject cdoObject = CDOUtil.getCDOObject(object);
+ if (object == null)
+ {
+ return false;
+ }
+
+ CDOWorkspace workspace = getWorkspace(cdoObject);
+ CDOWorkspaceBase2 base = getWorkspaceBase2(workspace.getBase());
+ return base.containsID(cdoObject.cdoID());
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static CDOWorkspaceBase2 getWorkspaceBase2(final CDOWorkspaceBase base)
+ {
+ if (base instanceof CDOWorkspaceBase2)
+ {
+ return (CDOWorkspaceBase2)base;
+ }
+
+ return new DelegatingWorkspaceBase2(base);
+ }
+
+ public static CDOWorkspaceBase createFolderWorkspaceBase(File folder)
+ {
+ return new FolderCDOWorkspaceBase(folder);
+ }
+
+ /**
+ * Returns a new configuration that can be used to checkout a new {@link CDOWorkspace} or open an existing one.
+ *
+ * @since 4.1
+ */
+ public static CDOWorkspaceConfiguration createWorkspaceConfiguration()
+ {
+ return new org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceConfigurationImpl();
+ }
+
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#open()}
+ */
+ @Deprecated
+ public static CDOWorkspace open(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
+ {
+ CDOWorkspaceConfiguration config = createWorkspaceConfiguration();
+ config.setStore(local);
+ config.setBase(base);
+ config.setRemote(remote);
+ return config.open();
+ }
+
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()}
+ */
+ @Deprecated
+ public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
+ {
+ return checkout(local, base, remote, null);
+ }
+
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()}
+ */
+ @Deprecated
+ public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote,
+ String branchPath)
+ {
+ return checkout(local, base, remote, branchPath, CDOBranchPoint.UNSPECIFIED_DATE);
+ }
+
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()}
+ */
+ @Deprecated
+ public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote,
+ long timeStamp)
+ {
+ return checkout(local, base, remote, null, timeStamp);
+ }
+
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()}
+ */
+ @Deprecated
+ public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote,
+ String branchPath, long timeStamp)
+ {
+ CDOWorkspaceConfiguration config = createWorkspaceConfiguration();
+ config.setStore(local);
+ config.setBase(base);
+ config.setRemote(remote);
+ config.setBranchPath(branchPath);
+ config.setTimeStamp(timeStamp);
+ return config.checkout();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class DelegatingWorkspaceBase2 implements CDOWorkspaceBase2
+ {
+ private final CDOWorkspaceBase delegate;
+
+ private DelegatingWorkspaceBase2(CDOWorkspaceBase base)
+ {
+ delegate = base;
+ }
+
+ public CDOWorkspace getWorkspace()
+ {
+ return delegate.getWorkspace();
+ }
+
+ public Set<CDOID> getIDs()
+ {
+ return delegate.getIDs();
+ }
+
+ public CDORevision getRevision(CDOID id)
+ {
+ return delegate.getRevision(id);
+ }
+
+ public boolean isEmpty()
+ {
+ return getIDs().isEmpty();
+ }
+
+ public boolean containsID(CDOID id)
+ {
+ return getIDs().contains(id);
+ }
+
+ public boolean isAddedObject(CDOID id)
+ {
+ return containsID(id) && getRevision(id) == null;
+ }
+ }
+}
|