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 { ...@@ -30,7 +30,7 @@ public interface IMessage {
public void setCreationDate(Long creationDate); public void setCreationDate(Long creationDate);
public void setParameters(List<Parameter> params); public void setParameters(List<MessageParameter> params);
public List getParameters(); public List getParameters();
......
...@@ -38,7 +38,7 @@ public class Message implements IMessage, Serializable { ...@@ -38,7 +38,7 @@ public class Message implements IMessage, Serializable {
// @Temporal(TemporalType.DATE) // @Temporal(TemporalType.DATE)
private Long creationDate; private Long creationDate;
private List<Parameter> parameters; private List<MessageParameter> parameters;
@Override @Override
public Long getCreationDate() { public Long getCreationDate() {
...@@ -46,12 +46,12 @@ public class Message implements IMessage, Serializable { ...@@ -46,12 +46,12 @@ public class Message implements IMessage, Serializable {
} }
@Override @Override
public void setParameters(List<Parameter> parameters) { public void setParameters(List<MessageParameter> parameters) {
this.parameters = parameters; this.parameters = parameters;
} }
@Override @Override
public List<Parameter> getParameters() { public List<MessageParameter> getParameters() {
return this.parameters; return this.parameters;
} }
......
...@@ -22,7 +22,7 @@ import java.util.Map; ...@@ -22,7 +22,7 @@ import java.util.Map;
* *
* @author S. Koulouzis. * @author S. Koulouzis.
*/ */
public class Parameter implements Serializable { public class MessageParameter implements Serializable {
private String url; private String url;
private String encoding; private String encoding;
......
...@@ -112,14 +112,14 @@ public class TypesJUnitTest { ...@@ -112,14 +112,14 @@ public class TypesJUnitTest {
private static void initMessages() throws IOException { private static void initMessages() throws IOException {
message1 = new Message(); message1 = new Message();
message1.setCreationDate((System.currentTimeMillis())); message1.setCreationDate((System.currentTimeMillis()));
List<Parameter> parameters = new ArrayList(); List<MessageParameter> parameters = new ArrayList();
Parameter numParam = new Parameter(); MessageParameter numParam = new MessageParameter();
String numParamName = "input"; String numParamName = "input";
numParam.setName(numParamName); numParam.setName(numParamName);
numParam.setValue("33000"); numParam.setValue("33000");
parameters.add(numParam); parameters.add(numParam);
Parameter fileParamContents = new Parameter(); MessageParameter fileParamContents = new MessageParameter();
fileParamContentsName = "someInputFile"; fileParamContentsName = "someInputFile";
fileParamContents.setName(fileParamContentsName); fileParamContents.setName(fileParamContentsName);
byte[] bytes = Files.readAllBytes(Paths.get(tempFile1.getAbsolutePath())); byte[] bytes = Files.readAllBytes(Paths.get(tempFile1.getAbsolutePath()));
...@@ -128,7 +128,7 @@ public class TypesJUnitTest { ...@@ -128,7 +128,7 @@ public class TypesJUnitTest {
fileParamContents.setEncoding(charset); fileParamContents.setEncoding(charset);
parameters.add(fileParamContents); parameters.add(fileParamContents);
Parameter fileParamRef = new Parameter(); MessageParameter fileParamRef = new MessageParameter();
fileParamRef.setName("theNameOfTheParamater"); fileParamRef.setName("theNameOfTheParamater");
fileParamRef.setURL("http://www.gutenberg.org/cache/epub/3160/pg3160.txt"); fileParamRef.setURL("http://www.gutenberg.org/cache/epub/3160/pg3160.txt");
parameters.add(fileParamRef); parameters.add(fileParamRef);
...@@ -158,11 +158,11 @@ public class TypesJUnitTest { ...@@ -158,11 +158,11 @@ public class TypesJUnitTest {
// System.err.println(jsonInString); // System.err.println(jsonInString);
Message request = mapper.readValue(jsonInString, Message.class); Message request = mapper.readValue(jsonInString, Message.class);
List<Parameter> params = request.getParameters(); List<MessageParameter> params = request.getParameters();
assertEquals(message1.getParameters().size(), params.size()); assertEquals(message1.getParameters().size(), params.size());
fileParam = new File(fileParamContentsName); fileParam = new File(fileParamContentsName);
for (Parameter param : params) { for (MessageParameter param : params) {
if (param.getName().equals(fileParamContentsName)) { if (param.getName().equals(fileParamContentsName)) {
String value = param.getValue(); String value = param.getValue();
try (PrintWriter out = new PrintWriter(fileParam)) { try (PrintWriter out = new PrintWriter(fileParam)) {
...@@ -195,9 +195,9 @@ public class TypesJUnitTest { ...@@ -195,9 +195,9 @@ public class TypesJUnitTest {
fileParam = new File(fileParamContentsName); fileParam = new File(fileParamContentsName);
for (int i = 0; i < parameters.length(); i++) { for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(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)) { if (name.equals(fileParamContentsName)) {
String value = (String) param.get(Parameter.VALUE); String value = (String) param.get(MessageParameter.VALUE);
try (PrintWriter out = new PrintWriter(fileParam)) { try (PrintWriter out = new PrintWriter(fileParam)) {
out.print(value); out.print(value);
} }
...@@ -223,7 +223,7 @@ public class TypesJUnitTest { ...@@ -223,7 +223,7 @@ public class TypesJUnitTest {
List parameters = new ArrayList(); List parameters = new ArrayList();
String charset = "UTF-8"; String charset = "UTF-8";
for (File f : files) { for (File f : files) {
Parameter fileParam = new Parameter(); MessageParameter fileParam = new MessageParameter();
byte[] bytes = Files.readAllBytes(Paths.get(f.getAbsolutePath())); byte[] bytes = Files.readAllBytes(Paths.get(f.getAbsolutePath()));
fileParam.setValue(new String(bytes, charset)); fileParam.setValue(new String(bytes, charset));
fileParam.setEncoding(charset); fileParam.setEncoding(charset);
......
...@@ -38,7 +38,7 @@ import java.util.Map; ...@@ -38,7 +38,7 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; 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.FileUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.json.JSONArray; import org.json.JSONArray;
...@@ -371,12 +371,12 @@ public class Consumer extends DefaultConsumer { ...@@ -371,12 +371,12 @@ public class Consumer extends DefaultConsumer {
private File getCloudConfigurationFile(JSONArray parameters, String tempInputDirPath) throws JSONException { private File getCloudConfigurationFile(JSONArray parameters, String tempInputDirPath) throws JSONException {
for (int i = 0; i < parameters.length(); i++) { for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(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")) { if (name.equals("ec2.conf") || name.equals("geni.conf")) {
try { try {
File confFile = new File(tempInputDirPath + File.separator + name); File confFile = new File(tempInputDirPath + File.separator + name);
if (confFile.createNewFile()) { if (confFile.createNewFile()) {
writeValueToFile((String) param.get(Parameter.VALUE), confFile); writeValueToFile((String) param.get(MessageParameter.VALUE), confFile);
return confFile; return confFile;
} else { } else {
return null; return null;
...@@ -393,7 +393,7 @@ public class Consumer extends DefaultConsumer { ...@@ -393,7 +393,7 @@ public class Consumer extends DefaultConsumer {
private File getTopology(JSONArray parameters, String tempInputDirPath, int level) throws JSONException, IOException { private File getTopology(JSONArray parameters, String tempInputDirPath, int level) throws JSONException, IOException {
for (int i = 0; i < parameters.length(); i++) { for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(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")) { if (name.equals("topology")) {
JSONObject attributes = param.getJSONObject("attributes"); JSONObject attributes = param.getJSONObject("attributes");
int fileLevel = Integer.valueOf((String) attributes.get("level")); int fileLevel = Integer.valueOf((String) attributes.get("level"));
...@@ -408,7 +408,7 @@ public class Consumer extends DefaultConsumer { ...@@ -408,7 +408,7 @@ public class Consumer extends DefaultConsumer {
if (fileLevel == level) { if (fileLevel == level) {
File topologyFile = new File(tempInputDirPath + File.separator + fileName); File topologyFile = new File(tempInputDirPath + File.separator + fileName);
if (topologyFile.createNewFile()) { 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' //Replace '{' with indentation otherwise we get 'End of document execption'
// val = val.replaceAll("- \\{", " - ").replaceAll(", ", "\n ").replaceAll("}", ""); // val = val.replaceAll("- \\{", " - ").replaceAll(", ", "\n ").replaceAll("}", "");
...@@ -427,13 +427,13 @@ public class Consumer extends DefaultConsumer { ...@@ -427,13 +427,13 @@ public class Consumer extends DefaultConsumer {
Map<String, File> files = new HashMap<>(); Map<String, File> files = new HashMap<>();
for (int i = 0; i < parameters.length(); i++) { for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(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")) { if (name.equals("certificate")) {
JSONObject attribute = param.getJSONObject("attributes"); JSONObject attribute = param.getJSONObject("attributes");
String fileName = (String) attribute.get("filename"); String fileName = (String) attribute.get("filename");
File certificate = new File(tempInputDirPath + File.separator + fileName + ".pem"); File certificate = new File(tempInputDirPath + File.separator + fileName + ".pem");
if (certificate.createNewFile()) { if (certificate.createNewFile()) {
writeValueToFile((String) param.get(Parameter.VALUE), certificate); writeValueToFile((String) param.get(MessageParameter.VALUE), certificate);
files.put(fileName, certificate); files.put(fileName, certificate);
} }
} }
...@@ -444,9 +444,9 @@ public class Consumer extends DefaultConsumer { ...@@ -444,9 +444,9 @@ public class Consumer extends DefaultConsumer {
private String getLogDirPath(JSONArray parameters, String tempInputDirPath) throws JSONException { private String getLogDirPath(JSONArray parameters, String tempInputDirPath) throws JSONException {
for (int i = 0; i < parameters.length(); i++) { for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(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")) { if (name.equals("logdir")) {
return (String) param.get(Parameter.VALUE); return (String) param.get(MessageParameter.VALUE);
} }
} }
return System.getProperty("java.io.tmpdir"); return System.getProperty("java.io.tmpdir");
...@@ -455,9 +455,9 @@ public class Consumer extends DefaultConsumer { ...@@ -455,9 +455,9 @@ public class Consumer extends DefaultConsumer {
private File getSSHKey(JSONArray parameters, String tempInputDirPath) throws JSONException, IOException { private File getSSHKey(JSONArray parameters, String tempInputDirPath) throws JSONException, IOException {
for (int i = 0; i < parameters.length(); i++) { for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(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")) { 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"); File sshKeyFile = new File(tempInputDirPath + File.separator + "user.pem");
if (sshKeyFile.createNewFile()) { if (sshKeyFile.createNewFile()) {
writeValueToFile(sshKeyContent, sshKeyFile); writeValueToFile(sshKeyContent, sshKeyFile);
...@@ -471,9 +471,9 @@ public class Consumer extends DefaultConsumer { ...@@ -471,9 +471,9 @@ public class Consumer extends DefaultConsumer {
private File getSciptFile(JSONArray parameters, String tempInputDirPath) throws JSONException, IOException { private File getSciptFile(JSONArray parameters, String tempInputDirPath) throws JSONException, IOException {
for (int i = 0; i < parameters.length(); i++) { for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(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")) { 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"); File scriptFile = new File(tempInputDirPath + File.separator + "guiscipt.sh");
if (scriptFile.createNewFile()) { if (scriptFile.createNewFile()) {
writeValueToFile(scriptContent, scriptFile); writeValueToFile(scriptContent, scriptFile);
......
...@@ -33,7 +33,7 @@ import java.util.List; ...@@ -33,7 +33,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; 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 nl.uva.sne.drip.commons.types.Message;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
...@@ -108,13 +108,13 @@ public class Consumer extends DefaultConsumer { ...@@ -108,13 +108,13 @@ public class Consumer extends DefaultConsumer {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
Message request = mapper.readValue(message, Message.class); Message request = mapper.readValue(message, Message.class);
List<Parameter> params = request.getParameters(); List<MessageParameter> params = request.getParameters();
//Create tmp input files //Create tmp input files
File inputFile = File.createTempFile("input-", Long.toString(System.nanoTime())); File inputFile = File.createTempFile("input-", Long.toString(System.nanoTime()));
File exampleFile = File.createTempFile("example-", 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 //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")) { if (param.getName().equals("input")) {
try (PrintWriter out = new PrintWriter(inputFile)) { try (PrintWriter out = new PrintWriter(inputFile)) {
out.print(param.getValue()); out.print(param.getValue());
...@@ -141,16 +141,16 @@ public class Consumer extends DefaultConsumer { ...@@ -141,16 +141,16 @@ public class Consumer extends DefaultConsumer {
File exampleFile = File.createTempFile("example-", Long.toString(System.nanoTime())); File exampleFile = File.createTempFile("example-", Long.toString(System.nanoTime()));
for (int i = 0; i < parameters.length(); i++) { for (int i = 0; i < parameters.length(); i++) {
JSONObject param = (JSONObject) parameters.get(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")) { if (name.equals("input")) {
try (PrintWriter out = new PrintWriter(inputFile)) { try (PrintWriter out = new PrintWriter(inputFile)) {
out.print(param.get(Parameter.VALUE)); out.print(param.get(MessageParameter.VALUE));
} }
files[0] = inputFile; files[0] = inputFile;
} }
if (name.equals("example")) { if (name.equals("example")) {
try (PrintWriter out = new PrintWriter(exampleFile)) { try (PrintWriter out = new PrintWriter(exampleFile)) {
out.print(param.get(Parameter.VALUE)); out.print(param.get(MessageParameter.VALUE));
} }
files[1] = exampleFile; files[1] = exampleFile;
} }
...@@ -164,7 +164,7 @@ public class Consumer extends DefaultConsumer { ...@@ -164,7 +164,7 @@ public class Consumer extends DefaultConsumer {
List parameters = new ArrayList(); List parameters = new ArrayList();
String charset = "UTF-8"; String charset = "UTF-8";
for (File f : files) { for (File f : files) {
Parameter fileParam = new Parameter(); MessageParameter fileParam = new MessageParameter();
byte[] bytes = Files.readAllBytes(Paths.get(f.getAbsolutePath())); byte[] bytes = Files.readAllBytes(Paths.get(f.getAbsolutePath()));
fileParam.setValue(new String(bytes, charset)); fileParam.setValue(new String(bytes, charset));
fileParam.setEncoding(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