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
18012161
Commit
18012161
authored
Feb 22, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw exception if provider name is null
parent
a2148dd6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
8 deletions
+26
-8
ProvisionController.java
...in/java/nl/uva/sne/drip/api/rest/ProvisionController.java
+6
-1
DRIPCaller.java
...api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java
+8
-2
PlannerService.java
...main/java/nl/uva/sne/drip/api/service/PlannerService.java
+7
-2
SimplePlannerService.java
...ava/nl/uva/sne/drip/api/service/SimplePlannerService.java
+5
-3
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/rest/ProvisionController.java
View file @
18012161
...
...
@@ -43,6 +43,7 @@ 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.dao.ToscaDao
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.rpc.DRIPCaller
;
import
nl.uva.sne.drip.api.rpc.ProvisionerCaller
;
...
...
@@ -74,7 +75,7 @@ public class ProvisionController {
ProvisionRequest
get
()
{
ProvisionRequest
re
=
new
ProvisionRequest
();
re
.
setCloudConfID
(
"58a1f0a963d42f004b1d63ad"
);
re
.
setPlanID
(
"58a
c1e70e4949b54f8ac1051
"
);
re
.
setPlanID
(
"58a
d99d578b6ba941aeb22a4
"
);
re
.
setUserKeyID
(
"58a20be263d4a5898835676e"
);
re
.
setUserScriptID
(
"58a2112363d41754cca042b4"
);
return
re
;
...
...
@@ -123,6 +124,10 @@ public class ProvisionController {
private
Parameter
buildCloudConfParam
(
CloudCredentials
cred
)
throws
JsonProcessingException
,
JSONException
,
IOException
{
Parameter
conf
=
null
;
String
provider
=
cred
.
getCloudProviderName
();
if
(
provider
==
null
)
{
throw
new
BadRequestException
(
"Provider name can't be null. Check the cloud credentials: "
+
cred
.
getId
());
}
switch
(
cred
.
getCloudProviderName
().
toLowerCase
())
{
case
"ec2"
:
conf
=
buildEC2Conf
(
cred
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rpc/DRIPCaller.java
View file @
18012161
...
...
@@ -118,11 +118,16 @@ public abstract class DRIPCaller implements AutoCloseable {
}
});
String
strResponse
=
response
.
take
();
// return unMarshallWithSimpleJson(strResponse);
return
mapper
.
readValue
(
strResponse
,
Message
.
class
);
}
private
Message
unMarshallWithSimpleJson
(
String
strResponse
)
throws
JSONException
{
strResponse
=
strResponse
.
replaceAll
(
"'null'"
,
"null"
).
replaceAll
(
"\'"
,
"\""
).
replaceAll
(
" "
,
""
);
// System.err.println(strResponse);
JSONObject
jsonObj
=
new
JSONObject
(
strResponse
);
Message
responseMessage
=
new
Message
();
responseMessage
.
setCreationDate
((
Long
)
jsonObj
.
get
(
"creationDate"
));
JSONArray
jsonParams
=
(
JSONArray
)
jsonObj
.
get
(
"parameters"
);
List
<
Parameter
>
parameters
=
new
ArrayList
<>();
...
...
@@ -137,7 +142,8 @@ public abstract class DRIPCaller implements AutoCloseable {
}
responseMessage
.
setParameters
(
parameters
);
return
responseMessage
;
//mapper.readValue(strResponse, Message.class);
return
responseMessage
;
//
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlannerService.java
View file @
18012161
...
...
@@ -21,6 +21,8 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeoutException
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Parameter
;
...
...
@@ -51,8 +53,8 @@ public class PlannerService {
Message
plannerReturnedMessage
=
planner
.
call
(
plannerInvokationMessage
);
List
<
Parameter
>
parameters
=
plannerReturnedMessage
.
getParameters
();
for
(
Parameter
param:
parameters
)
{
for
(
Parameter
param
:
parameters
)
{
}
ToscaRepresentation
tr
=
new
ToscaRepresentation
();
Map
<
String
,
Object
>
kvMap
=
null
;
...
...
@@ -65,6 +67,9 @@ public class PlannerService {
private
Message
buildPlannerMessage
(
String
toscaId
)
throws
JSONException
,
UnsupportedEncodingException
{
ToscaRepresentation
t2
=
toscaService
.
getDao
().
findOne
(
toscaId
);
if
(
t2
==
null
||
t2
.
getType
().
equals
(
ToscaRepresentation
.
Type
.
PLAN
))
{
throw
new
BadRequestException
(
"The description: "
+
toscaId
+
" is a plan. Cannot be used as planner input"
);
}
Map
<
String
,
Object
>
map
=
t2
.
getKvMap
();
String
json
=
Converter
.
map2JsonString
(
map
);
json
=
json
.
replaceAll
(
"\\uff0E"
,
"\\."
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/SimplePlannerService.java
View file @
18012161
...
...
@@ -26,6 +26,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeoutException
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.commons.types.Message
;
...
...
@@ -81,7 +82,8 @@ public class SimplePlannerService {
}
ids
.
add
(
tr
.
getId
());
topLevel
.
setLowerLevelIDs
(
ids
);
}
topLevel
.
setType
(
ToscaRepresentation
.
Type
.
PLAN
);
}
topLevel
.
setType
(
ToscaRepresentation
.
Type
.
PLAN
);
toscaService
.
getDao
().
save
(
topLevel
);
}
return
topLevel
;
...
...
@@ -89,8 +91,8 @@ public class SimplePlannerService {
private
Message
buildSimplePlannerMessage
(
String
toscaId
)
throws
JSONException
,
UnsupportedEncodingException
,
IOException
{
ToscaRepresentation
t2
=
toscaService
.
getDao
().
findOne
(
toscaId
);
if
(
t2
==
null
)
{
throw
new
NotFoundException
(
);
if
(
t2
==
null
||
t2
.
getType
().
equals
(
ToscaRepresentation
.
Type
.
PLAN
)
)
{
throw
new
BadRequestException
(
"The description: "
+
toscaId
+
" is a plan. Cannot be used as planner input"
);
}
Map
<
String
,
Object
>
map
=
t2
.
getKvMap
();
String
ymlStr
=
Converter
.
map2YmlString
(
map
);
...
...
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