Skip to main content
summaryrefslogtreecommitdiffstats
blob: 48a6eed5a6646c04a30eaa58e61c735f81557d5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*******************************************************************************
 * Copyright (c) 2015 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.orcs.rest.internal.writer;

import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import javax.ws.rs.core.StreamingOutput;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.rest.model.writer.reader.OwCollector;

/**
 * @author Donald G. Dunne
 */
public final class OrcsWriterStreamingOutput implements StreamingOutput {
   private final OrcsApi orcsApi;
   private final long branchUuid;
   private final OwCollector collector;

   public OrcsWriterStreamingOutput(OrcsApi orcsApi, long branchUuid, OwCollector collector) {
      this.orcsApi = orcsApi;
      this.branchUuid = branchUuid;
      this.collector = collector;
   }

   @Override
   public void write(OutputStream output) {
      try {
         Writer writer = new OutputStreamWriter(output);
         OrcsWriterWorkbookGenerator generator = new OrcsWriterWorkbookGenerator(collector, orcsApi);
         generator.runOperation(orcsApi, branchUuid, writer);
      } catch (Exception ex) {
         // do nothing
      }
   }
}

Back to the top