Commit 86b8f9db authored by Spiros Koulouzis's avatar Spiros Koulouzis

Renamed POJOs

parent be293ab9
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.commons.types;
import java.util.Map;
import org.springframework.data.annotation.Id;
/**
*
* @author S. Koulouzis
*/
public class ClusterCredentials {
@Id
private String id;
private Map<String, Object> kvMap;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the kvMap
*/
public Map<String, Object> getKvMap() {
return kvMap;
}
/**
* @param kvMap the kvMap to set
*/
public void setKvMap(Map<String, Object> kvMap) {
this.kvMap = kvMap;
}
}
......@@ -30,7 +30,7 @@ public interface IMessage {
public void setCreationDate(Long creationDate);
public void setParameters(List<Parameter> params);
public void setParameters(List<MessageParameter> params);
public List getParameters();
......
......@@ -38,7 +38,7 @@ public class Message implements IMessage, Serializable {
// @Temporal(TemporalType.DATE)
private Long creationDate;
private List<Parameter> parameters;
private List<MessageParameter> parameters;
@Override
public Long getCreationDate() {
......@@ -46,12 +46,12 @@ public class Message implements IMessage, Serializable {
}
@Override
public void setParameters(List<Parameter> parameters) {
public void setParameters(List<MessageParameter> parameters) {
this.parameters = parameters;
}
@Override
public List<Parameter> getParameters() {
public List<MessageParameter> getParameters() {
return this.parameters;
}
......
......@@ -22,7 +22,7 @@ import java.util.Map;
*
* @author S. Koulouzis.
*/
public class Parameter implements Serializable {
public class MessageParameter implements Serializable {
private String url;
private String encoding;
......
......@@ -112,14 +112,14 @@ public class TypesJUnitTest {
private static void initMessages() throws IOException {
message1 = new Message();
message1.setCreationDate((System.currentTimeMillis()));
List<Parameter> parameters = new ArrayList();
Parameter numParam = new Parameter();
List<MessageParameter> parameters = new ArrayList();
MessageParameter numParam = new MessageParameter();
String numParamName = "input";
numParam.setName(numParamName);
numParam.setValue("33000");
parameters.add(numParam);
Parameter fileParamContents = new Parameter();
MessageParameter fileParamContents = new MessageParameter();
fileParamContentsName = "someInputFile";
fileParamContents.setName(fileParamContentsName);
byte[] bytes = Files.readAllBytes(Paths.get(tempFile1.getAbsolutePath()));
......@@ -128,7 +128,7 @@ public class TypesJUnitTest {
fileParamContents.setEncoding(charset);
parameters.add(fileParamContents);
Parameter fileParamRef = new Parameter();
MessageParameter fileParamRef = new MessageParameter();
fileParamRef.setName("theNameOfTheParamater");
fileParamRef.setURL("http://www.gutenberg.org/cache/epub/3160/pg3160.txt");
parameters.add(fileParamRef);
......@@ -158,11 +158,11 @@ public class TypesJUnitTest {
// System.err.println(jsonInString);
Message request = mapper.readValue(jsonInString, Message.class);
List<Parameter> params = request.getParameters();
List<MessageParameter> params = request.getParameters();
assertEquals(message1.getParameters().size(), params.size());
fileParam = new File(fileParamContentsName);
for (Parameter param : params) {
for (MessageParameter param : params) {
if (param.getName().equals(fileParamContentsName)) {
String value = param.getValue();
try (PrintWriter out = new PrintWriter(fileParam)) {
......@@ -195,9 +195,9 @@ public class TypesJUnitTest {
fileParam = new File(fileParamContentsName);
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get(Parameter.NAME);
String name = (String) param.get(MessageParameter.NAME);
if (name.equals(fileParamContentsName)) {
String value = (String) param.get(Parameter.VALUE);
String value = (String) param.get(MessageParameter.VALUE);
try (PrintWriter out = new PrintWriter(fileParam)) {
out.print(value);
}
......@@ -223,7 +223,7 @@ public class TypesJUnitTest {
List parameters = new ArrayList();
String charset = "UTF-8";
for (File f : files) {
Parameter fileParam = new Parameter();
MessageParameter fileParam = new MessageParameter();
byte[] bytes = Files.readAllBytes(Paths.get(f.getAbsolutePath()));
fileParam.setValue(new String(bytes, charset));
fileParam.setEncoding(charset);
......
......@@ -38,7 +38,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.commons.types.Parameter;
import nl.uva.sne.drip.commons.types.MessageParameter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.json.JSONArray;
......@@ -371,12 +371,12 @@ public class Consumer extends DefaultConsumer {
private File getCloudConfigurationFile(JSONArray parameters, String tempInputDirPath) throws JSONException {
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get(Parameter.NAME);
String name = (String) param.get(MessageParameter.NAME);
if (name.equals("ec2.conf") || name.equals("geni.conf")) {
try {
File confFile = new File(tempInputDirPath + File.separator + name);
if (confFile.createNewFile()) {
writeValueToFile((String) param.get(Parameter.VALUE), confFile);
writeValueToFile((String) param.get(MessageParameter.VALUE), confFile);
return confFile;
} else {
return null;
......@@ -393,7 +393,7 @@ public class Consumer extends DefaultConsumer {
private File getTopology(JSONArray parameters, String tempInputDirPath, int level) throws JSONException, IOException {
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get(Parameter.NAME);
String name = (String) param.get(MessageParameter.NAME);
if (name.equals("topology")) {
JSONObject attributes = param.getJSONObject("attributes");
int fileLevel = Integer.valueOf((String) attributes.get("level"));
......@@ -408,7 +408,7 @@ public class Consumer extends DefaultConsumer {
if (fileLevel == level) {
File topologyFile = new File(tempInputDirPath + File.separator + fileName);
if (topologyFile.createNewFile()) {
String val = (String) param.get(Parameter.VALUE);
String val = (String) param.get(MessageParameter.VALUE);
//Replace '{' with indentation otherwise we get 'End of document execption'
// val = val.replaceAll("- \\{", " - ").replaceAll(", ", "\n ").replaceAll("}", "");
......@@ -427,13 +427,13 @@ public class Consumer extends DefaultConsumer {
Map<String, File> files = new HashMap<>();
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get(Parameter.NAME);
String name = (String) param.get(MessageParameter.NAME);
if (name.equals("certificate")) {
JSONObject attribute = param.getJSONObject("attributes");
String fileName = (String) attribute.get("filename");
File certificate = new File(tempInputDirPath + File.separator + fileName + ".pem");
if (certificate.createNewFile()) {
writeValueToFile((String) param.get(Parameter.VALUE), certificate);
writeValueToFile((String) param.get(MessageParameter.VALUE), certificate);
files.put(fileName, certificate);
}
}
......@@ -444,9 +444,9 @@ public class Consumer extends DefaultConsumer {
private String getLogDirPath(JSONArray parameters, String tempInputDirPath) throws JSONException {
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get(Parameter.NAME);
String name = (String) param.get(MessageParameter.NAME);
if (name.equals("logdir")) {
return (String) param.get(Parameter.VALUE);
return (String) param.get(MessageParameter.VALUE);
}
}
return System.getProperty("java.io.tmpdir");
......@@ -455,9 +455,9 @@ public class Consumer extends DefaultConsumer {
private File getSSHKey(JSONArray parameters, String tempInputDirPath) throws JSONException, IOException {
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get(Parameter.NAME);
String name = (String) param.get(MessageParameter.NAME);
if (name.equals("sshkey")) {
String sshKeyContent = (String) param.get(Parameter.VALUE);
String sshKeyContent = (String) param.get(MessageParameter.VALUE);
File sshKeyFile = new File(tempInputDirPath + File.separator + "user.pem");
if (sshKeyFile.createNewFile()) {
writeValueToFile(sshKeyContent, sshKeyFile);
......@@ -471,9 +471,9 @@ public class Consumer extends DefaultConsumer {
private File getSciptFile(JSONArray parameters, String tempInputDirPath) throws JSONException, IOException {
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get(Parameter.NAME);
String name = (String) param.get(MessageParameter.NAME);
if (name.equals("guiscript")) {
String scriptContent = (String) param.get(Parameter.VALUE);
String scriptContent = (String) param.get(MessageParameter.VALUE);
File scriptFile = new File(tempInputDirPath + File.separator + "guiscipt.sh");
if (scriptFile.createNewFile()) {
writeValueToFile(scriptContent, scriptFile);
......
......@@ -33,7 +33,7 @@ import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.commons.types.Parameter;
import nl.uva.sne.drip.commons.types.MessageParameter;
import nl.uva.sne.drip.commons.types.Message;
import org.json.JSONArray;
import org.json.JSONException;
......@@ -108,13 +108,13 @@ public class Consumer extends DefaultConsumer {
ObjectMapper mapper = new ObjectMapper();
Message request = mapper.readValue(message, Message.class);
List<Parameter> params = request.getParameters();
List<MessageParameter> params = request.getParameters();
//Create tmp input files
File inputFile = File.createTempFile("input-", Long.toString(System.nanoTime()));
File exampleFile = File.createTempFile("example-", Long.toString(System.nanoTime()));
//loop through the parameters in a message to find the input files
for (Parameter param : params) {
for (MessageParameter param : params) {
if (param.getName().equals("input")) {
try (PrintWriter out = new PrintWriter(inputFile)) {
out.print(param.getValue());
......@@ -141,16 +141,16 @@ public class Consumer extends DefaultConsumer {
File exampleFile = File.createTempFile("example-", Long.toString(System.nanoTime()));
for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(i);
String name = (String) param.get(Parameter.NAME);
String name = (String) param.get(MessageParameter.NAME);
if (name.equals("input")) {
try (PrintWriter out = new PrintWriter(inputFile)) {
out.print(param.get(Parameter.VALUE));
out.print(param.get(MessageParameter.VALUE));
}
files[0] = inputFile;
}
if (name.equals("example")) {
try (PrintWriter out = new PrintWriter(exampleFile)) {
out.print(param.get(Parameter.VALUE));
out.print(param.get(MessageParameter.VALUE));
}
files[1] = exampleFile;
}
......@@ -164,7 +164,7 @@ public class Consumer extends DefaultConsumer {
List parameters = new ArrayList();
String charset = "UTF-8";
for (File f : files) {
Parameter fileParam = new Parameter();
MessageParameter fileParam = new MessageParameter();
byte[] bytes = Files.readAllBytes(Paths.get(f.getAbsolutePath()));
fileParam.setValue(new String(bytes, charset));
fileParam.setEncoding(charset);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment