From 4624cfa326b8dfc70ab83e3aba7b53587ecdc64c Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Tue, 14 Oct 2008 20:39:37 +0000 Subject: [249847] Store resources in a hierarchical structure https://bugs.eclipse.org/bugs/show_bug.cgi?id=249847 --- .../org/eclipse/emf/cdo/common/id/CDOIDUtil.java | 5 +- .../org/eclipse/emf/cdo/common/model/CDOClass.java | 10 + .../common/model/resource/CDOContentsFeature.java | 2 +- .../common/model/resource/CDOFolderFeature.java | 25 ++ .../cdo/common/model/resource/CDONameFeature.java | 25 ++ .../cdo/common/model/resource/CDONodesFeature.java | 25 ++ .../cdo/common/model/resource/CDOPathFeature.java | 24 -- .../common/model/resource/CDOResourceClass.java | 4 +- .../model/resource/CDOResourceFolderClass.java | 27 ++ .../model/resource/CDOResourceNodeClass.java | 29 ++ .../common/model/resource/CDOResourcePackage.java | 11 +- .../emf/cdo/common/revision/CDORevision.java | 10 + .../cdo/common/revision/CDORevisionResolver.java | 2 +- .../common/revision/cache/CDORevisionCache.java | 8 +- .../cdo/internal/common/model/CDOClassImpl.java | 10 + .../model/resource/CDOContentsFeatureImpl.java | 7 +- .../model/resource/CDOFolderFeatureImpl.java | 32 ++ .../common/model/resource/CDONameFeatureImpl.java | 27 ++ .../common/model/resource/CDONodesFeatureImpl.java | 32 ++ .../common/model/resource/CDOPathFeatureImpl.java | 27 -- .../model/resource/CDOResourceClassImpl.java | 32 +- .../model/resource/CDOResourceFolderClassImpl.java | 57 ++++ .../model/resource/CDOResourceNodeClassImpl.java | 61 ++++ .../model/resource/CDOResourcePackageImpl.java | 16 + .../internal/common/revision/CDORevisionImpl.java | 10 + .../common/revision/CDORevisionResolverImpl.java | 11 +- .../revision/cache/lru/LRURevisionCache.java | 39 ++- .../revision/cache/mem/MEMRevisionCache.java | 41 ++- .../revision/cache/two/TwoLevelRevisionCache.java | 26 +- .../emf/cdo/spi/common/AbstractCDOIDLong.java | 9 +- .../.settings/.api_filters | 15 + ...reateCDOResourceFolder_contents_CDOResource.gif | Bin 0 -> 225 bytes ...DOResourceFolder_contents_CDOResourceFolder.gif | Bin 0 -> 225 bytes .../CreateCDOResourceFolder_nodes_CDOResource.gif | Bin 0 -> 225 bytes ...teCDOResourceFolder_nodes_CDOResourceFolder.gif | Bin 0 -> 225 bytes .../icons/full/obj16/CDOResourceFolder.gif | Bin 0 -> 131 bytes plugins/org.eclipse.emf.cdo.edit/plugin.properties | 7 + .../provider/CDOResourceFolderItemProvider.java | 158 ++++++++++ .../provider/CDOResourceItemProvider.java | 32 +- .../provider/CDOResourceNodeItemProvider.java | 153 +++++++++ .../EresourceItemProviderAdapterFactory.java | 29 ++ .../eclipse/emf/cdo/server/db/IClassMapping.java | 5 + .../emf/cdo/server/db/IMappingStrategy.java | 4 +- .../emf/cdo/server/internal/db/ClassMapping.java | 84 ++--- .../emf/cdo/server/internal/db/DBStore.java | 2 +- .../emf/cdo/server/internal/db/DBStoreReader.java | 4 +- .../cdo/server/internal/db/MappingStrategy.java | 113 ++++--- .../emf/cdo/server/internal/db/NoClassMapping.java | 6 + .../cdo/server/internal/db/ReferenceMapping.java | 1 + .../hibernate/tuplizer/CDORevisionProxy.java | 21 +- .../eclipse/emf/cdo/internal/server/MEMStore.java | 54 +++- .../emf/cdo/internal/server/MEMStoreAccessor.java | 6 +- .../cdo/internal/server/ResourcesQueryHandler.java | 2 +- .../emf/cdo/internal/server/RevisionManager.java | 5 +- .../org/eclipse/emf/cdo/internal/server/Store.java | 20 -- .../org/eclipse/emf/cdo/internal/server/View.java | 35 ++- .../org/eclipse/emf/cdo/server/IStoreReader.java | 8 +- .../org/eclipse/emf/cdo/tests/ResourceTest.java | 34 +- .../eclipse/emf/cdo/tests/RevisionHolderTest.java | 10 + plugins/org.eclipse.emf.cdo/model/eresource.ecore | 27 +- .../org.eclipse.emf.cdo/model/resource.genmodel | 9 +- .../src/org/eclipse/emf/cdo/CDOView.java | 16 +- .../org/eclipse/emf/cdo/eresource/CDOResource.java | 41 +-- .../emf/cdo/eresource/CDOResourceFolder.java | 46 +++ .../emf/cdo/eresource/CDOResourceInputStream.java | 58 ++++ .../eclipse/emf/cdo/eresource/CDOResourceNode.java | 99 ++++++ .../emf/cdo/eresource/EresourceFactory.java | 9 + .../eclipse/emf/cdo/eresource/EresourceObject.java | 26 -- .../emf/cdo/eresource/EresourcePackage.java | 309 ++++++++++++++++--- .../cdo/eresource/impl/CDOResourceFactoryImpl.java | 30 +- .../cdo/eresource/impl/CDOResourceFolderImpl.java | 62 ++++ .../emf/cdo/eresource/impl/CDOResourceImpl.java | 343 ++++++++++++++++----- .../cdo/eresource/impl/CDOResourceNodeImpl.java | 121 ++++++++ .../cdo/eresource/impl/EresourceFactoryImpl.java | 13 + .../cdo/eresource/impl/EresourcePackageImpl.java | 127 +++++++- .../eresource/util/EresourceAdapterFactory.java | 44 +++ .../emf/cdo/eresource/util/EresourceSwitch.java | 62 ++++ .../src/org/eclipse/emf/cdo/util/CDOURIUtil.java | 83 +++-- .../eclipse/emf/cdo/util/InvalidURIException.java | 42 +++ .../eclipse/emf/internal/cdo/CDOObjectImpl.java | 16 +- .../emf/internal/cdo/CDORevisionManagerImpl.java | 5 +- .../emf/internal/cdo/CDOTransactionImpl.java | 115 +++++-- .../eclipse/emf/internal/cdo/CDOURIHandler.java | 78 +++++ .../org/eclipse/emf/internal/cdo/CDOViewImpl.java | 249 +++++++++++++-- .../eclipse/emf/internal/cdo/CDOViewSetImpl.java | 24 +- .../eclipse/emf/internal/cdo/util/ModelUtil.java | 17 +- 86 files changed, 2902 insertions(+), 621 deletions(-) create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOFolderFeature.java create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDONameFeature.java create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDONodesFeature.java delete mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOPathFeature.java create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceFolderClass.java create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceNodeClass.java create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOFolderFeatureImpl.java create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDONameFeatureImpl.java create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDONodesFeatureImpl.java delete mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOPathFeatureImpl.java create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceFolderClassImpl.java create mode 100644 plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceNodeClassImpl.java create mode 100644 plugins/org.eclipse.emf.cdo.edit/.settings/.api_filters create mode 100644 plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResource.gif create mode 100644 plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResourceFolder.gif create mode 100644 plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResource.gif create mode 100644 plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceFolder.gif create mode 100644 plugins/org.eclipse.emf.cdo.edit/icons/full/obj16/CDOResourceFolder.gif create mode 100644 plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceFolderItemProvider.java create mode 100644 plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceNodeItemProvider.java create mode 100644 plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceFolder.java create mode 100644 plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceInputStream.java create mode 100644 plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceNode.java delete mode 100644 plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceObject.java create mode 100644 plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java create mode 100644 plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java create mode 100644 plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/InvalidURIException.java create mode 100644 plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java index 9f93adb10c..5e43875407 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java @@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.internal.common.id.CDOIDMetaRangeImpl; import org.eclipse.emf.cdo.internal.common.id.CDOIDTempMetaImpl; import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectImpl; import org.eclipse.emf.cdo.spi.common.AbstractCDOID; +import org.eclipse.emf.cdo.spi.common.AbstractCDOIDLong; import org.eclipse.emf.cdo.spi.common.CDOIDLibraryDescriptorImpl; import org.eclipse.emf.cdo.spi.common.CDOIDLongImpl; @@ -47,13 +48,13 @@ public final class CDOIDUtil { if (id == null) { - return 0L; + return AbstractCDOIDLong.NULL_VALUE; } switch (id.getType()) { case NULL: - return 0L; + return AbstractCDOIDLong.NULL_VALUE; case OBJECT: if (id instanceof CDOIDLongImpl) diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClass.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClass.java index 86a41ad434..32246265c6 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClass.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClass.java @@ -20,6 +20,16 @@ public interface CDOClass extends CDOModelElement, Comparable public boolean isAbstract(); + /** + * @since 2.0 + */ + public boolean isResourceNode(); + + /** + * @since 2.0 + */ + public boolean isResourceFolder(); + public boolean isResource(); public boolean isRoot(); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOContentsFeature.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOContentsFeature.java index f0658e1e70..40da1e730f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOContentsFeature.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOContentsFeature.java @@ -18,7 +18,7 @@ import org.eclipse.emf.cdo.common.model.CDOFeature; */ public interface CDOContentsFeature extends CDOFeature { - public static final int FEATURE_ID = 2; + public static final int FEATURE_ID = 6; public static final String NAME = "contents"; } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOFolderFeature.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOFolderFeature.java new file mode 100644 index 0000000000..f183ddd0d5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOFolderFeature.java @@ -0,0 +1,25 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOFeature; + +/** + * @author Eike Stepper + * @noimplement This interface is not intended to be implemented by clients. + * @since 2.0 + */ +public interface CDOFolderFeature extends CDOFeature +{ + public static final int FEATURE_ID = 0; + + public static final String NAME = "folder"; +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDONameFeature.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDONameFeature.java new file mode 100644 index 0000000000..ed43489563 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDONameFeature.java @@ -0,0 +1,25 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOFeature; + +/** + * @author Eike Stepper + * @noimplement This interface is not intended to be implemented by clients. + * @since 2.0 + */ +public interface CDONameFeature extends CDOFeature +{ + public static final int FEATURE_ID = 1; + + public static final String NAME = "name"; +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDONodesFeature.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDONodesFeature.java new file mode 100644 index 0000000000..b69d81bdb1 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDONodesFeature.java @@ -0,0 +1,25 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOFeature; + +/** + * @author Eike Stepper + * @noimplement This interface is not intended to be implemented by clients. + * @since 2.0 + */ +public interface CDONodesFeature extends CDOFeature +{ + public static final int FEATURE_ID = 3; + + public static final String NAME = "nodes"; +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOPathFeature.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOPathFeature.java deleted file mode 100644 index 7e43a15189..0000000000 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOPathFeature.java +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.common.model.resource; - -import org.eclipse.emf.cdo.common.model.CDOFeature; - -/** - * @author Eike Stepper - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOPathFeature extends CDOFeature -{ - public static final int FEATURE_ID = 9; - - public static final String NAME = "path"; -} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceClass.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceClass.java index 1a303164e9..38940008d1 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceClass.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceClass.java @@ -18,11 +18,9 @@ import org.eclipse.emf.cdo.common.model.CDOClass; */ public interface CDOResourceClass extends CDOClass { - public static final int CLASSIFIER_ID = 0; + public static final int CLASSIFIER_ID = 2; public static final String NAME = "CDOResource"; - public CDOPathFeature getCDOPathFeature(); - public CDOContentsFeature getCDOContentsFeature(); } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceFolderClass.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceFolderClass.java new file mode 100644 index 0000000000..3d305b9a2d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceFolderClass.java @@ -0,0 +1,27 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOClass; + +/** + * @author Eike Stepper + * @noimplement This interface is not intended to be implemented by clients. + * @since 2.0 + */ +public interface CDOResourceFolderClass extends CDOClass +{ + public static final int CLASSIFIER_ID = 1; + + public static final String NAME = "CDOResourceFolder"; + + public CDONodesFeature getCDONodesFeature(); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceNodeClass.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceNodeClass.java new file mode 100644 index 0000000000..6dad3016e6 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourceNodeClass.java @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOClass; + +/** + * @author Eike Stepper + * @noimplement This interface is not intended to be implemented by clients. + * @since 2.0 + */ +public interface CDOResourceNodeClass extends CDOClass +{ + public static final int CLASSIFIER_ID = 0; + + public static final String NAME = "CDOResourceNode"; + + public CDOFolderFeature getCDOFolderFeature(); + + public CDONameFeature getCDONameFeature(); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourcePackage.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourcePackage.java index baf5e54288..cd18184438 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourcePackage.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/resource/CDOResourcePackage.java @@ -22,6 +22,15 @@ public interface CDOResourcePackage extends CDOPackage public static final String NAME = "cdoresource"; - public CDOResourceClass getCDOResourceClass(); + /** + * @since 2.0 + */ + public CDOResourceNodeClass getCDOResourceNodeClass(); + + /** + * @since 2.0 + */ + public CDOResourceFolderClass getCDOResourceFolderClass(); + public CDOResourceClass getCDOResourceClass(); } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java index 247dc10b17..f7f7fe3e83 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java @@ -41,6 +41,16 @@ public interface CDORevision public boolean isTransactional(); + /** + * @since 2.0 + */ + public boolean isResourceNode(); + + /** + * @since 2.0 + */ + public boolean isResourceFolder(); + public boolean isResource(); public CDORevisionData getData(); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionResolver.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionResolver.java index b06487ad2a..a70a6cbd8a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionResolver.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionResolver.java @@ -59,7 +59,7 @@ public interface CDORevisionResolver /** * @since 2.0 */ - public CDOID getResourceID(String path, long timeStamp); + public CDOID getResourceID(CDOID folderID, String name, long timeStamp); /** * @since 2.0 diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/cache/CDORevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/cache/CDORevisionCache.java index 3db0bf307e..044568ec94 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/cache/CDORevisionCache.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/cache/CDORevisionCache.java @@ -12,7 +12,7 @@ package org.eclipse.emf.cdo.common.revision.cache; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOClass; -import org.eclipse.emf.cdo.common.model.CDOFeature; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.spi.common.InternalCDORevision; @@ -45,11 +45,11 @@ public interface CDORevisionCache extends INotifier.Introspection public boolean addRevision(InternalCDORevision revision); - public CDOID getResourceID(String path, long timeStamp); + public CDOID getResourceID(CDOID folderID, String name, long timeStamp); - public CDOFeature getResourcePathFeature(); + public CDOPackageManager getPackageManager(); - public void setResourcePathFeature(CDOFeature resourcePathFeature); + public void setPackageManager(CDOPackageManager packageManager); public void clear(); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassImpl.java index 7f84abb03b..1c4e871524 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassImpl.java @@ -169,6 +169,16 @@ public class CDOClassImpl extends CDOModelElementImpl implements InternalCDOClas this.isAbstract = isAbstract; } + public boolean isResourceNode() + { + return false; + } + + public boolean isResourceFolder() + { + return false; + } + public boolean isResource() { return false; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOContentsFeatureImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOContentsFeatureImpl.java index f8eed25188..6cb5ca1e53 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOContentsFeatureImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOContentsFeatureImpl.java @@ -12,7 +12,10 @@ package org.eclipse.emf.cdo.internal.common.model.resource; import org.eclipse.emf.cdo.common.model.CDOClass; import org.eclipse.emf.cdo.common.model.CDOClassProxy; +import org.eclipse.emf.cdo.common.model.CDOModelUtil; import org.eclipse.emf.cdo.common.model.CDOPackageManager; +import org.eclipse.emf.cdo.common.model.core.CDOCorePackage; +import org.eclipse.emf.cdo.common.model.core.CDOObjectClass; import org.eclipse.emf.cdo.common.model.resource.CDOContentsFeature; import org.eclipse.emf.cdo.internal.common.model.CDOFeatureImpl; @@ -23,7 +26,7 @@ public class CDOContentsFeatureImpl extends CDOFeatureImpl implements CDOContent { public CDOContentsFeatureImpl(CDOClass containingClass, CDOPackageManager packageManager) { - super(containingClass, FEATURE_ID, NAME, new CDOClassProxy(packageManager.getCDOCorePackage().getCDOObjectClass()), - true, true); + super(containingClass, FEATURE_ID, NAME, new CDOClassProxy(CDOModelUtil.createClassRef(CDOCorePackage.PACKAGE_URI, + CDOObjectClass.CLASSIFIER_ID), packageManager), true, true); } } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOFolderFeatureImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOFolderFeatureImpl.java new file mode 100644 index 0000000000..094106ccd5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOFolderFeatureImpl.java @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOClass; +import org.eclipse.emf.cdo.common.model.CDOClassProxy; +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; +import org.eclipse.emf.cdo.common.model.resource.CDOFolderFeature; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceFolderClass; +import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage; +import org.eclipse.emf.cdo.internal.common.model.CDOFeatureImpl; + +/** + * @author Eike Stepper + */ +public class CDOFolderFeatureImpl extends CDOFeatureImpl implements CDOFolderFeature +{ + public CDOFolderFeatureImpl(CDOClass containingClass, CDOPackageManager packageManager) + { + super(containingClass, FEATURE_ID, NAME, new CDOClassProxy(CDOModelUtil.createClassRef( + CDOResourcePackage.PACKAGE_URI, CDOResourceFolderClass.CLASSIFIER_ID), packageManager), false, false); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDONameFeatureImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDONameFeatureImpl.java new file mode 100644 index 0000000000..e4fbc9be58 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDONameFeatureImpl.java @@ -0,0 +1,27 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOClass; +import org.eclipse.emf.cdo.common.model.resource.CDONameFeature; +import org.eclipse.emf.cdo.internal.common.model.CDOFeatureImpl; +import org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl; + +/** + * @author Eike Stepper + */ +public class CDONameFeatureImpl extends CDOFeatureImpl implements CDONameFeature +{ + public CDONameFeatureImpl(CDOClass containingClass) + { + super(containingClass, FEATURE_ID, NAME, CDOTypeImpl.STRING, false); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDONodesFeatureImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDONodesFeatureImpl.java new file mode 100644 index 0000000000..6d5e437a81 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDONodesFeatureImpl.java @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOClass; +import org.eclipse.emf.cdo.common.model.CDOClassProxy; +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; +import org.eclipse.emf.cdo.common.model.resource.CDONodesFeature; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; +import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage; +import org.eclipse.emf.cdo.internal.common.model.CDOFeatureImpl; + +/** + * @author Eike Stepper + */ +public class CDONodesFeatureImpl extends CDOFeatureImpl implements CDONodesFeature +{ + public CDONodesFeatureImpl(CDOClass containingClass, CDOPackageManager packageManager) + { + super(containingClass, FEATURE_ID, NAME, new CDOClassProxy(CDOModelUtil.createClassRef( + CDOResourcePackage.PACKAGE_URI, CDOResourceNodeClass.CLASSIFIER_ID), packageManager), true, true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOPathFeatureImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOPathFeatureImpl.java deleted file mode 100644 index f42709edb5..0000000000 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOPathFeatureImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.common.model.resource; - -import org.eclipse.emf.cdo.common.model.CDOClass; -import org.eclipse.emf.cdo.common.model.resource.CDOPathFeature; -import org.eclipse.emf.cdo.internal.common.model.CDOFeatureImpl; -import org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl; - -/** - * @author Eike Stepper - */ -public class CDOPathFeatureImpl extends CDOFeatureImpl implements CDOPathFeature -{ - public CDOPathFeatureImpl(CDOClass containingClass) - { - super(containingClass, FEATURE_ID, NAME, CDOTypeImpl.STRING, false); - } -} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceClassImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceClassImpl.java index ec747c5195..9127c66168 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceClassImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceClassImpl.java @@ -10,9 +10,13 @@ **************************************************************************/ package org.eclipse.emf.cdo.internal.common.model.resource; +import org.eclipse.emf.cdo.common.model.CDOFeature; +import org.eclipse.emf.cdo.common.model.CDOModelUtil; import org.eclipse.emf.cdo.common.model.CDOPackage; import org.eclipse.emf.cdo.common.model.CDOPackageManager; import org.eclipse.emf.cdo.common.model.resource.CDOResourceClass; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; +import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage; import org.eclipse.emf.cdo.internal.common.model.CDOClassImpl; /** @@ -20,30 +24,46 @@ import org.eclipse.emf.cdo.internal.common.model.CDOClassImpl; */ public class CDOResourceClassImpl extends CDOClassImpl implements CDOResourceClass { - private CDOPathFeatureImpl cdoPathFeature; - private CDOContentsFeatureImpl cdoContentsFeature; public CDOResourceClassImpl(CDOPackage containingPackage, CDOPackageManager packageManager) { super(containingPackage, CLASSIFIER_ID, NAME, false); - addFeature(cdoPathFeature = new CDOPathFeatureImpl(this)); + addSuperType(CDOModelUtil.createClassRef(CDOResourcePackage.PACKAGE_URI, CDOResourceNodeClass.CLASSIFIER_ID)); addFeature(cdoContentsFeature = new CDOContentsFeatureImpl(this, packageManager)); } @Override - public boolean isResource() + public boolean isResourceNode() { return true; } - public CDOPathFeatureImpl getCDOPathFeature() + @Override + public boolean isResourceFolder() + { + return false; + } + + @Override + public boolean isResource() { - return cdoPathFeature; + return true; } public CDOContentsFeatureImpl getCDOContentsFeature() { return cdoContentsFeature; } + + @Override + public CDOFeature lookupFeature(int featureID) + { + if (featureID == 5) + { + return cdoContentsFeature; + } + + return super.lookupFeature(featureID); + } } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceFolderClassImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceFolderClassImpl.java new file mode 100644 index 0000000000..890756457a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceFolderClassImpl.java @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOPackage; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceFolderClass; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; +import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage; +import org.eclipse.emf.cdo.internal.common.model.CDOClassImpl; + +/** + * @author Eike Stepper + */ +public class CDOResourceFolderClassImpl extends CDOClassImpl implements CDOResourceFolderClass +{ + private CDONodesFeatureImpl cdoNodesFeature; + + public CDOResourceFolderClassImpl(CDOPackage containingPackage, CDOPackageManager packageManager) + { + super(containingPackage, CLASSIFIER_ID, NAME, false); + addSuperType(CDOModelUtil.createClassRef(CDOResourcePackage.PACKAGE_URI, CDOResourceNodeClass.CLASSIFIER_ID)); + addFeature(cdoNodesFeature = new CDONodesFeatureImpl(this, packageManager)); + } + + @Override + public boolean isResourceNode() + { + return true; + } + + @Override + public boolean isResourceFolder() + { + return true; + } + + @Override + public boolean isResource() + { + return false; + } + + public CDONodesFeatureImpl getCDONodesFeature() + { + return cdoNodesFeature; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceNodeClassImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceNodeClassImpl.java new file mode 100644 index 0000000000..b3cc654280 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourceNodeClassImpl.java @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.common.model.resource; + +import org.eclipse.emf.cdo.common.model.CDOPackage; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; +import org.eclipse.emf.cdo.internal.common.model.CDOClassImpl; + +/** + * @author Eike Stepper + */ +public class CDOResourceNodeClassImpl extends CDOClassImpl implements CDOResourceNodeClass +{ + private CDOFolderFeatureImpl cdoFolderFeature; + + private CDONameFeatureImpl cdoNameFeature; + + public CDOResourceNodeClassImpl(CDOPackage containingPackage, CDOPackageManager packageManager) + { + super(containingPackage, CLASSIFIER_ID, NAME, false); + addFeature(cdoFolderFeature = new CDOFolderFeatureImpl(this, packageManager)); + addFeature(cdoNameFeature = new CDONameFeatureImpl(this)); + } + + @Override + public boolean isResourceNode() + { + return true; + } + + @Override + public boolean isResourceFolder() + { + return false; + } + + @Override + public boolean isResource() + { + return false; + } + + public CDOFolderFeatureImpl getCDOFolderFeature() + { + return cdoFolderFeature; + } + + public CDONameFeatureImpl getCDONameFeature() + { + return cdoNameFeature; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourcePackageImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourcePackageImpl.java index f1ac7bf14c..4998ca4f08 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourcePackageImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/resource/CDOResourcePackageImpl.java @@ -19,14 +19,30 @@ import org.eclipse.emf.cdo.internal.common.model.CDOPackageManagerImpl; */ public final class CDOResourcePackageImpl extends CDOPackageImpl implements CDOResourcePackage { + private CDOResourceNodeClassImpl cdoResourceNodeClass; + + private CDOResourceFolderClassImpl cdoResourceFolderClass; + private CDOResourceClassImpl cdoResourceClass; public CDOResourcePackageImpl(CDOPackageManagerImpl packageManager) { super(packageManager, PACKAGE_URI, NAME, null, false, null, null); + addClass(cdoResourceNodeClass = new CDOResourceNodeClassImpl(this, packageManager)); + addClass(cdoResourceFolderClass = new CDOResourceFolderClassImpl(this, packageManager)); addClass(cdoResourceClass = new CDOResourceClassImpl(this, packageManager)); } + public CDOResourceFolderClassImpl getCDOResourceFolderClass() + { + return cdoResourceFolderClass; + } + + public CDOResourceNodeClassImpl getCDOResourceNodeClass() + { + return cdoResourceNodeClass; + } + public CDOResourceClassImpl getCDOResourceClass() { return cdoResourceClass; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java index b83043af65..a32269ffac 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java @@ -253,6 +253,16 @@ public class CDORevisionImpl implements InternalCDORevision return (revised == UNSPECIFIED_DATE || revised >= timeStamp) && timeStamp >= created; } + public boolean isResourceNode() + { + return cdoClass.isResourceNode(); + } + + public boolean isResourceFolder() + { + return cdoClass.isResourceFolder(); + } + public boolean isResource() { return cdoClass.isResource(); diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionResolverImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionResolverImpl.java index d08b908d24..c4fd19f89b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionResolverImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionResolverImpl.java @@ -15,6 +15,7 @@ package org.eclipse.emf.cdo.internal.common.revision; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOClass; import org.eclipse.emf.cdo.common.model.CDOFeature; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionResolver; import org.eclipse.emf.cdo.common.revision.cache.CDORevisionCache; @@ -214,9 +215,9 @@ public abstract class CDORevisionResolverImpl extends Lifecycle implements CDORe return revisions; } - public CDOID getResourceID(String path, long timeStamp) + public CDOID getResourceID(CDOID folderID, String name, long timeStamp) { - return cache.getResourceID(path, timeStamp); + return cache.getResourceID(folderID, name, timeStamp); } public String getResourcePath(CDOID id, long timeStamp) @@ -232,7 +233,7 @@ public abstract class CDORevisionResolverImpl extends Lifecycle implements CDORe throw new IllegalStateException("Revision is not a resource: " + revision); } - CDOFeature pathFeature = getResourcePathFeature(); + CDOFeature pathFeature = getResourceFolderFeature(); return (String)revision.getValue(pathFeature); } @@ -285,7 +286,7 @@ public abstract class CDORevisionResolverImpl extends Lifecycle implements CDORe protected abstract List loadRevisionsByTime(Collection ids, int referenceChunk, long timeStamp); - protected abstract CDOFeature getResourcePathFeature(); + protected abstract CDOPackageManager getPackageManager(); @Override protected void doBeforeActivate() throws Exception @@ -301,7 +302,7 @@ public abstract class CDORevisionResolverImpl extends Lifecycle implements CDORe protected void doActivate() throws Exception { super.doActivate(); - cache.setResourcePathFeature(getResourcePathFeature()); + cache.setPackageManager(getPackageManager()); LifecycleUtil.activate(cache); } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/lru/LRURevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/lru/LRURevisionCache.java index d4f7708b81..0a602a66fb 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/lru/LRURevisionCache.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/lru/LRURevisionCache.java @@ -14,7 +14,10 @@ package org.eclipse.emf.cdo.internal.common.revision.cache.lru; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOClass; -import org.eclipse.emf.cdo.common.model.CDOFeature; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; +import org.eclipse.emf.cdo.common.model.resource.CDOFolderFeature; +import org.eclipse.emf.cdo.common.model.resource.CDONameFeature; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.cache.CDORevisionCache; import org.eclipse.emf.cdo.internal.common.bundle.OM; @@ -40,7 +43,7 @@ public class LRURevisionCache extends Lifecycle implements CDORevisionCache private Map revisions = new HashMap(); - private CDOFeature resourcePathFeature; + private CDOPackageManager packageManager; private int capacityCurrent; @@ -50,18 +53,28 @@ public class LRURevisionCache extends Lifecycle implements CDORevisionCache private LRU revisedLRU; + private transient CDOFolderFeature cdoFolderFeature; + + private transient CDONameFeature cdoNameFeature; + public LRURevisionCache() { } - public CDOFeature getResourcePathFeature() + public CDOPackageManager getPackageManager() { - return resourcePathFeature; + return packageManager; } - public void setResourcePathFeature(CDOFeature resourcePathFeature) + public void setPackageManager(CDOPackageManager packageManager) { - this.resourcePathFeature = resourcePathFeature; + this.packageManager = packageManager; + if (packageManager != null) + { + CDOResourceNodeClass resourceNodeClass = packageManager.getCDOResourcePackage().getCDOResourceNodeClass(); + cdoFolderFeature = resourceNodeClass.getCDOFolderFeature(); + cdoNameFeature = resourceNodeClass.getCDONameFeature(); + } } public int getCapacityCurrent() @@ -245,7 +258,7 @@ public class LRURevisionCache extends Lifecycle implements CDORevisionCache return lookupHolder != null; } - public synchronized CDOID getResourceID(String path, long timeStamp) + public synchronized CDOID getResourceID(CDOID folderID, String name, long timeStamp) { CDOID[] ids = getRevisionIDs(); for (CDOID id : ids) @@ -254,15 +267,19 @@ public class LRURevisionCache extends Lifecycle implements CDORevisionCache if (holder != null) { InternalCDORevision revision = holder.getRevision(); - if (revision.isResource()) + if (revision.isResourceNode()) { revision = getRevisionByTime(holder, timeStamp); if (revision != null) { - String revisionPath = (String)revision.getValue(resourcePathFeature); - if (ObjectUtil.equals(revisionPath, path)) + CDOID revisionFolderID = (CDOID)revision.getValue(cdoFolderFeature); + if (ObjectUtil.equals(revisionFolderID, folderID)) { - return revision.getID(); + String revisionName = (String)revision.getValue(cdoNameFeature); + if (ObjectUtil.equals(revisionName, name)) + { + return revision.getID(); + } } } } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/mem/MEMRevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/mem/MEMRevisionCache.java index 3610d9e068..dbe32a18e3 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/mem/MEMRevisionCache.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/mem/MEMRevisionCache.java @@ -16,7 +16,10 @@ import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; import org.eclipse.emf.cdo.common.id.CDOIDUtil; import org.eclipse.emf.cdo.common.model.CDOClass; -import org.eclipse.emf.cdo.common.model.CDOFeature; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; +import org.eclipse.emf.cdo.common.model.resource.CDOFolderFeature; +import org.eclipse.emf.cdo.common.model.resource.CDONameFeature; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.cache.CDORevisionCache; import org.eclipse.emf.cdo.internal.common.bundle.OM; @@ -50,12 +53,16 @@ public class MEMRevisionCache extends ReferenceQueueWorker { private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, MEMRevisionCache.class); - private CDOFeature resourcePathFeature; + private CDOPackageManager packageManager; private Map cacheLists = new HashMap(); private ReferenceType referenceType; + private transient CDOFolderFeature cdoFolderFeature; + + private transient CDONameFeature cdoNameFeature; + public MEMRevisionCache(ReferenceType referenceType) { this.referenceType = referenceType; @@ -66,14 +73,20 @@ public class MEMRevisionCache extends ReferenceQueueWorker this(ReferenceType.SOFT); } - public CDOFeature getResourcePathFeature() + public CDOPackageManager getPackageManager() { - return resourcePathFeature; + return packageManager; } - public void setResourcePathFeature(CDOFeature resourcePathFeature) + public void setPackageManager(CDOPackageManager packageManager) { - this.resourcePathFeature = resourcePathFeature; + this.packageManager = packageManager; + if (packageManager != null) + { + CDOResourceNodeClass resourceNodeClass = packageManager.getCDOResourcePackage().getCDOResourceNodeClass(); + cdoFolderFeature = resourceNodeClass.getCDOFolderFeature(); + cdoNameFeature = resourceNodeClass.getCDONameFeature(); + } } public ReferenceType getReferenceType() @@ -190,7 +203,7 @@ public class MEMRevisionCache extends ReferenceQueueWorker return null; } - public CDOID getResourceID(String path, long timeStamp) + public CDOID getResourceID(CDOID folderID, String name, long timeStamp) { CDOID[] ids = getRevisionIDs(); for (CDOID id : ids) @@ -200,7 +213,7 @@ public class MEMRevisionCache extends ReferenceQueueWorker CacheList list = cacheLists.get(id); if (list != null) { - return list.getResourceID(path, timeStamp); + return list.getResourceID(folderID, name, timeStamp); } } } @@ -331,15 +344,19 @@ public class MEMRevisionCache extends ReferenceQueueWorker return getRevisionByTime(timeStamp, false); } - public CDOID getResourceID(String path, long timeStamp) + public CDOID getResourceID(CDOID folderID, String name, long timeStamp) { InternalCDORevision revision = getRevisionByTime(timeStamp, true); if (revision != null) { - String revisionPath = (String)revision.getValue(resourcePathFeature); - if (ObjectUtil.equals(revisionPath, path)) + CDOID revisionFolderID = (CDOID)revision.getValue(cdoFolderFeature); + if (ObjectUtil.equals(revisionFolderID, folderID)) { - return revision.getID(); + String revisionName = (String)revision.getValue(cdoNameFeature); + if (ObjectUtil.equals(revisionName, name)) + { + return revision.getID(); + } } } diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/two/TwoLevelRevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/two/TwoLevelRevisionCache.java index 796f3d8d05..ad50da602b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/two/TwoLevelRevisionCache.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/cache/two/TwoLevelRevisionCache.java @@ -14,7 +14,7 @@ package org.eclipse.emf.cdo.internal.common.revision.cache.two; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOClass; -import org.eclipse.emf.cdo.common.model.CDOFeature; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.cache.CDORevisionCache; import org.eclipse.emf.cdo.internal.common.bundle.OM; @@ -36,7 +36,7 @@ public class TwoLevelRevisionCache extends Lifecycle implements CDORevisionCache { private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, TwoLevelRevisionCache.class); - private CDOFeature resourcePathFeature; + private CDOPackageManager packageManager; private CDORevisionCache level1; @@ -46,22 +46,22 @@ public class TwoLevelRevisionCache extends Lifecycle implements CDORevisionCache { } - public CDOFeature getResourcePathFeature() + public CDOPackageManager getPackageManager() { - return resourcePathFeature; + return packageManager; } - public void setResourcePathFeature(CDOFeature resourcePathFeature) + public void setPackageManager(CDOPackageManager packageManager) { - this.resourcePathFeature = resourcePathFeature; + this.packageManager = packageManager; if (level1 != null) { - level1.setResourcePathFeature(resourcePathFeature); + level1.setPackageManager(packageManager); } if (level2 != null) { - level2.setResourcePathFeature(resourcePathFeature); + level2.setPackageManager(packageManager); } } @@ -73,7 +73,7 @@ public class TwoLevelRevisionCache extends Lifecycle implements CDORevisionCache public void setLevel1(CDORevisionCache level1) { this.level1 = level1; - setResourcePathFeature(resourcePathFeature); + setPackageManager(packageManager); } public CDORevisionCache getLevel2() @@ -84,7 +84,7 @@ public class TwoLevelRevisionCache extends Lifecycle implements CDORevisionCache public void setLevel2(CDORevisionCache level2) { this.level2 = level2; - setResourcePathFeature(resourcePathFeature); + setPackageManager(packageManager); } public CDOClass getObjectType(CDOID id) @@ -149,12 +149,12 @@ public class TwoLevelRevisionCache extends Lifecycle implements CDORevisionCache return revision; } - public CDOID getResourceID(String path, long timeStamp) + public CDOID getResourceID(CDOID folderID, String name, long timeStamp) { - CDOID id = level1.getResourceID(path, timeStamp); + CDOID id = level1.getResourceID(folderID, name, timeStamp); if (id == null) { - id = level2.getResourceID(path, timeStamp); + id = level2.getResourceID(folderID, name, timeStamp); } return id; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDLong.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDLong.java index 5b21e48ba4..85bb390b73 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDLong.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDLong.java @@ -22,6 +22,11 @@ import java.io.IOException; */ public abstract class AbstractCDOIDLong extends AbstractCDOID implements Comparable { + /** + * @since 2.0 + */ + public static final long NULL_VALUE = 0L; + private static final long serialVersionUID = 1L; private long value; @@ -32,9 +37,9 @@ public abstract class AbstractCDOIDLong extends AbstractCDOID implements Compara public AbstractCDOIDLong(long value) { - if (value == 0L) + if (value == NULL_VALUE) { - throw new IllegalArgumentException("value == 0L"); + throw new IllegalArgumentException("value == NULL_VALUE"); } this.value = value; diff --git a/plugins/org.eclipse.emf.cdo.edit/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.edit/.settings/.api_filters new file mode 100644 index 0000000000..26b699b4d0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.edit/.settings/.api_filters @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResource.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResource.gif new file mode 100644 index 0000000000..9d64092d8d Binary files /dev/null and b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResource.gif differ diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResourceFolder.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResourceFolder.gif new file mode 100644 index 0000000000..2c76ed1e2d Binary files /dev/null and b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_contents_CDOResourceFolder.gif differ diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResource.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResource.gif new file mode 100644 index 0000000000..9d64092d8d Binary files /dev/null and b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResource.gif differ diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceFolder.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceFolder.gif new file mode 100644 index 0000000000..2c76ed1e2d Binary files /dev/null and b/plugins/org.eclipse.emf.cdo.edit/icons/full/ctool16/CreateCDOResourceFolder_nodes_CDOResourceFolder.gif differ diff --git a/plugins/org.eclipse.emf.cdo.edit/icons/full/obj16/CDOResourceFolder.gif b/plugins/org.eclipse.emf.cdo.edit/icons/full/obj16/CDOResourceFolder.gif new file mode 100644 index 0000000000..480c478072 Binary files /dev/null and b/plugins/org.eclipse.emf.cdo.edit/icons/full/obj16/CDOResourceFolder.gif differ diff --git a/plugins/org.eclipse.emf.cdo.edit/plugin.properties b/plugins/org.eclipse.emf.cdo.edit/plugin.properties index a65712bce7..f4e7c4ae7b 100644 --- a/plugins/org.eclipse.emf.cdo.edit/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.edit/plugin.properties @@ -49,3 +49,10 @@ _UI_Unknown_feature = Unspecified # The above properties have been shipped for translation. # ============================================================================== _UI_CDOResource_timeStamp_feature = Time Stamp +_UI_CDOResourceNode_type = CDO Resource Node +_UI_CDOResourceFolder_type = CDO Resource Folder +_UI_CDOResourceNode_folder_feature = Folder +_UI_CDOResourceNode_name_feature = Name +_UI_CDOResourceNode_path_feature = Path +_UI_CDOResourceFolder_contents_feature = Contents +_UI_CDOResourceFolder_nodes_feature = Nodes diff --git a/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceFolderItemProvider.java b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceFolderItemProvider.java new file mode 100644 index 0000000000..e9114d34bc --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceFolderItemProvider.java @@ -0,0 +1,158 @@ +/** + * + * + * + * $Id: CDOResourceFolderItemProvider.java,v 1.1.2.1 2008-10-14 20:39:36 estepper Exp $ + */ +package org.eclipse.emf.cdo.eresource.provider; + +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.EresourceFactory; +import org.eclipse.emf.cdo.eresource.EresourcePackage; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ViewerNotification; + +import java.util.Collection; +import java.util.List; + +/** + * This is the item provider adapter for a {@link org.eclipse.emf.cdo.eresource.CDOResourceFolder} object. + * + * @generated + * @since 2.0 + */ +public class CDOResourceFolderItemProvider extends CDOResourceNodeItemProvider implements IEditingDomainItemProvider, + IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource +{ + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public CDOResourceFolderItemProvider(AdapterFactory adapterFactory) + { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) + { + if (itemPropertyDescriptors == null) + { + super.getPropertyDescriptors(object); + + } + return itemPropertyDescriptors; + } + + /** + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an + * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. + * + * @generated + */ + @Override + public Collection getChildrenFeatures(Object object) + { + if (childrenFeatures == null) + { + super.getChildrenFeatures(object); + childrenFeatures.add(EresourcePackage.Literals.CDO_RESOURCE_FOLDER__NODES); + } + return childrenFeatures; + } + + /** + * + * + * @generated + */ + @Override + protected EStructuralFeature getChildFeature(Object object, Object child) + { + // Check the type of the specified child object and return the proper feature to use for + // adding (see {@link AddCommand}) it as a child. + + return super.getChildFeature(object, child); + } + + /** + * This returns CDOResourceFolder.gif. + * + * @generated + */ + @Override + public Object getImage(Object object) + { + return overlayImage(object, getResourceLocator().getImage("full/obj16/CDOResourceFolder")); + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) + { + String label = ((CDOResourceFolder)object).getName(); + return label == null || label.length() == 0 ? getString("_UI_CDOResourceFolder_type") + : getString("_UI_CDOResourceFolder_type") + " " + label; + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating a + * viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) + { + updateChildren(notification); + + switch (notification.getFeatureID(CDOResourceFolder.class)) + { + case EresourcePackage.CDO_RESOURCE_FOLDER__NODES: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created under + * this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) + { + super.collectNewChildDescriptors(newChildDescriptors, object); + + newChildDescriptors.add(createChildParameter(EresourcePackage.Literals.CDO_RESOURCE_FOLDER__NODES, + EresourceFactory.eINSTANCE.createCDOResourceFolder())); + + newChildDescriptors.add(createChildParameter(EresourcePackage.Literals.CDO_RESOURCE_FOLDER__NODES, + EresourceFactory.eINSTANCE.createCDOResource())); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceItemProvider.java b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceItemProvider.java index c191c8080e..1ff7b4dc5a 100644 --- a/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceItemProvider.java +++ b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceItemProvider.java @@ -16,10 +16,8 @@ import org.eclipse.emf.cdo.eresource.EresourcePackage; import org.eclipse.emf.common.notify.AdapterFactory; import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.ResourceLocator; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; -import org.eclipse.emf.edit.provider.IChildCreationExtender; import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; import org.eclipse.emf.edit.provider.IItemLabelProvider; import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; @@ -27,7 +25,6 @@ import org.eclipse.emf.edit.provider.IItemPropertySource; import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; import org.eclipse.emf.edit.provider.ITreeItemContentProvider; import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; -import org.eclipse.emf.edit.provider.ItemProviderAdapter; import org.eclipse.emf.edit.provider.ViewerNotification; import java.util.Collection; @@ -39,7 +36,7 @@ import java.util.List; * * @generated */ -public class CDOResourceItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, +public class CDOResourceItemProvider extends CDOResourceNodeItemProvider implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { /** @@ -69,7 +66,6 @@ public class CDOResourceItemProvider extends ItemProviderAdapter implements IEdi addLoadedPropertyDescriptor(object); addTrackingModificationPropertyDescriptor(object); addTimeStampPropertyDescriptor(object); - addPathPropertyDescriptor(object); } return itemPropertyDescriptors; } @@ -145,20 +141,6 @@ public class CDOResourceItemProvider extends ItemProviderAdapter implements IEdi ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); } - /** - * This adds a property descriptor for the Path feature. - * - * @generated - */ - protected void addPathPropertyDescriptor(Object object) - { - itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory) - .getRootAdapterFactory(), getResourceLocator(), getString("_UI_CDOResource_path_feature"), getString( - "_UI_PropertyDescriptor_description", "_UI_CDOResource_path_feature", "_UI_CDOResource_type"), - EresourcePackage.Literals.CDO_RESOURCE__PATH, false, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, - null, null)); - } - /** * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or @@ -236,7 +218,6 @@ public class CDOResourceItemProvider extends ItemProviderAdapter implements IEdi case EresourcePackage.CDO_RESOURCE__ERRORS: case EresourcePackage.CDO_RESOURCE__WARNINGS: case EresourcePackage.CDO_RESOURCE__TIME_STAMP: - case EresourcePackage.CDO_RESOURCE__PATH: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; case EresourcePackage.CDO_RESOURCE__CONTENTS: @@ -257,15 +238,4 @@ public class CDOResourceItemProvider extends ItemProviderAdapter implements IEdi { } - /** - * Return the resource locator for this item provider's resources. - * - * @generated - */ - @Override - public ResourceLocator getResourceLocator() - { - return ((IChildCreationExtender)adapterFactory).getResourceLocator(); - } - } diff --git a/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceNodeItemProvider.java b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceNodeItemProvider.java new file mode 100644 index 0000000000..7be54dc222 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/CDOResourceNodeItemProvider.java @@ -0,0 +1,153 @@ +/** + * + * + * + * $Id: CDOResourceNodeItemProvider.java,v 1.1.2.1 2008-10-14 20:39:36 estepper Exp $ + */ +package org.eclipse.emf.cdo.eresource.provider; + +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.eresource.EresourcePackage; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.ResourceLocator; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IChildCreationExtender; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +import java.util.Collection; +import java.util.List; + +/** + * This is the item provider adapter for a {@link org.eclipse.emf.cdo.eresource.CDOResourceNode} object. + * + * @generated + * @since 2.0 + */ +public class CDOResourceNodeItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, + IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource +{ + /** + * This constructs an instance from a factory and a notifier. + * + * @generated + */ + public CDOResourceNodeItemProvider(AdapterFactory adapterFactory) + { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) + { + if (itemPropertyDescriptors == null) + { + super.getPropertyDescriptors(object); + + addNamePropertyDescriptor(object); + addPathPropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Name feature. + * + * @generated + */ + protected void addNamePropertyDescriptor(Object object) + { + itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory) + .getRootAdapterFactory(), getResourceLocator(), getString("_UI_CDOResourceNode_name_feature"), getString( + "_UI_PropertyDescriptor_description", "_UI_CDOResourceNode_name_feature", "_UI_CDOResourceNode_type"), + EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME, true, false, false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Path feature. + * + * @generated + */ + protected void addPathPropertyDescriptor(Object object) + { + itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory) + .getRootAdapterFactory(), getResourceLocator(), getString("_UI_CDOResourceNode_path_feature"), getString( + "_UI_PropertyDescriptor_description", "_UI_CDOResourceNode_path_feature", "_UI_CDOResourceNode_type"), + EresourcePackage.Literals.CDO_RESOURCE_NODE__PATH, false, false, false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This returns the label text for the adapted class. + * + * @generated + */ + @Override + public String getText(Object object) + { + String label = ((CDOResourceNode)object).getName(); + return label == null || label.length() == 0 ? getString("_UI_CDOResourceNode_type") + : getString("_UI_CDOResourceNode_type") + " " + label; + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached children and by creating a + * viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) + { + updateChildren(notification); + + switch (notification.getFeatureID(CDOResourceNode.class)) + { + case EresourcePackage.CDO_RESOURCE_NODE__NAME: + case EresourcePackage.CDO_RESOURCE_NODE__PATH: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that can be created under + * this object. + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) + { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + + /** + * Return the resource locator for this item provider's resources. + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() + { + return ((IChildCreationExtender)adapterFactory).getResourceLocator(); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/EresourceItemProviderAdapterFactory.java b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/EresourceItemProviderAdapterFactory.java index 7c2ca9f185..60396a1a28 100644 --- a/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/EresourceItemProviderAdapterFactory.java +++ b/plugins/org.eclipse.emf.cdo.edit/src/org/eclipse/emf/cdo/eresource/provider/EresourceItemProviderAdapterFactory.java @@ -93,6 +93,31 @@ public class EresourceItemProviderAdapterFactory extends EresourceAdapterFactory supportedTypes.add(IItemPropertySource.class); } + /** + * This keeps track of the one adapter used for all {@link org.eclipse.emf.cdo.eresource.CDOResourceFolder} instances. + * + * + * @generated + */ + protected CDOResourceFolderItemProvider cdoResourceFolderItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.emf.cdo.eresource.CDOResourceFolder}. + * + * @generated + */ + @Override + public Adapter createCDOResourceFolderAdapter() + { + if (cdoResourceFolderItemProvider == null) + { + cdoResourceFolderItemProvider = new CDOResourceFolderItemProvider(this); + } + + return cdoResourceFolderItemProvider; + } + /** * This keeps track of the one adapter used for all {@link org.eclipse.emf.cdo.eresource.CDOResource} instances. @@ -254,6 +279,10 @@ public class EresourceItemProviderAdapterFactory extends EresourceAdapterFactory */ public void dispose() { + if (cdoResourceFolderItemProvider != null) + { + cdoResourceFolderItemProvider.dispose(); + } if (cdoResourceItemProvider != null) { cdoResourceItemProvider.dispose(); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java index cebe25994b..9265682fcf 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IClassMapping.java @@ -33,6 +33,11 @@ public interface IClassMapping public Set getAffectedTables(); + /** + * @since 2.0 + */ + public IFeatureMapping getFeatureMapping(CDOFeature feature); + public List getAttributeMappings(); public List getReferenceMappings(); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java index 130f6a53a0..2a5419c51c 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java @@ -62,7 +62,7 @@ public interface IMappingStrategy /** * @since 2.0 */ - public CDOID readResourceID(IDBStoreReader storeReader, String path, long timeStamp); + public CDOID readResourceID(IDBStoreReader storeReader, CDOID folderID, String name, long timeStamp); /** * @since 2.0 @@ -70,7 +70,7 @@ public interface IMappingStrategy public void queryResources(IDBStoreReader storeReader, QueryResourcesContext context); /** - * Must return the maximum CDOID value . + * Returns the maximum CDOID value. */ public long repairAfterCrash(Connection connection); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java index 1f3c084b28..72118e2e4f 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java @@ -15,13 +15,13 @@ import org.eclipse.emf.cdo.common.id.CDOIDUtil; import org.eclipse.emf.cdo.common.model.CDOClass; import org.eclipse.emf.cdo.common.model.CDOFeature; import org.eclipse.emf.cdo.common.model.CDOType; -import org.eclipse.emf.cdo.common.model.resource.CDOResourceClass; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.server.db.IAttributeMapping; import org.eclipse.emf.cdo.server.db.IClassMapping; import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreReader; import org.eclipse.emf.cdo.server.db.IDBStoreWriter; +import org.eclipse.emf.cdo.server.db.IFeatureMapping; import org.eclipse.emf.cdo.server.db.IReferenceMapping; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; import org.eclipse.emf.cdo.spi.common.InternalCDORevision; @@ -31,7 +31,6 @@ import org.eclipse.net4j.db.DBType; import org.eclipse.net4j.db.DBUtil; import org.eclipse.net4j.db.IDBAdapter; import org.eclipse.net4j.db.ddl.IDBField; -import org.eclipse.net4j.db.ddl.IDBIndex; import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.util.ImplementationError; import org.eclipse.net4j.util.ObjectUtil; @@ -81,43 +80,38 @@ public abstract class ClassMapping implements IClassMapping attributeMappings = createAttributeMappings(features); referenceMappings = createReferenceMappings(features); - // Special handling of CDOResource table - CDOResourceClass resourceClass = getResourceClass(); - if (cdoClass == resourceClass) - { - // Create a unique ids to prevent duplicate resource paths - for (IAttributeMapping attributeMapping : attributeMappings) - { - if (attributeMapping.getFeature() == resourceClass.getCDOPathFeature()) - { - IDBField versionField = table.getField(CDODBSchema.ATTRIBUTES_VERSION); - IDBField pathField = attributeMapping.getField(); - pathField.setPrecision(760);// MYSQL key limitation 767 - pathField.setNotNull(true); - - // TODO Provide better design for store capabilities and repository support - // Example: Currently a store can not specify that it does not support non-auditing mode! - if (false && !mappingStrategy.getStore().getRepository().isSupportingAudits()) - { - // Create a unique ids to prevent duplicate resource paths - table.addIndex(IDBIndex.Type.UNIQUE, versionField, pathField); - } - - break; - } - } - } + // // Special handling of CDOResource table + // CDOResourceClass resourceClass = getResourceClass(); + // if (cdoClass == resourceClass) + // { + // // Create a unique ids to prevent duplicate resource paths + // for (IAttributeMapping attributeMapping : attributeMappings) + // { + // if (attributeMapping.getFeature() == resourceClass.getCDOPathFeature()) + // { + // IDBField versionField = table.getField(CDODBSchema.ATTRIBUTES_VERSION); + // IDBField pathField = attributeMapping.getField(); + // pathField.setPrecision(760);// MYSQL key limitation 767 + // pathField.setNotNull(true); + // + // // TODO Provide better design for store capabilities and repository support + // // Example: Currently a store can not specify that it does not support non-auditing mode! + // if (false && !mappingStrategy.getStore().getRepository().isSupportingAudits()) + // { + // // Create a unique ids to prevent duplicate resource paths + // table.addIndex(IDBIndex.Type.UNIQUE, versionField, pathField); + // } + // + // break; + // } + // } + // } } selectPrefix = createSelectPrefix(false); selectPrefixWithVersion = createSelectPrefix(true); } - private CDOResourceClass getResourceClass() - { - return mappingStrategy.getStore().getRepository().getPackageManager().getCDOResourcePackage().getCDOResourceClass(); - } - public MappingStrategy getMappingStrategy() { return mappingStrategy; @@ -325,6 +319,16 @@ public abstract class ClassMapping implements IClassMapping return builder.toString(); } + public IFeatureMapping getFeatureMapping(CDOFeature feature) + { + if (feature.isReference() && mappingStrategy.getToMany() != ToMany.LIKE_ATTRIBUTES) + { + return getReferenceMapping(feature); + } + + return getAttributeMapping(feature); + } + public List getAttributeMappings() { return attributeMappings; @@ -468,18 +472,22 @@ public abstract class ClassMapping implements IClassMapping writeRevisedRow(storeWriter, (InternalCDORevision)revision); } - if (revision.isResource()) + if (revision.isResourceNode()) { // TODO Provide better design for store capabilities and repository support // Example: Currently a store can not specify that it does not support non-auditing mode! if (true || mappingStrategy.getStore().getRepository().isSupportingAudits()) { // If auditing is not supported this is checked by a table index (see constructor) - CDOFeature resourcePathFeature = getResourceClass().getCDOPathFeature(); - String revisionPath = (String)revision.getData().get(resourcePathFeature, 0); - if (mappingStrategy.readResourceID(storeWriter, revisionPath, revision.getCreated()) != null) + CDOFeature resourceFolderFeature = mappingStrategy.getResourceFolderFeatureMapping().getFeature(); + CDOID revisionFolder = (CDOID)revision.getData().get(resourceFolderFeature, 0); + + CDOFeature resourceNameFeature = mappingStrategy.getResourceNameFeatureMapping().getFeature(); + String revisionName = (String)revision.getData().get(resourceNameFeature, 0); + + if (mappingStrategy.readResourceID(storeWriter, revisionFolder, revisionName, revision.getCreated()) != null) { - throw new IllegalStateException("Duplicate resource path: " + revisionPath); + throw new IllegalStateException("Duplicate resource: " + revisionName + " (folderID=" + revisionFolder + ")"); } } } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java index 4b8de1786c..727ebe6f90 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java @@ -232,7 +232,7 @@ public class DBStore extends LongIDStore implements IDBStore MappingStrategy mappingStrategy = (MappingStrategy)getMappingStrategy(); - IClassMapping resourceClassMapping = mappingStrategy.getResourceClassMapping(); + IClassMapping resourceClassMapping = mappingStrategy.getResourceNodeClassMapping(); Set tables = resourceClassMapping.getAffectedTables(); if (dbAdapter.createTables(tables, connection).size() != tables.size()) { diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java index df3e4e15d4..6c75ce6848 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java @@ -270,10 +270,10 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader return revision; } - public CDOID readResourceID(String path, long timeStamp) + public CDOID readResourceID(CDOID folderID, String name, long timeStamp) { IMappingStrategy mappingStrategy = getStore().getMappingStrategy(); - return mappingStrategy.readResourceID(this, path, timeStamp); + return mappingStrategy.readResourceID(this, folderID, name, timeStamp); } /** diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java index cb2304e4f3..630c3b923e 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java @@ -16,8 +16,10 @@ import org.eclipse.emf.cdo.common.id.CDOIDUtil; import org.eclipse.emf.cdo.common.model.CDOClass; import org.eclipse.emf.cdo.common.model.CDOClassRef; import org.eclipse.emf.cdo.common.model.CDOPackage; -import org.eclipse.emf.cdo.common.model.resource.CDOPathFeature; +import org.eclipse.emf.cdo.common.model.resource.CDOFolderFeature; +import org.eclipse.emf.cdo.common.model.resource.CDONameFeature; import org.eclipse.emf.cdo.common.model.resource.CDOResourceClass; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.server.IPackageManager; import org.eclipse.emf.cdo.server.IStoreReader.QueryResourcesContext; @@ -25,6 +27,7 @@ import org.eclipse.emf.cdo.server.db.IAttributeMapping; import org.eclipse.emf.cdo.server.db.IClassMapping; import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreReader; +import org.eclipse.emf.cdo.server.db.IFeatureMapping; import org.eclipse.emf.cdo.server.db.IMappingStrategy; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; @@ -59,15 +62,19 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat private Map classRefs = new HashMap(); - private IClassMapping resourceClassMapping; + private IClassMapping resourceNodeClassMapping; - private IAttributeMapping resourcePathMapping; + private IAttributeMapping resourceFolderFeatureMapping; - private IDBTable resourceTable; + private IAttributeMapping resourceNameFeatureMapping; + + private IDBTable resourceNodeTable; private IDBField resourceIDField; - private IDBField resourcePathField; + private IDBField resourceFolderField; + + private IDBField resourceNameField; public MappingStrategy() { @@ -160,34 +167,44 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat return mapping; } - public IClassMapping getResourceClassMapping() + public IClassMapping getResourceNodeClassMapping() + { + if (resourceNodeClassMapping == null) + { + initResourceInfos(); + } + + return resourceNodeClassMapping; + } + + public IFeatureMapping getResourceFolderFeatureMapping() { - if (resourceClassMapping == null) + if (resourceFolderFeatureMapping == null) { initResourceInfos(); } - return resourceClassMapping; + return resourceFolderFeatureMapping; } - public IAttributeMapping getResourcePathMapping() + public IAttributeMapping getResourceNameFeatureMapping() { - if (resourcePathMapping == null) + if (resourceNameFeatureMapping == null) { initResourceInfos(); } - return resourcePathMapping; + return resourceNameFeatureMapping; } - public IDBTable getResourceTable() + public IDBTable getResourceNodeTable() { - if (resourceTable == null) + if (resourceNodeTable == null) { initResourceInfos(); } - return resourceTable; + return resourceNodeTable; } public IDBField getResourceIDField() @@ -200,28 +217,41 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat return resourceIDField; } - public IDBField getResourcePathField() + public IDBField getResourceFolderField() { - if (resourcePathField == null) + if (resourceFolderField == null) { initResourceInfos(); } - return resourcePathField; + return resourceFolderField; } - protected void initResourceInfos() + public IDBField getResourceNameField() { - IPackageManager packageManager = getStore().getRepository().getPackageManager(); - CDOResourceClass resourceClass = packageManager.getCDOResourcePackage().getCDOResourceClass(); - CDOPathFeature pathFeature = packageManager.getCDOResourcePackage().getCDOResourceClass().getCDOPathFeature(); + if (resourceNameField == null) + { + initResourceInfos(); + } - resourceClassMapping = getClassMapping(resourceClass); - resourcePathMapping = resourceClassMapping.getAttributeMapping(pathFeature); + return resourceNameField; + } - resourceTable = resourceClassMapping.getTable(); - resourceIDField = resourceTable.getField(CDODBSchema.ATTRIBUTES_ID); - resourcePathField = resourcePathMapping.getField(); + protected void initResourceInfos() + { + IPackageManager packageManager = getStore().getRepository().getPackageManager(); + CDOResourceNodeClass resourceNodeClass = packageManager.getCDOResourcePackage().getCDOResourceNodeClass(); + CDOFolderFeature folderFeature = resourceNodeClass.getCDOFolderFeature(); + CDONameFeature nameFeature = resourceNodeClass.getCDONameFeature(); + + resourceNodeClassMapping = getClassMapping(resourceNodeClass); + resourceFolderFeatureMapping = resourceNodeClassMapping.getAttributeMapping(folderFeature); + resourceNameFeatureMapping = resourceNodeClassMapping.getAttributeMapping(nameFeature); + + resourceNodeTable = resourceNodeClassMapping.getTable(); + resourceIDField = resourceNodeTable.getField(CDODBSchema.ATTRIBUTES_ID); + resourceFolderField = resourceFolderFeatureMapping.getField(); + resourceNameField = resourceNameFeatureMapping.getField(); } public String getTableName(CDOPackage cdoPackage) @@ -311,7 +341,7 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat }; } - public CDOID readResourceID(IDBStoreReader storeReader, final String path, final long timeStamp) + public CDOID readResourceID(IDBStoreReader storeReader, CDOID folderID, final String name, final long timeStamp) { final CDOID[] result = new CDOID[1]; queryResources(storeReader, new QueryResourcesContext() @@ -321,9 +351,9 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat return timeStamp; } - public String getPathPrefix() + public String getNamePrefix() { - return path; + return name; } public int getMaxResults() @@ -336,22 +366,23 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat result[0] = resourceID; return false; } - }, true); + }, folderID, true); return result[0]; } public void queryResources(IDBStoreReader storeReader, QueryResourcesContext context) { - queryResources(storeReader, context, false); + queryResources(storeReader, context, CDOID.NULL, false); } - private void queryResources(IDBStoreReader storeReader, QueryResourcesContext context, boolean exactMatch) + private void queryResources(IDBStoreReader storeReader, QueryResourcesContext context, CDOID folderID, + boolean exactMatch) { - IClassMapping mapping = getResourceClassMapping(); - IDBTable resourceTable = mapping.getTable(); - IDBField pathField = getResourcePathField(); - String pathPrefix = context.getPathPrefix(); + IDBTable resourceTable = getResourceNodeTable(); + IDBField folderField = getResourceFolderField(); + IDBField nameField = getResourceNameField(); + String namePrefix = context.getNamePrefix(); StringBuilder builder = new StringBuilder(); builder.append("SELECT "); @@ -359,17 +390,21 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat builder.append(" FROM "); builder.append(resourceTable); builder.append(" WHERE "); - builder.append(pathField); + builder.append(folderField); + builder.append("="); + builder.append(CDOIDUtil.getLong(folderID)); + builder.append(" AND "); + builder.append(nameField); if (exactMatch) { builder.append("=\'"); - builder.append(pathPrefix); + builder.append(namePrefix); builder.append("\'"); } else { builder.append(" LIKE \'"); - builder.append(pathPrefix); + builder.append(namePrefix); builder.append("%\'"); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java index cb6f1f96c9..b945f29a3b 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java @@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.server.db.IAttributeMapping; import org.eclipse.emf.cdo.server.db.IClassMapping; import org.eclipse.emf.cdo.server.db.IDBStoreReader; import org.eclipse.emf.cdo.server.db.IDBStoreWriter; +import org.eclipse.emf.cdo.server.db.IFeatureMapping; import org.eclipse.emf.cdo.server.db.IMappingStrategy; import org.eclipse.emf.cdo.server.db.IReferenceMapping; @@ -58,6 +59,11 @@ public class NoClassMapping implements IClassMapping return Collections.emptySet(); } + public IFeatureMapping getFeatureMapping(CDOFeature feature) + { + return null; + } + public List getAttributeMappings() { return null; diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java index 0924734b41..7cf6c99bf7 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java @@ -146,6 +146,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin { TRACER.trace(sql); } + ResultSet resultSet = null; try diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxy.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxy.java index d9a8fd9293..ddbc1b661e 100644 --- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxy.java +++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDORevisionProxy.java @@ -10,7 +10,6 @@ **************************************************************************/ package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer; -import org.eclipse.emf.cdo.common.CDODataOutput; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOClass; import org.eclipse.emf.cdo.common.model.CDOFeature; @@ -25,7 +24,6 @@ import org.eclipse.emf.cdo.spi.common.InternalCDORevision; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.LazyInitializer; -import java.io.IOException; import java.io.Serializable; /** @@ -42,15 +40,6 @@ public class CDORevisionProxy implements HibernateProxy, InternalCDORevision, Se this.li = li; } - /** - * @deprecated Doesn't seem to be used - */ - @Deprecated - public void write(CDODataOutput out, int referenceChunk) throws IOException - { - out.writeCDORevision(li.getRevision(), referenceChunk); - } - public Object writeReplace() { return this; @@ -181,6 +170,16 @@ public class CDORevisionProxy implements HibernateProxy, InternalCDORevision, Se return li.getRevision().isEmpty(feature); } + public boolean isResourceNode() + { + return li.getRevision().isResourceNode(); + } + + public boolean isResourceFolder() + { + return li.getRevision().isResourceFolder(); + } + public boolean isResource() { return li.getRevision().isResource(); diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java index e91faffb83..799295a3b7 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java @@ -13,6 +13,8 @@ package org.eclipse.emf.cdo.internal.server; import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.model.CDOFeature; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.server.IMEMStore; import org.eclipse.emf.cdo.server.ISession; @@ -20,6 +22,8 @@ import org.eclipse.emf.cdo.server.IView; import org.eclipse.emf.cdo.server.IStoreReader.QueryResourcesContext; import org.eclipse.emf.cdo.spi.common.InternalCDORevision; +import org.eclipse.net4j.util.ObjectUtil; + import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -169,10 +173,11 @@ public class MEMStore extends LongIDStore implements IMEMStore if (revision.isResource()) { - String revisionPath = (String)revision.getData().get(getResourcePathFeature(), 0); - if (getResourceID(revisionPath, revision.getCreated()) != null) + CDOID revisionFolder = (CDOID)revision.getData().get(getResourceFolderFeature(), 0); + String revisionName = (String)revision.getData().get(getResourceNameFeature(), 0); + if (getResourceID(revisionFolder, revisionName, revision.getCreated()) != null) { - throw new IllegalStateException("Duplicate resource path: " + revisionPath); + throw new IllegalStateException("Duplicate resource: " + revisionName + " (folderID=" + revisionFolder + ")"); } } @@ -183,6 +188,21 @@ public class MEMStore extends LongIDStore implements IMEMStore } } + private CDOResourceNodeClass getResourceNodeClass() + { + return getRepository().getPackageManager().getCDOResourcePackage().getCDOResourceNodeClass(); + } + + private CDOFeature getResourceFolderFeature() + { + return getResourceNodeClass().getCDOFolderFeature(); + } + + private CDOFeature getResourceNameFeature() + { + return getResourceNodeClass().getCDONameFeature(); + } + /** * @since 2.0 */ @@ -224,7 +244,7 @@ public class MEMStore extends LongIDStore implements IMEMStore /** * @since 2.0 */ - public CDOID getResourceID(final String path, final long timeStamp) + public CDOID getResourceID(CDOID folderID, final String name, final long timeStamp) { final CDOID[] result = new CDOID[1]; queryResources(new QueryResourcesContext() @@ -234,9 +254,9 @@ public class MEMStore extends LongIDStore implements IMEMStore return timeStamp; } - public String getPathPrefix() + public String getNamePrefix() { - return path; + return name; } public int getMaxResults() @@ -249,7 +269,7 @@ public class MEMStore extends LongIDStore implements IMEMStore result[0] = resourceID; return false; } - }, true); + }, folderID, true); return result[0]; } @@ -257,9 +277,9 @@ public class MEMStore extends LongIDStore implements IMEMStore /** * @since 2.0 */ - public synchronized void queryResources(QueryResourcesContext context, boolean exactMatch) + public synchronized void queryResources(QueryResourcesContext context, CDOID folderID, boolean exactMatch) { - String pathPrefix = context.getPathPrefix(); + String namePrefix = context.getNamePrefix(); for (List list : revisions.values()) { if (!list.isEmpty()) @@ -270,14 +290,18 @@ public class MEMStore extends LongIDStore implements IMEMStore revision = getRevisionByTime(list, context.getTimeStamp()); if (revision != null) { - String path = (String)revision.getData().get(getResourcePathFeature(), 0); - boolean match = exactMatch ? path.equals(pathPrefix) : path.startsWith(pathPrefix); - if (match) + CDOID revisionFolder = (CDOID)revision.getData().get(getResourceFolderFeature(), 0); + if (ObjectUtil.equals(revisionFolder, folderID)) { - if (!context.addResource(revision.getID())) + String revisionName = (String)revision.getData().get(getResourceNameFeature(), 0); + boolean match = exactMatch ? revisionName.equals(namePrefix) : revisionName.startsWith(namePrefix); + if (match) { - // No more results allowed - break; + if (!context.addResource(revision.getID())) + { + // No more results allowed + break; + } } } } diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java index 4fad50d7b8..f5521ce4e0 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java @@ -213,9 +213,9 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt /** * @since 2.0 */ - public CDOID readResourceID(String path, long timeStamp) + public CDOID readResourceID(CDOID folderID, String name, long timeStamp) { - return getStore().getResourceID(path, timeStamp); + return getStore().getResourceID(folderID, name, timeStamp); } /** @@ -223,7 +223,7 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt */ public void queryResources(QueryResourcesContext context) { - getStore().queryResources(context, false); + getStore().queryResources(context, CDOID.NULL, false); } /** diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourcesQueryHandler.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourcesQueryHandler.java index 2891268f28..52f2836a65 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourcesQueryHandler.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ResourcesQueryHandler.java @@ -41,7 +41,7 @@ public class ResourcesQueryHandler implements IQueryHandler return context.getTimeStamp(); } - public String getPathPrefix() + public String getNamePrefix() { return info.getQueryString(); } diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java index a1d8bb3e2a..415a21a5da 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java @@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory; import org.eclipse.emf.cdo.common.model.CDOClass; import org.eclipse.emf.cdo.common.model.CDOFeature; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; import org.eclipse.emf.cdo.internal.common.revision.CDORevisionResolverImpl; import org.eclipse.emf.cdo.server.IRepository; import org.eclipse.emf.cdo.server.IRevisionManager; @@ -266,9 +267,9 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio * @since 2.0 */ @Override - protected CDOFeature getResourcePathFeature() + protected CDOPackageManager getPackageManager() { - return repository.getPackageManager().getCDOResourcePackage().getCDOResourceClass().getCDOPathFeature(); + return repository.getPackageManager(); } /** diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java index a2e49b8e1d..fecb7d4ca4 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java @@ -11,7 +11,6 @@ package org.eclipse.emf.cdo.internal.server; import org.eclipse.emf.cdo.common.CDOProtocolView; -import org.eclipse.emf.cdo.common.model.resource.CDOPathFeature; import org.eclipse.emf.cdo.server.IRepository; import org.eclipse.emf.cdo.server.ISession; import org.eclipse.emf.cdo.server.ISessionManager; @@ -171,14 +170,6 @@ public abstract class Store extends Lifecycle implements IStore this.lastMetaID = lastMetaID; } - /** - * @since 2.0 - */ - public CDOPathFeature getResourcePathFeature() - { - return resourcePathFeature; - } - public final IStoreReader getReader(ISession session) { IStoreReader reader = null; @@ -254,17 +245,6 @@ public abstract class Store extends Lifecycle implements IStore } } - /** - * @since 2.0 - */ - @Override - protected void doActivate() throws Exception - { - super.doActivate(); - resourcePathFeature = repository.getPackageManager().getCDOResourcePackage().getCDOResourceClass() - .getCDOPathFeature(); - } - /** * Returns a {@link StoreAccessorPool pool} that may contain {@link IStoreReader} instances that are compatible with * the given session. The implementor may return null to indicate that no pooling occurs. It's also left diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/View.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/View.java index 174a95b5f4..eabb2a76c0 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/View.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/View.java @@ -13,16 +13,18 @@ package org.eclipse.emf.cdo.internal.server; import org.eclipse.emf.cdo.common.CDOProtocolView; import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.model.resource.CDOPathFeature; import org.eclipse.emf.cdo.server.IRepository; import org.eclipse.emf.cdo.server.IStoreReader; import org.eclipse.emf.cdo.server.IView; import org.eclipse.emf.cdo.server.StoreThreadLocal; import org.eclipse.emf.cdo.spi.common.InternalCDORevision; +import org.eclipse.net4j.util.StringUtil; + import java.text.MessageFormat; import java.util.HashSet; import java.util.Set; +import java.util.StringTokenizer; /** * @author Eike Stepper @@ -35,8 +37,6 @@ public class View implements IView private IRepository repository; - private CDOPathFeature resourcePathFeature; - private Set changeSubscriptionIDs = new HashSet(); /** @@ -46,10 +46,7 @@ public class View implements IView { this.session = session; this.viewID = viewID; - repository = session.getSessionManager().getRepository(); - resourcePathFeature = repository.getPackageManager().getCDOResourcePackage().getCDOResourceClass() - .getCDOPathFeature(); } public Session getSession() @@ -83,11 +80,32 @@ public class View implements IView { checkOpen(); long timeStamp = getTimeStamp(); - CDOID id = repository.getRevisionManager().getResourceID(path, timeStamp); + CDOID resourceID = null; + + StringTokenizer tokenizer = new StringTokenizer(path, "/"); + while (tokenizer.hasMoreTokens()) + { + String token = tokenizer.nextToken(); + if (!StringUtil.isEmpty(token)) + { + resourceID = getResourceID(resourceID, token, timeStamp); + if (resourceID == null) + { + return null; + } + } + } + + return resourceID; + } + + private CDOID getResourceID(CDOID folderID, String name, long timeStamp) + { + CDOID id = repository.getRevisionManager().getResourceID(folderID, name, timeStamp); if (id == null) { IStoreReader storeReader = StoreThreadLocal.getStoreReader(); - id = storeReader.readResourceID(path, timeStamp); + id = storeReader.readResourceID(folderID, name, timeStamp); } return id; @@ -186,7 +204,6 @@ public class View implements IView clearChangeSubscription(); session = null; repository = null; - resourcePathFeature = null; changeSubscriptionIDs = null; } diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java index a9b6e89e3c..3fc8aee678 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java @@ -76,12 +76,12 @@ public interface IStoreReader extends IStoreAccessor, IQueryHandler public CDORevision readRevisionByTime(CDOID id, int referenceChunk, long timeStamp); /** - * Returns the CDOID of the resource with the given path if a resource with this path exists in the - * store, null otherwise. + * Returns the CDOID of the resource node with the given folderID and name if a resource with this + * folderID and name exists in the store, null otherwise. * * @since 2.0 */ - public CDOID readResourceID(String path, long timeStamp); + public CDOID readResourceID(CDOID folderID, String name, long timeStamp); public CDORevision verifyRevision(CDORevision revision); @@ -109,7 +109,7 @@ public interface IStoreReader extends IStoreAccessor, IQueryHandler */ public long getTimeStamp(); - public String getPathPrefix(); + public String getNamePrefix(); /** * Returns the maximum number of results expected by the client or {@link CDOQueryInfo#UNLIMITED_RESULTS} for no diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java index 8e2b4ceb46..26080e513d 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java @@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.CDOState; import org.eclipse.emf.cdo.CDOTransaction; import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; import org.eclipse.emf.cdo.tests.model1.Product1; import org.eclipse.emf.cdo.tests.model1.VAT; import org.eclipse.emf.cdo.util.CDOURIUtil; @@ -44,25 +45,38 @@ public class ResourceTest extends AbstractCDOTest { public void testCreateResource_FromResourceSet() throws Exception { - final URI uri = URI.createURI("cdo:/test1"); - - msg("Creating resourceSet"); + CDOSession session = openModel1Session(); ResourceSet resourceSet = new ResourceSetImpl(); + CDOTransaction transaction = session.openTransaction(resourceSet); - msg("Opening session"); - CDOSession session = openModel1Session(); + final URI uri = URI.createURI("cdo:/test1"); + CDOResource resource = (CDOResource)resourceSet.createResource(uri); + assertActive(resource); + assertNew(resource, transaction); + assertEquals(transaction.getResourceSet(), resource.getResourceSet()); + assertEquals(CDOURIUtil.createResourceURI(session, "test1"), resource.getURI()); + assertEquals("test1", resource.getName()); + assertEquals(null, resource.getFolder()); + } - msg("Opening transaction"); + public void testCreateNestedResource_FromResourceSet() throws Exception + { + CDOSession session = openModel1Session(); + ResourceSet resourceSet = new ResourceSetImpl(); CDOTransaction transaction = session.openTransaction(resourceSet); - msg("Creating resource"); + final URI uri = URI.createURI("cdo:/folder/test1"); CDOResource resource = (CDOResource)resourceSet.createResource(uri); assertActive(resource); - - msg("Verifying resource"); assertNew(resource, transaction); - assertEquals(CDOURIUtil.createResourceURI(session, "test1"), resource.getURI()); assertEquals(transaction.getResourceSet(), resource.getResourceSet()); + assertEquals(CDOURIUtil.createResourceURI(session, "folder/test1"), resource.getURI()); + assertEquals("test1", resource.getName()); + + CDOResourceFolder folder = resource.getFolder(); + assertNotNull(folder); + assertEquals("folder", folder.getName()); + assertEquals(null, folder.getFolder()); } public void testCreateResource_FromTransaction() throws Exception diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java index b5be98fc82..705669ff39 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionHolderTest.java @@ -330,6 +330,16 @@ public class RevisionHolderTest extends AbstractCDOTest throw new UnsupportedOperationException(); } + public boolean isResourceNode() + { + throw new UnsupportedOperationException(); + } + + public boolean isResourceFolder() + { + throw new UnsupportedOperationException(); + } + public boolean isResource() { throw new UnsupportedOperationException(); diff --git a/plugins/org.eclipse.emf.cdo/model/eresource.ecore b/plugins/org.eclipse.emf.cdo/model/eresource.ecore index d3e21c6033..af16f7edcf 100644 --- a/plugins/org.eclipse.emf.cdo/model/eresource.ecore +++ b/plugins/org.eclipse.emf.cdo/model/eresource.ecore @@ -3,7 +3,18 @@ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="eresource" nsURI="http://www.eclipse.org/emf/CDO/resource/1.0.0" nsPrefix="eresource"> - + + + + + + + + + @@ -13,20 +24,18 @@ - -
- - + changeable="false" volatile="true" transient="true" defaultValueLiteral="true" + derived="true"/> + eType="#//Diagnostic" changeable="false" volatile="true" transient="true" + derived="true"/> + eType="#//Diagnostic" changeable="false" volatile="true" transient="true" + derived="true"/> - diff --git a/plugins/org.eclipse.emf.cdo/model/resource.genmodel b/plugins/org.eclipse.emf.cdo/model/resource.genmodel index f1ae370ca8..bfdfb4a8f3 100644 --- a/plugins/org.eclipse.emf.cdo/model/resource.genmodel +++ b/plugins/org.eclipse.emf.cdo/model/resource.genmodel @@ -14,6 +14,14 @@ + + + + + + + + @@ -24,7 +32,6 @@ - diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java index 621ea687fd..dcf40c74d1 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java @@ -15,6 +15,8 @@ package org.eclipse.emf.cdo; import org.eclipse.emf.cdo.common.CDOProtocolView; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; import org.eclipse.emf.cdo.query.CDOQuery; import org.eclipse.net4j.util.collection.CloseableIterator; @@ -23,6 +25,7 @@ import org.eclipse.net4j.util.event.INotifier; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.URIHandler; import java.util.List; import java.util.concurrent.locks.ReentrantLock; @@ -49,6 +52,11 @@ public interface CDOView extends CDOProtocolView, INotifier public ResourceSet getResourceSet(); + /** + * @since 2.0 + */ + public URIHandler getURIHandler(); + /** * Returns a reentrant lock that can be used to prevent the framework from writing to any object in this view (caused, * for example, by passive updates). @@ -235,19 +243,19 @@ public interface CDOView extends CDOProtocolView, INotifier /** * Returns a list of those resources whose path starts with the value of the pathPrefix parameter. * - * @param pathPrefix + * @param namePrefix * the prefix of the resources' path * @since 2.0 */ - public List queryResources(String pathPrefix); + public List queryResources(CDOResourceFolder folder, String namePrefix); /** * Returns an iterator over those resources whose path starts with the value of the pathPrefix parameter. The * underlying query will be executed asynchronously. * - * @param pathPrefix + * @param namePrefix * the prefix of the resources' path * @since 2.0 */ - public CloseableIterator queryResourcesAsync(String pathPrefix); + public CloseableIterator queryResourcesAsync(CDOResourceFolder folder, String namePrefix); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java index 8e1f845aec..b1e3d4be5e 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResource.java @@ -10,17 +10,16 @@ **************************************************************************/ package org.eclipse.emf.cdo.eresource; -import org.eclipse.emf.cdo.CDOObject; - import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; /** * A representation of the model object 'CDO Resource'. * - * @extends EresourceObject + * @extends Resource *

* The following features are supported: *

    @@ -33,15 +32,13 @@ import org.eclipse.emf.ecore.resource.ResourceSet; *
  • {@link org.eclipse.emf.cdo.eresource.CDOResource#getErrors Errors}
  • *
  • {@link org.eclipse.emf.cdo.eresource.CDOResource#getWarnings Warnings}
  • *
  • {@link org.eclipse.emf.cdo.eresource.CDOResource#getTimeStamp Time Stamp}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.CDOResource#getPath Path}
  • *
*

* @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource() * @model - * @extends CDOObject * @generated */ -public interface CDOResource extends CDOObject, EresourceObject +public interface CDOResource extends CDOResourceNode, Resource { /** * Returns the value of the 'Resource Set' attribute. @@ -192,7 +189,8 @@ public interface CDOResource extends CDOObject, EresourceObject * * @return the value of the 'Errors' attribute list. * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_Errors() - * @model dataType="org.eclipse.emf.cdo.eresource.Diagnostic" transient="true" + * @model dataType="org.eclipse.emf.cdo.eresource.Diagnostic" transient="true" changeable="false" volatile="true" + * derived="true" * @generated */ EList getErrors(); @@ -208,7 +206,8 @@ public interface CDOResource extends CDOObject, EresourceObject * * @return the value of the 'Warnings' attribute list. * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_Warnings() - * @model dataType="org.eclipse.emf.cdo.eresource.Diagnostic" transient="true" + * @model dataType="org.eclipse.emf.cdo.eresource.Diagnostic" transient="true" changeable="false" volatile="true" + * derived="true" * @generated */ EList getWarnings(); @@ -241,29 +240,9 @@ public interface CDOResource extends CDOObject, EresourceObject void setTimeStamp(long value); /** - * Returns the value of the 'Path' attribute. - *

- * If the meaning of the 'Path' attribute isn't clear, there really should be more of a description here... - *

- * - * - * @return the value of the 'Path' attribute. - * @see #setPath(String) - * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResource_Path() - * @model - * @generated - */ - String getPath(); - - /** - * Sets the value of the '{@link org.eclipse.emf.cdo.eresource.CDOResource#getPath Path}' attribute. - * - * @param value - * the new value of the 'Path' attribute. - * @see #getPath() - * @generated + * @ADDED + * @since 2.0 */ - void setPath(String value); + public boolean isExisting(); } // CDOResource diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceFolder.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceFolder.java new file mode 100644 index 0000000000..047373959b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceFolder.java @@ -0,0 +1,46 @@ +/** + * + * + * + * $Id: CDOResourceFolder.java,v 1.1.2.1 2008-10-14 20:39:30 estepper Exp $ + */ +package org.eclipse.emf.cdo.eresource; + +import org.eclipse.emf.common.util.EList; + +/** + * A representation of the model object 'CDO Resource Folder'. + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.emf.cdo.eresource.CDOResourceFolder#getContents Contents}
  • + *
+ *

+ * + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResourceFolder() + * @model + * @generated + * @since 2.0 + */ +public interface CDOResourceFolder extends CDOResourceNode +{ + /** + * Returns the value of the 'Nodes' containment reference list. The list contents are of type + * {@link org.eclipse.emf.cdo.eresource.CDOResourceNode}. It is bidirectional and its opposite is ' + * {@link org.eclipse.emf.cdo.eresource.CDOResourceNode#getFolder Folder}'. + *

+ * If the meaning of the 'Nodes' containment reference list isn't clear, there really should be more of a + * description here... + *

+ * + * + * @return the value of the 'Nodes' containment reference list. + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResourceFolder_Nodes() + * @see org.eclipse.emf.cdo.eresource.CDOResourceNode#getFolder + * @model opposite="folder" containment="true" + * @generated + */ + EList getNodes(); + +} // CDOResourceFolder diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceInputStream.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceInputStream.java new file mode 100644 index 0000000000..b42abbce9e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceInputStream.java @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.eresource; + +import org.eclipse.emf.cdo.CDOView; + +import org.eclipse.emf.common.util.URI; + +import java.io.IOException; +import java.io.InputStream; +import java.text.MessageFormat; + +/** + * @author Eike Stepper + * @since 2.0 + */ +public final class CDOResourceInputStream extends InputStream +{ + private CDOView view; + + private URI uri; + + public CDOResourceInputStream(CDOView view, URI uri) + { + this.view = view; + this.uri = uri; + } + + public CDOView getView() + { + return view; + } + + public URI getURI() + { + return uri; + } + + @Override + public int read() throws IOException + { + throw new IOException("read not supported"); + } + + @Override + public String toString() + { + return MessageFormat.format("CDOInputStream[{0}]", uri); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceNode.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceNode.java new file mode 100644 index 0000000000..a6eb0fd28c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/CDOResourceNode.java @@ -0,0 +1,99 @@ +/** + * + * + * + * $Id: CDOResourceNode.java,v 1.1.2.1 2008-10-14 20:39:30 estepper Exp $ + */ +package org.eclipse.emf.cdo.eresource; + +import org.eclipse.emf.cdo.CDOObject; + +/** + * A representation of the model object 'CDO Resource Node'. + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.emf.cdo.eresource.CDOResourceNode#getFolder Folder}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.CDOResourceNode#getName Name}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.CDOResourceNode#getPath Path}
  • + *
