Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
a428e436
Commit
a428e436
authored
Mar 02, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse to Message POJO
parent
c3886b3f
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
159 additions
and
48 deletions
+159
-48
ClusterCredentialsDao.java
...n/java/nl/uva/sne/drip/api/dao/ClusterCredentialsDao.java
+27
-0
DeployController.java
.../main/java/nl/uva/sne/drip/api/rest/DeployController.java
+54
-9
ProvisionController.java
...in/java/nl/uva/sne/drip/api/rest/ProvisionController.java
+26
-26
DRIPCaller.java
...api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java
+5
-4
ClusterCredentialService.java
...nl/uva/sne/drip/api/service/ClusterCredentialService.java
+38
-0
PlannerService.java
...main/java/nl/uva/sne/drip/api/service/PlannerService.java
+4
-4
SimplePlannerService.java
...ava/nl/uva/sne/drip/api/service/SimplePlannerService.java
+5
-5
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/dao/ClusterCredentialsDao.java
0 → 100644
View file @
a428e436
/*
* 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
.
api
.
dao
;
import
nl.uva.sne.drip.commons.types.ClusterCredentials
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
/**
*
* @author S. Koulouzis
*/
public
interface
ClusterCredentialsDao
extends
MongoRepository
<
ClusterCredentials
,
String
>
{
}
drip-api/src/main/java/nl/uva/sne/drip/api/rest/DeployController.java
View file @
a428e436
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/rest/ProvisionController.java
View file @
a428e436
...
@@ -33,7 +33,7 @@ import java.util.logging.Logger;
...
@@ -33,7 +33,7 @@ import java.util.logging.Logger;
import
javax.annotation.security.RolesAllowed
;
import
javax.annotation.security.RolesAllowed
;
import
nl.uva.sne.drip.api.dao.CloudCredentialsDao
;
import
nl.uva.sne.drip.api.dao.CloudCredentialsDao
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Parameter
;
import
nl.uva.sne.drip.commons.types.
Message
Parameter
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -104,9 +104,9 @@ public class ProvisionController {
...
@@ -104,9 +104,9 @@ public class ProvisionController {
Message
response
=
provisioner
.
call
(
provisionerInvokationMessage
);
Message
response
=
provisioner
.
call
(
provisionerInvokationMessage
);
// Message response = generateFakeResponse();
// Message response = generateFakeResponse();
List
<
Parameter
>
params
=
response
.
getParameters
();
List
<
Message
Parameter
>
params
=
response
.
getParameters
();
for
(
Parameter
p
:
params
)
{
for
(
Message
Parameter
p
:
params
)
{
String
name
=
p
.
getName
();
String
name
=
p
.
getName
();
if
(!
name
.
equals
(
"kubernetes"
))
{
if
(!
name
.
equals
(
"kubernetes"
))
{
String
value
=
p
.
getValue
();
String
value
=
p
.
getValue
();
...
@@ -147,29 +147,29 @@ public class ProvisionController {
...
@@ -147,29 +147,29 @@ public class ProvisionController {
private
Message
buildProvisionerMessage
(
ProvisionInfo
pReq
)
throws
JSONException
,
IOException
{
private
Message
buildProvisionerMessage
(
ProvisionInfo
pReq
)
throws
JSONException
,
IOException
{
Message
invokationMessage
=
new
Message
();
Message
invokationMessage
=
new
Message
();
List
<
Parameter
>
parameters
=
new
ArrayList
();
List
<
Message
Parameter
>
parameters
=
new
ArrayList
();
CloudCredentials
cred
=
cloudCredentialsDao
.
findOne
(
pReq
.
getCloudConfID
());
CloudCredentials
cred
=
cloudCredentialsDao
.
findOne
(
pReq
.
getCloudConfID
());
if
(
cred
==
null
)
{
if
(
cred
==
null
)
{
throw
new
NotFoundException
(
"Cloud credentials :"
+
pReq
.
getCloudConfID
()
+
" not found"
);
throw
new
NotFoundException
(
"Cloud credentials :"
+
pReq
.
getCloudConfID
()
+
" not found"
);
}
}
Parameter
conf
=
buildCloudConfParam
(
cred
);
Message
Parameter
conf
=
buildCloudConfParam
(
cred
);
parameters
.
add
(
conf
);
parameters
.
add
(
conf
);
List
<
Parameter
>
certs
=
buildCertificatesParam
(
cred
);
List
<
Message
Parameter
>
certs
=
buildCertificatesParam
(
cred
);
parameters
.
addAll
(
certs
);
parameters
.
addAll
(
certs
);
List
<
Parameter
>
topologies
=
buildTopologyParams
(
pReq
.
getPlanID
());
List
<
Message
Parameter
>
topologies
=
buildTopologyParams
(
pReq
.
getPlanID
());
parameters
.
addAll
(
topologies
);
parameters
.
addAll
(
topologies
);
String
scriptID
=
pReq
.
getUserScriptID
();
String
scriptID
=
pReq
.
getUserScriptID
();
if
(
scriptID
!=
null
)
{
if
(
scriptID
!=
null
)
{
List
<
Parameter
>
userScripts
=
buildScriptParams
(
scriptID
);
List
<
Message
Parameter
>
userScripts
=
buildScriptParams
(
scriptID
);
parameters
.
addAll
(
userScripts
);
parameters
.
addAll
(
userScripts
);
}
}
String
userKeyID
=
pReq
.
getUserKeyID
();
String
userKeyID
=
pReq
.
getUserKeyID
();
if
(
userKeyID
!=
null
)
{
if
(
userKeyID
!=
null
)
{
List
<
Parameter
>
userKeys
=
buildKeysParams
(
userKeyID
);
List
<
Message
Parameter
>
userKeys
=
buildKeysParams
(
userKeyID
);
parameters
.
addAll
(
userKeys
);
parameters
.
addAll
(
userKeys
);
}
}
...
@@ -178,8 +178,8 @@ public class ProvisionController {
...
@@ -178,8 +178,8 @@ public class ProvisionController {
return
invokationMessage
;
return
invokationMessage
;
}
}
private
Parameter
buildCloudConfParam
(
CloudCredentials
cred
)
throws
JsonProcessingException
,
JSONException
,
IOException
{
private
Message
Parameter
buildCloudConfParam
(
CloudCredentials
cred
)
throws
JsonProcessingException
,
JSONException
,
IOException
{
Parameter
conf
=
null
;
Message
Parameter
conf
=
null
;
String
provider
=
cred
.
getCloudProviderName
();
String
provider
=
cred
.
getCloudProviderName
();
if
(
provider
==
null
)
{
if
(
provider
==
null
)
{
throw
new
BadRequestException
(
"Provider name can't be null. Check the cloud credentials: "
+
cred
.
getId
());
throw
new
BadRequestException
(
"Provider name can't be null. Check the cloud credentials: "
+
cred
.
getId
());
...
@@ -192,18 +192,18 @@ public class ProvisionController {
...
@@ -192,18 +192,18 @@ public class ProvisionController {
return
conf
;
return
conf
;
}
}
private
List
<
Parameter
>
buildCertificatesParam
(
CloudCredentials
cred
)
{
private
List
<
Message
Parameter
>
buildCertificatesParam
(
CloudCredentials
cred
)
{
List
<
LoginKey
>
loginKeys
=
cred
.
getLoginKeys
();
List
<
LoginKey
>
loginKeys
=
cred
.
getLoginKeys
();
if
(
loginKeys
==
null
||
loginKeys
.
isEmpty
())
{
if
(
loginKeys
==
null
||
loginKeys
.
isEmpty
())
{
throw
new
BadRequestException
(
"Log in keys can't be empty"
);
throw
new
BadRequestException
(
"Log in keys can't be empty"
);
}
}
List
<
Parameter
>
parameters
=
new
ArrayList
<>();
List
<
Message
Parameter
>
parameters
=
new
ArrayList
<>();
for
(
LoginKey
lk
:
loginKeys
)
{
for
(
LoginKey
lk
:
loginKeys
)
{
String
domainName
=
lk
.
getAttributes
().
get
(
"domain_name"
);
String
domainName
=
lk
.
getAttributes
().
get
(
"domain_name"
);
if
(
domainName
==
null
)
{
if
(
domainName
==
null
)
{
domainName
=
lk
.
getAttributes
().
get
(
"domain_name "
);
domainName
=
lk
.
getAttributes
().
get
(
"domain_name "
);
}
}
Parameter
cert
=
new
Parameter
();
MessageParameter
cert
=
new
Message
Parameter
();
cert
.
setName
(
"certificate"
);
cert
.
setName
(
"certificate"
);
cert
.
setValue
(
lk
.
getKey
());
cert
.
setValue
(
lk
.
getKey
());
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
...
@@ -214,13 +214,13 @@ public class ProvisionController {
...
@@ -214,13 +214,13 @@ public class ProvisionController {
return
parameters
;
return
parameters
;
}
}
private
List
<
Parameter
>
buildTopologyParams
(
String
planID
)
throws
JSONException
{
private
List
<
Message
Parameter
>
buildTopologyParams
(
String
planID
)
throws
JSONException
{
Plan
plan
=
planService
.
getDao
().
findOne
(
planID
);
Plan
plan
=
planService
.
getDao
().
findOne
(
planID
);
if
(
plan
==
null
)
{
if
(
plan
==
null
)
{
throw
new
NotFoundException
();
throw
new
NotFoundException
();
}
}
List
<
Parameter
>
parameters
=
new
ArrayList
();
List
<
Message
Parameter
>
parameters
=
new
ArrayList
();
Parameter
topology
=
new
Parameter
();
MessageParameter
topology
=
new
Message
Parameter
();
topology
.
setName
(
"topology"
);
topology
.
setName
(
"topology"
);
topology
.
setValue
(
Converter
.
map2YmlString
(
plan
.
getKvMap
()));
topology
.
setValue
(
Converter
.
map2YmlString
(
plan
.
getKvMap
()));
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
...
@@ -232,7 +232,7 @@ public class ProvisionController {
...
@@ -232,7 +232,7 @@ public class ProvisionController {
Set
<
String
>
ids
=
plan
.
getLoweLevelPlanIDs
();
Set
<
String
>
ids
=
plan
.
getLoweLevelPlanIDs
();
for
(
String
lowID
:
ids
)
{
for
(
String
lowID
:
ids
)
{
Plan
lowPlan
=
planService
.
getDao
().
findOne
(
lowID
);
Plan
lowPlan
=
planService
.
getDao
().
findOne
(
lowID
);
topology
=
new
Parameter
();
topology
=
new
Message
Parameter
();
topology
.
setName
(
"topology"
);
topology
.
setName
(
"topology"
);
topology
.
setValue
(
Converter
.
map2YmlString
(
lowPlan
.
getKvMap
()));
topology
.
setValue
(
Converter
.
map2YmlString
(
lowPlan
.
getKvMap
()));
attributes
=
new
HashMap
<>();
attributes
=
new
HashMap
<>();
...
@@ -244,13 +244,13 @@ public class ProvisionController {
...
@@ -244,13 +244,13 @@ public class ProvisionController {
return
parameters
;
return
parameters
;
}
}
private
Parameter
buildEC2Conf
(
CloudCredentials
cred
)
throws
JsonProcessingException
,
JSONException
,
IOException
{
private
Message
Parameter
buildEC2Conf
(
CloudCredentials
cred
)
throws
JsonProcessingException
,
JSONException
,
IOException
{
Properties
prop
=
Converter
.
getEC2Properties
(
cred
);
Properties
prop
=
Converter
.
getEC2Properties
(
cred
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
prop
.
store
(
baos
,
null
);
prop
.
store
(
baos
,
null
);
byte
[]
bytes
=
baos
.
toByteArray
();
byte
[]
bytes
=
baos
.
toByteArray
();
Parameter
conf
=
new
Parameter
();
MessageParameter
conf
=
new
Message
Parameter
();
conf
.
setName
(
"ec2.conf"
);
conf
.
setName
(
"ec2.conf"
);
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
conf
.
setValue
(
new
String
(
bytes
,
charset
));
conf
.
setValue
(
new
String
(
bytes
,
charset
));
...
@@ -258,13 +258,13 @@ public class ProvisionController {
...
@@ -258,13 +258,13 @@ public class ProvisionController {
}
}
private
List
<
Parameter
>
buildScriptParams
(
String
userScriptID
)
{
private
List
<
Message
Parameter
>
buildScriptParams
(
String
userScriptID
)
{
UserScript
script
=
userScriptService
.
getDao
().
findOne
(
userScriptID
);
UserScript
script
=
userScriptService
.
getDao
().
findOne
(
userScriptID
);
if
(
script
==
null
)
{
if
(
script
==
null
)
{
throw
new
BadRequestException
(
"User script: "
+
userScriptID
+
" was not found"
);
throw
new
BadRequestException
(
"User script: "
+
userScriptID
+
" was not found"
);
}
}
List
<
Parameter
>
parameters
=
new
ArrayList
();
List
<
Message
Parameter
>
parameters
=
new
ArrayList
();
Parameter
scriptParameter
=
new
Parameter
();
MessageParameter
scriptParameter
=
new
Message
Parameter
();
scriptParameter
.
setName
(
"guiscript"
);
scriptParameter
.
setName
(
"guiscript"
);
scriptParameter
.
setValue
(
script
.
getContents
());
scriptParameter
.
setValue
(
script
.
getContents
());
scriptParameter
.
setEncoding
(
"UTF-8"
);
scriptParameter
.
setEncoding
(
"UTF-8"
);
...
@@ -272,13 +272,13 @@ public class ProvisionController {
...
@@ -272,13 +272,13 @@ public class ProvisionController {
return
parameters
;
return
parameters
;
}
}
private
List
<
Parameter
>
buildKeysParams
(
String
userKeyID
)
{
private
List
<
Message
Parameter
>
buildKeysParams
(
String
userKeyID
)
{
LoginKey
key
=
userKeysService
.
get
(
userKeyID
,
LoginKey
.
Type
.
PUBLIC
);
LoginKey
key
=
userKeysService
.
get
(
userKeyID
,
LoginKey
.
Type
.
PUBLIC
);
if
(
key
==
null
)
{
if
(
key
==
null
)
{
throw
new
BadRequestException
(
"User key: "
+
userKeyID
+
" was not found"
);
throw
new
BadRequestException
(
"User key: "
+
userKeyID
+
" was not found"
);
}
}
List
<
Parameter
>
parameters
=
new
ArrayList
();
List
<
Message
Parameter
>
parameters
=
new
ArrayList
();
Parameter
keyParameter
=
new
Parameter
();
MessageParameter
keyParameter
=
new
Message
Parameter
();
keyParameter
.
setName
(
"sshkey"
);
keyParameter
.
setName
(
"sshkey"
);
keyParameter
.
setValue
(
key
.
getKey
());
keyParameter
.
setValue
(
key
.
getKey
());
keyParameter
.
setEncoding
(
"UTF-8"
);
keyParameter
.
setEncoding
(
"UTF-8"
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java
View file @
a428e436
...
@@ -16,7 +16,7 @@ import java.util.concurrent.ArrayBlockingQueue;
...
@@ -16,7 +16,7 @@ import java.util.concurrent.ArrayBlockingQueue;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.TimeoutException
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Parameter
;
import
nl.uva.sne.drip.commons.types.
Message
Parameter
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -118,7 +118,8 @@ public abstract class DRIPCaller implements AutoCloseable {
...
@@ -118,7 +118,8 @@ public abstract class DRIPCaller implements AutoCloseable {
}
}
});
});
String
strResponse
=
response
.
take
();
String
strResponse
=
response
.
take
();
strResponse
=
strResponse
.
replaceAll
(
"'null'"
,
"null"
).
replaceAll
(
"\'"
,
"\""
).
replaceAll
(
" "
,
""
);
System
.
err
.
println
(
strResponse
);
// return unMarshallWithSimpleJson(strResponse);
// return unMarshallWithSimpleJson(strResponse);
return
mapper
.
readValue
(
strResponse
,
Message
.
class
);
return
mapper
.
readValue
(
strResponse
,
Message
.
class
);
}
}
...
@@ -130,12 +131,12 @@ public abstract class DRIPCaller implements AutoCloseable {
...
@@ -130,12 +131,12 @@ public abstract class DRIPCaller implements AutoCloseable {
Message
responseMessage
=
new
Message
();
Message
responseMessage
=
new
Message
();
responseMessage
.
setCreationDate
((
Long
)
jsonObj
.
get
(
"creationDate"
));
responseMessage
.
setCreationDate
((
Long
)
jsonObj
.
get
(
"creationDate"
));
JSONArray
jsonParams
=
(
JSONArray
)
jsonObj
.
get
(
"parameters"
);
JSONArray
jsonParams
=
(
JSONArray
)
jsonObj
.
get
(
"parameters"
);
List
<
Parameter
>
parameters
=
new
ArrayList
<>();
List
<
Message
Parameter
>
parameters
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
jsonParams
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
jsonParams
.
length
();
i
++)
{
JSONObject
jsonParam
=
(
JSONObject
)
jsonParams
.
get
(
i
);
JSONObject
jsonParam
=
(
JSONObject
)
jsonParams
.
get
(
i
);
Parameter
parameter
=
new
Parameter
();
MessageParameter
parameter
=
new
Message
Parameter
();
parameter
.
setName
(
jsonParam
.
getString
(
"name"
));
parameter
.
setName
(
jsonParam
.
getString
(
"name"
));
parameter
.
setValue
(
jsonParam
.
getString
(
"value"
));
parameter
.
setValue
(
jsonParam
.
getString
(
"value"
));
parameters
.
add
(
parameter
);
parameters
.
add
(
parameter
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/ClusterCredentialService.java
0 → 100644
View file @
a428e436
/*
* 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
.
api
.
service
;
import
nl.uva.sne.drip.api.dao.ClusterCredentialsDao
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
*
* @author S. Koulouzis
*/
@Service
public
class
ClusterCredentialService
{
@Autowired
private
ClusterCredentialsDao
dao
;
/**
* @return the dao
*/
public
ClusterCredentialsDao
getDao
()
{
return
dao
;
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlannerService.java
View file @
a428e436
...
@@ -24,7 +24,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -24,7 +24,7 @@ import java.util.concurrent.TimeoutException;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Parameter
;
import
nl.uva.sne.drip.commons.types.
Message
Parameter
;
import
nl.uva.sne.drip.commons.types.ToscaRepresentation
;
import
nl.uva.sne.drip.commons.types.ToscaRepresentation
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
org.json.JSONException
;
import
org.json.JSONException
;
...
@@ -51,8 +51,8 @@ public class PlannerService {
...
@@ -51,8 +51,8 @@ public class PlannerService {
Message
plannerInvokationMessage
=
buildPlannerMessage
(
toscaId
);
Message
plannerInvokationMessage
=
buildPlannerMessage
(
toscaId
);
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
List
<
Parameter
>
parameters
=
plannerReturnedMessage
.
getParameters
();
List
<
Message
Parameter
>
parameters
=
plannerReturnedMessage
.
getParameters
();
for
(
Parameter
param
:
parameters
)
{
for
(
Message
Parameter
param
:
parameters
)
{
}
}
ToscaRepresentation
tr
=
new
ToscaRepresentation
();
ToscaRepresentation
tr
=
new
ToscaRepresentation
();
...
@@ -75,7 +75,7 @@ public class PlannerService {
...
@@ -75,7 +75,7 @@ public class PlannerService {
Message
invokationMessage
=
new
Message
();
Message
invokationMessage
=
new
Message
();
List
parameters
=
new
ArrayList
();
List
parameters
=
new
ArrayList
();
Parameter
jsonArgument
=
new
Parameter
();
MessageParameter
jsonArgument
=
new
Message
Parameter
();
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
jsonArgument
.
setValue
(
new
String
(
bytes
,
charset
));
jsonArgument
.
setValue
(
new
String
(
bytes
,
charset
));
jsonArgument
.
setEncoding
(
charset
);
jsonArgument
.
setEncoding
(
charset
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/SimplePlannerService.java
View file @
a428e436
...
@@ -30,7 +30,7 @@ import nl.uva.sne.drip.api.dao.PlanDao;
...
@@ -30,7 +30,7 @@ import nl.uva.sne.drip.api.dao.PlanDao;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Parameter
;
import
nl.uva.sne.drip.commons.types.
Message
Parameter
;
import
nl.uva.sne.drip.commons.types.Plan
;
import
nl.uva.sne.drip.commons.types.Plan
;
import
nl.uva.sne.drip.commons.types.ToscaRepresentation
;
import
nl.uva.sne.drip.commons.types.ToscaRepresentation
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.utils.Converter
;
...
@@ -62,14 +62,14 @@ public class SimplePlannerService {
...
@@ -62,14 +62,14 @@ public class SimplePlannerService {
Plan
topLevel
;
Plan
topLevel
;
try
(
PlannerCaller
planner
=
new
PlannerCaller
(
messageBrokerHost
))
{
try
(
PlannerCaller
planner
=
new
PlannerCaller
(
messageBrokerHost
))
{
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
List
<
Parameter
>
planFiles
=
plannerReturnedMessage
.
getParameters
();
List
<
Message
Parameter
>
planFiles
=
plannerReturnedMessage
.
getParameters
();
topLevel
=
new
Plan
();
topLevel
=
new
Plan
();
Set
<
String
>
ids
=
topLevel
.
getLoweLevelPlanIDs
();
Set
<
String
>
ids
=
topLevel
.
getLoweLevelPlanIDs
();
if
(
ids
==
null
)
{
if
(
ids
==
null
)
{
ids
=
new
HashSet
<>();
ids
=
new
HashSet
<>();
}
}
Plan
lowerLevelPlan
=
null
;
Plan
lowerLevelPlan
=
null
;
for
(
Parameter
p
:
planFiles
)
{
for
(
Message
Parameter
p
:
planFiles
)
{
//Should have levels in attributes
//Should have levels in attributes
Map
<
String
,
String
>
attributess
=
p
.
getAttributes
();
Map
<
String
,
String
>
attributess
=
p
.
getAttributes
();
if
(
attributess
!=
null
)
{
if
(
attributess
!=
null
)
{
...
@@ -108,7 +108,7 @@ public class SimplePlannerService {
...
@@ -108,7 +108,7 @@ public class SimplePlannerService {
Message
invokationMessage
=
new
Message
();
Message
invokationMessage
=
new
Message
();
List
parameters
=
new
ArrayList
();
List
parameters
=
new
ArrayList
();
Parameter
fileArgument
=
new
Parameter
();
MessageParameter
fileArgument
=
new
Message
Parameter
();
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
fileArgument
.
setValue
(
new
String
(
bytes
,
charset
));
fileArgument
.
setValue
(
new
String
(
bytes
,
charset
));
...
@@ -116,7 +116,7 @@ public class SimplePlannerService {
...
@@ -116,7 +116,7 @@ public class SimplePlannerService {
fileArgument
.
setName
(
"input"
);
fileArgument
.
setName
(
"input"
);
parameters
.
add
(
fileArgument
);
parameters
.
add
(
fileArgument
);
fileArgument
=
new
Parameter
();
fileArgument
=
new
Message
Parameter
();
bytes
=
Files
.
readAllBytes
(
Paths
.
get
(
System
.
getProperty
(
"user.home"
)
+
File
.
separator
+
"Downloads/DRIP/example_a.yml"
));
bytes
=
Files
.
readAllBytes
(
Paths
.
get
(
System
.
getProperty
(
"user.home"
)
+
File
.
separator
+
"Downloads/DRIP/example_a.yml"
));
fileArgument
.
setValue
(
new
String
(
bytes
,
charset
));
fileArgument
.
setValue
(
new
String
(
bytes
,
charset
));
fileArgument
.
setEncoding
(
charset
);
fileArgument
.
setEncoding
(
charset
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment