blob: ddec7e8613f81e9612cfd8324062bcf5f35a6ea7 (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/*******************************************************************************
* 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.manager.servlet.data;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
/**
* @author Roberto E. Escobar
*/
public class HttpBranchExchangeInfo {
public enum BranchExchangeFunctions {
exportBranch,
importBranch,
checkExchange;
};
private BranchExchangeFunctions function;
private String exchangeFileName;
private String path;
private final List<Integer> selectedBranchIds;
private boolean sendExportFile;
private boolean deleteExportFile;
private final PropertyStore options;
@SuppressWarnings("unchecked")
public HttpBranchExchangeInfo(HttpServletRequest request) throws Exception {
this.options = new PropertyStore();
this.function = null;
this.selectedBranchIds = new ArrayList<Integer>();
this.sendExportFile = false;
this.deleteExportFile = false;
this.exchangeFileName = null;
this.path = null;
Enumeration<String> enumeration = request.getParameterNames();
while (enumeration.hasMoreElements()) {
String name = enumeration.nextElement();
String value = request.getParameter(name);
if (name.equalsIgnoreCase("filename")) {
this.exchangeFileName = value;
} else if (name.equalsIgnoreCase("uri")) {
this.path = value;
} else if (name.equalsIgnoreCase("send.export.file")) {
this.sendExportFile = Boolean.valueOf(value);
} else if (name.equalsIgnoreCase("delete.export.file")) {
this.deleteExportFile = Boolean.valueOf(value);
} else if (name.equalsIgnoreCase("function")) {
isFunctionValid(value);
} else if (name.equalsIgnoreCase("branchIds")) {
for (String entry : value.split(",")) {
selectedBranchIds.add(new Integer(entry));
}
} else {
options.put(name.toUpperCase(), value);
}
}
}
public BranchExchangeFunctions getFunction() {
return this.function;
}
public boolean isSendExportFile() {
return this.sendExportFile;
}
public boolean isDeleteExportFile() {
return this.deleteExportFile;
}
public String getExchangeFileName() {
return this.exchangeFileName;
}
public String getPath() {
return this.path;
}
public List<Integer> getSelectedBranchIds() {
return this.selectedBranchIds;
}
public PropertyStore getOptions() {
return this.options;
}
private void isFunctionValid(String function) throws Exception {
if (function == null) {
throw new Exception("A 'function' parameter must be defined.");
}
try {
this.function = BranchExchangeFunctions.valueOf(function);
} catch (IllegalArgumentException ex) {
throw new Exception(String.format("[%s] is not a valid function.", function), ex);
}
}
}
|