Author: tfmorris
Date: 2008-08-19 09:06:02-0700
New Revision: 15583
Added:
trunk/src/argouml-app/tests/testmodels/uml14/href-test.xmi
trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceException.java (contents, props changed)
trunk/src/argouml-core-model/src/org/argouml/model/XmiReferenceException.java (contents, props changed)
Removed:
trunk/src/argouml-app/src/org/argouml/persistence/XmiReferenceException.java
Modified:
trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties
trunk/src/argouml-app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java
trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java
trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java
trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java
trunk/src/argouml-app/tests/org/argouml/persistence/TestXmiFilePersister.java
trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java
trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java
trunk/src/argouml-core-model/src/org/argouml/model/XmiException.java
Log:
RESOLVED - issue 5044: Improve error reporting for unresolved XMI HREFs
http://argouml.tigris.org/issues/show_bug.cgi?id=5044
Modified: trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties?view=diff&rev=15583&p1=trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties&p2=trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties&r1=15582&r2=15583
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties (original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties 2008-08-19 09:06:02-0700
@@ -68,8 +68,10 @@
the problem as a bug by going to \
<a href="http://argouml.tigris.org/project_bugs.html">\
http://argouml.tigris.org/project_bugs.html</a>.
-dialog.error.xmi.reference.error = XMI reference error : {0} \n\
- Please make sure that the profile is available:\n\
+dialog.error.xmi.reference.error = XMI external reference error attempting to read : {0} \n\
+ error message : {1} \n\
+ Please check that the referenced file is available.\n\
+ If the reference refers to a profile, make sure that the profile is available by doing the following:\n\
(1) Either load a module which contains that profile,\n\
(2) or make sure that the URL can be resolved,\n\
(3) or load it as a user defined profile in the profile configuration in \
Modified: trunk/src/argouml-app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java?view=diff&rev=15583&p1=trunk/src/argouml-app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java&r1=15582&r2=15583
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java 2008-08-19 09:06:02-0700
@@ -122,20 +122,20 @@
}
private static Profile handlePluginProfile(BufferedReader br)
- throws IOException, XmiReferenceException {
+ throws IOException, OpenException {
Profile profile;
String className = br.readLine().trim();
profile = ProfileFacade.getManager().getProfileForClass(
className);
if (profile == null)
- throw new XmiReferenceException(
+ throw new OpenException(
"Plugin profile \"" + className
+ "\" is not available in installation.", null);
return profile;
}
private static Profile handleUserDefinedProfile(BufferedReader br)
- throws IOException, XmiReferenceException {
+ throws IOException, OpenException {
String line;
Profile profile;
line = br.readLine().trim();
@@ -158,7 +158,7 @@
profile = getMatchingUserDefinedProfile(fileName,
profileManager);
if (profile == null) {
- throw new XmiReferenceException(
+ throw new OpenException(
"User defined profile \"" + fileName
+ "\" isn't available in the current configuration.",
null);
Modified: trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java?view=diff&rev=15583&p1=trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java&r1=15582&r2=15583
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java 2008-08-19 09:06:02-0700
@@ -77,7 +77,7 @@
/**
* To persist to and from argo (xml file) storage.
*
- * @author Bob Tarling, Thomas Neustupny
+ * @author Bob Tarling
*/
public class UmlFilePersister extends AbstractFilePersister {
@@ -104,11 +104,6 @@
private static final String ARGO_TEE =
"/org/argouml/persistence/argo.tee";
- // TODO: either don't rely on that string or move it elsewhere, it must
- // have the same value as used in org.argouml.model.mdr.XmiReaderImpl:
- private static final String REFERENCE_ERROR =
- "Error reading external document ";
-
/**
* The constructor.
*/
@@ -312,7 +307,7 @@
protected Project doLoad(File originalFile, File file,
ProgressMgr progressMgr) throws OpenException,
- InterruptedException, XmiReferenceException {
+ InterruptedException {
XmlInputStream inputStream = null;
try {
@@ -382,12 +377,6 @@
inputStream.reopen("uml:Model");
persister.load(p, inputStream);
} else {
- int ix = e.getMessage().indexOf(REFERENCE_ERROR);
- if (ix != -1) {
- // detected failed external reference loading
- throw new XmiReferenceException(
- e.getMessage(), null);
- }
throw e;
}
}
Removed: trunk/src/argouml-app/src/org/argouml/persistence/XmiReferenceException.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/XmiReferenceException.java?view=auto&rev=15582
Modified: trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java?view=diff&rev=15583&p1=trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java&p2=trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java&r1=15582&r2=15583
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java 2008-08-19 09:06:02-0700
@@ -80,6 +80,7 @@
import org.argouml.kernel.Project;
import org.argouml.kernel.ProjectManager;
import org.argouml.model.Model;
+import org.argouml.model.XmiReferenceException;
import org.argouml.persistence.AbstractFilePersister;
import org.argouml.persistence.OpenException;
import org.argouml.persistence.PersistenceManager;
@@ -88,7 +89,6 @@
import org.argouml.persistence.UmlVersionException;
import org.argouml.persistence.VersionException;
import org.argouml.persistence.XmiFormatException;
-import org.argouml.persistence.XmiReferenceException;
import org.argouml.taskmgmt.ProgressMonitor;
import org.argouml.ui.cmd.GenericArgoMenuBar;
import org.argouml.ui.targetmanager.TargetEvent;
@@ -1670,23 +1670,27 @@
"dialog.error.file.version.error",
new Object[] {ex.getMessage()}),
showUI, ex);
- } catch (XmiReferenceException ex) {
- // an error that can be corrected by the user, so no stack
- // trace, but instead an explanation and a hint how to fix it
- reportError(
- pmw,
- Translator.localize(
- "dialog.error.xmi.reference.error",
- new Object[] {ex.getMessage()}),
- ex.toString(),
- showUI);
} catch (XmiFormatException ex) {
- reportError(
- pmw,
- Translator.localize(
- "dialog.error.xmi.format.error",
- new Object[] {ex.getMessage()}),
- showUI, ex);
+ if (ex.getCause() instanceof XmiReferenceException) {
+ // an error that can be corrected by the user, so no stack
+ // trace, but instead an explanation and a hint how to fix
+ String reference =
+ ((XmiReferenceException) ex.getCause()).getReference();
+ reportError(
+ pmw,
+ Translator.localize(
+ "dialog.error.xmi.reference.error",
+ new Object[] {reference, ex.getMessage()}),
+ ex.toString(),
+ showUI);
+ } else {
+ reportError(
+ pmw,
+ Translator.localize(
+ "dialog.error.xmi.format.error",
+ new Object[] {ex.getMessage()}),
+ showUI, ex);
+ }
} catch (IOException ex) {
LOG.error("Exception while loading project", ex);
reportError(
Modified: trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java?view=diff&rev=15583&p1=trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java&p2=trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java&r1=15582&r2=15583
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/kernel/TestProjectWithProfiles.java 2008-08-19 09:06:02-0700
@@ -27,7 +27,6 @@
import static org.argouml.model.Model.getCoreFactory;
import static org.argouml.model.Model.getExtensionMechanismsHelper;
import static org.argouml.model.Model.getFacade;
-import static org.argouml.model.Model.getModelManagementFactory;
import java.io.File;
import java.io.IOException;
@@ -41,11 +40,12 @@
import org.argouml.application.helpers.ApplicationVersion;
import org.argouml.model.InitializeModel;
import org.argouml.model.Model;
+import org.argouml.model.XmiReferenceException;
import org.argouml.persistence.AbstractFilePersister;
import org.argouml.persistence.OpenException;
import org.argouml.persistence.PersistenceManager;
import org.argouml.persistence.SaveException;
-import org.argouml.persistence.XmiReferenceException;
+import org.argouml.persistence.XmiFormatException;
import org.argouml.profile.Profile;
import org.argouml.profile.ProfileFacade;
import org.argouml.profile.ProfileManager;
@@ -152,7 +152,7 @@
javaProfile));
// create a dependency from the project's model to the UML profile for
// Java
- Object model = getModelManagementFactory().getRootModel();
+ Object model = project.getUserDefinedModelList().get(0);
assertNotNull(model);
Object fooClass = Model.getCoreFactory().buildClass("Foo", model);
Object javaListType = project.findType("List", false);
@@ -180,6 +180,8 @@
AbstractFilePersister persister = getProjectPersister(file);
project.setVersion(ApplicationVersion.getVersion());
persister.save(project, file);
+ project.remove();
+
// reopen the project and assert that the Java profile isn't part of
// the profile configuration, including the fact that the type
// java.util.List isn't found
@@ -250,7 +252,7 @@
project.getProfileConfiguration().addProfile(userDefinedProfile);
// create a dependency between the project's model and the user defined
// profile
- Object model = getModelManagementFactory().getRootModel();
+ Object model = project.getUserDefinedModelList().get(0);
Model.getCoreHelper().setName(model,
"testProjectWithUserDefinedProfilePersistency-model");
Object fooClass = getCoreFactory().buildClass(
@@ -275,6 +277,8 @@
AbstractFilePersister persister = getProjectPersister(file);
project.setVersion(ApplicationVersion.getVersion());
persister.save(project, file);
+ project.remove();
+
// load the project
project = persister.doLoad(file);
project.postLoad();
@@ -328,7 +332,7 @@
project.getProfileConfiguration().addProfile(userDefinedProfile);
// create a dependency between the project's model and the user defined
// profile
- Object model = getModelManagementFactory().getRootModel();
+ Object model = project.getUserDefinedModelList().get(0);
final String className = "Foo4" + testName;
Object fooClass = getCoreFactory().buildClass(className, model);
Collection stereotypes = getExtensionMechanismsHelper().getStereotypes(
@@ -357,8 +361,8 @@
try {
project = persister.doLoad(file);
fail("Failed to throw exception for missing user defined profile");
- } catch (XmiReferenceException e) {
- // success
+ } catch (OpenException e) {
+ // Success - expected exception
}
}
Modified: trunk/src/argouml-app/tests/org/argouml/persistence/TestXmiFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/persistence/TestXmiFilePersister.java?view=diff&rev=15583&p1=trunk/src/argouml-app/tests/org/argouml/persistence/TestXmiFilePersister.java&p2=trunk/src/argouml-app/tests/org/argouml/persistence/TestXmiFilePersister.java&r1=15582&r2=15583
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/persistence/TestXmiFilePersister.java (original)
+++ trunk/src/argouml-app/tests/org/argouml/persistence/TestXmiFilePersister.java 2008-08-19 09:06:02-0700
@@ -28,12 +28,13 @@
import java.net.URL;
import junit.framework.TestCase;
-import org.argouml.model.InitializeModel;
import org.argouml.kernel.Project;
import org.argouml.kernel.ProjectManager;
+import org.argouml.model.InitializeModel;
import org.argouml.model.Model;
-import org.argouml.profile.init.InitProfileSubsystem;
+import org.argouml.model.XmiReferenceException;
+import org.argouml.profile.ProfileFacade;
/**
* Testclass for the XMIReader. Placeholder for all saving/loading tests
@@ -57,8 +58,14 @@
*/
public void setUp() throws Exception {
super.setUp();
- InitializeModel.initializeMDR();
- new InitProfileSubsystem().init();
+ if (!Model.isInitiated()) {
+ InitializeModel.initializeMDR();
+ }
+// new InitProfileSubsystem().init();
+ // TODO: Why is this necessary? - tfm
+ // Always force reinitialization of Profile subsystem
+ ProfileFacade.setManager(
+ new org.argouml.profile.internal.ProfileManagerImpl());
}
/**
@@ -100,6 +107,7 @@
*/
public void testCreateSaveAndLoadYieldsCorrectModel() throws Exception {
Project project = ProjectManager.getManager().makeEmptyProject();
+ ProjectManager.getManager().setCurrentProject(project);
Object model = Model.getModelManagementFactory().getRootModel();
assertNotNull(model);
Object classifier = Model.getCoreFactory().buildClass("Foo", model);
@@ -124,15 +132,20 @@
Model.getUmlFactory().delete(classifier);
- ProjectManager.getManager().makeEmptyProject();
+ ProjectManager.getManager().removeProject(project);
+ project = ProjectManager.getManager().makeEmptyProject();
+ ProjectManager.getManager().setCurrentProject(project);
persister = new XmiFilePersister();
project = persister.doLoad(file);
+ ProjectManager.getManager().setCurrentProject(project);
+
Object attType = checkFoo(project.findType("Foo", false));
assertEquals("Integer", Model.getFacade().getName(attType));
file.delete();
+ ProjectManager.getManager().removeProject(project);
}
private Object checkFoo(Object theClass) {
@@ -155,9 +168,12 @@
XmiFilePersister persister = new XmiFilePersister();
- ProjectManager.getManager().makeEmptyProject();
+ Project project = ProjectManager.getManager().makeEmptyProject();
+ ProjectManager.getManager().setCurrentProject(project);
persister.doLoad(file);
+
+ ProjectManager.getManager().removeProject(project);
}
/**
@@ -174,8 +190,45 @@
XmiFilePersister persister = new XmiFilePersister();
- ProjectManager.getManager().makeEmptyProject();
+ Project project = ProjectManager.getManager().makeEmptyProject();
+ ProjectManager.getManager().setCurrentProject(project);
persister.doLoad(new File(name));
+
+ ProjectManager.getManager().removeProject(project);
+ }
+
+ /**
+ * Test loading an XMI file with a bad external reference (HREF).
+ *
+ * @throws Exception if loading project fails
+ */
+ public void testLoadBadHref() throws Exception {
+ String filename = "/testmodels/uml14/href-test.xmi";
+ URL url = TestZargoFilePersister.class.getResource(filename);
+ assertTrue("Unintended failure: resource to be tested is not found: "
+ + filename + ", converted to URL: " + url, url != null);
+ String name = url.getFile();
+
+ XmiFilePersister persister = new XmiFilePersister();
+
+ Project project = ProjectManager.getManager().makeEmptyProject();
+ ProjectManager.getManager().setCurrentProject(project);
+
+ try {
+ persister.doLoad(new File(name));
+ fail("Expected exception not thrown");
+ } catch (OpenException e) {
+ // Success - expected exception
+ if (e.getCause() instanceof XmiReferenceException) {
+ XmiReferenceException xre =
+ (XmiReferenceException) e.getCause();
+ assertTrue(xre.getReference().contains("bad-reference"));
+ } else {
+ fail("Unexpected exception cause");
+ }
+ } finally {
+ ProjectManager.getManager().removeProject(project);
+ }
}
}
Added: trunk/src/argouml-app/tests/testmodels/uml14/href-test.xmi
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/testmodels/uml14/href-test.xmi?view=auto&rev=15583
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/tests/testmodels/uml14/href-test.xmi 2008-08-19 09:06:02-0700
@@ -0,0 +1,43 @@
+<?xml version = '1.0' encoding = 'UTF-8' ?>
+<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Tue Aug 19 02:00:27 EDT 2008'>
+ <XMI.header> <XMI.documentation>
+ <XMI.exporter>ArgoUML (using Netbeans XMI Writer version 1.0)</XMI.exporter>
+ <XMI.exporterVersion>PRE-0.26.beta1(6) revised on $Date: 2007-05-12 02:08:08 -0400 (Sat, 12 May 2007) $ </XMI.exporterVersion>
+ </XMI.documentation>
+ <XMI.metamodel xmi.name="UML" xmi.version="1.4"/></XMI.header>
+ <XMI.content>
+ <UML:Model xmi.id = '-64--88-1-101--36241a54:11bd98ab81c:-8000:0000000000000B06'
+ name = 'untitledModel' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
+ isAbstract = 'false'>
+ <UML:Namespace.ownedElement>
+ <UML:Class xmi.id = '-64--88-1-101--36241a54:11bd98ab81c:-8000:0000000000000B07'
+ name = 'MyClass' visibility = 'public' isSpecification = 'false' isRoot = 'false'
+ isLeaf = 'false' isAbstract = 'false' isActive = 'false'>
+ <UML:Classifier.feature>
+ <UML:Attribute xmi.id = '-64--88-1-101--36241a54:11bd98ab81c:-8000:0000000000000B08'
+ name = 'myAttribute' visibility = 'public' isSpecification = 'false' ownerScope = 'instance'
+ changeability = 'changeable' targetScope = 'instance'>
+ <UML:StructuralFeature.multiplicity>
+ <UML:Multiplicity xmi.id = '-64--88-1-101--36241a54:11bd98ab81c:-8000:0000000000000B0C'>
+ <UML:Multiplicity.range>
+ <UML:MultiplicityRange xmi.id = '-64--88-1-101--36241a54:11bd98ab81c:-8000:0000000000000B0B'
+ lower = '1' upper = '1'/>
+ </UML:Multiplicity.range>
+ </UML:Multiplicity>
+ </UML:StructuralFeature.multiplicity>
+ <UML:StructuralFeature.type>
+ <UML:DataType href = 'bad-reference.xmi#-84-17--56-5-43645a83:11466542d86:-8000:000000000000087E'/>
+ </UML:StructuralFeature.type>
+ </UML:Attribute>
+ </UML:Classifier.feature>
+ </UML:Class>
+ </UML:Namespace.ownedElement>
+ </UML:Model>
+ <UML:Multiplicity xmi.id = '-64--88-1-101--36241a54:11bd98ab81c:-8000:0000000000000B09'>
+ <UML:Multiplicity.range>
+ <UML:MultiplicityRange xmi.id = '-64--88-1-101--36241a54:11bd98ab81c:-8000:0000000000000B0A'
+ lower = '1' upper = '1'/>
+ </UML:Multiplicity.range>
+ </UML:Multiplicity>
+ </XMI.content>
+</XMI>
Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java?view=diff&rev=15583&p1=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java&p2=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java&r1=15582&r2=15583
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java (original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java 2008-08-19 09:06:02-0700
@@ -57,6 +57,7 @@
import org.argouml.model.UmlException;
import org.argouml.model.XmiException;
import org.argouml.model.XmiReader;
+import org.argouml.model.XmiReferenceException;
import org.netbeans.api.xmi.XMIReader;
import org.netbeans.api.xmi.XMIReaderFactory;
import org.netbeans.lib.jmi.xmi.InputConfig;
@@ -259,11 +260,6 @@
}
} catch (MalformedXMIException e) {
- // If we failed reading an external referenced document (href)
- if (resolver.getLastFailedExternalReference() != null) {
- throw new XmiException("Error reading external document "
- + resolver.getLastFailedExternalReference());
- }
// If we can find a nested SAX exception, it will have information
// on the line number, etc.
ErrorManager.Annotation[] annotations =
@@ -275,6 +271,16 @@
throw new XmiException(spe.getMessage(), spe.getPublicId(),
spe.getSystemId(), spe.getLineNumber(),
spe.getColumnNumber(), e);
+ } else if (throwable instanceof SAXException) {
+ SAXException se = (SAXException) throwable;
+ Exception e1 = se.getException();
+ if (e1 instanceof org.argouml.model.mdr.XmiReferenceException) {
+ String href = ((org.argouml.model.mdr.XmiReferenceException) e1)
+ .getReference();
+ throw new org.argouml.model.XmiReferenceException(href,
+ e);
+ }
+ throw new XmiException(se.getMessage(), se);
}
}
modelImpl.removeExtent(extent);
Added: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceException.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceException.java?view=auto&rev=15583
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceException.java 2008-08-19 09:06:02-0700
@@ -0,0 +1,76 @@
+// $Id$
+// Copyright (c) 2006 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.model.mdr;
+
+
+/**
+ * Exception for external reference problems with XMI files. This is an
+ * internal MDR exception which extends RuntimeException so that it can be
+ * thrown from MDR internals.
+ *
+ * @author Tom Morris
+ */
+public class XmiReferenceException extends RuntimeException {
+
+ private String reference;
+
+ /**
+ * Construct an XmiReferenceException with the given message.
+ *
+ * @param message the message
+ */
+ public XmiReferenceException(String message) {
+ super(message);
+ }
+
+ /**
+ * Construct an XmiReferenceException for the given reference
+ *
+ * @param href the reference that caused the error
+ * @param cause the nested exception if available
+ */
+ public XmiReferenceException(String href, Throwable cause) {
+ super(href, cause);
+ reference = href;
+ }
+
+ /**
+ * @return the external reference (href) that caused the exception
+ */
+ public String getReference() {
+ return reference;
+ }
+
+ /**
+ * Construct an exception with a causing exception.
+ *
+ * @param c the cause of the exception
+ */
+ public XmiReferenceException(Throwable c) {
+ super(c);
+ }
+
+
+}
Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java?view=diff&rev=15583&p1=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java&p2=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java&r1=15582&r2=15583
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java (original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java 2008-08-19 09:06:02-0700
@@ -126,13 +126,7 @@
private Map<String, String> public2SystemIds;
private String modelPublicId;
-
- /**
- * The URL of the last document that we failed to read. Used for error
- * reporting if the read fails inside MDR.
- */
- private String lastFailedExternalReference = null;
-
+
/**
* Constructor.
* @param systemId
@@ -260,17 +254,8 @@
idToObjects.clear();
objectsToId.clear();
}
-
- /**
- * Gets the URL of the last document that we attempted to read. Used for
- * error reporting if the read fails inside MDR.
- *
- * @return URL of the last document that we attempted to read
- */
- public String getLastFailedExternalReference() {
- return lastFailedExternalReference;
- }
-
+
+
/////////////////////////////////////////////////////
////////// Begin AndroMDA Code //////////////////////
/////////////////////////////////////////////////////
@@ -349,6 +334,8 @@
// composition error problem - tfm
reverseUrlMap.put(modelUrl.toString(), relativeUri);
reverseUrlMap.put(systemId, relativeUri);
+ } else {
+ // TODO: We failed to resolve URL - signal error
}
}
return modelUrl;
@@ -376,9 +363,10 @@
}
for (String moduleDirectory : modulesPath) {
File candidate = new File(moduleDirectory, moduleName);
- if (LOG.isDebugEnabled())
+ if (LOG.isDebugEnabled()) {
LOG.debug("candidate '" + candidate.toString() + "' exists="
+ candidate.exists());
+ }
if (candidate.exists()) {
String urlString;
try {
@@ -391,10 +379,11 @@
}
}
if (public2SystemIds.containsKey(moduleName)) {
- if (LOG.isDebugEnabled())
+ if (LOG.isDebugEnabled()) {
LOG.debug("Couldn't find user model (\"" + moduleName
+ "\") in modulesPath, attempt "
+ "to use a model stored within the zargo file.");
+ }
return moduleName;
}
return null;
@@ -476,9 +465,10 @@
if (CLASSPATH_MODEL_SUFFIXES != null
&& CLASSPATH_MODEL_SUFFIXES.length > 0) {
for (String suffix : CLASSPATH_MODEL_SUFFIXES) {
- if (LOG.isDebugEnabled())
+ if (LOG.isDebugEnabled()) {
LOG.debug("searching for model reference --> '"
+ modelUrl + "'");
+ }
modelUrl = Thread.currentThread().getContextClassLoader()
.getResource(modelName + dot + suffix);
if (modelUrl != null) {
@@ -544,13 +534,15 @@
@Override
public void readExternalDocument(String arg0) {
- lastFailedExternalReference = null;
try {
super.readExternalDocument(arg0);
} catch (DebugException e) {
- lastFailedExternalReference = arg0;
+ // Unfortunately the MDR super implementation throws
+ // DebugException with just the message from the causing
+ // exception rather than nesting the exception itself, so
+ // we don't have all the information we'd like
LOG.error("Error reading external document " + arg0);
- throw e;
+ throw new XmiReferenceException(arg0, e);
}
}
}
Modified: trunk/src/argouml-core-model/src/org/argouml/model/XmiException.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/src/org/argouml/model/XmiException.java?view=diff&rev=15583&p1=trunk/src/argouml-core-model/src/org/argouml/model/XmiException.java&p2=trunk/src/argouml-core-model/src/org/argouml/model/XmiException.java&r1=15582&r2=15583
==============================================================================
--- trunk/src/argouml-core-model/src/org/argouml/model/XmiException.java (original)
+++ trunk/src/argouml-core-model/src/org/argouml/model/XmiException.java 2008-08-19 09:06:02-0700
@@ -70,7 +70,7 @@
}
/**
- * Create a new SAXParseException.
+ * Create a new XmiException.
*
* @param message The error or warning message.
* @param publicId The public identifier of the entity that generated
@@ -90,7 +90,7 @@
/**
- * Create a new SAXParseException with an embedded exception.
+ * Create a new XmiException with an embedded exception.
*
* @param message The error or warning message, or null to use the message
* from the embedded exception.
Added: trunk/src/argouml-core-model/src/org/argouml/model/XmiReferenceException.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model/src/org/argouml/model/XmiReferenceException.java?view=auto&rev=15583
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-model/src/org/argouml/model/XmiReferenceException.java 2008-08-19 09:06:02-0700
@@ -0,0 +1,123 @@
+// $Id$
+// Copyright (c) 2006 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.model;
+
+
+/**
+ * Exception for external reference problems with XMI files.
+ *
+ * @author Tom Morris
+ */
+public class XmiReferenceException extends XmiException {
+
+ private String reference;
+
+ /**
+ * Construct an XmiReferenceException with the given message.
+ *
+ * @param message the message
+ */
+ public XmiReferenceException(String message) {
+ super(message);
+ }
+
+// /**
+// * Construct an exception with a message and a causing exception.
+// *
+// * @param message the message
+// * @param c the cause of the exception
+// */
+// public XmiReferenceException(String message, Throwable c) {
+// super(message, c);
+// }
+
+ /**
+ * Construct an XmiReferenceException for the given reference
+ *
+ * @param href the reference that caused the error
+ * @param cause the nested exception if available
+ */
+ public XmiReferenceException(String href, Throwable cause) {
+ super(href, cause);
+ reference = href;
+ }
+
+ /**
+ * @return the external reference (href) that caused the exception
+ */
+ public String getReference() {
+ return reference;
+ }
+
+ /**
+ * Construct an exception with a causing exception.
+ *
+ * @param c the cause of the exception
+ */
+ public XmiReferenceException(Throwable c) {
+ super(c);
+ }
+
+ /**
+ * Create a new XmiReferenceException.
+ *
+ * @param message The error or warning message.
+ * @param publicId The public identifier of the entity that generated
+ * the error or warning.
+ * @param systemId The system identifier of the entity that generated
+ * the error or warning.
+ * @param lineNumber The line number of the end of the text that
+ * caused the error or warning.
+ * @param columnNumber The column number of the end of the text that
+ * cause the error or warning.
+ */
+ public XmiReferenceException(String message, String publicId,
+ String systemId, int lineNumber, int columnNumber) {
+ super(message, publicId, systemId, lineNumber, columnNumber);
+ }
+
+
+ /**
+ * Create a new XmiReferenceException with an embedded exception.
+ *
+ * @param message The error or warning message, or null to use the message
+ * from the embedded exception.
+ * @param publicId The public identifier of the entity that generated the
+ * error or warning.
+ * @param systemId The system identifier of the entity that generated the
+ * error or warning.
+ * @param lineNumber The line number of the end of the text that caused the
+ * error or warning.
+ * @param columnNumber The column number of the end of the text that cause
+ * the error or warning.
+ * @param e Another exception to embed in this one.
+ */
+ public XmiReferenceException(String message, String publicId,
+ String systemId, int lineNumber, int columnNumber, Exception e) {
+ super(message, publicId, systemId, lineNumber, columnNumber, e);
+ }
+
+
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.