diff options
author | kwilk | 2012-04-05 14:26:06 -0400 |
---|---|---|
committer | Roberto E. Escobar | 2012-04-05 14:26:06 -0400 |
commit | bd1ba6260391302aaba0212fd6e3cb0366522d2f (patch) | |
tree | 2a4e5d5161dcf94af7c398275ca48f23260a3e3e | |
parent | 6d29b94e3e03afe335d40047af45888434e6bcee (diff) | |
download | org.eclipse.osee-bd1ba6260391302aaba0212fd6e3cb0366522d2f.zip org.eclipse.osee-bd1ba6260391302aaba0212fd6e3cb0366522d2f.tar.gz org.eclipse.osee-bd1ba6260391302aaba0212fd6e3cb0366522d2f.tar.xz |
feature: OseeVersion into OseeExceptions.wrapAndThrow()
29 files changed, 535 insertions, 23 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/test/exception/ExceptionTestSuite.java b/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/test/exception/ExceptionTestSuite.java index c7addf1..e03aeac 100644 --- a/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/test/exception/ExceptionTestSuite.java +++ b/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/test/exception/ExceptionTestSuite.java @@ -14,7 +14,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) -@Suite.SuiteClasses({OseeCoreExceptionTest.class}) +@Suite.SuiteClasses({OseeCoreExceptionTest.class, OseeExceptionsTest.class}) /** * @author Ryan D. Brooks */ diff --git a/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/test/exception/OseeExceptionsTest.java b/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/test/exception/OseeExceptionsTest.java new file mode 100644 index 0000000..4f9deec --- /dev/null +++ b/plugins/org.eclipse.osee.framework.core.test/src/org/eclipse/osee/framework/core/test/exception/OseeExceptionsTest.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2012 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.core.test.exception; + +import junit.framework.Assert; +import org.eclipse.osee.framework.core.data.OseeCodeVersion; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.exception.OseeExceptions; +import org.eclipse.osee.framework.core.exception.OseeWrappedException; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +/** + * {@link OseeExceptions} + * + * @author Karol Wilk + */ +public class OseeExceptionsTest { + + @Rule + public TestName test = new TestName(); + + @Test + public void test_wrapAndThrow_RuntimeException() { + String resultMessage = null; + + try { + OseeExceptions.wrapAndThrow(new RuntimeException(test.getMethodName())); + } catch (Exception ex) { + Assert.assertTrue(ex.getStackTrace().length > 0); + resultMessage = ex.getMessage(); + } + Assert.assertNotNull(resultMessage); + Assert.assertTrue(resultMessage.contains(OseeCodeVersion.getVersion())); + Assert.assertTrue(resultMessage.contains(test.getMethodName())); + } + + @Test + public void test_wrapAndThrow_OseeCoreException() { + String resultMessage = null; + + try { + OseeExceptions.wrapAndThrow(new OseeCoreException(test.getMethodName())); + } catch (OseeCoreException ex) { + Assert.assertTrue(ex.getStackTrace().length > 0); + resultMessage = ex.getMessage(); + } + Assert.assertNotNull(resultMessage); + Assert.assertTrue(resultMessage.contains(OseeCodeVersion.getVersion())); + Assert.assertTrue(resultMessage.contains(test.getMethodName())); + } + + @Test + public void test_wrapAndThrow_OseeWrappedException() { + String resultMessage = null; + + try { + OseeExceptions.wrapAndThrow(new OseeWrappedException(test.getMethodName(), new Throwable())); + } catch (OseeCoreException ex) { + Assert.assertTrue(ex.getStackTrace().length > 0); + resultMessage = ex.getMessage(); + } + Assert.assertNotNull(resultMessage); + Assert.assertTrue(resultMessage.contains(OseeCodeVersion.getVersion())); + Assert.assertTrue(resultMessage.contains(test.getMethodName())); + } +} diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeCodeVersion.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeCodeVersion.java index 2d7d2f8..f01308a 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeCodeVersion.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeCodeVersion.java @@ -11,8 +11,9 @@ package org.eclipse.osee.framework.core.data; -import org.eclipse.osee.framework.core.internal.Activator; +import org.eclipse.osee.framework.jdk.core.util.Strings; import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; import org.osgi.framework.Version; /** @@ -26,25 +27,30 @@ public final class OseeCodeVersion { } /** - * Gets version - * - * @return the version + * @return version <b>V</b> from <code>-Dosee.version <b>V</b></code> or pull one from + * <code>OseeCodeVersion.getBundleVersion()</code> */ public static String getVersion() { - if (!System.getProperty("osee.version", "").equals("")) { - return System.getProperty("osee.version", ""); + String version = System.getProperty("osee.version", ""); + if (!Strings.isValid(version)) { + version = getBundleVersion(); + if (isDevelopment(version)) { + version = "Development"; + } } - String bundleVersion = getBundleVersion(); - if (isDevelopment(bundleVersion)) { - return "Development"; - } - return bundleVersion; + return version; } + /** + * @return bundle version or "" + */ public static String getBundleVersion() { - Bundle bundle = Activator.getBundleContext().getBundle(); - Version version = bundle.getVersion(); - return version.toString(); + Bundle bundle = FrameworkUtil.getBundle(OseeCodeVersion.class); + Version version = null; + if (bundle != null) { + version = bundle.getVersion(); + } + return version != null ? version.toString() : ""; } public static boolean isDevelopment() { @@ -53,6 +59,6 @@ public final class OseeCodeVersion { private static boolean isDevelopment(String version) { // The version of this bundle ends with .qualifier until it is replaced by PDE build with a time stamp - return version.endsWith("qualifier"); + return !Strings.isValid(version) || version.endsWith("qualifier"); } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/ArtifactDoesNotExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/ArtifactDoesNotExist.java index 35b43a3..1c52f99 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/ArtifactDoesNotExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/ArtifactDoesNotExist.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Donald G. Dunne */ @@ -20,4 +22,20 @@ public class ArtifactDoesNotExist extends OseeCoreException { public ArtifactDoesNotExist(String message, Object... args) { super(message, args); } + + public ArtifactDoesNotExist(IStatus status) { + super(status); + } + + public ArtifactDoesNotExist(String message, Throwable cause) { + super(message, cause); + } + + public ArtifactDoesNotExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public ArtifactDoesNotExist(Throwable cause) { + super(cause); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/AttributeDoesNotExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/AttributeDoesNotExist.java index 8077cb4..57737a1 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/AttributeDoesNotExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/AttributeDoesNotExist.java @@ -11,6 +11,8 @@ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Donald G. Dunne */ @@ -21,4 +23,20 @@ public class AttributeDoesNotExist extends OseeCoreException { public AttributeDoesNotExist(String message, Object... args) { super(message, args); } + + public AttributeDoesNotExist(IStatus status) { + super(status); + } + + public AttributeDoesNotExist(String message, Throwable cause) { + super(message, cause); + } + + public AttributeDoesNotExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public AttributeDoesNotExist(Throwable cause) { + super(cause); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/BranchDoesNotExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/BranchDoesNotExist.java index 97888e4..ff85199 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/BranchDoesNotExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/BranchDoesNotExist.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Ryan D. Brooks */ @@ -19,4 +21,20 @@ public class BranchDoesNotExist extends OseeCoreException { public BranchDoesNotExist(String message, Object... args) { super(message, args); } + + public BranchDoesNotExist(IStatus status) { + super(status); + } + + public BranchDoesNotExist(String message, Throwable cause) { + super(message, cause); + } + + public BranchDoesNotExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public BranchDoesNotExist(Throwable cause) { + super(cause); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/BranchMergeException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/BranchMergeException.java index 47c16b7..3fa73c2 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/BranchMergeException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/BranchMergeException.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Donald G. Dunne */ @@ -20,4 +22,20 @@ public class BranchMergeException extends OseeCoreException { public BranchMergeException(String message, Object... args) { super(message, args); } + + public BranchMergeException(IStatus status) { + super(status); + } + + public BranchMergeException(String message, Throwable cause) { + super(message, cause); + } + + public BranchMergeException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public BranchMergeException(Throwable cause) { + super(cause); + } } diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/ItemDoesNotExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/ItemDoesNotExist.java index 39d707d..c835aa6 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/ItemDoesNotExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/ItemDoesNotExist.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; /** * @author Roberto E. Escobar @@ -21,4 +22,20 @@ public class ItemDoesNotExist extends OseeCoreException { public ItemDoesNotExist(String message, Object... args) { super(message, args); } + + public ItemDoesNotExist(IStatus status) { + super(status); + } + + public ItemDoesNotExist(String message, Throwable cause) { + super(message, cause); + } + + public ItemDoesNotExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public ItemDoesNotExist(Throwable cause) { + super(cause); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleArtifactsExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleArtifactsExist.java index 7c77fdb..f77daf3 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleArtifactsExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleArtifactsExist.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Donald G. Dunne */ @@ -20,4 +22,20 @@ public class MultipleArtifactsExist extends OseeCoreException { public MultipleArtifactsExist(String message, Object... args) { super(message, args); } + + public MultipleArtifactsExist(IStatus status) { + super(status); + } + + public MultipleArtifactsExist(String message, Throwable cause) { + super(message, cause); + } + + public MultipleArtifactsExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public MultipleArtifactsExist(Throwable cause) { + super(cause); + } } diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleAttributesExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleAttributesExist.java index eeef19d..f8fc2b8 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleAttributesExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleAttributesExist.java @@ -11,11 +11,29 @@ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Donald G. Dunne */ public class MultipleAttributesExist extends OseeCoreException { + public MultipleAttributesExist(IStatus status) { + super(status); + } + + public MultipleAttributesExist(String message, Throwable cause) { + super(message, cause); + } + + public MultipleAttributesExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public MultipleAttributesExist(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = 1L; public MultipleAttributesExist(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleBranchesExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleBranchesExist.java index 5b1288c..3cc6dde 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleBranchesExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleBranchesExist.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Donald G. Dunne */ @@ -20,4 +22,20 @@ public class MultipleBranchesExist extends OseeCoreException { public MultipleBranchesExist(String message, Object... args) { super(message, args); } + + public MultipleBranchesExist(IStatus status) { + super(status); + } + + public MultipleBranchesExist(String message, Throwable cause) { + super(message, cause); + } + + public MultipleBranchesExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public MultipleBranchesExist(Throwable cause) { + super(cause); + } } diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleItemsExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleItemsExist.java index f78872b..ef4a5b0 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleItemsExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/MultipleItemsExist.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; /** * @author Roberto E. Escobar @@ -21,4 +22,20 @@ public class MultipleItemsExist extends OseeCoreException { public MultipleItemsExist(String message, Object... args) { super(message, args); } + + public MultipleItemsExist(IStatus status) { + super(status); + } + + public MultipleItemsExist(String message, Throwable cause) { + super(message, cause); + } + + public MultipleItemsExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public MultipleItemsExist(Throwable cause) { + super(cause); + } } diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAccessDeniedException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAccessDeniedException.java index efc96f7..275d68f 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAccessDeniedException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAccessDeniedException.java @@ -10,11 +10,29 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Roberto E. Escobar */ public class OseeAccessDeniedException extends OseeCoreException { + public OseeAccessDeniedException(IStatus status) { + super(status); + } + + public OseeAccessDeniedException(String message, Throwable cause) { + super(message, cause); + } + + public OseeAccessDeniedException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public OseeAccessDeniedException(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = 1L; public OseeAccessDeniedException(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeArgumentException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeArgumentException.java index c6a0835..0f77fd2 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeArgumentException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeArgumentException.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Donald G. Dunne */ @@ -20,4 +22,21 @@ public class OseeArgumentException extends OseeCoreException { public OseeArgumentException(String message, Object... args) { super(message, args); } + + public OseeArgumentException(IStatus status) { + super(status); + } + + public OseeArgumentException(String message, Throwable cause) { + super(message, cause); + } + + public OseeArgumentException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public OseeArgumentException(Throwable cause) { + super(cause); + } + } diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAuthenticationException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAuthenticationException.java index c107695..0aa056f 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAuthenticationException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAuthenticationException.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Roberto E. Escobar */ @@ -32,6 +34,26 @@ public class OseeAuthenticationException extends OseeCoreException { this.errorCode = null; } + public OseeAuthenticationException(IStatus status) { + super(status); + this.errorCode = null; + } + + public OseeAuthenticationException(String message, Throwable cause) { + super(message, cause); + this.errorCode = null; + } + + public OseeAuthenticationException(Throwable cause, String message, Object... args) { + super(cause, message, args); + this.errorCode = null; + } + + public OseeAuthenticationException(Throwable cause) { + super(cause); + this.errorCode = null; + } + public AuthenticationErrorCode getCode() { return errorCode; } diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAuthenticationRequiredException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAuthenticationRequiredException.java index d06bed2..283b9df 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAuthenticationRequiredException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeAuthenticationRequiredException.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Roberto E. Escobar */ @@ -20,4 +22,20 @@ public class OseeAuthenticationRequiredException extends OseeDataStoreException public OseeAuthenticationRequiredException(String message, Object... args) { super(message, args); } + + public OseeAuthenticationRequiredException(IStatus status) { + super(status); + } + + public OseeAuthenticationRequiredException(String message, Throwable cause) { + super(message, cause); + } + + public OseeAuthenticationRequiredException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public OseeAuthenticationRequiredException(Throwable cause) { + super(cause); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeDataStoreException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeDataStoreException.java index 5f06462..7643b70 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeDataStoreException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeDataStoreException.java @@ -10,10 +10,28 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Ryan D. Brooks */ public class OseeDataStoreException extends OseeCoreException { + public OseeDataStoreException(IStatus status) { + super(status); + } + + public OseeDataStoreException(String message, Throwable cause) { + super(message, cause); + } + + public OseeDataStoreException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public OseeDataStoreException(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = 7339636628746394923L; public OseeDataStoreException(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeExceptions.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeExceptions.java index 566a556..ec75810 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeExceptions.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeExceptions.java @@ -10,22 +10,50 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import java.lang.reflect.Constructor; +import org.eclipse.osee.framework.core.data.OseeCodeVersion; + /** + * {@link OseeExceptionsTest} + * * @author Roberto E. Escobar */ public final class OseeExceptions { + private static final String MSG = "OSEE Version: [%s]\nException message: [%s]"; + private OseeExceptions() { // private empty constructor is to prevent external instantiation } public static void wrapAndThrow(Throwable ex) throws OseeCoreException { + String value = ex != null ? ex.getMessage() : ""; + String finalMsg = String.format(MSG, OseeCodeVersion.getVersion(), value); if (ex instanceof RuntimeException) { - throw (RuntimeException) ex; + RuntimeException exception = new RuntimeException(finalMsg, ex); + throw exception; } else if (ex instanceof OseeCoreException) { - throw (OseeCoreException) ex; + throw appendMessage(finalMsg, (OseeCoreException) ex); } else { - throw new OseeWrappedException(ex); + throw new OseeWrappedException(finalMsg, ex); + } + } + + private static OseeCoreException appendMessage(String message, OseeCoreException ex) { + OseeCoreException exception; + try { + Constructor<? extends OseeCoreException> constructor = + ex.getClass().getConstructor(String.class, Throwable.class); + exception = constructor.newInstance(message, ex); + } catch (Throwable th1) { + try { + Constructor<? extends OseeCoreException> constructor = + ex.getClass().getConstructor(Throwable.class, String.class); + exception = constructor.newInstance(message, ex); + } catch (Throwable th2) { + exception = new OseeCoreException(message, ex); + } } + return exception; } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeInvalidInheritanceException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeInvalidInheritanceException.java index eb153ca..26ae99d 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeInvalidInheritanceException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeInvalidInheritanceException.java @@ -10,8 +10,26 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + public class OseeInvalidInheritanceException extends OseeCoreException { + public OseeInvalidInheritanceException(IStatus status) { + super(status); + } + + public OseeInvalidInheritanceException(String message, Throwable cause) { + super(message, cause); + } + + public OseeInvalidInheritanceException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public OseeInvalidInheritanceException(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = -4553986819597790648L; public OseeInvalidInheritanceException(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeNotFoundException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeNotFoundException.java index d824bae..075bbe2 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeNotFoundException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeNotFoundException.java @@ -10,12 +10,29 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; /** * @author Ryan D. Brooks */ public class OseeNotFoundException extends OseeCoreException { + public OseeNotFoundException(IStatus status) { + super(status); + } + + public OseeNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public OseeNotFoundException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public OseeNotFoundException(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = 3496442169445903235L; public OseeNotFoundException(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeStateException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeStateException.java index 33ffe09..6defbb9 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeStateException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeStateException.java @@ -10,11 +10,29 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Donald G. Dunne */ public class OseeStateException extends OseeCoreException { + public OseeStateException(IStatus status) { + super(status); + } + + public OseeStateException(String message, Throwable cause) { + super(message, cause); + } + + public OseeStateException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public OseeStateException(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = 1L; public OseeStateException(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeTypeDoesNotExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeTypeDoesNotExist.java index f33ea56..5356340 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeTypeDoesNotExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeTypeDoesNotExist.java @@ -10,11 +10,29 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Ryan D. Brooks */ public class OseeTypeDoesNotExist extends OseeCoreException { + public OseeTypeDoesNotExist(IStatus status) { + super(status); + } + + public OseeTypeDoesNotExist(String message, Throwable cause) { + super(message, cause); + } + + public OseeTypeDoesNotExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public OseeTypeDoesNotExist(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = 1L; public OseeTypeDoesNotExist(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeWrappedException.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeWrappedException.java index 98d95f6..1cd4587 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeWrappedException.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/OseeWrappedException.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Ryan D. Brooks */ @@ -23,4 +25,16 @@ public class OseeWrappedException extends OseeCoreException { public OseeWrappedException(Throwable cause) { super(cause); } + + public OseeWrappedException(IStatus status) { + super(status); + } + + public OseeWrappedException(String message, Object... args) { + super(message, args); + } + + public OseeWrappedException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/TransactionDoesNotExist.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/TransactionDoesNotExist.java index a876ad9..0cde78f 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/TransactionDoesNotExist.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/TransactionDoesNotExist.java @@ -10,10 +10,28 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Ryan D. Brooks */ public class TransactionDoesNotExist extends OseeCoreException { + public TransactionDoesNotExist(IStatus status) { + super(status); + } + + public TransactionDoesNotExist(String message, Throwable cause) { + super(message, cause); + } + + public TransactionDoesNotExist(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public TransactionDoesNotExist(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = -6197324585250025613L; public TransactionDoesNotExist(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/UserInDatabaseMultipleTimes.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/UserInDatabaseMultipleTimes.java index 209487d..3db899d 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/UserInDatabaseMultipleTimes.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/UserInDatabaseMultipleTimes.java @@ -11,11 +11,29 @@ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Ryan D. Brooks * @author Donald G. Dunne */ public class UserInDatabaseMultipleTimes extends OseeCoreException { + public UserInDatabaseMultipleTimes(IStatus status) { + super(status); + } + + public UserInDatabaseMultipleTimes(String message, Throwable cause) { + super(message, cause); + } + + public UserInDatabaseMultipleTimes(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public UserInDatabaseMultipleTimes(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = 1L; public UserInDatabaseMultipleTimes(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/UserNotInDatabase.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/UserNotInDatabase.java index ac6519c..a60264f 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/UserNotInDatabase.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/exception/UserNotInDatabase.java @@ -11,11 +11,29 @@ package org.eclipse.osee.framework.core.exception; +import org.eclipse.core.runtime.IStatus; + /** * @author Ryan D. Brooks * @author Donald G. Dunne */ public class UserNotInDatabase extends OseeCoreException { + public UserNotInDatabase(IStatus status) { + super(status); + } + + public UserNotInDatabase(String message, Throwable cause) { + super(message, cause); + } + + public UserNotInDatabase(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + + public UserNotInDatabase(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = 1L; public UserNotInDatabase(String message, Object... args) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/operation/Operations.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/operation/Operations.java index 935471f..c9af4b9 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/operation/Operations.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/operation/Operations.java @@ -54,8 +54,9 @@ public final class Operations { */ public static void checkForErrorStatus(IStatus status) throws OseeCoreException { if (status.getSeverity() == IStatus.ERROR) { - if (status.getException() != null) { - OseeExceptions.wrapAndThrow(status.getException()); + Throwable th = status.getException(); + if (th != null) { + OseeExceptions.wrapAndThrow(th); } else { throw new OseeStateException(status.getMessage()); } diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeActiveMq.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeActiveMq.java index 14814b1..b276dbc 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeActiveMq.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/activemq/ConnectionNodeActiveMq.java @@ -19,7 +19,6 @@ import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.logging.Level; - import javax.jms.Connection; import javax.jms.DeliveryMode; import javax.jms.ExceptionListener; @@ -31,7 +30,6 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TemporaryTopic; import javax.jms.Topic; - import org.apache.activemq.ActiveMQConnectionFactory; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.exception.OseeExceptions; diff --git a/plugins/org.eclipse.osee.framework.resource.management/src/org/eclipse/osee/framework/resource/management/exception/MalformedLocatorException.java b/plugins/org.eclipse.osee.framework.resource.management/src/org/eclipse/osee/framework/resource/management/exception/MalformedLocatorException.java index 3cae53b..b5a659b 100644 --- a/plugins/org.eclipse.osee.framework.resource.management/src/org/eclipse/osee/framework/resource/management/exception/MalformedLocatorException.java +++ b/plugins/org.eclipse.osee.framework.resource.management/src/org/eclipse/osee/framework/resource/management/exception/MalformedLocatorException.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.framework.resource.management.exception; +import org.eclipse.core.runtime.IStatus; import org.eclipse.osee.framework.core.exception.OseeCoreException; /** @@ -31,4 +32,12 @@ public class MalformedLocatorException extends OseeCoreException { super(cause); } + public MalformedLocatorException(IStatus status) { + super(status); + } + + public MalformedLocatorException(Throwable cause, String message, Object... args) { + super(cause, message, args); + } + } |