diff options
Diffstat (limited to 'org.eclipse.osee.framework.skynet.core/src/org/eclipse')
3 files changed, 78 insertions, 1 deletions
diff --git a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactChecks.java b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactChecks.java new file mode 100644 index 00000000000..3d4cdddd4f2 --- /dev/null +++ b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactChecks.java @@ -0,0 +1,51 @@ +/*
+ * Created on Feb 28, 2008
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.skynet.core.artifact;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osee.framework.plugin.core.config.ConfigUtil;
+import org.eclipse.osee.framework.plugin.core.util.ExtensionPoints;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ArtifactChecks {
+
+ public static List<IArtifactCheck> tasks;
+ protected static final Logger logger = ConfigUtil.getConfigFactory().getLogger(ArtifactChecks.class);
+ public static String EXTENSION_POINT = "org.eclipse.osee.framework.skynet.core.ArtifactCheck";
+
+ public static List<IArtifactCheck> getArtifactChecks() throws Exception {
+ if (tasks == null) {
+ tasks = new ArrayList<IArtifactCheck>();
+ List<IConfigurationElement> iExtensions =
+ ExtensionPoints.getExtensionElements(EXTENSION_POINT, "ArtifactCheck");
+ for (IConfigurationElement element : iExtensions) {
+ String className = element.getAttribute("classname");
+ String bundleName = element.getContributor().getName();
+ try {
+ if (className != null && bundleName != null) {
+ Bundle bundle = Platform.getBundle(bundleName);
+ Class<?> interfaceClass = bundle.loadClass(className);
+ IArtifactCheck check = (IArtifactCheck) interfaceClass.getConstructor().newInstance();
+ tasks.add(check);
+ }
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Problem loading ArtifactCheck extension \"" + className + "\". Ignorning.",
+ ex);
+ }
+ }
+ }
+ return tasks;
+ }
+
+}
diff --git a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java index 551ab02d16a..f9d601100b3 100644 --- a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java +++ b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactPersistenceManager.java @@ -25,6 +25,7 @@ import java.io.InputStream; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -88,6 +89,7 @@ import org.eclipse.osee.framework.skynet.core.word.WordUtil; import org.eclipse.osee.framework.ui.plugin.event.Event; import org.eclipse.osee.framework.ui.plugin.sql.SQL3DataType; import org.eclipse.osee.framework.ui.plugin.util.Jobs; +import org.eclipse.osee.framework.ui.plugin.util.Result; import org.eclipse.osee.framework.ui.plugin.util.db.ConnectionHandler; import org.eclipse.osee.framework.ui.plugin.util.db.ConnectionHandlerStatement; import org.eclipse.osee.framework.ui.plugin.util.db.DbUtil; @@ -1028,9 +1030,15 @@ public class ArtifactPersistenceManager implements PersistenceManager { * @param artifacts The artifacts to delete. * @throws SQLException */ - public void deleteArtifact(final Artifact... artifacts) throws SQLException { + public void deleteArtifact(final Artifact... artifacts) throws Exception { if (artifacts.length == 0) return; + // Confirm artifacts are fit to delete + for (IArtifactCheck check : ArtifactChecks.getArtifactChecks()) { + Result result = check.isDeleteable(Arrays.asList(artifacts)); + if (result.isFalse()) throw new IllegalStateException(result.getText()); + } + final Branch branch = artifacts[0].getBranch(); if (transactionManager.isInBatch(branch)) { for (Artifact artifact : artifacts) { diff --git a/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/IArtifactCheck.java b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/IArtifactCheck.java new file mode 100644 index 00000000000..8bae0f0b95d --- /dev/null +++ b/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/IArtifactCheck.java @@ -0,0 +1,18 @@ +/*
+ * Created on Feb 28, 2008
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.skynet.core.artifact;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.ui.plugin.util.Result;
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface IArtifactCheck {
+
+ public Result isDeleteable(Collection<Artifact> artifacts) throws Exception;
+
+}
|