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
86b8f9db
Commit
86b8f9db
authored
Mar 02, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed POJOs
parent
be293ab9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
34 deletions
+94
-34
ClusterCredentials.java
...ava/nl/uva/sne/drip/commons/types/ClusterCredentials.java
+60
-0
IMessage.java
...src/main/java/nl/uva/sne/drip/commons/types/IMessage.java
+1
-1
Message.java
.../src/main/java/nl/uva/sne/drip/commons/types/Message.java
+3
-3
MessageParameter.java
.../java/nl/uva/sne/drip/commons/types/MessageParameter.java
+1
-1
TypesJUnitTest.java
...st/java/nl/uva/sne/drip/commons/types/TypesJUnitTest.java
+9
-9
Consumer.java
.../main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
+13
-13
Consumer.java
.../src/main/java/nl/uva/sne/drip/drip/planner/Consumer.java
+7
-7
No files found.
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/ClusterCredentials.java
0 → 100644
View file @
86b8f9db
/*
* 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
.
types
;
import
java.util.Map
;
import
org.springframework.data.annotation.Id
;
/**
*
* @author S. Koulouzis
*/
public
class
ClusterCredentials
{
@Id
private
String
id
;
private
Map
<
String
,
Object
>
kvMap
;
/**
* @return the id
*/
public
String
getId
()
{
return
id
;
}
/**
* @param id the id to set
*/
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
/**
* @return the kvMap
*/
public
Map
<
String
,
Object
>
getKvMap
()
{
return
kvMap
;
}
/**
* @param kvMap the kvMap to set
*/
public
void
setKvMap
(
Map
<
String
,
Object
>
kvMap
)
{
this
.
kvMap
=
kvMap
;
}
}
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/IMessage.java
View file @
86b8f9db
...
@@ -30,7 +30,7 @@ public interface IMessage {
...
@@ -30,7 +30,7 @@ public interface IMessage {
public
void
setCreationDate
(
Long
creationDate
);
public
void
setCreationDate
(
Long
creationDate
);
public
void
setParameters
(
List
<
Parameter
>
params
);
public
void
setParameters
(
List
<
Message
Parameter
>
params
);
public
List
getParameters
();
public
List
getParameters
();
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/Message.java
View file @
86b8f9db
...
@@ -38,7 +38,7 @@ public class Message implements IMessage, Serializable {
...
@@ -38,7 +38,7 @@ public class Message implements IMessage, Serializable {
// @Temporal(TemporalType.DATE)
// @Temporal(TemporalType.DATE)
private
Long
creationDate
;
private
Long
creationDate
;
private
List
<
Parameter
>
parameters
;
private
List
<
Message
Parameter
>
parameters
;
@Override
@Override
public
Long
getCreationDate
()
{
public
Long
getCreationDate
()
{
...
@@ -46,12 +46,12 @@ public class Message implements IMessage, Serializable {
...
@@ -46,12 +46,12 @@ public class Message implements IMessage, Serializable {
}
}
@Override
@Override
public
void
setParameters
(
List
<
Parameter
>
parameters
)
{
public
void
setParameters
(
List
<
Message
Parameter
>
parameters
)
{
this
.
parameters
=
parameters
;
this
.
parameters
=
parameters
;
}
}
@Override
@Override
public
List
<
Parameter
>
getParameters
()
{
public
List
<
Message
Parameter
>
getParameters
()
{
return
this
.
parameters
;
return
this
.
parameters
;
}
}
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/Parameter.java
→
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/
Message
Parameter.java
View file @
86b8f9db
...
@@ -22,7 +22,7 @@ import java.util.Map;
...
@@ -22,7 +22,7 @@ import java.util.Map;
*
*
* @author S. Koulouzis.
* @author S. Koulouzis.
*/
*/
public
class
Parameter
implements
Serializable
{
public
class
Message
Parameter
implements
Serializable
{
private
String
url
;
private
String
url
;
private
String
encoding
;
private
String
encoding
;
...
...
drip-commons/src/test/java/nl/uva/sne/drip/commons/types/TypesJUnitTest.java
View file @
86b8f9db
...
@@ -112,14 +112,14 @@ public class TypesJUnitTest {
...
@@ -112,14 +112,14 @@ public class TypesJUnitTest {
private
static
void
initMessages
()
throws
IOException
{
private
static
void
initMessages
()
throws
IOException
{
message1
=
new
Message
();
message1
=
new
Message
();
message1
.
setCreationDate
((
System
.
currentTimeMillis
()));
message1
.
setCreationDate
((
System
.
currentTimeMillis
()));
List
<
Parameter
>
parameters
=
new
ArrayList
();
List
<
Message
Parameter
>
parameters
=
new
ArrayList
();
Parameter
numParam
=
new
Parameter
();
MessageParameter
numParam
=
new
Message
Parameter
();
String
numParamName
=
"input"
;
String
numParamName
=
"input"
;
numParam
.
setName
(
numParamName
);
numParam
.
setName
(
numParamName
);
numParam
.
setValue
(
"33000"
);
numParam
.
setValue
(
"33000"
);
parameters
.
add
(
numParam
);
parameters
.
add
(
numParam
);
Parameter
fileParamContents
=
new
Parameter
();
MessageParameter
fileParamContents
=
new
Message
Parameter
();
fileParamContentsName
=
"someInputFile"
;
fileParamContentsName
=
"someInputFile"
;
fileParamContents
.
setName
(
fileParamContentsName
);
fileParamContents
.
setName
(
fileParamContentsName
);
byte
[]
bytes
=
Files
.
readAllBytes
(
Paths
.
get
(
tempFile1
.
getAbsolutePath
()));
byte
[]
bytes
=
Files
.
readAllBytes
(
Paths
.
get
(
tempFile1
.
getAbsolutePath
()));
...
@@ -128,7 +128,7 @@ public class TypesJUnitTest {
...
@@ -128,7 +128,7 @@ public class TypesJUnitTest {
fileParamContents
.
setEncoding
(
charset
);
fileParamContents
.
setEncoding
(
charset
);
parameters
.
add
(
fileParamContents
);
parameters
.
add
(
fileParamContents
);
Parameter
fileParamRef
=
new
Parameter
();
MessageParameter
fileParamRef
=
new
Message
Parameter
();
fileParamRef
.
setName
(
"theNameOfTheParamater"
);
fileParamRef
.
setName
(
"theNameOfTheParamater"
);
fileParamRef
.
setURL
(
"http://www.gutenberg.org/cache/epub/3160/pg3160.txt"
);
fileParamRef
.
setURL
(
"http://www.gutenberg.org/cache/epub/3160/pg3160.txt"
);
parameters
.
add
(
fileParamRef
);
parameters
.
add
(
fileParamRef
);
...
@@ -158,11 +158,11 @@ public class TypesJUnitTest {
...
@@ -158,11 +158,11 @@ public class TypesJUnitTest {
// System.err.println(jsonInString);
// System.err.println(jsonInString);
Message
request
=
mapper
.
readValue
(
jsonInString
,
Message
.
class
);
Message
request
=
mapper
.
readValue
(
jsonInString
,
Message
.
class
);
List
<
Parameter
>
params
=
request
.
getParameters
();
List
<
Message
Parameter
>
params
=
request
.
getParameters
();
assertEquals
(
message1
.
getParameters
().
size
(),
params
.
size
());
assertEquals
(
message1
.
getParameters
().
size
(),
params
.
size
());
fileParam
=
new
File
(
fileParamContentsName
);
fileParam
=
new
File
(
fileParamContentsName
);
for
(
Parameter
param
:
params
)
{
for
(
Message
Parameter
param
:
params
)
{
if
(
param
.
getName
().
equals
(
fileParamContentsName
))
{
if
(
param
.
getName
().
equals
(
fileParamContentsName
))
{
String
value
=
param
.
getValue
();
String
value
=
param
.
getValue
();
try
(
PrintWriter
out
=
new
PrintWriter
(
fileParam
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
fileParam
))
{
...
@@ -195,9 +195,9 @@ public class TypesJUnitTest {
...
@@ -195,9 +195,9 @@ public class TypesJUnitTest {
fileParam
=
new
File
(
fileParamContentsName
);
fileParam
=
new
File
(
fileParamContentsName
);
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
String
name
=
(
String
)
param
.
get
(
Parameter
.
NAME
);
String
name
=
(
String
)
param
.
get
(
Message
Parameter
.
NAME
);
if
(
name
.
equals
(
fileParamContentsName
))
{
if
(
name
.
equals
(
fileParamContentsName
))
{
String
value
=
(
String
)
param
.
get
(
Parameter
.
VALUE
);
String
value
=
(
String
)
param
.
get
(
Message
Parameter
.
VALUE
);
try
(
PrintWriter
out
=
new
PrintWriter
(
fileParam
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
fileParam
))
{
out
.
print
(
value
);
out
.
print
(
value
);
}
}
...
@@ -223,7 +223,7 @@ public class TypesJUnitTest {
...
@@ -223,7 +223,7 @@ public class TypesJUnitTest {
List
parameters
=
new
ArrayList
();
List
parameters
=
new
ArrayList
();
String
charset
=
"UTF-8"
;
String
charset
=
"UTF-8"
;
for
(
File
f
:
files
)
{
for
(
File
f
:
files
)
{
Parameter
fileParam
=
new
Parameter
();
MessageParameter
fileParam
=
new
Message
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
);
...
...
drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
View file @
86b8f9db
...
@@ -38,7 +38,7 @@ import java.util.Map;
...
@@ -38,7 +38,7 @@ import java.util.Map;
import
java.util.Properties
;
import
java.util.Properties
;
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.Parameter
;
import
nl.uva.sne.drip.commons.types.
Message
Parameter
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
...
@@ -371,12 +371,12 @@ public class Consumer extends DefaultConsumer {
...
@@ -371,12 +371,12 @@ public class Consumer extends DefaultConsumer {
private
File
getCloudConfigurationFile
(
JSONArray
parameters
,
String
tempInputDirPath
)
throws
JSONException
{
private
File
getCloudConfigurationFile
(
JSONArray
parameters
,
String
tempInputDirPath
)
throws
JSONException
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
String
name
=
(
String
)
param
.
get
(
Parameter
.
NAME
);
String
name
=
(
String
)
param
.
get
(
Message
Parameter
.
NAME
);
if
(
name
.
equals
(
"ec2.conf"
)
||
name
.
equals
(
"geni.conf"
))
{
if
(
name
.
equals
(
"ec2.conf"
)
||
name
.
equals
(
"geni.conf"
))
{
try
{
try
{
File
confFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
name
);
File
confFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
name
);
if
(
confFile
.
createNewFile
())
{
if
(
confFile
.
createNewFile
())
{
writeValueToFile
((
String
)
param
.
get
(
Parameter
.
VALUE
),
confFile
);
writeValueToFile
((
String
)
param
.
get
(
Message
Parameter
.
VALUE
),
confFile
);
return
confFile
;
return
confFile
;
}
else
{
}
else
{
return
null
;
return
null
;
...
@@ -393,7 +393,7 @@ public class Consumer extends DefaultConsumer {
...
@@ -393,7 +393,7 @@ public class Consumer extends DefaultConsumer {
private
File
getTopology
(
JSONArray
parameters
,
String
tempInputDirPath
,
int
level
)
throws
JSONException
,
IOException
{
private
File
getTopology
(
JSONArray
parameters
,
String
tempInputDirPath
,
int
level
)
throws
JSONException
,
IOException
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
String
name
=
(
String
)
param
.
get
(
Parameter
.
NAME
);
String
name
=
(
String
)
param
.
get
(
Message
Parameter
.
NAME
);
if
(
name
.
equals
(
"topology"
))
{
if
(
name
.
equals
(
"topology"
))
{
JSONObject
attributes
=
param
.
getJSONObject
(
"attributes"
);
JSONObject
attributes
=
param
.
getJSONObject
(
"attributes"
);
int
fileLevel
=
Integer
.
valueOf
((
String
)
attributes
.
get
(
"level"
));
int
fileLevel
=
Integer
.
valueOf
((
String
)
attributes
.
get
(
"level"
));
...
@@ -408,7 +408,7 @@ public class Consumer extends DefaultConsumer {
...
@@ -408,7 +408,7 @@ public class Consumer extends DefaultConsumer {
if
(
fileLevel
==
level
)
{
if
(
fileLevel
==
level
)
{
File
topologyFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
fileName
);
File
topologyFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
fileName
);
if
(
topologyFile
.
createNewFile
())
{
if
(
topologyFile
.
createNewFile
())
{
String
val
=
(
String
)
param
.
get
(
Parameter
.
VALUE
);
String
val
=
(
String
)
param
.
get
(
Message
Parameter
.
VALUE
);
//Replace '{' with indentation otherwise we get 'End of document execption'
//Replace '{' with indentation otherwise we get 'End of document execption'
// val = val.replaceAll("- \\{", " - ").replaceAll(", ", "\n ").replaceAll("}", "");
// val = val.replaceAll("- \\{", " - ").replaceAll(", ", "\n ").replaceAll("}", "");
...
@@ -427,13 +427,13 @@ public class Consumer extends DefaultConsumer {
...
@@ -427,13 +427,13 @@ public class Consumer extends DefaultConsumer {
Map
<
String
,
File
>
files
=
new
HashMap
<>();
Map
<
String
,
File
>
files
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
String
name
=
(
String
)
param
.
get
(
Parameter
.
NAME
);
String
name
=
(
String
)
param
.
get
(
Message
Parameter
.
NAME
);
if
(
name
.
equals
(
"certificate"
))
{
if
(
name
.
equals
(
"certificate"
))
{
JSONObject
attribute
=
param
.
getJSONObject
(
"attributes"
);
JSONObject
attribute
=
param
.
getJSONObject
(
"attributes"
);
String
fileName
=
(
String
)
attribute
.
get
(
"filename"
);
String
fileName
=
(
String
)
attribute
.
get
(
"filename"
);
File
certificate
=
new
File
(
tempInputDirPath
+
File
.
separator
+
fileName
+
".pem"
);
File
certificate
=
new
File
(
tempInputDirPath
+
File
.
separator
+
fileName
+
".pem"
);
if
(
certificate
.
createNewFile
())
{
if
(
certificate
.
createNewFile
())
{
writeValueToFile
((
String
)
param
.
get
(
Parameter
.
VALUE
),
certificate
);
writeValueToFile
((
String
)
param
.
get
(
Message
Parameter
.
VALUE
),
certificate
);
files
.
put
(
fileName
,
certificate
);
files
.
put
(
fileName
,
certificate
);
}
}
}
}
...
@@ -444,9 +444,9 @@ public class Consumer extends DefaultConsumer {
...
@@ -444,9 +444,9 @@ public class Consumer extends DefaultConsumer {
private
String
getLogDirPath
(
JSONArray
parameters
,
String
tempInputDirPath
)
throws
JSONException
{
private
String
getLogDirPath
(
JSONArray
parameters
,
String
tempInputDirPath
)
throws
JSONException
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
String
name
=
(
String
)
param
.
get
(
Parameter
.
NAME
);
String
name
=
(
String
)
param
.
get
(
Message
Parameter
.
NAME
);
if
(
name
.
equals
(
"logdir"
))
{
if
(
name
.
equals
(
"logdir"
))
{
return
(
String
)
param
.
get
(
Parameter
.
VALUE
);
return
(
String
)
param
.
get
(
Message
Parameter
.
VALUE
);
}
}
}
}
return
System
.
getProperty
(
"java.io.tmpdir"
);
return
System
.
getProperty
(
"java.io.tmpdir"
);
...
@@ -455,9 +455,9 @@ public class Consumer extends DefaultConsumer {
...
@@ -455,9 +455,9 @@ public class Consumer extends DefaultConsumer {
private
File
getSSHKey
(
JSONArray
parameters
,
String
tempInputDirPath
)
throws
JSONException
,
IOException
{
private
File
getSSHKey
(
JSONArray
parameters
,
String
tempInputDirPath
)
throws
JSONException
,
IOException
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
String
name
=
(
String
)
param
.
get
(
Parameter
.
NAME
);
String
name
=
(
String
)
param
.
get
(
Message
Parameter
.
NAME
);
if
(
name
.
equals
(
"sshkey"
))
{
if
(
name
.
equals
(
"sshkey"
))
{
String
sshKeyContent
=
(
String
)
param
.
get
(
Parameter
.
VALUE
);
String
sshKeyContent
=
(
String
)
param
.
get
(
Message
Parameter
.
VALUE
);
File
sshKeyFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
"user.pem"
);
File
sshKeyFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
"user.pem"
);
if
(
sshKeyFile
.
createNewFile
())
{
if
(
sshKeyFile
.
createNewFile
())
{
writeValueToFile
(
sshKeyContent
,
sshKeyFile
);
writeValueToFile
(
sshKeyContent
,
sshKeyFile
);
...
@@ -471,9 +471,9 @@ public class Consumer extends DefaultConsumer {
...
@@ -471,9 +471,9 @@ public class Consumer extends DefaultConsumer {
private
File
getSciptFile
(
JSONArray
parameters
,
String
tempInputDirPath
)
throws
JSONException
,
IOException
{
private
File
getSciptFile
(
JSONArray
parameters
,
String
tempInputDirPath
)
throws
JSONException
,
IOException
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
String
name
=
(
String
)
param
.
get
(
Parameter
.
NAME
);
String
name
=
(
String
)
param
.
get
(
Message
Parameter
.
NAME
);
if
(
name
.
equals
(
"guiscript"
))
{
if
(
name
.
equals
(
"guiscript"
))
{
String
scriptContent
=
(
String
)
param
.
get
(
Parameter
.
VALUE
);
String
scriptContent
=
(
String
)
param
.
get
(
Message
Parameter
.
VALUE
);
File
scriptFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
"guiscipt.sh"
);
File
scriptFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
"guiscipt.sh"
);
if
(
scriptFile
.
createNewFile
())
{
if
(
scriptFile
.
createNewFile
())
{
writeValueToFile
(
scriptContent
,
scriptFile
);
writeValueToFile
(
scriptContent
,
scriptFile
);
...
...
drip-simple_planner/src/main/java/nl/uva/sne/drip/drip/planner/Consumer.java
View file @
86b8f9db
...
@@ -33,7 +33,7 @@ import java.util.List;
...
@@ -33,7 +33,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
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.Parameter
;
import
nl.uva.sne.drip.commons.types.
Message
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
;
...
@@ -108,13 +108,13 @@ public class Consumer extends DefaultConsumer {
...
@@ -108,13 +108,13 @@ public class Consumer extends DefaultConsumer {
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
Message
request
=
mapper
.
readValue
(
message
,
Message
.
class
);
Message
request
=
mapper
.
readValue
(
message
,
Message
.
class
);
List
<
Parameter
>
params
=
request
.
getParameters
();
List
<
Message
Parameter
>
params
=
request
.
getParameters
();
//Create tmp input files
//Create tmp input files
File
inputFile
=
File
.
createTempFile
(
"input-"
,
Long
.
toString
(
System
.
nanoTime
()));
File
inputFile
=
File
.
createTempFile
(
"input-"
,
Long
.
toString
(
System
.
nanoTime
()));
File
exampleFile
=
File
.
createTempFile
(
"example-"
,
Long
.
toString
(
System
.
nanoTime
()));
File
exampleFile
=
File
.
createTempFile
(
"example-"
,
Long
.
toString
(
System
.
nanoTime
()));
//loop through the parameters in a message to find the input files
//loop through the parameters in a message to find the input files
for
(
Parameter
param
:
params
)
{
for
(
Message
Parameter
param
:
params
)
{
if
(
param
.
getName
().
equals
(
"input"
))
{
if
(
param
.
getName
().
equals
(
"input"
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
inputFile
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
inputFile
))
{
out
.
print
(
param
.
getValue
());
out
.
print
(
param
.
getValue
());
...
@@ -141,16 +141,16 @@ public class Consumer extends DefaultConsumer {
...
@@ -141,16 +141,16 @@ public class Consumer extends DefaultConsumer {
File
exampleFile
=
File
.
createTempFile
(
"example-"
,
Long
.
toString
(
System
.
nanoTime
()));
File
exampleFile
=
File
.
createTempFile
(
"example-"
,
Long
.
toString
(
System
.
nanoTime
()));
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
parameters
.
length
();
i
++)
{
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
JSONObject
param
=
(
JSONObject
)
parameters
.
get
(
i
);
String
name
=
(
String
)
param
.
get
(
Parameter
.
NAME
);
String
name
=
(
String
)
param
.
get
(
Message
Parameter
.
NAME
);
if
(
name
.
equals
(
"input"
))
{
if
(
name
.
equals
(
"input"
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
inputFile
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
inputFile
))
{
out
.
print
(
param
.
get
(
Parameter
.
VALUE
));
out
.
print
(
param
.
get
(
Message
Parameter
.
VALUE
));
}
}
files
[
0
]
=
inputFile
;
files
[
0
]
=
inputFile
;
}
}
if
(
name
.
equals
(
"example"
))
{
if
(
name
.
equals
(
"example"
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
exampleFile
))
{
try
(
PrintWriter
out
=
new
PrintWriter
(
exampleFile
))
{
out
.
print
(
param
.
get
(
Parameter
.
VALUE
));
out
.
print
(
param
.
get
(
Message
Parameter
.
VALUE
));
}
}
files
[
1
]
=
exampleFile
;
files
[
1
]
=
exampleFile
;
}
}
...
@@ -164,7 +164,7 @@ public class Consumer extends DefaultConsumer {
...
@@ -164,7 +164,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
)
{
Parameter
fileParam
=
new
Parameter
();
MessageParameter
fileParam
=
new
Message
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
);
...
...
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