summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn F. Cook2011-08-02 16:05:38 (EDT)
committerRyan D. Brooks2011-08-02 16:05:38 (EDT)
commitd24f7321717fdd9b86a82724d03f5b0731720ca3 (patch)
treefda50d06a4b45dfc1c8bd02f1976e5d40b018993
parent670e09d7c26b97fe066357e301eba39aa1cf6b03 (diff)
downloadorg.eclipse.osee-d24f7321717fdd9b86a82724d03f5b0731720ca3.zip
org.eclipse.osee-d24f7321717fdd9b86a82724d03f5b0731720ca3.tar.gz
org.eclipse.osee-d24f7321717fdd9b86a82724d03f5b0731720ca3.tar.bz2
refinement[bgz_350331]: Migrate PruneWorkspace to server side command line
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/PruneWorkspaceOperation.java80
-rw-r--r--plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java35
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml3
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PruneWorkspace.java64
4 files changed, 115 insertions, 67 deletions
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/PruneWorkspaceOperation.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/PruneWorkspaceOperation.java
new file mode 100644
index 0000000..29eb3d5
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/PruneWorkspaceOperation.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.database.operation;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.regex.Pattern;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.operation.OperationLogger;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.AbstractDbTxOperation;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.database.internal.Activator;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+
+/**
+ * @author Ryan D. Brooks
+ * @author Shawn F. Cook
+ */
+public class PruneWorkspaceOperation extends AbstractDbTxOperation {
+ private final String preserveFilePattern;
+ private final String workspacePathStr;
+ private final String purgeFilePattern;
+
+ public PruneWorkspaceOperation(IOseeDatabaseService databaseService, IOseeCachingService cachingService, OperationLogger logger, String preserveFilePattern, String workspacePathStr, String purgeFilePattern) {
+ super(databaseService, "Prune Workspace", Activator.PLUGIN_ID, logger);
+ this.preserveFilePattern = preserveFilePattern;
+ this.workspacePathStr = workspacePathStr;
+ this.purgeFilePattern = purgeFilePattern;
+ }
+
+ @Override
+ protected void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException {
+
+ log();
+ log("Pruning Workspace:");
+
+ File keeperFile = new File(preserveFilePattern);
+ File workspacePath = new File(workspacePathStr);
+ String filePathPattern = purgeFilePattern;
+
+ ArrayList<String> preserveList;
+ try {
+ if (!preserveFilePattern.isEmpty()) {
+ preserveList = Lib.readListFromFile(keeperFile, true);
+ } else {
+ preserveList = new ArrayList<String>();
+ }
+
+ HashSet<String> preserveSet = new HashSet<String>(preserveList);
+
+ List<File> files = Lib.recursivelyListFiles(workspacePath, Pattern.compile(filePathPattern));
+ for (File file : files) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+ if (!preserveSet.contains(file.getName())) {
+ file.delete();
+ }
+ }
+ } catch (IOException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ log("...done.");
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java
index ceed981..f92abb0 100644
--- a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java
+++ b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java
@@ -28,6 +28,7 @@ import org.eclipse.osee.framework.core.operation.OperationLogger;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.database.operation.ConsolidateArtifactVersionTxOperation;
import org.eclipse.osee.framework.database.operation.ParseWindowsDirectoryListingOperation;
+import org.eclipse.osee.framework.database.operation.PruneWorkspaceOperation;
import org.eclipse.osee.framework.database.operation.FindInvalidUTF8CharsOperation;
import org.eclipse.osee.framework.database.operation.ConsolidateRelationsTxOperation;
import org.eclipse.osee.framework.database.operation.PurgeUnusedBackingDataAndTransactions;
@@ -181,6 +182,39 @@ public class ServerAdminCommandProvider implements CommandProvider {
return Operations.executeAsJob(operation, false);
}
+ public Job _prune_workspace(CommandInterpreter ci) {
+ OperationLogger logger = new CommandInterpreterLogger(ci);
+
+ String preserveFilePattern = "";
+ String workspacePathStr = "";
+ String purgeFilePattern = "";
+
+ //to be purged
+ final ArrayList<String> args = new ArrayList<String>();
+
+ boolean force = false;
+ for (String arg = ci.nextArgument(); Strings.isValid(arg); arg = ci.nextArgument()) {
+ args.add(arg);
+ }
+
+ if (args.size() <= 1) {
+ ci.print(getHelp());
+ } else if (args.size() == 2) {
+ workspacePathStr = args.get(0);
+ purgeFilePattern = args.get(1);
+ } else {
+ preserveFilePattern = args.get(0);
+ workspacePathStr = args.get(1);
+ purgeFilePattern = args.get(2);
+ }
+
+ IOperation operation =
+ new PruneWorkspaceOperation(Activator.getOseeDatabaseService(), Activator.getOseeCachingService(), logger,
+ preserveFilePattern, workspacePathStr, purgeFilePattern);
+
+ return Operations.executeAsJob(operation, false);
+ }
+
@Override
public String getHelp() {
StringBuilder sb = new StringBuilder();
@@ -199,6 +233,7 @@ public class ServerAdminCommandProvider implements CommandProvider {
sb.append(" schedule <delay seconds> <iterations> <command> - runs the command after the specified delay and repeat given number of times\n");
sb.append(" purge_relation_type -force excute the operation, relationType1 ...\n");
sb.append(" parse_dir - converts the given file into a formatted CSV file\n");
+ sb.append(" prune_workspace [preserve_file_pattern] workspace_path purge_file_pattern - delete files that are found in workspace_path and whose filenames match purge_file_pattern. Any filename that matches the optional preserve_file_pattern are not deleted\n");
sb.append(" find_invalid_utf8 - finds invalid UTF8 chars in table osee_attribute\n");
sb.append(" consolidate_relations - consolidate rows of relations\n");
sb.append(String.format(" reload_cache %s? - reloads server caches\n",
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
index a0d5a5c..76872b5 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
@@ -183,9 +183,6 @@
<extension point="org.eclipse.search.searchResultViewPages">
<viewPage class="org.eclipse.osee.framework.ui.skynet.search.page.ArtifactSearchPage" id="org.eclipse.osee.framework.ui.skynet.ArtifactSearchViewPage" searchResultClass="org.eclipse.osee.framework.ui.skynet.search.ArtifactSearchResult"/>
</extension>
- <extension id="PruneWorkspace" name="PruneWorkspace" point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation className="org.eclipse.osee.framework.ui.skynet.blam.operation.PruneWorkspace"/>
- </extension>
<extension id="PurgeTransaction" point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
<Operation className="org.eclipse.osee.framework.ui.skynet.blam.operation.PurgeTransactionBlam"/>
</extension>
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PruneWorkspace.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PruneWorkspace.java
deleted file mode 100644
index d15e9ef..0000000
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PruneWorkspace.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.ui.skynet.blam.operation;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.regex.Pattern;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-
-/**
- * @author Ryan D. Brooks
- */
-public class PruneWorkspace extends AbstractBlam {
-
- @Override
- public String getName() {
- return "Prune Workspace";
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- File keeperFile = new File(variableMap.getString("Preserve List File"));
- File workspacePath = new File(variableMap.getString("Workspace Path"));
- String filePathPattern = variableMap.getString("File Path Pattern");
-
- ArrayList<String> preserveList = Lib.readListFromFile(keeperFile, true);
- HashSet<String> preserveSet = new HashSet<String>(preserveList);
-
- List<File> files = Lib.recursivelyListFiles(workspacePath, Pattern.compile(filePathPattern));
- for (File file : files) {
- if (monitor.isCanceled()) {
- return;
- }
- if (!preserveSet.contains(file.getName())) {
- file.delete();
- }
- }
- }
-
- @Override
- public String getXWidgetsXml() {
- return "<xWidgets><XWidget xwidgetType=\"XText\" displayName=\"Preserve List File\" /><XWidget xwidgetType=\"XText\" displayName=\"Workspace Path\" /><XWidget xwidgetType=\"XText\" displayName=\"File Path Pattern\" /></xWidgets>";
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("OTE");
- }
-} \ No newline at end of file