+ *

+ * + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResourceNode() + * @model abstract="true" + * @generated + * @since 2.0 + */ +public interface CDOResourceNode extends CDOObject +{ + /** + * Returns the value of the 'Folder' container reference. It is bidirectional and its opposite is ' + * {@link org.eclipse.emf.cdo.eresource.CDOResourceFolder#getNodes Nodes}'. + *

+ * If the meaning of the 'Folder' container reference isn't clear, there really should be more of a + * description here... + *

+ * + * + * @return the value of the 'Folder' container reference. + * @see #setFolder(CDOResourceFolder) + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResourceNode_Folder() + * @see org.eclipse.emf.cdo.eresource.CDOResourceFolder#getNodes + * @model opposite="nodes" transient="false" + * @generated + */ + CDOResourceFolder getFolder(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.eresource.CDOResourceNode#getFolder Folder}' container + * reference. + * + * @param value + * the new value of the 'Folder' container reference. + * @see #getFolder() + * @generated + */ + void setFolder(CDOResourceFolder value); + + /** + * Returns the value of the 'Name' attribute. + *

+ * If the meaning of the 'Name' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResourceNode_Name() + * @model + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.eresource.CDOResourceNode#getName Name}' attribute. + * + * @param value + * the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the 'Path' attribute. + *

+ * If the meaning of the 'Path' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Path' attribute. + * @see org.eclipse.emf.cdo.eresource.EresourcePackage#getCDOResourceNode_Path() + * @model transient="true" changeable="false" volatile="true" derived="true" + * @generated + */ + String getPath(); + +} // CDOResourceNode diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceFactory.java index 57e4841c29..50e830ded4 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceFactory.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceFactory.java @@ -28,6 +28,15 @@ public interface EresourceFactory extends EFactory */ EresourceFactory eINSTANCE = org.eclipse.emf.cdo.eresource.impl.EresourceFactoryImpl.init(); + /** + * Returns a new object of class 'CDO Resource Folder'. + * + * @since 2.0 + * @return a new object of class 'CDO Resource Folder'. + * @generated + */ + CDOResourceFolder createCDOResourceFolder(); + /** * Returns a new object of class 'CDO Resource'. * diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceObject.java deleted file mode 100644 index e3f6b2223a..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourceObject.java +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * 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.eresource; - -import org.eclipse.emf.cdo.CDOObject; - -import org.eclipse.emf.ecore.resource.Resource; - -/** - * @author Eike Stepper - */ -public interface EresourceObject extends CDOObject, Resource.Internal -{ - /** - * @since 2.0 - */ - public boolean isExisting(); -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourcePackage.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourcePackage.java index 5863888173..60006d6e1b 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourcePackage.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/EresourcePackage.java @@ -60,6 +60,109 @@ public interface EresourcePackage extends EPackage */ EresourcePackage eINSTANCE = org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl.init(); + /** + * The meta object id for the '{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl + * CDO Resource Node}' class. + * + * @since 2.0 + * @see org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getCDOResourceNode() + * @generated + */ + int CDO_RESOURCE_NODE = 0; + + /** + * The feature id for the 'Folder' container reference. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE_NODE__FOLDER = 0; + + /** + * The feature id for the 'Name' attribute. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE_NODE__NAME = 1; + + /** + * The feature id for the 'Path' attribute. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE_NODE__PATH = 2; + + /** + * The number of structural features of the 'CDO Resource Node' class. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE_NODE_FEATURE_COUNT = 3; + + /** + * The meta object id for the '{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceFolderImpl + * CDO Resource Folder}' class. + * + * @since 2.0 + * @see org.eclipse.emf.cdo.eresource.impl.CDOResourceFolderImpl + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getCDOResourceFolder() + * @generated + */ + int CDO_RESOURCE_FOLDER = 1; + + /** + * The feature id for the 'Folder' container reference. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE_FOLDER__FOLDER = CDO_RESOURCE_NODE__FOLDER; + + /** + * The feature id for the 'Name' attribute. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE_FOLDER__NAME = CDO_RESOURCE_NODE__NAME; + + /** + * The feature id for the 'Path' attribute. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE_FOLDER__PATH = CDO_RESOURCE_NODE__PATH; + + /** + * The feature id for the 'Nodes' containment reference list. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE_FOLDER__NODES = CDO_RESOURCE_NODE_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'CDO Resource Folder' class. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE_FOLDER_FEATURE_COUNT = CDO_RESOURCE_NODE_FEATURE_COUNT + 1; + /** * The meta object id for the '{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl CDO Resource}' * class. @@ -68,7 +171,33 @@ public interface EresourcePackage extends EPackage * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getCDOResource() * @generated */ - int CDO_RESOURCE = 0; + int CDO_RESOURCE = 2; + + /** + * The feature id for the 'Folder' container reference. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE__FOLDER = CDO_RESOURCE_NODE__FOLDER; + + /** + * The feature id for the 'Name' attribute. + * + * @since 2.0 + * @generated + * @ordered + */ + int CDO_RESOURCE__NAME = CDO_RESOURCE_NODE__NAME; + + /** + * The feature id for the 'Path' attribute. + * + * @generated + * @ordered + */ + int CDO_RESOURCE__PATH = CDO_RESOURCE_NODE__PATH; /** * The feature id for the 'Resource Set' attribute. @@ -76,7 +205,7 @@ public interface EresourcePackage extends EPackage * @generated * @ordered */ - int CDO_RESOURCE__RESOURCE_SET = 0; + int CDO_RESOURCE__RESOURCE_SET = CDO_RESOURCE_NODE_FEATURE_COUNT + 0; /** * The feature id for the 'URI' attribute. @@ -84,7 +213,7 @@ public interface EresourcePackage extends EPackage * @generated * @ordered */ - int CDO_RESOURCE__URI = 1; + int CDO_RESOURCE__URI = CDO_RESOURCE_NODE_FEATURE_COUNT + 1; /** * The feature id for the 'Contents' containment reference list. @@ -101,7 +230,7 @@ public interface EresourcePackage extends EPackage * @generated * @ordered */ - int CDO_RESOURCE__MODIFIED = 3; + int CDO_RESOURCE__MODIFIED = CDO_RESOURCE_NODE_FEATURE_COUNT + 3; /** * The feature id for the 'Loaded' attribute. @@ -109,7 +238,7 @@ public interface EresourcePackage extends EPackage * @generated * @ordered */ - int CDO_RESOURCE__LOADED = 4; + int CDO_RESOURCE__LOADED = CDO_RESOURCE_NODE_FEATURE_COUNT + 4; /** * The feature id for the 'Tracking Modification' attribute. @@ -126,7 +255,7 @@ public interface EresourcePackage extends EPackage * @generated * @ordered */ - int CDO_RESOURCE__ERRORS = 6; + int CDO_RESOURCE__ERRORS = CDO_RESOURCE_NODE_FEATURE_COUNT + 6; /** * The feature id for the 'Warnings' attribute list. @@ -134,7 +263,7 @@ public interface EresourcePackage extends EPackage * @generated * @ordered */ - int CDO_RESOURCE__WARNINGS = 7; + int CDO_RESOURCE__WARNINGS = CDO_RESOURCE_NODE_FEATURE_COUNT + 7; /** * The feature id for the 'Time Stamp' attribute. @@ -142,15 +271,7 @@ public interface EresourcePackage extends EPackage * @generated * @ordered */ - int CDO_RESOURCE__TIME_STAMP = 8; - - /** - * The feature id for the 'Path' attribute. - * - * @generated - * @ordered - */ - int CDO_RESOURCE__PATH = 9; + int CDO_RESOURCE__TIME_STAMP = CDO_RESOURCE_NODE_FEATURE_COUNT + 8; /** * The number of structural features of the 'CDO Resource' class. @@ -168,7 +289,7 @@ public interface EresourcePackage extends EPackage * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getResourceSet() * @generated */ - int RESOURCE_SET = 1; + int RESOURCE_SET = 3; /** * The meta object id for the 'URI' data type. @@ -177,7 +298,7 @@ public interface EresourcePackage extends EPackage * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getURI() * @generated */ - int URI = 2; + int URI = 4; /** * The meta object id for the 'Diagnostic' data type. @@ -186,7 +307,77 @@ public interface EresourcePackage extends EPackage * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getDiagnostic() * @generated */ - int DIAGNOSTIC = 3; + int DIAGNOSTIC = 5; + + /** + * Returns the meta object for class '{@link org.eclipse.emf.cdo.eresource.CDOResourceNode CDO Resource Node} + * '. + * + * @since 2.0 + * @return the meta object for class 'CDO Resource Node'. + * @see org.eclipse.emf.cdo.eresource.CDOResourceNode + * @generated + */ + EClass getCDOResourceNode(); + + /** + * Returns the meta object for the container reference ' + * {@link org.eclipse.emf.cdo.eresource.CDOResourceNode#getFolder Folder}'. + * + * @since 2.0 + * @return the meta object for the container reference 'Folder'. + * @see org.eclipse.emf.cdo.eresource.CDOResourceNode#getFolder() + * @see #getCDOResourceNode() + * @generated + */ + EReference getCDOResourceNode_Folder(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.eresource.CDOResourceNode#getName + * Name}'. + * + * @since 2.0 + * @return the meta object for the attribute 'Name'. + * @see org.eclipse.emf.cdo.eresource.CDOResourceNode#getName() + * @see #getCDOResourceNode() + * @generated + */ + EAttribute getCDOResourceNode_Name(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.eresource.CDOResourceNode#getPath + * Path}'. + * + * @since 2.0 + * @return the meta object for the attribute 'Path'. + * @see org.eclipse.emf.cdo.eresource.CDOResourceNode#getPath() + * @see #getCDOResourceNode() + * @generated + */ + EAttribute getCDOResourceNode_Path(); + + /** + * Returns the meta object for class '{@link org.eclipse.emf.cdo.eresource.CDOResourceFolder + * CDO Resource Folder}'. + * + * @since 2.0 + * @return the meta object for class 'CDO Resource Folder'. + * @see org.eclipse.emf.cdo.eresource.CDOResourceFolder + * @generated + */ + EClass getCDOResourceFolder(); + + /** + * Returns the meta object for the containment reference list ' + * {@link org.eclipse.emf.cdo.eresource.CDOResourceFolder#getNodes Nodes}'. + * + * @since 2.0 + * @return the meta object for the containment reference list 'Nodes'. + * @see org.eclipse.emf.cdo.eresource.CDOResourceFolder#getNodes() + * @see #getCDOResourceFolder() + * @generated + */ + EReference getCDOResourceFolder_Nodes(); /** * Returns the meta object for class '{@link org.eclipse.emf.cdo.eresource.CDOResource CDO Resource}'. - * - * @return the meta object for the attribute 'Path'. - * @see org.eclipse.emf.cdo.eresource.CDOResource#getPath() - * @see #getCDOResource() - * @generated - */ - EAttribute getCDOResource_Path(); - /** * Returns the meta object for data type '{@link org.eclipse.emf.ecore.resource.ResourceSet Resource Set}'. * @@ -364,6 +544,61 @@ public interface EresourcePackage extends EPackage */ interface Literals { + /** + * The meta object literal for the '{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl + * CDO Resource Node}' class. + * + * @since 2.0 + * @see org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getCDOResourceNode() + * @generated + */ + EClass CDO_RESOURCE_NODE = eINSTANCE.getCDOResourceNode(); + + /** + * The meta object literal for the 'Folder' container reference feature. + * + * @since 2.0 + * @generated + */ + EReference CDO_RESOURCE_NODE__FOLDER = eINSTANCE.getCDOResourceNode_Folder(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * @since 2.0 + * @generated + */ + EAttribute CDO_RESOURCE_NODE__NAME = eINSTANCE.getCDOResourceNode_Name(); + + /** + * The meta object literal for the 'Path' attribute feature. + * + * @since 2.0 + * @generated + */ + EAttribute CDO_RESOURCE_NODE__PATH = eINSTANCE.getCDOResourceNode_Path(); + + /** + * The meta object literal for the '{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceFolderImpl + * CDO Resource Folder}' class. + * + * @since 2.0 + * @see org.eclipse.emf.cdo.eresource.impl.CDOResourceFolderImpl + * @see org.eclipse.emf.cdo.eresource.impl.EresourcePackageImpl#getCDOResourceFolder() + * @generated + */ + EClass CDO_RESOURCE_FOLDER = eINSTANCE.getCDOResourceFolder(); + + /** + * The meta object literal for the 'Nodes' containment reference list feature. + * + * @since 2.0 + * @generated + */ + EReference CDO_RESOURCE_FOLDER__NODES = eINSTANCE.getCDOResourceFolder_Nodes(); + /** * The meta object literal for the '{@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl CDO Resource} * ' class. @@ -446,14 +681,6 @@ public interface EresourcePackage extends EPackage */ EAttribute CDO_RESOURCE__TIME_STAMP = eINSTANCE.getCDOResource_TimeStamp(); - /** - * The meta object literal for the 'Path' attribute feature. - * - * @generated - */ - EAttribute CDO_RESOURCE__PATH = eINSTANCE.getCDOResource_Path(); - /** * The meta object literal for the 'Resource Set' data type. * diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java index a4c5b392a9..e05e84bdc1 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java @@ -46,41 +46,27 @@ public class CDOResourceFactoryImpl implements Resource.Factory, CDOResourceFact public Resource createResource(URI uri) { - // URI can be invalid or incomplete. - // Extract repo + resource path and build a new URI. - - String repoUUID = CDOURIUtil.extractRepositoryUUID(uri); + CDOResourceImpl resource = (CDOResourceImpl)EresourceFactory.eINSTANCE.createCDOResource(); + // URI can be invalid or incomplete. Extract repo + resource path and build a new URI. + String repositoryUUID = CDOURIUtil.extractRepositoryUUID(uri); // repoUUID can be null but can be null - CDOViewImpl view = viewSet.resolveUUID(repoUUID); - - // Extract path - String path = uri.path(); + CDOViewImpl view = viewSet.resolveView(repositoryUUID); + String path = CDOURIUtil.extractResourcePath(uri); // Build a new URI with the view and the path URI newURI = CDOURIUtil.createResourceURI(view, path); - CDOResourceImpl resource = (CDOResourceImpl)EresourceFactory.eINSTANCE.createCDOResource(); + // Important: Set URI *after* registration with the view! resource.setURI(newURI); - resource.setExisting(isExistingResource()); - - if (resource.isExisting()) - { - // Doesn't have any resource for that path! - if (!view.registerProxyResource(resource)) - { - // TODO Should fill getErrors here !! - resource.setExisting(false); - } - } - + resource.setExisting(isGetResource()); return resource; } /** * TODO Add TCs to ensure that Ecore internally doesn't change the way the stack is used!!! */ - private boolean isExistingResource() + private boolean isGetResource() { boolean inResourceSet = false; StackTraceElement[] elements = Thread.currentThread().getStackTrace(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java new file mode 100644 index 0000000000..d4153ed285 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFolderImpl.java @@ -0,0 +1,62 @@ +/** + * + * + * + * $Id: CDOResourceFolderImpl.java,v 1.1.2.1 2008-10-14 20:39:30 estepper Exp $ + */ +package org.eclipse.emf.cdo.eresource.impl; + +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.eresource.EresourcePackage; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; + +/** + * An implementation of the model object 'CDO Resource Folder'. + * + * @since 2.0 + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceFolderImpl#getNodes Nodes}
  • + *
+ *

+ * @generated + */ +public class CDOResourceFolderImpl extends CDOResourceNodeImpl implements CDOResourceFolder +{ + /** + * + * + * @generated + */ + protected CDOResourceFolderImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return EresourcePackage.Literals.CDO_RESOURCE_FOLDER; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + public EList getNodes() + { + return (EList)eGet(EresourcePackage.Literals.CDO_RESOURCE_FOLDER__NODES, true); + } + +} // CDOResourceFolderImpl diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java index 8ab57f6e25..6242a7b86e 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java @@ -18,16 +18,19 @@ import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDUtil; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; import org.eclipse.emf.cdo.eresource.EresourcePackage; import org.eclipse.emf.cdo.util.CDOURIUtil; import org.eclipse.emf.cdo.util.ObjectNotFoundException; -import org.eclipse.emf.internal.cdo.CDOObjectImpl; import org.eclipse.emf.internal.cdo.CDOStateMachine; import org.eclipse.emf.internal.cdo.CDOTransactionImpl; +import org.eclipse.emf.internal.cdo.CDOViewImpl; import org.eclipse.emf.internal.cdo.InternalCDOObject; import org.eclipse.emf.internal.cdo.util.FSMUtil; +import org.eclipse.net4j.util.ObjectUtil; + import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.notify.impl.NotificationChainImpl; @@ -43,6 +46,8 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.URIConverter; +import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl; import org.eclipse.emf.ecore.resource.impl.ResourceImpl; import org.eclipse.emf.ecore.util.InternalEList; @@ -56,32 +61,60 @@ import java.util.ListIterator; import java.util.Map; /** - * An implementation of the model object 'CDO Resource'. - *

- * The following features are implemented: - *

    - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getResourceSet Resource Set}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getURI URI}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getContents Contents}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#isModified Modified}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#isLoaded Loaded}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#isTrackingModification Tracking Modification}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getErrors Errors}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getWarnings Warnings}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getTimeStamp Time Stamp}
  • - *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getPath Path}
  • - *
