Commit bcffffd4 authored by Spiros Koulouzis's avatar Spiros Koulouzis

Implemented Planning API v0

parent 2f8b45bf
......@@ -75,6 +75,19 @@ public class ToscaService {
return t.getId();
}
public String save(String yamlString, String name) throws IOException {
if (name == null) {
name = System.currentTimeMillis() + "_" + "tosca.yaml";
}
yamlString = yamlString.replaceAll("\\.", "\uff0E");
Map<String, Object> map = Converter.ymlString2Map(yamlString);
ToscaRepresentation t = new ToscaRepresentation();
t.setName(name);
t.setKvMap(map);
dao.save(t);
return t.getId();
}
public void delete(String id) {
dao.delete(id);
}
......
......@@ -105,7 +105,7 @@ public class UserScriptController {
*
* @return a list of all the IDs
*/
@RequestMapping(value = "/ids")
@RequestMapping(value = "/ids", method = RequestMethod.GET)
public @ResponseBody
List<String> getIds() {
List<UserScript> all = dao.findAll();
......
/*
* 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.v0.types;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
/**
*
* @author S. Koulouzis
*/
public class File {
@XmlAttribute
public String name;
@XmlAttribute
public String level;
@XmlValue
public String content;
}
......@@ -17,7 +17,6 @@ package nl.uva.sne.drip.commons.v0.types;
import com.webcohesion.enunciate.metadata.DocumentationExample;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
......
......@@ -15,6 +15,10 @@
*/
package nl.uva.sne.drip.commons.v0.types;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
/**
......@@ -24,4 +28,40 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Result {
private status status;
private String info;
public List<File> file;
/**
* @return the type
*/
public status getStatus() {
return status;
}
public void setStatus(status status) {
this.status = status;
}
public static enum status {
Success,
Fail
}
/**
* @return the info
*/
public String getInfo() {
return info;
}
/**
* @param info the info to set
*/
public void setInfo(String info) {
this.info = info;
}
}
......@@ -53,7 +53,7 @@ public class UserScript {
*
* @return the name
*/
@DocumentationExample("client.py")
@DocumentationExample("config.sh")
public String getName() {
return name;
}
......@@ -70,14 +70,6 @@ public class UserScript {
*
* @return the contents
*/
@DocumentationExample("config.sh")
public String getContents() {
return contents;
}
/**
* @param contents the contents to set
*/
@DocumentationExample(" #!/bin/bash\n"
+ "echo \"Reading system-wide config....\" >&2\\n"
+ ". /etc/cool.cfg\n"
......@@ -85,6 +77,13 @@ public class UserScript {
+ " echo \"Reading user config....\" >&2\\n"
+ " . ~/.coolrc\\n"
+ "fi")
public String getContents() {
return contents;
}
/**
* @param contents the contents to set
*/
public void setContents(String contents) {
this.contents = contents;
}
......
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