diff options
author | rescobar | 2010-09-23 01:50:48 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2010-09-23 01:50:48 +0000 |
commit | a08a5929900b29b779d4a538227d02f688d96d22 (patch) | |
tree | 719e5c56a82125a661840f663208a1ecfce250d1 /plugins/org.eclipse.osee.framework.core.dsl.ui.integration | |
parent | 74f184469e0a480a2ea846c56d0a88eb634a4494 (diff) | |
download | org.eclipse.osee-a08a5929900b29b779d4a538227d02f688d96d22.tar.gz org.eclipse.osee-a08a5929900b29b779d4a538227d02f688d96d22.tar.xz org.eclipse.osee-a08a5929900b29b779d4a538227d02f688d96d22.zip |
feature[ats_YGHW1]: Update OseeTypesExportOperation to write to an outputstream
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.dsl.ui.integration')
2 files changed, 42 insertions, 21 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesExportOperation.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesExportOperation.java index fb96fc122d1..15db5ba9085 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesExportOperation.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/operations/OseeTypesExportOperation.java @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.dsl.ui.integration.operations; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; import java.io.OutputStream; import java.net.URL; import java.util.HashMap; @@ -24,42 +21,33 @@ import org.eclipse.osee.framework.core.data.OseeServerContext; import org.eclipse.osee.framework.core.dsl.ui.integration.internal.Activator; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.operation.AbstractOperation; +import org.eclipse.osee.framework.core.util.Conditions; import org.eclipse.osee.framework.core.util.HttpProcessor; import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult; -import org.eclipse.osee.framework.jdk.core.util.Lib; /** * @author Roberto E. Escobar */ public class OseeTypesExportOperation extends AbstractOperation { - private final File folder; + private final OutputStream outputStream; - public OseeTypesExportOperation(File folder) { + public OseeTypesExportOperation(OutputStream outputStream) { super("Export Osee Types Model", Activator.PLUGIN_ID); - this.folder = folder; + this.outputStream = outputStream; } @Override protected void doWork(IProgressMonitor monitor) throws Exception { + Conditions.checkNotNull(outputStream, "outputStream"); Map<String, String> parameters = new HashMap<String, String>(); parameters.put("sessionId", ClientSessionManager.getSessionId()); String url = HttpUrlBuilderClient.getInstance().getOsgiServletServiceUrl(OseeServerContext.OSEE_MODEL_CONTEXT, parameters); - OutputStream outputStream = null; - try { - outputStream = new BufferedOutputStream(new FileOutputStream(new File(folder, getOseeFileName()))); - AcquireResult results = HttpProcessor.acquire(new URL(url), outputStream); - if (!results.wasSuccessful()) { - throw new OseeCoreException("Error exporting osee types"); - } - } finally { - Lib.close(outputStream); + AcquireResult results = HttpProcessor.acquire(new URL(url), outputStream); + if (!results.wasSuccessful()) { + throw new OseeCoreException("Error exporting osee types"); } } - - private String getOseeFileName() { - return "OseeTypes_" + Lib.getDateTimeString() + ".osee"; - } } diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesExportWizard.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesExportWizard.java index c947ed892de..d4b3482817f 100644 --- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesExportWizard.java +++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/wizards/OseeTypesExportWizard.java @@ -10,11 +10,23 @@ *******************************************************************************/ package org.eclipse.osee.framework.core.dsl.ui.integration.wizards; +import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStream; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; +import org.eclipse.osee.framework.core.dsl.ui.integration.internal.Activator; import org.eclipse.osee.framework.core.dsl.ui.integration.operations.OseeTypesExportOperation; +import org.eclipse.osee.framework.core.operation.IOperation; import org.eclipse.osee.framework.core.operation.Operations; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.logging.OseeLevel; +import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.ui.IImportWizard; import org.eclipse.ui.IWorkbench; @@ -35,10 +47,31 @@ public class OseeTypesExportWizard extends Wizard implements IImportWizard { @Override public boolean performFinish() { File folder = mainPage.getFile(); - Operations.executeAsJob(new OseeTypesExportOperation(folder), true); + + File file = new File(folder, getOseeFileName()); + FileOutputStream fos = null; + try { + fos = new FileOutputStream(file); + final OutputStream outputStream = new BufferedOutputStream(fos); + IOperation op = new OseeTypesExportOperation(outputStream); + Operations.executeAsJob(op, true, Job.LONG, new JobChangeAdapter() { + @Override + public void done(IJobChangeEvent event) { + Lib.close(outputStream); + } + }); + } catch (FileNotFoundException ex) { + OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); + } finally { + Lib.close(fos); + } return true; } + private String getOseeFileName() { + return "OseeTypes_" + Lib.getDateTimeString() + ".osee"; + } + @Override public void init(IWorkbench workbench, IStructuredSelection selection) { mainPage = new ResourceSelectionPage(getWindowTitle()); |