Commit f102f1f4 authored by skoulouzis's avatar skoulouzis Committed by GitHub

Merge pull request #30 from skoulouzis/v0.0_API

Implmented provisioner for v0.0
parents bda62e5e 416a104a
......@@ -28,7 +28,7 @@ public class WebAppInitializer implements WebApplicationInitializer {
ctx.register(MultipartConfig.class);
ctx.register(MongoConfig.class);
ctx.register(SecurityConfig.class);
ctx.register(MethodSecurityConfig.class);
// ctx.register(MethodSecurityConfig.class);
ctx.setServletContext(servletContext);
......
......@@ -22,6 +22,6 @@ import org.springframework.data.mongodb.repository.MongoRepository;
*
* @author S. Koulouzis
*/
public interface UserScriptDao extends MongoRepository<Script, String> {
public interface ScriptDao extends MongoRepository<Script, String> {
}
......@@ -18,10 +18,12 @@ package nl.uva.sne.drip.api.service;
import java.util.List;
import nl.uva.sne.drip.api.dao.CloudCredentialsDao;
import nl.uva.sne.drip.commons.v1.types.CloudCredentials;
import nl.uva.sne.drip.commons.v1.types.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
/**
......@@ -29,33 +31,35 @@ import org.springframework.stereotype.Service;
* @author S. Koulouzis
*/
@Service
@PreAuthorize("isAuthenticated()")
public class CloudCredentialsService {
@Autowired
private CloudCredentialsDao dao;
// @PreFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public CloudCredentials save(CloudCredentials cloudCredentials) {
// String owner = user.getUsername();
// cloudCredentials.setOwner(owner);
System.err.println(cloudCredentials.getOwner());
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
cloudCredentials.setOwner(owner);
return dao.save(cloudCredentials);
}
// @PreAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
@PreAuthorize("hasPermission(#returnObject, 'read')")
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public CloudCredentials findOne(String id) {
CloudCredentials creds = dao.findOne(id);
return creds;
}
public void delete(String id) {
dao.delete(id);
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public CloudCredentials delete(String id) {
CloudCredentials creds = dao.findOne(id);
dao.delete(creds);
return creds;
}
// @PreAuthorize(" (hasRole('ROLE_ADMIN')) or (hasRole('ROLE_USER'))")
// @PostFilter("(filterObject.owner == authentication.name)")
@PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
// @PostFilter("hasPermission(filterObject, 'read') or hasPermission(filterObject, 'admin')")
public List<CloudCredentials> findAll() {
return dao.findAll();
}
......
......@@ -34,11 +34,14 @@ import nl.uva.sne.drip.commons.v1.types.MessageParameter;
import nl.uva.sne.drip.commons.v1.types.Plan;
import nl.uva.sne.drip.commons.v1.types.ToscaRepresentation;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.commons.v1.types.User;
import nl.uva.sne.drip.drip.converter.P2PConverter;
import nl.uva.sne.drip.drip.converter.SimplePlanContainer;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
/**
......@@ -46,6 +49,7 @@ import org.springframework.stereotype.Service;
* @author S. Koulouzis
*/
@Service
@PreAuthorize("isAuthenticated()")
public class PlannerService {
@Autowired
......@@ -92,18 +96,18 @@ public class PlannerService {
lowLevelPlan.setToscaID(toscaId);
lowLevelPlan.setName(lowLevelNames);
lowLevelPlan.setKvMap(Converter.ymlString2Map(map.get(lowLevelNames)));
planDao.save(lowLevelPlan);
save(lowLevelPlan);
loweLevelPlansIDs.add(lowLevelPlan.getId());
}
topLevel.setLoweLevelPlansIDs(loweLevelPlansIDs);
planDao.save(topLevel);
save(topLevel);
return topLevel;
}
}
private Message buildPlannerMessage(String toscaId) throws JSONException, UnsupportedEncodingException {
ToscaRepresentation t2 = toscaService.getDao().findOne(toscaId);
ToscaRepresentation t2 = toscaService.findOne(toscaId);
if (t2 == null) {
throw new BadRequestException();
}
......@@ -136,7 +140,9 @@ public class PlannerService {
Set<String> ids = plan.getLoweLevelPlanIDs();
for (String lowID : ids) {
Map<String, Object> lowLevelMap = planDao.findOne(lowID).getKeyValue();
map.putAll(lowLevelMap);
if (lowLevelMap != null) {
map.putAll(lowLevelMap);
}
}
if (fromat != null && fromat.equals("yml")) {
......@@ -158,10 +164,6 @@ public class PlannerService {
return planDao.findOne(id).getToscaID();
}
public PlanDao getDao() {
return this.planDao;
}
public List<Plan> findAll() {
List<Plan> all = planDao.findAll();
List<Plan> topLevel = new ArrayList<>();
......@@ -173,4 +175,21 @@ public class PlannerService {
return topLevel;
}
public Plan save(Plan plan) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
plan.setOwner(owner);
return planDao.save(plan);
}
public Plan findOne(String lowiID) {
return planDao.findOne(lowiID);
}
public Plan delete(String id) {
Plan plan = planDao.findOne(id);
planDao.delete(plan);
return plan;
}
}
......@@ -56,7 +56,7 @@ public class SimplePlannerService {
private PlanDao planDao;
public Plan getPlan(String toscaId) throws JSONException, IOException, TimeoutException, InterruptedException {
ToscaRepresentation tosca = toscaService.getDao().findOne(toscaId);
ToscaRepresentation tosca = toscaService.findOne(toscaId);
Message plannerInvokationMessage = buildSimplePlannerMessage(tosca);
Plan topLevel;
......
......@@ -22,8 +22,13 @@ import nl.uva.sne.drip.api.dao.ToscaDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.commons.v1.types.ToscaRepresentation;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.commons.v1.types.User;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
......@@ -32,13 +37,14 @@ import org.springframework.web.multipart.MultipartFile;
* @author S. Koulouzis
*/
@Service
@PreAuthorize("isAuthenticated()")
public class ToscaService {
@Autowired
private ToscaDao dao;
public String get(String id, String fromat) throws JSONException {
ToscaRepresentation tosca = dao.findOne(id);
ToscaRepresentation tosca = findOne(id);
if (tosca == null) {
throw new NotFoundException();
}
......@@ -60,7 +66,7 @@ public class ToscaService {
return ymlStr;
}
public String save(MultipartFile file) throws IOException {
public String saveFile(MultipartFile file) throws IOException {
String originalFileName = file.getOriginalFilename();
String name = System.currentTimeMillis() + "_" + originalFileName;
byte[] bytes = file.getBytes();
......@@ -71,11 +77,11 @@ public class ToscaService {
ToscaRepresentation t = new ToscaRepresentation();
t.setName(name);
t.setKvMap(map);
dao.save(t);
save(t);
return t.getId();
}
public String save(String yamlString, String name) throws IOException {
public String saveYamlString(String yamlString, String name) throws IOException {
if (name == null) {
name = System.currentTimeMillis() + "_" + "tosca.yaml";
}
......@@ -84,27 +90,31 @@ public class ToscaService {
ToscaRepresentation t = new ToscaRepresentation();
t.setName(name);
t.setKvMap(map);
dao.save(t);
save(t);
return t.getId();
}
public void delete(String id) {
dao.delete(id);
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public ToscaRepresentation delete(String id) {
ToscaRepresentation tr = dao.findOne(id);
dao.delete(tr);
return tr;
}
@PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public List<ToscaRepresentation> findAll() {
return dao.findAll();
}
public ToscaDao getDao() {
return dao;
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public ToscaRepresentation findOne(String id) {
return dao.findOne(id);
}
public ToscaRepresentation get(String planID) {
ToscaRepresentation tosca = dao.findOne(planID);
if (tosca == null) {
throw new NotFoundException();
}
return tosca;
private ToscaRepresentation save(ToscaRepresentation t) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
t.setOwner(owner);
return dao.save(t);
}
}
......@@ -19,7 +19,11 @@ import java.util.ArrayList;
import java.util.List;
import nl.uva.sne.drip.api.dao.UserKeyDao;
import nl.uva.sne.drip.commons.v1.types.LoginKey;
import nl.uva.sne.drip.commons.v1.types.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
/**
......@@ -32,12 +36,8 @@ public class UserKeyService {
@Autowired
UserKeyDao dao;
public UserKeyDao getDao() {
return dao;
}
public List<LoginKey> getAll(LoginKey.Type type) {
List<LoginKey> all = getDao().findAll();
List<LoginKey> all = findAll();
if (all != null) {
List<LoginKey> allPublic = new ArrayList<>();
for (LoginKey tr : all) {
......@@ -51,7 +51,7 @@ public class UserKeyService {
}
public LoginKey get(String id, LoginKey.Type type) {
LoginKey key = getDao().findOne(id);
LoginKey key = findOne(id);
if (key.getType().equals(type)) {
return key;
}
......@@ -61,7 +61,31 @@ public class UserKeyService {
public void delete(String id, LoginKey.Type type) {
LoginKey k = get(id, type);
if (k != null) {
getDao().delete(k);
delete(k);
}
}
@PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public List<LoginKey> findAll() {
return dao.findAll();
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public LoginKey findOne(String id) {
return dao.findOne(id);
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public LoginKey delete(LoginKey k) {
k = dao.findOne(k.getId());
dao.delete(k);
return k;
}
public LoginKey save(LoginKey upk) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
upk.setOwner(owner);
return dao.save(upk);
}
}
......@@ -15,21 +15,52 @@
*/
package nl.uva.sne.drip.api.service;
import nl.uva.sne.drip.api.dao.UserScriptDao;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import nl.uva.sne.drip.api.dao.ScriptDao;
import nl.uva.sne.drip.commons.v1.types.Script;
import nl.uva.sne.drip.commons.v1.types.User;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.core.context.SecurityContextHolder;
/**
*
* @author S. Koulouzis
*/
@Service
@PreAuthorize("isAuthenticated()")
public class UserScriptService {
@Autowired
UserScriptDao dao;
ScriptDao dao;
public UserScriptDao getDao() {
return dao;
public Script save(Script script) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String owner = user.getUsername();
script.setOwner(owner);
return dao.save(script);
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public Script findOne(String id) {
Script script = dao.findOne(id);
return script;
}
@PostAuthorize("(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
public Script delete(String id) {
Script script = dao.findOne(id);
dao.delete(script);
return script;
}
// @PreAuthorize(" (hasRole('ROLE_ADMIN')) or (hasRole('ROLE_USER'))")
@PostFilter("(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))")
// @PostFilter("hasPermission(filterObject, 'read') or hasPermission(filterObject, 'admin')")
public List<Script> findAll() {
return dao.findAll();
}
}
......@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.dao.CloudCredentialsDao;
import nl.uva.sne.drip.api.exception.NullKeyException;
import nl.uva.sne.drip.api.exception.NullKeyIDException;
import nl.uva.sne.drip.api.service.CloudCredentialsService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.commons.v0.types.Configure;
import nl.uva.sne.drip.commons.v1.types.LoginKey;
......@@ -49,7 +50,7 @@ import org.springframework.web.bind.annotation.RequestBody;
public class CloudConfigurationController0 {
@Autowired
private CloudCredentialsDao cloudCredentialsDao;
private CloudCredentialsService cloudCredentialsDao;
@RequestMapping(value = "/ec2", method = RequestMethod.POST, consumes = MediaType.TEXT_XML_VALUE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
......@@ -77,7 +78,7 @@ public class CloudConfigurationController0 {
}
cloudCredentials.setLogineKeys(loginKeys);
cloudCredentials.setCloudProviderName("ec2");
cloudCredentials = cloudCredentialsDao.save(cloudCredentials);
return "Success: " + cloudCredentials.getId();
}
......
......@@ -35,7 +35,6 @@ import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.commons.v0.types.File;
import nl.uva.sne.drip.commons.v0.types.Plan;
import org.apache.commons.io.FilenameUtils;
import org.json.JSONException;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -65,44 +64,26 @@ public class PlannerController0 {
try {
String yaml = plan0.file;
yaml = yaml.replaceAll("\\\\n", "\n");
String id = toscaService.save(yaml, null);
String id = toscaService.saveYamlString(yaml, null);
nl.uva.sne.drip.commons.v1.types.Plan plan1 = plannerService.getPlan(id);
Result r = new Result();
r.info = ("INFO");
r.status = ("Success");
List<File> files = new ArrayList<>();
File e = new File();
e.level = String.valueOf(plan1.getLevel());
String p1Name = FilenameUtils.getBaseName(plan1.getName());
if (p1Name == null) {
p1Name = "Planned_tosca_file_" + plan1.getLevel();
plan1.setName(p1Name);
plannerService.getDao().save(plan1);
}
File e = Converter.plan1toFile(plan1);
e.name = p1Name;
e.content = Converter.map2YmlString(plan1.getKeyValue()).replaceAll("\n", "\\n");
files.add(e);
for (String lowiID : plan1.getLoweLevelPlanIDs()) {
nl.uva.sne.drip.commons.v1.types.Plan lowPlan1 = plannerService.getDao().findOne(lowiID);
e = new File();
e.level = String.valueOf(lowPlan1.getLevel());
p1Name = lowPlan1.getName();
if (p1Name == null) {
p1Name = "Planned_tosca_file_" + lowPlan1.getLevel();
plan1.setName(p1Name);
plannerService.getDao().save(lowPlan1);
}
e.name = p1Name;
e.content = Converter.map2YmlString(lowPlan1.getKeyValue()).replaceAll("\n", "\\n");;
nl.uva.sne.drip.commons.v1.types.Plan lowPlan1 = plannerService.findOne(lowiID);
e = Converter.plan1toFile(lowPlan1);
files.add(e);
//Don't save them cause they will be re-uploaded in the provision step
plannerService.delete(lowPlan1.getId());
}
r.file = files;
plannerService.delete(plan1.getId());
return r;
} catch (IOException | JSONException | TimeoutException | InterruptedException ex) {
Logger.getLogger(PlannerController0.class.getName()).log(Level.SEVERE, null, ex);
......
......@@ -39,9 +39,7 @@ import nl.uva.sne.drip.api.exception.NullKeyIDException;
import nl.uva.sne.drip.api.service.CloudCredentialsService;
import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.commons.v1.types.LoginKey;
import nl.uva.sne.drip.commons.v1.types.User;
import org.apache.commons.io.FilenameUtils;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
......
......@@ -26,7 +26,6 @@ import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.security.RolesAllowed;
import nl.uva.sne.drip.api.dao.CloudCredentialsDao;
import nl.uva.sne.drip.api.exception.BadRequestException;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.commons.v1.types.Message;
......@@ -34,13 +33,13 @@ import nl.uva.sne.drip.commons.v1.types.MessageParameter;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.rpc.DRIPCaller;
import nl.uva.sne.drip.api.rpc.DeployerCaller;
import nl.uva.sne.drip.api.service.CloudCredentialsService;
import nl.uva.sne.drip.api.service.ClusterCredentialService;
import nl.uva.sne.drip.api.service.ProvisionService;
import nl.uva.sne.drip.api.service.UserService;
......@@ -67,7 +66,7 @@ public class DeployController {
private String messageBrokerHost;
@Autowired
private CloudCredentialsDao cloudCredentialsDao;
private CloudCredentialsService cloudCredentialsService;
@Autowired
private ProvisionService provisionService;
......@@ -152,19 +151,19 @@ public class DeployController {
String delete(@PathVariable("id") String id) {
ClusterCredentials cred = clusterCredentialService.getDao().findOne(id);
if (cred != null) {
provisionService.getDao().delete(id);
provisionService.delete(id);
return "Deleted : " + id;
}
throw new NotFoundException();
}
private Message buildDeployerMessage(String provisionID, String clusterType) {
ProvisionInfo pro = provisionService.getDao().findOne(provisionID);
ProvisionInfo pro = provisionService.findOne(provisionID);
if (pro == null) {
throw new NotFoundException();
}
String cloudConfID = pro.getCloudcloudCredentialsID();
CloudCredentials cCred = cloudCredentialsDao.findOne(cloudConfID);
CloudCredentials cCred = cloudCredentialsService.findOne(cloudConfID);
List<LoginKey> loginKeys = cCred.getLoginKeys();
List<DeployParameter> deployParams = pro.getDeployParameters();
List<MessageParameter> parameters = new ArrayList<>();
......
......@@ -25,7 +25,6 @@ import javax.annotation.security.RolesAllowed;
import nl.uva.sne.drip.api.exception.NotFoundException;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -117,7 +116,7 @@ public class PlannerController {
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String delete(@PathVariable("id") String id) {
plannerService.getDao().delete(id);
plannerService.delete(id);
return "Deleted : " + id;
}
......
......@@ -62,7 +62,7 @@ public class ToscaController {
throw new BadRequestException("Must uplaod a file");
}
try {
return toscaService.save(file);
return toscaService.saveFile(file);
} catch (IOException | IllegalStateException ex) {
Logger.getLogger(ToscaController.class.getName()).log(Level.SEVERE, null, ex);
}
......
......@@ -77,7 +77,7 @@ public class UserPublicKeysController {
upk.setName(name);
upk.setType(LoginKey.Type.PUBLIC);
service.getDao().save(upk);
service.save(upk);
return upk.getId();
} catch (IOException | IllegalStateException ex) {
......@@ -119,7 +119,7 @@ public class UserPublicKeysController {
key.setName(name);
key.setType(LoginKey.Type.PUBLIC);
service.getDao().save(key);
service.save(key);
return key.getId();
}
......
......@@ -28,10 +28,10 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import nl.uva.sne.drip.api.dao.UserScriptDao;
import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.commons.v1.types.Script;
import org.springframework.web.bind.annotation.PathVariable;
import nl.uva.sne.drip.api.dao.ScriptDao;
/**
* This controller is responsible for handling user scripts. These user can be
......@@ -45,7 +45,7 @@ import org.springframework.web.bind.annotation.PathVariable;
public class UserScriptController {
@Autowired
private UserScriptDao dao;
private ScriptDao dao;
// curl -v -X POST -F "file=@script.sh" localhost:8080/drip-api/rest/user_script/upload
/**
......
......@@ -26,9 +26,12 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import nl.uva.sne.drip.commons.v0.types.File;
import nl.uva.sne.drip.commons.v1.types.CloudCredentials;
import nl.uva.sne.drip.commons.v1.types.Message;
import nl.uva.sne.drip.commons.v1.types.MessageParameter;
import nl.uva.sne.drip.commons.v1.types.Plan;
import org.apache.commons.io.FilenameUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -174,4 +177,29 @@ public class Converter {
return mess;
}
public static File plan1toFile(Plan plan1) throws JSONException {
File e = new File();
e.level = String.valueOf(plan1.getLevel());
String p1Name = FilenameUtils.getBaseName(plan1.getName());
if (p1Name == null) {
p1Name = "Planned_tosca_file_" + plan1.getLevel();
plan1.setName(p1Name);
}
e.name = p1Name;
String ymlString = Converter.map2YmlString(plan1.getKeyValue());
e.content = ymlString.replaceAll("\n", "\\\\n");
return e;
}
public static Plan File2Plan1(File p0) {
Plan p1 = new Plan();
p1.setLevel(Integer.valueOf(p0.level));
p1.setName(p0.name);
String yaml = p0.content.replaceAll("\\\\n", "\n");
p1.setKvMap(ymlString2Map(yaml));
return p1;
}
}
......@@ -16,16 +16,18 @@
package nl.uva.sne.drip.commons.v0.types;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public class Upload {
public String user;
public String pwd;
List<File> file;
public List<File> file;
}
......@@ -24,7 +24,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
public class KeyValueHolder {
public class KeyValueHolder extends OwnedObject{
@Id
private String id;
......
......@@ -28,7 +28,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
public class LoginKey {
public class LoginKey extends OwnedObject {
@Id
private String id;
......
......@@ -25,7 +25,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
* @author S. Koulouzis
*/
@Document
public class Script {
public class Script extends OwnedObject{
@Id
private String id;
......
......@@ -15,8 +15,6 @@
*/
package nl.uva.sne.drip.commons.v1.types;
import java.util.Map;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
......
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