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
e1e33d95
Commit
e1e33d95
authored
8 years ago
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make parameter more generic
parent
a5bb42ce
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
98 deletions
+45
-98
UploadToscaController.java
.../java/nl/uva/sne/drip/api/rest/UploadToscaController.java
+19
-11
IFileParameter.java
...in/java/nl/uva/sne/drip/commons/types/IFileParameter.java
+0
-36
IMessage.java
...src/main/java/nl/uva/sne/drip/commons/types/IMessage.java
+2
-2
IParameter.java
...c/main/java/nl/uva/sne/drip/commons/types/IParameter.java
+13
-0
Message.java
.../src/main/java/nl/uva/sne/drip/commons/types/Message.java
+1
-1
Parameter.java
...rc/main/java/nl/uva/sne/drip/commons/types/Parameter.java
+1
-6
RequestRepository.java
...java/nl/uva/sne/drip/commons/types/RequestRepository.java
+0
-31
Consumer.java
.../src/main/java/nl/uva/sne/drip/drip/planner/Consumer.java
+9
-11
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/rest/UploadToscaController.java
View file @
e1e33d95
...
@@ -15,10 +15,8 @@
...
@@ -15,10 +15,8 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
rest
;
package
nl
.
uva
.
sne
.
drip
.
api
.
rest
;
import
nl.uva.sne.drip.commons.types.FileParameter
;
import
nl.uva.sne.drip.commons.types.Parameter
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
nl.uva.sne.drip.api.rpc.PlannerCaller
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
...
@@ -28,6 +26,7 @@ import java.util.List;
...
@@ -28,6 +26,7 @@ import java.util.List;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.TimeoutException
;
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.IParameter
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.Message
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -37,7 +36,6 @@ import org.springframework.web.bind.annotation.RequestParam;
...
@@ -37,7 +36,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
nl.uva.sne.drip.commons.types.IMessage
;
/**
/**
*
*
...
@@ -69,7 +67,7 @@ public class UploadToscaController {
...
@@ -69,7 +67,7 @@ public class UploadToscaController {
Message
invokationMessage
=
new
Message
();
Message
invokationMessage
=
new
Message
();
List
parameters
=
new
ArrayList
();
List
parameters
=
new
ArrayList
();
FileParameter
fileArgument
=
new
File
Parameter
();
Parameter
fileArgument
=
new
Parameter
();
byte
[]
bytes
=
file
.
getBytes
();
//Files.readAllBytes(Paths.get(targetToscaFile.getAbsolutePath()));
byte
[]
bytes
=
file
.
getBytes
();
//Files.readAllBytes(Paths.get(targetToscaFile.getAbsolutePath()));
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
fileArgument
.
setValue
(
new
String
(
bytes
,
charset
));
fileArgument
.
setValue
(
new
String
(
bytes
,
charset
));
...
@@ -77,7 +75,7 @@ public class UploadToscaController {
...
@@ -77,7 +75,7 @@ public class UploadToscaController {
fileArgument
.
setName
(
name
);
fileArgument
.
setName
(
name
);
parameters
.
add
(
fileArgument
);
parameters
.
add
(
fileArgument
);
fileArgument
=
new
File
Parameter
();
fileArgument
=
new
Parameter
();
bytes
=
Files
.
readAllBytes
(
Paths
.
get
(
"/home/alogo/Downloads/DRIP/example_a.yml"
));
bytes
=
Files
.
readAllBytes
(
Paths
.
get
(
"/home/alogo/Downloads/DRIP/example_a.yml"
));
fileArgument
.
setValue
(
new
String
(
bytes
,
charset
));
fileArgument
.
setValue
(
new
String
(
bytes
,
charset
));
fileArgument
.
setEncoding
(
charset
);
fileArgument
.
setEncoding
(
charset
);
...
@@ -103,16 +101,26 @@ public class UploadToscaController {
...
@@ -103,16 +101,26 @@ public class UploadToscaController {
public
Message
args
()
{
public
Message
args
()
{
try
{
try
{
Message
r
=
new
Message
();
Message
r
=
new
Message
();
List
args
=
new
ArrayList
();
List
<
IParameter
>
args
=
new
ArrayList
();
args
.
add
(
1
);
IParameter
intParam
=
new
Parameter
();
args
.
add
(
"str"
);
intParam
.
setValue
(
"1"
);
FileParameter
targetToscaFile
=
new
FileParameter
();
args
.
add
(
intParam
);
Parameter
strParam
=
new
Parameter
();
strParam
.
setValue
(
"string"
);
args
.
add
(
strParam
);
IParameter
targetToscaFile
=
new
Parameter
();
byte
[]
bytes
=
Files
.
readAllBytes
(
Paths
.
get
(
"/home/alogo/Downloads/planner_output_all.yml"
));
byte
[]
bytes
=
Files
.
readAllBytes
(
Paths
.
get
(
"/home/alogo/Downloads/planner_output_all.yml"
));
targetToscaFile
.
setValue
(
new
String
(
bytes
,
"UTF-8"
));
targetToscaFile
.
setValue
(
new
String
(
bytes
,
"UTF-8"
));
targetToscaFile
.
setName
(
"planner_output_all.yml"
);
targetToscaFile
.
setName
(
"planner_output_all.yml"
);
targetToscaFile
.
setEncoding
(
"UTF-8"
);
targetToscaFile
.
setEncoding
(
"UTF-8"
);
args
.
add
(
targetToscaFile
);
args
.
add
(
targetToscaFile
);
IParameter
file
=
new
Parameter
();
file
.
setName
(
"Dockerfile"
);
file
.
setURL
(
"https://github.com/QCAPI-DRIP/DRIP-integradation/releases/download/valpha/Dockerfile"
);
args
.
add
(
file
);
r
.
setParameters
(
args
);
r
.
setParameters
(
args
);
r
.
setCreationDate
(
new
Date
(
System
.
currentTimeMillis
()));
r
.
setCreationDate
(
new
Date
(
System
.
currentTimeMillis
()));
...
...
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/IFileParameter.java
deleted
100644 → 0
View file @
a5bb42ce
/*
* Copyright 2017 S. Koulouzis.
*
* 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
;
/**
*
* @author S. Koulouzis.
*/
public
interface
IFileParameter
{
public
String
getURL
();
public
void
setURL
(
String
url
);
public
String
getEncoding
();
public
void
setEncoding
(
String
encoding
);
public
void
setName
(
String
name
);
public
String
getName
();
}
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/IMessage.java
View file @
e1e33d95
...
@@ -28,8 +28,8 @@ public interface IMessage {
...
@@ -28,8 +28,8 @@ public interface IMessage {
public
void
setCreationDate
(
Date
creationDate
);
public
void
setCreationDate
(
Date
creationDate
);
public
void
setParameters
(
List
arg
s
);
public
void
setParameters
(
List
<
IParameter
>
param
s
);
public
List
getParameters
();
public
List
getParameters
();
}
}
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/IParameter.java
View file @
e1e33d95
...
@@ -21,6 +21,11 @@ package nl.uva.sne.drip.commons.types;
...
@@ -21,6 +21,11 @@ package nl.uva.sne.drip.commons.types;
*/
*/
public
interface
IParameter
{
public
interface
IParameter
{
public
static
final
String
NAME
=
"name"
;
public
static
final
String
URL
=
"url"
;
public
static
final
String
VALUE
=
"value"
;
public
static
final
String
ENCODING
=
"encoding"
;
public
void
setName
(
String
name
);
public
void
setName
(
String
name
);
public
String
getName
();
public
String
getName
();
...
@@ -29,4 +34,12 @@ public interface IParameter {
...
@@ -29,4 +34,12 @@ public interface IParameter {
public
void
setValue
(
String
value
);
public
void
setValue
(
String
value
);
public
String
getURL
();
public
void
setURL
(
String
url
);
public
String
getEncoding
();
public
void
setEncoding
(
String
encoding
);
}
}
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/Message.java
View file @
e1e33d95
...
@@ -49,7 +49,7 @@ public class Message implements IMessage, Serializable {
...
@@ -49,7 +49,7 @@ public class Message implements IMessage, Serializable {
}
}
@Override
@Override
public
void
setParameters
(
List
args
)
{
public
void
setParameters
(
List
<
IParameter
>
args
)
{
this
.
parameters
=
args
;
this
.
parameters
=
args
;
}
}
...
...
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/
File
Parameter.java
→
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/Parameter.java
View file @
e1e33d95
...
@@ -21,12 +21,7 @@ import java.io.Serializable;
...
@@ -21,12 +21,7 @@ import java.io.Serializable;
*
*
* @author S. Koulouzis.
* @author S. Koulouzis.
*/
*/
public
class
FileParameter
implements
IFileParameter
,
IParameter
,
Serializable
{
public
class
Parameter
implements
IParameter
,
Serializable
{
public
static
final
String
NAME
=
"name"
;
public
static
final
String
URL
=
"url"
;
public
static
final
String
VALUE
=
"value"
;
public
static
final
String
ENCODING
=
"encoding"
;
private
String
url
;
private
String
url
;
private
String
encoding
;
private
String
encoding
;
...
...
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/RequestRepository.java
deleted
100644 → 0
View file @
a5bb42ce
/*
* Copyright 2017 S. Koulouzis.
*
* 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
;
/**
*
* @author S. Koulouzis
*/
import
java.util.List
;
//import org.springframework.data.repository.PagingAndSortingRepository;
//import org.springframework.data.repository.query.Param;
//import org.springframework.data.rest.core.annotation.RepositoryRestResource;
//@RepositoryRestResource(collectionResourceRel = "requests", path = "requests")
public
interface
RequestRepository
{
//extends PagingAndSortingRepository<Request, Long> {
// List<Request> findById(@Param("id") String id);
}
This diff is collapsed.
Click to expand it.
drip-planner/src/main/java/nl/uva/sne/drip/drip/planner/Consumer.java
View file @
e1e33d95
...
@@ -32,15 +32,13 @@ import java.util.Date;
...
@@ -32,15 +32,13 @@ import java.util.Date;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
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.
File
Parameter
;
import
nl.uva.sne.drip.commons.types.Parameter
;
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
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
nl.uva.sne.drip.commons.types.IFileParameter
;
/**
/**
*
*
...
@@ -95,15 +93,15 @@ public class Consumer extends DefaultConsumer {
...
@@ -95,15 +93,15 @@ public class Consumer extends DefaultConsumer {
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Map
<
String
,
String
>
fileArg
=
(
java
.
util
.
LinkedHashMap
)
request
.
getParameters
().
get
(
i
);
Map
<
String
,
String
>
fileArg
=
(
java
.
util
.
LinkedHashMap
)
request
.
getParameters
().
get
(
i
);
String
fileName
=
fileArg
.
get
(
File
Parameter
.
NAME
);
String
fileName
=
fileArg
.
get
(
Parameter
.
NAME
);
//If not null should be able to use it to download file
//If not null should be able to use it to download file
String
url
=
fileArg
.
get
(
File
Parameter
.
URL
);
String
url
=
fileArg
.
get
(
Parameter
.
URL
);
if
(
url
!=
null
)
{
if
(
url
!=
null
)
{
//download
//download
}
}
String
encoding
=
fileArg
.
get
(
File
Parameter
.
ENCODING
);
String
encoding
=
fileArg
.
get
(
Parameter
.
ENCODING
);
String
value
=
fileArg
.
get
(
File
Parameter
.
VALUE
);
String
value
=
fileArg
.
get
(
Parameter
.
VALUE
);
try
(
PrintWriter
out
=
new
PrintWriter
(
fileName
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
fileName
))
{
out
.
print
(
value
);
out
.
print
(
value
);
}
}
...
@@ -120,7 +118,7 @@ public class Consumer extends DefaultConsumer {
...
@@ -120,7 +118,7 @@ public class Consumer extends DefaultConsumer {
//We know that in parameters 0-2 we should have files
//We know that in parameters 0-2 we should have files
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
JSONObject
arg
=
(
JSONObject
)
args
.
get
(
i
);
JSONObject
arg
=
(
JSONObject
)
args
.
get
(
i
);
String
fileName
=
(
String
)
arg
.
get
(
File
Parameter
.
NAME
);
String
fileName
=
(
String
)
arg
.
get
(
Parameter
.
NAME
);
//If not null should be able to use it to download file
//If not null should be able to use it to download file
if
(!
arg
.
isNull
(
"url"
))
{
if
(!
arg
.
isNull
(
"url"
))
{
...
@@ -128,8 +126,8 @@ public class Consumer extends DefaultConsumer {
...
@@ -128,8 +126,8 @@ public class Consumer extends DefaultConsumer {
//download
//download
}
}
//Otherwise get contents as string
//Otherwise get contents as string
String
value
=
(
String
)
arg
.
get
(
File
Parameter
.
VALUE
);
String
value
=
(
String
)
arg
.
get
(
Parameter
.
VALUE
);
String
encoding
=
(
String
)
arg
.
get
(
File
Parameter
.
ENCODING
);
String
encoding
=
(
String
)
arg
.
get
(
Parameter
.
ENCODING
);
try
(
PrintWriter
out
=
new
PrintWriter
(
fileName
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
fileName
))
{
out
.
print
(
value
);
out
.
print
(
value
);
...
@@ -145,7 +143,7 @@ public class Consumer extends DefaultConsumer {
...
@@ -145,7 +143,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
)
{
FileParameter
fileParam
=
new
File
Parameter
();
Parameter
fileParam
=
new
Parameter
();
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
);
...
...
This diff is collapsed.
Click to expand it.
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