diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IStorageProvider.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IStorageProvider.java index de9c13044b50a1242ea78bc3bfccfc714a903154..b70073f96dd0f989a21804462beb3ec668ad1cca 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IStorageProvider.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/IStorageProvider.java @@ -19,6 +19,7 @@ package org.fortiss.tooling.kernel.extension; import java.util.List; +import org.fortiss.tooling.kernel.extension.data.ModelStorageError; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; /** @@ -28,6 +29,9 @@ import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; * like the Team feature or EMFStore providing remote storage capability. After * the context was provided to the kernel it invokes the methods of the context * to execute commands, save, an so on. + * <P> + * The {@link IStorageProvider} may report out-dated models (e.g. due to meta-model changes) to the + * kernel with the {@link #getStorageErrors()} method. * * <P> * By default, the kernel uses the Eclipse workspace resources and XML-based file storage. See @@ -36,7 +40,7 @@ import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: B4C8AB3B094357B7E39438196B6C5798 + * @ConQAT.Rating YELLOW Hash: 92D403C9923FAA1BCEC27781C23BB68D */ public interface IStorageProvider { @@ -46,4 +50,7 @@ public interface IStorageProvider { * successfully loaded models must be returned to the persitency service. */ List<ITopLevelElement> getTopLevelElements(); + + /** Returns the list of storage errors. */ + List<ModelStorageError> getStorageErrors(); } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/ModelStorageError.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/ModelStorageError.java new file mode 100644 index 0000000000000000000000000000000000000000..9f21a73fc2c38840e35e012d34b3f9a76305e70e --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/extension/data/ModelStorageError.java @@ -0,0 +1,52 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2013 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.extension.data; + +import org.fortiss.tooling.kernel.extension.IStorageProvider; + +/** + * Class for reporting errors during the load operation of {@link IStorageProvider}s. + * + * @author hoelzl + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating YELLOW Hash: C93A947E5A831F66341ACDD34343441F + */ +public class ModelStorageError { + + /** The cause exception. */ + private Exception cause; + /** The error message. */ + private String message; + + /** Constructor. */ + public ModelStorageError(String msg, Exception cause) { + this.message = msg; + this.cause = cause; + } + + /** Returns the exception that caused the model storage error. */ + public Exception getCause() { + return cause; + } + + /** Returns the error message. */ + public String getMessage() { + return message; + } +} diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PersistencyService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PersistencyService.java index 2628c44451a1c8158f210e558d13214037aaeb0b..266855387fc59bb44b4aeea86bff2d2304226140 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PersistencyService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/PersistencyService.java @@ -40,6 +40,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.ToolingKernelActivator; import org.fortiss.tooling.kernel.extension.IStorageProvider; +import org.fortiss.tooling.kernel.extension.data.ModelStorageError; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.service.IPersistencyService; import org.fortiss.tooling.kernel.service.listener.IPersistencyServiceListener; @@ -52,7 +53,7 @@ import org.osgi.framework.Bundle; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: DA27C565BD0AC1F080FAB4114C3965BD + * @ConQAT.Rating YELLOW Hash: 6FF152B18C6E73C9240F070F3541992F */ public class PersistencyService implements IPersistencyService { @@ -266,4 +267,14 @@ public class PersistencyService implements IPersistencyService { elementCache.remove(dummyCache.get(dummy)); dummyCache.remove(dummy); } + + /** {@inheritDoc} */ + @Override + public List<ModelStorageError> getAllStorageErrors() { + List<ModelStorageError> errors = new ArrayList<ModelStorageError>(); + for(IStorageProvider provider : storageProviderList) { + errors.addAll(provider.getStorageErrors()); + } + return errors; + } } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/storage/eclipse/EclipseResourceStorageProvider.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/storage/eclipse/EclipseResourceStorageProvider.java index 5508fa91c7a360e6ddbaa68093200a8be1552857..8073047edeb790d24429e0426e0cf5b52b752d5c 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/storage/eclipse/EclipseResourceStorageProvider.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/storage/eclipse/EclipseResourceStorageProvider.java @@ -52,6 +52,7 @@ import org.fortiss.tooling.kernel.ToolingKernelActivator; import org.fortiss.tooling.kernel.extension.IEclipseResourceStorageLocationProvider; import org.fortiss.tooling.kernel.extension.IStorageProvider; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; +import org.fortiss.tooling.kernel.extension.data.ModelStorageError; import org.fortiss.tooling.kernel.service.IEclipseResourceStorageService; import org.fortiss.tooling.kernel.service.IPersistencyService; import org.osgi.framework.Bundle; @@ -63,7 +64,7 @@ import org.osgi.framework.Bundle; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: BC8F00C99F1F865076DA8B37B5E76BEE + * @ConQAT.Rating YELLOW Hash: CD1228D699275835E9DA2E9079A5F264 */ public class EclipseResourceStorageProvider implements IEclipseResourceStorageService, IResourceChangeListener, IResourceDeltaVisitor, IStorageProvider { @@ -82,6 +83,9 @@ public class EclipseResourceStorageProvider implements IEclipseResourceStorageSe /** Cache of models loaded so far. */ private final Map<IFile, ModelContext> loadedContexts = new HashMap<IFile, ModelContext>(); + /** List of failed model storage files. */ + private final List<ModelStorageError> errorFiles = new ArrayList<ModelStorageError>(); + /** Map from toplevel elements to context. */ private final Map<EObject, ModelContext> rootElementContexts = new IdentityHashMap<EObject, ModelContext>(); @@ -216,8 +220,9 @@ public class EclipseResourceStorageProvider implements IEclipseResourceStorageSe loadedContexts.put(file, mc); rootElementContexts.put(mc.getRootModelElement(), mc); } catch(Exception ioex) { - error(ToolingKernelActivator.getDefault(), "Exception while loading model file: " + - file.getName(), ioex); + String msg = "Exception while loading model file: " + file.getName(); + errorFiles.add(new FileModelStorageError(msg, ioex, file)); + error(ToolingKernelActivator.getDefault(), msg, ioex); } } @@ -260,4 +265,33 @@ public class EclipseResourceStorageProvider implements IEclipseResourceStorageSe public List<IFile> getModelElementResources() { return new ArrayList<IFile>(loadedContexts.keySet()); } + + /** {@inheritDoc} */ + @Override + public List<ModelStorageError> getStorageErrors() { + checkFiles(); + return errorFiles; + } + + /** Checks the erroneous files for existence. */ + private void checkFiles() { + List<ModelStorageError> iter = new ArrayList<ModelStorageError>(errorFiles); + for(ModelStorageError err : iter) { + if(!((FileModelStorageError)err).file.exists()) { + errorFiles.remove(err); + } + } + } + + /** Class for file-based model errors. */ + private static class FileModelStorageError extends ModelStorageError { + /** The file. */ + public IFile file; + + /** Constructor. */ + public FileModelStorageError(String msg, Exception cause, IFile file) { + super(msg, cause); + this.file = file; + } + } } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/IPersistencyService.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/IPersistencyService.java index dfcf3ea28ba9155ef74376d4d6c3811f3da50f85..f3e915be8c0cc455c4bfa61cffb9e573d7b7abf7 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/IPersistencyService.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/service/IPersistencyService.java @@ -22,6 +22,7 @@ import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.extension.IStorageProvider; +import org.fortiss.tooling.kernel.extension.data.ModelStorageError; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.internal.PersistencyService; import org.fortiss.tooling.kernel.service.listener.IPersistencyServiceListener; @@ -41,7 +42,7 @@ import org.fortiss.tooling.kernel.service.listener.IPersistencyServiceListener; * @author hoelzl * @author $Author$ * @version $Rev$ - * @ConQAT.Rating GREEN Hash: A76C6B0A18E77C3F05A731AE11FAA0E0 + * @ConQAT.Rating YELLOW Hash: 340FD8B4B4B8FFF8E73395007D5ECC8D */ public interface IPersistencyService { @@ -95,4 +96,7 @@ public interface IPersistencyService { * is intended for JUnit testing purposes only. */ public void removeDummyTopLevelElement(EObject dummy); + + /** Returns all model storage errors from all storage providers. */ + public List<ModelStorageError> getAllStorageErrors(); }