- *

+ * An implementation of the model object 'CDO Resource'. * + * @extends Resource.Internal + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getResourceSet Resource Set}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getURI URI}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getContents Contents}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#isModified Modified}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#isLoaded Loaded}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#isTrackingModification Tracking + * Modification}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getErrors Errors}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getWarnings Warnings}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl#getTimeStamp Time Stamp}
  • + *
+ *

* @generated */ -public class CDOResourceImpl extends CDOObjectImpl implements CDOResource +public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource, Resource.Internal { + /** + * The default URI converter when there is no resource set. + * + * @ADDED + */ + private static URIConverter defaultURIConverter; + /** * @ADDED */ private boolean existing; + /** + * @ADDED + */ + private boolean loading; + + /** + * @ADDED + */ + private boolean loaded; + + /** + * @ADDED + */ + private EList errors; + + /** + * @ADDED + */ + private EList warnings; + /** * * @@ -108,10 +141,9 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource * * @generated */ - @Override - protected int eStaticFeatureCount() + public ResourceSet getResourceSet() { - return 0; + return (ResourceSet)eGet(EresourcePackage.Literals.CDO_RESOURCE__RESOURCE_SET, true); } /** @@ -119,9 +151,9 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource * * @generated */ - public ResourceSet getResourceSet() + public void setResourceSet(ResourceSet newResourceSet) { - return (ResourceSet)eGet(EresourcePackage.Literals.CDO_RESOURCE__RESOURCE_SET, true); + eSet(EresourcePackage.Literals.CDO_RESOURCE__RESOURCE_SET, newResourceSet); } /** @@ -129,19 +161,20 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource * * @generated */ - public void setResourceSet(ResourceSet newResourceSet) + public URI getURI() { - eSet(EresourcePackage.Literals.CDO_RESOURCE__RESOURCE_SET, newResourceSet); + return (URI)eGet(EresourcePackage.Literals.CDO_RESOURCE__URI, true); } /** - * + * * + * @since 2.0 * @generated */ - public URI getURI() + public void setURIGen(URI newURI) { - return (URI)eGet(EresourcePackage.Literals.CDO_RESOURCE__URI, true); + eSet(EresourcePackage.Literals.CDO_RESOURCE__URI, newURI); } /** @@ -151,8 +184,29 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource */ public void setURI(URI newURI) { - eSet(EresourcePackage.Literals.CDO_RESOURCE__URI, newURI); - basicSetPath(CDOURIUtil.extractResourcePath(newURI)); + URI oldURI = getURI(); + if (!ObjectUtil.equals(oldURI, newURI)) + { + setURIGen(newURI); + + CDOViewImpl view = cdoView(); + if (view != null) + { + handleChangedURI(view, newURI); + } + } + } + + /** + * @ADDED + * @since 2.0 + */ + public void handleChangedURI(CDOViewImpl view, URI newURI) + { + String[] folderAndName = CDOURIUtil.extractResourceFolderAndName(newURI); + CDOResourceFolder folder = view.getResourceFolder(folderAndName[0]); + setFolder(folder); + setName(folderAndName[1]); } /** @@ -202,21 +256,44 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource /** * * - * @generated + * @generated NOT */ public boolean isLoaded() { - return ((Boolean)eGet(EresourcePackage.Literals.CDO_RESOURCE__LOADED, true)).booleanValue(); + return loaded; } /** - * - * - * @generated + * @see ResourceImpl#setLoaded(boolean) + * @ADDED */ - public void setLoaded(boolean newLoaded) + private Notification setLoaded(boolean isLoaded) { - eSet(EresourcePackage.Literals.CDO_RESOURCE__LOADED, new Boolean(newLoaded)); + boolean oldIsLoaded = loaded; + loaded = isLoaded; + + if (eNotificationRequired()) + { + Notification notification = new NotificationImpl(Notification.SET, oldIsLoaded, isLoaded) + { + @Override + public Object getNotifier() + { + return CDOResourceImpl.this; + } + + @Override + public int getFeatureID(Class expectedClass) + { + return EresourcePackage.CDO_RESOURCE__LOADED; + } + }; + return notification; + } + else + { + return null; + } } /** @@ -242,23 +319,73 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource /** * * - * @generated + * @generated NOT */ - @SuppressWarnings("unchecked") public EList getErrors() { - return (EList)eGet(EresourcePackage.Literals.CDO_RESOURCE__ERRORS, true); + if (errors == null) + { + errors = new NotifyingListImpl() + { + private static final long serialVersionUID = 1L; + + @Override + protected boolean isNotificationRequired() + { + return CDOResourceImpl.this.eNotificationRequired(); + } + + @Override + public Object getNotifier() + { + return CDOResourceImpl.this; + } + + @Override + public int getFeatureID() + { + return EresourcePackage.CDO_RESOURCE__ERRORS; + } + }; + } + + return errors; } /** * * - * @generated + * @generated NOT */ - @SuppressWarnings("unchecked") public EList getWarnings() { - return (EList)eGet(EresourcePackage.Literals.CDO_RESOURCE__WARNINGS, true); + if (warnings == null) + { + warnings = new NotifyingListImpl() + { + private static final long serialVersionUID = 1L; + + @Override + protected boolean isNotificationRequired() + { + return CDOResourceImpl.this.eNotificationRequired(); + } + + @Override + public Object getNotifier() + { + return CDOResourceImpl.this; + } + + @Override + public int getFeatureID() + { + return EresourcePackage.CDO_RESOURCE__WARNINGS; + } + }; + } + + return warnings; } /** @@ -281,26 +408,6 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource eSet(EresourcePackage.Literals.CDO_RESOURCE__TIME_STAMP, new Long(newTimeStamp)); } - /** - * - * - * @generated - */ - public String getPath() - { - return (String)eGet(EresourcePackage.Literals.CDO_RESOURCE__PATH, true); - } - - /** - * - * - * @generated NOT - */ - public void setPath(String newPath) - { - setURI(CDOURIUtil.createResourceURI(cdoView(), newPath)); - } - /** * @ADDED * @see ResourceImpl#getAllContents() @@ -379,7 +486,16 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource */ public void load(InputStream inputStream, Map options) throws IOException { - // Do nothing + throw new UnsupportedOperationException(); + // if (inputStream instanceof CDOResourceInputStream) + // { + // CDOResourceInputStream stream = (CDOResourceInputStream)inputStream; + // URI uri = stream.getURI(); + // } + // else + // { + // throw new IOException("Stream not supported: " + inputStream); + // } } /** @@ -387,7 +503,91 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource */ public void load(Map options) throws IOException { - // Do nothing + if (!isLoaded()) + { + CDOViewImpl view = cdoView(); + view.registerProxyResource(this); + + // URIConverter uriConverter = getURIConverter(); + // + // // If an input stream can't be created, ensure that the resource is still considered loaded after the failure, + // // and do all the same processing we'd do if we actually were able to create a valid input stream. + // // + // InputStream inputStream = null; + // + // try + // { + // inputStream = uriConverter.createInputStream(getURI(), options); + // } + // catch (IOException exception) + // { + // Notification notification = setLoaded(true); + // loading = true; + // if (errors != null) + // { + // errors.clear(); + // } + // + // if (warnings != null) + // { + // warnings.clear(); + // } + // + // loading = false; + // if (notification != null) + // { + // eNotify(notification); + // } + // + // setModified(false); + // throw exception; + // } + // + // try + // { + // load(inputStream, options); + // } + // finally + // { + // inputStream.close(); + // // TODO Handle timeStamp + // // Long timeStamp = (Long)response.get(URIConverter.RESPONSE_TIME_STAMP_PROPERTY); + // // if (timeStamp != null) + // // { + // // setTimeStamp(timeStamp); + // // } + // } + } + } + + /** + * Returns the URI converter. This typically gets the {@link ResourceSet#getURIConverter converter} from the + * {@link #getResourceSet containing} resource set, but it calls {@link #getDefaultURIConverter} when there is no + * containing resource set. + * + * @return the URI converter. + * @ADDED + */ + private URIConverter getURIConverter() + { + return getResourceSet() == null ? getDefaultURIConverter() : getResourceSet().getURIConverter(); + } + + /** + * Returns the default URI converter that's used when there is no resource set. + * + * @return the default URI converter. + * @see #getURIConverter + * @ADDED + */ + private static synchronized URIConverter getDefaultURIConverter() + { + if (defaultURIConverter == null) + { + defaultURIConverter = new ExtensibleURIConverterImpl(); + } + + return defaultURIConverter; } /** @@ -403,7 +603,7 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource } else { - throw new IOException("CDO view is read only: " + view); + throw new IOException("CDO view is read-only: " + view); } } @@ -516,8 +716,7 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource */ public boolean isLoading() { - // TODO Implement method CDOResourceImpl.isLoading() - throw new UnsupportedOperationException("Not yet implemented"); + return loading; } /** @@ -550,14 +749,6 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource return super.createList(eStructuralFeature); } - /** - * @ADDED - */ - private void basicSetPath(String newPath) - { - eSet(EresourcePackage.Literals.CDO_RESOURCE__PATH, newPath); - } - /** * {@link ResourceImpl.ContentsEList}!!! --> Bugzilla! * diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java new file mode 100644 index 0000000000..7a5f74779a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java @@ -0,0 +1,121 @@ +/** + * + * + * + * $Id: CDOResourceNodeImpl.java,v 1.1.2.1 2008-10-14 20:39:30 estepper Exp $ + */ +package org.eclipse.emf.cdo.eresource.impl; + +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.eresource.EresourcePackage; + +import org.eclipse.emf.internal.cdo.CDOObjectImpl; + +import org.eclipse.emf.ecore.EClass; + +/** + * An implementation of the model object 'CDO Resource Node'. + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl#getFolder Folder}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl#getName Name}
  • + *
  • {@link org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl#getPath Path}
  • + *
+ *

+ * + * @generated + * @since 2.0 + */ +public abstract class CDOResourceNodeImpl extends CDOObjectImpl implements CDOResourceNode +{ + /** + * + * + * @generated + */ + protected CDOResourceNodeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() + { + return EresourcePackage.Literals.CDO_RESOURCE_NODE; + } + + /** + * + * + * @generated + */ + @Override + protected int eStaticFeatureCount() + { + return 0; + } + + /** + * + * + * @generated + */ + public CDOResourceFolder getFolder() + { + return (CDOResourceFolder)eGet(EresourcePackage.Literals.CDO_RESOURCE_NODE__FOLDER, true); + } + + /** + * + * + * @generated + */ + public void setFolder(CDOResourceFolder newFolder) + { + eSet(EresourcePackage.Literals.CDO_RESOURCE_NODE__FOLDER, newFolder); + } + + /** + * + * + * @generated + */ + public String getName() + { + return (String)eGet(EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME, true); + } + + /** + * + * + * @generated + */ + public void setName(String newName) + { + eSet(EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME, newName); + } + + /** + * + * + * @generated NOT + */ + public String getPath() + { + CDOResourceFolder folder = getFolder(); + if (folder == null) + { + return "/" + getName(); + } + + return folder.getPath() + "/" + getName(); + } +} // CDOResourceNodeImpl diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java index e36d510f4c..789873bed1 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourceFactoryImpl.java @@ -11,6 +11,7 @@ package org.eclipse.emf.cdo.eresource.impl; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; import org.eclipse.emf.cdo.eresource.EresourceFactory; import org.eclipse.emf.cdo.eresource.EresourcePackage; @@ -113,6 +114,18 @@ public class EresourceFactoryImpl extends EFactoryImpl implements EresourceFacto } } + /** + * + * + * @since 2.0 + * @generated + */ + public CDOResourceFolder createCDOResourceFolder() + { + CDOResourceFolderImpl cdoResourceFolder = new CDOResourceFolderImpl(); + return cdoResourceFolder; + } + /** * * diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourcePackageImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourcePackageImpl.java index 9f94999836..0945a393d0 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourcePackageImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/EresourcePackageImpl.java @@ -11,6 +11,8 @@ package org.eclipse.emf.cdo.eresource.impl; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; import org.eclipse.emf.cdo.eresource.EresourceFactory; import org.eclipse.emf.cdo.eresource.EresourcePackage; @@ -31,6 +33,20 @@ import org.eclipse.emf.ecore.resource.Resource.Diagnostic; */ public class EresourcePackageImpl extends EPackageImpl implements EresourcePackage { + /** + * + * + * @generated + */ + private EClass cdoResourceNodeEClass = null; + + /** + * + * + * @generated + */ + private EClass cdoResourceFolderEClass = null; + /** * * @@ -131,6 +147,72 @@ public class EresourcePackageImpl extends EPackageImpl implements EresourcePacka return theEresourcePackage; } + /** + * + * + * @since 2.0 + * @generated + */ + public EClass getCDOResourceNode() + { + return cdoResourceNodeEClass; + } + + /** + * + * + * @since 2.0 + * @generated + */ + public EReference getCDOResourceNode_Folder() + { + return (EReference)cdoResourceNodeEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @since 2.0 + * @generated + */ + public EAttribute getCDOResourceNode_Name() + { + return (EAttribute)cdoResourceNodeEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @since 2.0 + * @generated + */ + public EAttribute getCDOResourceNode_Path() + { + return (EAttribute)cdoResourceNodeEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @since 2.0 + * @generated + */ + public EClass getCDOResourceFolder() + { + return cdoResourceFolderEClass; + } + + /** + * + * + * @since 2.0 + * @generated + */ + public EReference getCDOResourceFolder_Nodes() + { + return (EReference)cdoResourceFolderEClass.getEStructuralFeatures().get(0); + } + /** * * @@ -231,16 +313,6 @@ public class EresourcePackageImpl extends EPackageImpl implements EresourcePacka return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(8); } - /** - * - * - * @generated - */ - public EAttribute getCDOResource_Path() - { - return (EAttribute)cdoResourceEClass.getEStructuralFeatures().get(9); - } - /** * * @@ -303,6 +375,14 @@ public class EresourcePackageImpl extends EPackageImpl implements EresourcePacka isCreated = true; // Create classes and their features + cdoResourceNodeEClass = createEClass(CDO_RESOURCE_NODE); + createEReference(cdoResourceNodeEClass, CDO_RESOURCE_NODE__FOLDER); + createEAttribute(cdoResourceNodeEClass, CDO_RESOURCE_NODE__NAME); + createEAttribute(cdoResourceNodeEClass, CDO_RESOURCE_NODE__PATH); + + cdoResourceFolderEClass = createEClass(CDO_RESOURCE_FOLDER); + createEReference(cdoResourceFolderEClass, CDO_RESOURCE_FOLDER__NODES); + cdoResourceEClass = createEClass(CDO_RESOURCE); createEAttribute(cdoResourceEClass, CDO_RESOURCE__RESOURCE_SET); createEAttribute(cdoResourceEClass, CDO_RESOURCE__URI); @@ -313,7 +393,6 @@ public class EresourcePackageImpl extends EPackageImpl implements EresourcePacka createEAttribute(cdoResourceEClass, CDO_RESOURCE__ERRORS); createEAttribute(cdoResourceEClass, CDO_RESOURCE__WARNINGS); createEAttribute(cdoResourceEClass, CDO_RESOURCE__TIME_STAMP); - createEAttribute(cdoResourceEClass, CDO_RESOURCE__PATH); // Create data types resourceSetEDataType = createEDataType(RESOURCE_SET); @@ -355,8 +434,26 @@ public class EresourcePackageImpl extends EPackageImpl implements EresourcePacka // Set bounds for type parameters // Add supertypes to classes + cdoResourceFolderEClass.getESuperTypes().add(getCDOResourceNode()); + cdoResourceEClass.getESuperTypes().add(getCDOResourceNode()); // Initialize classes and features; add operations and parameters + initEClass(cdoResourceNodeEClass, CDOResourceNode.class, "CDOResourceNode", IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEReference(getCDOResourceNode_Folder(), getCDOResourceFolder(), getCDOResourceFolder_Nodes(), "folder", null, + 0, 1, CDOResourceNode.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getCDOResourceNode_Name(), ecorePackage.getEString(), "name", null, 0, 1, CDOResourceNode.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getCDOResourceNode_Path(), ecorePackage.getEString(), "path", null, 0, 1, CDOResourceNode.class, + IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + + initEClass(cdoResourceFolderEClass, CDOResourceFolder.class, "CDOResourceFolder", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEReference(getCDOResourceFolder_Nodes(), getCDOResourceNode(), getCDOResourceNode_Folder(), "nodes", null, 0, + -1, CDOResourceFolder.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, + !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEClass(cdoResourceEClass, CDOResource.class, "CDOResource", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getCDOResource_ResourceSet(), getResourceSet(), "resourceSet", null, 0, 1, CDOResource.class, @@ -369,18 +466,16 @@ public class EresourcePackageImpl extends EPackageImpl implements EresourcePacka initEAttribute(getCDOResource_Modified(), ecorePackage.getEBoolean(), "modified", null, 0, 1, CDOResource.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getCDOResource_Loaded(), ecorePackage.getEBoolean(), "loaded", "true", 0, 1, CDOResource.class, - IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEAttribute(getCDOResource_TrackingModification(), ecorePackage.getEBoolean(), "trackingModification", null, 0, 1, CDOResource.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getCDOResource_Errors(), getDiagnostic(), "errors", null, 0, -1, CDOResource.class, IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEAttribute(getCDOResource_Warnings(), getDiagnostic(), "warnings", null, 0, -1, CDOResource.class, - IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEAttribute(getCDOResource_TimeStamp(), theEcorePackage.getELong(), "timeStamp", null, 0, 1, CDOResource.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getCDOResource_Path(), ecorePackage.getEString(), "path", null, 0, 1, CDOResource.class, - !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); // Initialize data types initEDataType(resourceSetEDataType, ResourceSet.class, "ResourceSet", !IS_SERIALIZABLE, diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceAdapterFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceAdapterFactory.java index 84265bd643..b682d6a099 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceAdapterFactory.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceAdapterFactory.java @@ -11,6 +11,8 @@ package org.eclipse.emf.cdo.eresource.util; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; import org.eclipse.emf.cdo.eresource.EresourcePackage; import org.eclipse.emf.common.notify.Adapter; @@ -76,6 +78,18 @@ public class EresourceAdapterFactory extends AdapterFactoryImpl */ protected EresourceSwitch modelSwitch = new EresourceSwitch() { + @Override + public Adapter caseCDOResourceNode(CDOResourceNode object) + { + return createCDOResourceNodeAdapter(); + } + + @Override + public Adapter caseCDOResourceFolder(CDOResourceFolder object) + { + return createCDOResourceFolderAdapter(); + } + @Override public Adapter caseCDOResource(CDOResource object) { @@ -103,6 +117,36 @@ public class EresourceAdapterFactory extends AdapterFactoryImpl return modelSwitch.doSwitch((EObject)target); } + /** + * Creates a new adapter for an object of class '{@link org.eclipse.emf.cdo.eresource.CDOResourceNode + * CDO Resource Node}'. This default implementation returns null so that we can + * easily ignore cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @since 2.0 + * @return the new adapter. + * @see org.eclipse.emf.cdo.eresource.CDOResourceNode + * @generated + */ + public Adapter createCDOResourceNodeAdapter() + { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.emf.cdo.eresource.CDOResourceFolder + * CDO Resource Folder}'. This default implementation returns null so that we can + * easily ignore cases; it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @since 2.0 + * @return the new adapter. + * @see org.eclipse.emf.cdo.eresource.CDOResourceFolder + * @generated + */ + public Adapter createCDOResourceFolderAdapter() + { + return null; + } + /** * Creates a new adapter for an object of class '{@link org.eclipse.emf.cdo.eresource.CDOResource * CDO Resource}'. This default implementation returns null so that we can easily diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceSwitch.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceSwitch.java index 75c3246f12..6075a7f16e 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceSwitch.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/util/EresourceSwitch.java @@ -11,6 +11,8 @@ package org.eclipse.emf.cdo.eresource.util; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; import org.eclipse.emf.cdo.eresource.EresourcePackage; import org.eclipse.emf.ecore.EClass; @@ -92,11 +94,39 @@ public class EresourceSwitch { switch (classifierID) { + case EresourcePackage.CDO_RESOURCE_NODE: + { + CDOResourceNode cdoResourceNode = (CDOResourceNode)theEObject; + T result = caseCDOResourceNode(cdoResourceNode); + if (result == null) + { + result = defaultCase(theEObject); + } + return result; + } + case EresourcePackage.CDO_RESOURCE_FOLDER: + { + CDOResourceFolder cdoResourceFolder = (CDOResourceFolder)theEObject; + T result = caseCDOResourceFolder(cdoResourceFolder); + if (result == null) + { + result = caseCDOResourceNode(cdoResourceFolder); + } + if (result == null) + { + result = defaultCase(theEObject); + } + return result; + } case EresourcePackage.CDO_RESOURCE: { CDOResource cdoResource = (CDOResource)theEObject; T result = caseCDOResource(cdoResource); if (result == null) + { + result = caseCDOResourceNode(cdoResource); + } + if (result == null) { result = defaultCase(theEObject); } @@ -107,6 +137,38 @@ public class EresourceSwitch } } + /** + * Returns the result of interpreting the object as an instance of 'CDO Resource Node'. This implementation returns null; returning a non-null result will terminate the switch. + * + * @since 2.0 + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'CDO Resource Node'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseCDOResourceNode(CDOResourceNode object) + { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'CDO Resource Folder'. This implementation returns null; returning a non-null result will terminate the switch. + * + * @since 2.0 + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'CDO Resource Folder'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseCDOResourceFolder(CDOResourceFolder object) + { + return null; + } + /** * Returns the result of interpreting the object as an instance of 'CDO Resource'. * This implementation returns null; returning a non-null result will terminate the switch. diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java index 66aace87bc..f30a2a6c2e 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java @@ -7,6 +7,7 @@ * * Contributors: * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance **************************************************************************/ package org.eclipse.emf.cdo.util; @@ -19,49 +20,74 @@ import org.eclipse.emf.cdo.internal.common.id.CDOIDExternalImpl; import org.eclipse.emf.common.util.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + /** * @author Simon McDuff * @since 2.0 */ public class CDOURIUtil { - private static final char SEGMENT_SEPARATOR = '/'; + public static final char SEGMENT_SEPARATOR_CHAR = '/'; + + public static final String SEGMENT_SEPARATOR = new String(new char[] { SEGMENT_SEPARATOR_CHAR }); - public static boolean validateURI(URI uri) + public static void validateURI(URI uri) throws InvalidURIException { if (!CDOProtocolConstants.PROTOCOL_NAME.equals(uri.scheme())) { - return false; + throw new InvalidURIException(uri); } if (!uri.isHierarchical()) { - return false; + throw new InvalidURIException(uri); } if (!uri.hasAbsolutePath()) { - return false; + throw new InvalidURIException(uri); } - return true; } - public static String extractResourcePath(URI uri) + public static String extractRepositoryUUID(URI uri) { - if (!validateURI(uri)) + try + { + validateURI(uri); + if (!uri.hasAuthority()) + { + throw new InvalidURIException(uri); + } + + return uri.authority(); + } + catch (InvalidURIException ex) { return null; } - return uri.path(); } - public static String extractRepositoryUUID(URI uri) + public static String[] extractResourceFolderAndName(URI uri) throws InvalidURIException { - if (!validateURI(uri) || !uri.hasAuthority()) + String path = extractResourcePath(uri); + int lastSeparator = path.lastIndexOf(SEGMENT_SEPARATOR_CHAR); + if (lastSeparator == -1) { - return null; + return new String[] { null, path }; } - return uri.authority(); + + String folder = path.substring(0, lastSeparator); + String name = path.substring(lastSeparator + 1); + return new String[] { folder, name }; + } + + public static String extractResourcePath(URI uri) throws InvalidURIException + { + validateURI(uri); + return uri.path(); } /** @@ -86,10 +112,11 @@ public class CDOURIUtil stringBuilder.append(repositoryUUID); } - if (path.charAt(0) != SEGMENT_SEPARATOR) + if (path.charAt(0) != SEGMENT_SEPARATOR_CHAR) { - stringBuilder.append(SEGMENT_SEPARATOR); + stringBuilder.append(SEGMENT_SEPARATOR_CHAR); } + stringBuilder.append(path); return URI.createURI(stringBuilder.toString()); } @@ -113,13 +140,31 @@ public class CDOURIUtil */ public static CDOID convertExternalCDOID(URI baseURI, CDOID newCDOID) { - baseURI = baseURI.trimFragment(); - StringBuilder builder = new StringBuilder(); - CDOIDUtil.write(builder, newCDOID); - baseURI = baseURI.appendFragment(builder.toString()); + baseURI = baseURI.trimFragment().appendFragment(builder.toString()); return new CDOIDExternalImpl(baseURI.toString()); } + + public static List analyzePath(URI uri) + { + return analyzePath(extractResourcePath(uri)); + } + + public static List analyzePath(String path) + { + List segments = new ArrayList(); + StringTokenizer tokenizer = new StringTokenizer(path, CDOURIUtil.SEGMENT_SEPARATOR); + while (tokenizer.hasMoreTokens()) + { + String name = tokenizer.nextToken(); + if (name != null) + { + segments.add(name); + } + } + + return segments; + } } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/InvalidURIException.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/InvalidURIException.java new file mode 100644 index 0000000000..667c880ca2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/InvalidURIException.java @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.util; + +import org.eclipse.emf.cdo.common.util.CDOException; + +import org.eclipse.emf.common.util.URI; + +/** + * @author Eike Stepper + * @since 2.0 + */ +public class InvalidURIException extends CDOException +{ + private static final long serialVersionUID = 1L; + + private URI uri; + + public InvalidURIException(URI uri, Throwable cause) + { + super("Invalid URI: " + uri, cause); + this.uri = uri; + } + + public InvalidURIException(URI uri) + { + this(uri, null); + } + + public URI getURI() + { + return uri; + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java index 1d3262c13b..e8a9f3f407 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java @@ -72,7 +72,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec private CDOState state; - private CDOViewImpl cdoView; + private CDOViewImpl view; // TODO Consider removal because it's only an optimization (proof that revision.resourceID could be used in all cases // as well) @@ -108,7 +108,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec public CDOViewImpl cdoView() { - return cdoView; + return view; } public CDOResourceImpl cdoResource() @@ -171,10 +171,10 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec public void cdoInternalSetView(CDOView view) { - cdoView = (CDOViewImpl)view; - if (cdoView != null) + this.view = (CDOViewImpl)view; + if (this.view != null) { - eSetStore(cdoView.getStore()); + eSetStore(this.view.getStore()); } else { @@ -591,7 +591,6 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec } else if (resource instanceof CDOResourceImpl || resource == null) { - this.resource = (CDOResourceImpl)resource; getStore().setContainer(this, cdoResource(), eInternalContainer(), eContainerFeatureID()); } @@ -767,7 +766,8 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec newResource = newContainer.eInternalResource(); } } - CDOView oldView = cdoView; + + CDOView oldView = view; CDOView newView = newResource != null && newResource instanceof CDOResource ? ((CDOResource)newResource).cdoView() : null; @@ -829,7 +829,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec { Resource.Internal oldResource = eDirectResource(); - CDOView oldView = cdoView; + CDOView oldView = view; CDOView newView = resource != null && resource instanceof CDOResource ? ((CDOResource)resource).cdoView() : null; boolean isSameView = oldView != null && oldView == newView; diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java index 4e026fe621..3f4c60cd95 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java @@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory; import org.eclipse.emf.cdo.common.model.CDOFeature; +import org.eclipse.emf.cdo.common.model.CDOPackageManager; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.util.TransportException; import org.eclipse.emf.cdo.internal.common.revision.CDORevisionResolverImpl; @@ -133,9 +134,9 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C * @since 2.0 */ @Override - protected CDOFeature getResourcePathFeature() + protected CDOPackageManager getPackageManager() { - return session.getPackageManager().getCDOResourcePackage().getCDOResourceClass().getCDOPathFeature(); + return session.getPackageManager(); } private List send(LoadRevisionRequest request) diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java index 98d349866a..07d13e18e0 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java @@ -29,7 +29,11 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDeltaUtil; +import org.eclipse.emf.cdo.common.util.CDOException; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; +import org.eclipse.emf.cdo.eresource.EresourceFactory; import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; import org.eclipse.emf.cdo.spi.common.InternalCDOPackage; import org.eclipse.emf.cdo.spi.common.InternalCDORevision; @@ -199,38 +203,71 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa return createResource(path); } - /** - * @since 2.0 - */ - - public void attach(CDOResourceImpl cdoResource) + @Override + public void attachResource(CDOResourceImpl resource) { - try + if (resource.isExisting()) { - CDOStateMachine.INSTANCE.attach(cdoResource, this); - fireEvent(new ResourcesEvent(cdoResource.getPath(), ResourcesEvent.Kind.ADDED)); + super.attachResource(resource); } - catch (RuntimeException ex) + else + { + // ResourceSet.createResource(uri) was called!! + attachNewResource(resource); + } + } + + private void attachNewResource(CDOResourceImpl resource) + { + URI uri = resource.getURI(); + List names = CDOURIUtil.analyzePath(uri); + String resourceName = names.remove(names.size() - 1); + + CDOResourceFolder folder = null; + for (String name : names) { - OM.LOG.error(ex); + CDOResourceNode node; try { - ((InternalCDOObject)cdoResource).cdoInternalSetState(CDOState.NEW); - getResourceSet().getResources().remove(cdoResource); + CDOID folderID = folder == null ? null : folder.cdoID(); + node = getResourceNode(folderID, name); } - catch (RuntimeException ignore) + catch (CDOException ex) { + node = EresourceFactory.eINSTANCE.createCDOResourceFolder(); + attachNewResourceNode(folder, name, node); } - throw ex; + if (node instanceof CDOResourceFolder) + { + folder = (CDOResourceFolder)node; + } + else + { + throw new CDOException("Not a ResourceFolder: " + node); + } + } + + attachNewResourceNode(folder, resourceName, resource); + } + + private void attachNewResourceNode(CDOResourceFolder folder, String name, CDOResourceNode newNode) + { + newNode.setName(name); + if (folder == null) + { + CDOStateMachine.INSTANCE.attach((InternalCDOObject)newNode, this); + } + else + { + newNode.setFolder(folder); } } /** * @since 2.0 */ - public void detach(CDOResourceImpl cdoResource) { CDOStateMachine.INSTANCE.detach(cdoResource); @@ -271,21 +308,54 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa } this.transactionStrategy = transactionStrategy; - if (this.transactionStrategy != null) { this.transactionStrategy.setTarget(this); } } - /** - * @since 2.0 - */ @Override - public CDOID getResourceID(String path) + protected CDOResourceNode getRootResourceNode(String name) + { + if (dirty) + { + CDOResourceNode node = getRootResourceNode(name, getDirtyObjects().values()); + if (node != null) + { + return node; + } + + node = getRootResourceNode(name, getNewObjects().values()); + if (node != null) + { + return node; + } + + node = getRootResourceNode(name, getNewResources().values()); + if (node != null) + { + return node; + } + } + + return super.getRootResourceNode(name); + } + + private CDOResourceNode getRootResourceNode(String name, Collection objects) { - CDOID id = super.getResourceID(path); - return isDetached(id) ? CDOID.NULL : id; + for (CDOObject object : objects) + { + if (object instanceof CDOResourceNode) + { + CDOResourceNode node = (CDOResourceNode)object; + if (name.equals(node.getName())) + { + return node; + } + } + } + + return null; } private boolean isDetached(CDOID id) @@ -300,7 +370,6 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa public InternalCDOObject getObject(CDOID id, boolean loadOnDemand) { checkOpen(); - if (id == null || id.isNull()) { return null; diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java new file mode 100644 index 0000000000..8e8310a0e1 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java @@ -0,0 +1,78 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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.internal.cdo; + +import org.eclipse.emf.cdo.eresource.CDOResourceInputStream; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.URIHandler; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Map; + +/** + * @author Eike Stepper + * @since 2.0 + */ +public class CDOURIHandler implements URIHandler +{ + private CDOViewImpl view; + + public CDOURIHandler(CDOViewImpl view) + { + this.view = view; + } + + public CDOViewImpl getView() + { + return view; + } + + public boolean canHandle(URI uri) + { + return false; + } + + public boolean exists(URI uri, Map options) + { + return false; + } + + public void delete(URI uri, Map options) throws IOException + { + } + + public InputStream createInputStream(URI uri, Map options) throws IOException + { + return new CDOResourceInputStream(view, uri); + } + + public OutputStream createOutputStream(URI uri, Map options) throws IOException + { + return null; + } + + public Map contentDescription(URI uri, Map options) throws IOException + { + return null; + } + + public Map getAttributes(URI uri, Map options) + { + return null; + } + + public void setAttributes(URI uri, Map attributes, Map options) throws IOException + { + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java index 240b940afc..64ed45631d 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java @@ -27,28 +27,34 @@ import org.eclipse.emf.cdo.common.id.CDOIDMeta; import org.eclipse.emf.cdo.common.id.CDOIDProvider; import org.eclipse.emf.cdo.common.id.CDOIDUtil; import org.eclipse.emf.cdo.common.model.CDOClass; +import org.eclipse.emf.cdo.common.model.resource.CDOFolderFeature; +import org.eclipse.emf.cdo.common.model.resource.CDONameFeature; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionResolver; import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; import org.eclipse.emf.cdo.common.util.CDOException; import org.eclipse.emf.cdo.common.util.TransportException; import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; +import org.eclipse.emf.cdo.eresource.CDOResourceNode; import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; import org.eclipse.emf.cdo.query.CDOQuery; import org.eclipse.emf.cdo.spi.common.InternalCDORevision; import org.eclipse.emf.cdo.util.CDOURIUtil; import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.util.InvalidURIException; import org.eclipse.emf.cdo.util.ReadOnlyException; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.emf.internal.cdo.protocol.ChangeSubscriptionRequest; -import org.eclipse.emf.internal.cdo.protocol.ResourceIDRequest; import org.eclipse.emf.internal.cdo.protocol.ResourcePathRequest; import org.eclipse.emf.internal.cdo.query.CDOQueryImpl; import org.eclipse.emf.internal.cdo.util.FSMUtil; import org.eclipse.emf.internal.cdo.util.ModelUtil; import org.eclipse.net4j.util.ImplementationError; +import org.eclipse.net4j.util.StringUtil; import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; import org.eclipse.net4j.util.collection.CloseableIterator; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -73,6 +79,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.StringTokenizer; import java.util.Map.Entry; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.locks.ReentrantLock; @@ -90,6 +97,8 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement private CDOViewSet viewSet; + private CDOURIHandler uriHandler = new CDOURIHandler(this); + private boolean uniqueResourceContents = true; private boolean invalidationNotificationEnabled; @@ -165,6 +174,14 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement return store; } + /** + * @since 2.0 + */ + public CDOURIHandler getURIHandler() + { + return uriHandler; + } + /** * @since 2.0 */ @@ -277,8 +294,16 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement public boolean hasResource(String path) { checkOpen(); - CDOID id = getResourceID(path); - return id != null && !id.isNull(); + + try + { + getResourceID(path); + return true; + } + catch (Exception ex) + { + return false; + } } /** @@ -290,23 +315,86 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement return new CDOQueryImpl(this, language, queryString); } - public CDOID getResourceID(String path) + protected CDOID getResourceID(String path) { - try + if (StringUtil.isEmpty(path)) + { + throw new IllegalArgumentException("path"); + } + + CDOResourceNode node = null; + CDOID folderID = null; + StringTokenizer tokenizer = new StringTokenizer(path, CDOURIUtil.SEGMENT_SEPARATOR); + while (tokenizer.hasMoreTokens()) { - CDOResource resource = getResource(path, false); - if (resource != null && resource.cdoID() != null) + String name = tokenizer.nextToken(); + if (name != null) { - return resource.cdoID(); + node = getResourceNode(folderID, name); + folderID = node.cdoID(); } + } - ResourceIDRequest request = new ResourceIDRequest(session.getProtocol(), viewID, path); - return session.getFailOverStrategy().send(request); + if (node instanceof CDOResource) + { + return folderID; } - catch (Exception ex) + + throw new CDOException("Path does not denote a resource: " + path); + } + + /** + * @return never null + * @since 2.0 + */ + protected CDOResourceNode getResourceNode(CDOID folderID, String name) + { + if (name == null) + { + throw new IllegalArgumentException("name"); + } + + if (folderID == null) + { + return getRootResourceNode(name); + } + + InternalCDOObject object = getObject(folderID, true); + if (object instanceof CDOResourceFolder) + { + CDOResourceFolder folder = (CDOResourceFolder)object; + for (CDOResourceNode node : folder.getNodes()) + { + if (name.equals(node.getName())) + { + return node; + } + } + + throw new CDOException("ResourceNode " + name + " not found in folder " + folder.getPath()); + } + + throw new CDOException("ResourceNode " + name + " expected in folder " + folderID + " which is not a folder"); + } + + /** + * @return never null + * @since 2.0 + */ + protected CDOResourceNode getRootResourceNode(String name) + { + List nodes = queryResources((CDOID)null, name); + if (nodes.isEmpty()) { - throw new TransactionException(ex); + throw new CDOException("No root ResourceNode with the name " + name); } + + if (nodes.size() > 1) + { + throw new ImplementationError("Duplicate root ResourceNodes with the same name"); + } + + return nodes.get(0); } /** @@ -320,12 +408,40 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement } } + /** + * @since 2.0 + */ + public CDOResourceFolder getResourceFolder(String path) + { + if (path == null) + { + return null; + } + + CDOResourceFolder folder = null; + StringTokenizer tokenizer = new StringTokenizer(path, CDOURIUtil.SEGMENT_SEPARATOR); + while (tokenizer.hasMoreTokens()) + { + String segment = tokenizer.nextToken(); + if (segment != null) + { + if (folder == null) + { + } + else + { + } + } + } + + return folder; + } + /** * @since 2.0 */ public CDOResource getResource(String path) { - checkOpen(); return getResource(path, true); } @@ -342,19 +458,31 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement /** * @since 2.0 */ - public List queryResources(String pathPrefix) + public List queryResources(CDOResourceFolder folder, String namePrefix) { - CDOQuery resourceQuery = createResourcesQuery(pathPrefix); - return resourceQuery.getResult(CDOResource.class); + CDOID folderID = folder == null ? null : folder.cdoID(); + return queryResources(folderID, namePrefix); } /** * @since 2.0 */ - public CloseableIterator queryResourcesAsync(String pathPrefix) + public CloseableIterator queryResourcesAsync(CDOResourceFolder folder, String namePrefix) + { + CDOID folderID = folder == null ? null : folder.cdoID(); + return queryResourcesAsync(folderID, namePrefix); + } + + private List queryResources(CDOID folderID, String namePrefix) + { + CDOQuery resourceQuery = createResourcesQuery(namePrefix); + return resourceQuery.getResult(CDOResourceNode.class); + } + + private CloseableIterator queryResourcesAsync(CDOID folderID, String namePrefix) { - CDOQuery resourceQuery = createResourcesQuery(pathPrefix); - return resourceQuery.getResultAsync(CDOResource.class); + CDOQuery resourceQuery = createResourcesQuery(namePrefix); + return resourceQuery.getResultAsync(CDOResourceNode.class); } private CDOQuery createResourcesQuery(String pathPrefix) @@ -572,11 +700,53 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement FSMUtil.validate(id, revision); CDOClass cdoClass = revision.getCDOClass(); - InternalCDOObject object = newInstance(cdoClass); + InternalCDOObject object; + if (cdoClass.isResource()) + { + object = (InternalCDOObject)newResourceInstance(revision); + // object is PROXY + } + else + { + object = newInstance(cdoClass); + // object is TRANSIENT + } + cleanObject(object, revision); return object; } + private CDOResource newResourceInstance(InternalCDORevision revision) + { + String path = getResourcePath(revision); + return getResource(path, true); + } + + private String getResourcePath(InternalCDORevision revision) + { + CDOResourceNodeClass resourceNodeClass = session.getPackageManager().getCDOResourcePackage() + .getCDOResourceNodeClass(); + CDOFolderFeature folderFeature = resourceNodeClass.getCDOFolderFeature(); + CDONameFeature nameFeature = resourceNodeClass.getCDONameFeature(); + + CDOID folderID = (CDOID)revision.getData().get(folderFeature, 0); + String name = (String)revision.getData().get(nameFeature, 0); + if (folderID == null) + { + return name; + } + + InternalCDOObject object = getObject(folderID, true); + if (object instanceof CDOResourceFolder) + { + CDOResourceFolder folder = (CDOResourceFolder)object; + String path = folder.getPath(); + return path + CDOURIUtil.SEGMENT_SEPARATOR + name; + } + + throw new ImplementationError("Not a ResourceFolder: " + object); + } + /** * @since 2.0 */ @@ -601,7 +771,6 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement object.cdoInternalSetRevision(revision); object.cdoInternalSetID(revision.getID()); object.cdoInternalSetState(CDOState.CLEAN); - object.cdoInternalPostLoad(); } @@ -716,21 +885,37 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement /** * @since 2.0 */ - public boolean registerProxyResource(CDOResourceImpl resource) + public void attachResource(CDOResourceImpl resource) { - CDOID id = getResourceID(resource.getPath()); + if (!resource.isExisting()) + { + throw new ReadOnlyException("CDO view is read-only: " + this); + } + + // ResourceSet.getResource(uri, true) was called!! + resource.cdoInternalSetView(this); + resource.cdoInternalSetState(CDOState.PROXY); + } - boolean exists = id != null && !id.isNull(); - if (exists) + /** + * @since 2.0 + */ + public void registerProxyResource(CDOResourceImpl resource) + { + URI uri = resource.getURI(); + String path = CDOURIUtil.extractResourcePath(uri); + + try { - resource.cdoInternalSetResource(resource); - resource.cdoInternalSetView(this); + CDOID id = getResourceID(path); resource.cdoInternalSetID(id); - resource.cdoInternalSetState(CDOState.PROXY); + resource.cdoInternalSetResource(resource); registerObject(resource); } - - return exists; + catch (Exception ex) + { + throw new InvalidURIException(uri, ex); + } } public void registerObject(InternalCDOObject object) @@ -1000,6 +1185,10 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement public void setViewSet(CDOViewSet viewSet) { this.viewSet = viewSet; + if (viewSet != null) + { + viewSet.getResourceSet().getURIConverter().getURIHandlers().add(getURIHandler()); + } } private void checkOpen() diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewSetImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewSetImpl.java index b0b057a7be..8ace72ae07 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewSetImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewSetImpl.java @@ -21,7 +21,6 @@ import org.eclipse.emf.cdo.util.CDOURIUtil; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.emf.internal.cdo.util.CDOViewSetPackageRegistryImpl; -import org.eclipse.emf.internal.cdo.util.FSMUtil; import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; @@ -89,14 +88,12 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter * @throws IllegalArgumentException * if repositoryUUID doesn't match any CDOView. */ - public CDOViewImpl resolveUUID(String repositoryUUID) + public CDOViewImpl resolveView(String repositoryUUID) { CDOViewImpl view = null; - synchronized (views) { view = mapOfViews.get(repositoryUUID); - if (view == null) { if (repositoryUUID != null) @@ -117,6 +114,7 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter throw new IllegalStateException("Don't know which CDOView to take since no authority has been specified"); } } + return view; } @@ -246,13 +244,18 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter switch (notification.getEventType()) { case Notification.ADD: - if (notification.getNewValue() instanceof CDOResourceImpl) + { + Object newResource = notification.getNewValue(); + if (newResource instanceof CDOResourceImpl) { - notifyAdd((CDOResourceImpl)notification.getNewValue()); + notifyAdd((CDOResourceImpl)newResource); } + break; + } case Notification.ADD_MANY: + { List newResources = (List)notification.getNewValue(); for (Resource newResource : newResources) { @@ -261,8 +264,10 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter notifyAdd((CDOResourceImpl)newResource); } } + break; } + } } catch (RuntimeException ex) { @@ -276,10 +281,11 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter */ private void notifyAdd(CDOResourceImpl resource) { - CDOViewImpl view = resolveUUID(resource.getURI().authority()); - if (view != null && FSMUtil.isTransient(resource)) + String respositoryUUID = CDOURIUtil.extractRepositoryUUID(resource.getURI()); + CDOViewImpl view = resolveView(respositoryUUID); + if (view != null) { - view.toTransaction().attach(resource); + view.attachResource(resource); } } } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java index 3583d992c9..fc89625646 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java @@ -22,6 +22,8 @@ import org.eclipse.emf.cdo.common.model.CDOPackageManager; import org.eclipse.emf.cdo.common.model.CDOType; import org.eclipse.emf.cdo.common.model.core.CDOCorePackage; import org.eclipse.emf.cdo.common.model.resource.CDOResourceClass; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceFolderClass; +import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass; import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage; import org.eclipse.emf.cdo.eresource.EresourcePackage; import org.eclipse.emf.cdo.spi.common.InternalCDOClass; @@ -393,11 +395,22 @@ public final class ModelUtil // Eresource CDOResourcePackage resourcePackage = packageManager.getCDOResourcePackage(); ((InternalCDOPackage)resourcePackage).setClientInfo(EresourcePackage.eINSTANCE); + + CDOResourceNodeClass resourceNodeClass = resourcePackage.getCDOResourceNodeClass(); + ((InternalCDOClass)resourceNodeClass).setClientInfo(EresourcePackage.eINSTANCE.getCDOResourceNode()); + ((InternalCDOFeature)resourceNodeClass.getCDOFolderFeature()).setClientInfo(EresourcePackage.eINSTANCE + .getCDOResourceNode_Folder()); + ((InternalCDOFeature)resourceNodeClass.getCDONameFeature()).setClientInfo(EresourcePackage.eINSTANCE + .getCDOResourceNode_Name()); + + CDOResourceFolderClass resourceFolderClass = resourcePackage.getCDOResourceFolderClass(); + ((InternalCDOClass)resourceFolderClass).setClientInfo(EresourcePackage.eINSTANCE.getCDOResourceFolder()); + ((InternalCDOFeature)resourceFolderClass.getCDONodesFeature()).setClientInfo(EresourcePackage.eINSTANCE + .getCDOResourceFolder_Nodes()); + CDOResourceClass resourceClass = resourcePackage.getCDOResourceClass(); ((InternalCDOClass)resourceClass).setClientInfo(EresourcePackage.eINSTANCE.getCDOResource()); ((InternalCDOFeature)resourceClass.getCDOContentsFeature()).setClientInfo(EresourcePackage.eINSTANCE .getCDOResource_Contents()); - ((InternalCDOFeature)resourceClass.getCDOPathFeature()).setClientInfo(EresourcePackage.eINSTANCE - .getCDOResource_Path()); } } -- cgit v1.2.3