Skip to content
Snippets Groups Projects
Commit 2373b14d authored by Florian Hölzl's avatar Florian Hölzl
Browse files

implemented model storage error log

refs 1086
parent 36361fb6
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
/*--------------------------------------------------------------------------+
$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;
}
}
......@@ -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;
}
}
......@@ -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;
}
}
}
......@@ -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();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment