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
352deb9e
Commit
352deb9e
authored
May 10, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved method to utils
parent
174fdc54
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
73 deletions
+31
-73
PlannerService.java
...main/java/nl/uva/sne/drip/api/service/PlannerService.java
+1
-25
PlaybookService.java
...ain/java/nl/uva/sne/drip/api/service/PlaybookService.java
+1
-25
ToscaService.java
...c/main/java/nl/uva/sne/drip/api/service/ToscaService.java
+1
-23
Converter.java
...rc/main/java/nl/uva/sne/drip/commons/utils/Converter.java
+28
-0
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlannerService.java
View file @
352deb9e
...
...
@@ -226,31 +226,7 @@ public class PlannerService {
}
public
String
saveStringContents
(
String
ymlContents
,
Integer
level
,
String
name
)
{
//Remove '\' and 'n' if they are together and replace them with '\n'
char
[]
array
=
ymlContents
.
toCharArray
();
StringBuilder
sb
=
new
StringBuilder
();
int
prevChar
=
-
1
;
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
int
currentChar
=
(
int
)
array
[
i
];
if
(
prevChar
>
0
&&
prevChar
==
92
&&
currentChar
==
110
)
{
sb
.
delete
(
sb
.
length
()
-
1
,
sb
.
length
());
sb
.
append
(
'\n'
);
}
else
{
sb
.
append
((
char
)
currentChar
);
}
prevChar
=
(
int
)
array
[
i
];
}
ymlContents
=
sb
.
toString
();
ymlContents
=
ymlContents
.
replaceAll
(
"(?m)^[ \t]*\r?\n"
,
""
);
for
(
int
i
=
0
;
i
<
Constants
.
BAD_CHARS
.
length
;
i
++)
{
int
hex
=
Constants
.
BAD_CHARS
[
i
];
ymlContents
=
ymlContents
.
replaceAll
(
String
.
valueOf
((
char
)
hex
),
""
);
}
ymlContents
=
ymlContents
.
replaceAll
(
"\\."
,
"\uff0E"
);
// ymlContents = ymlContents.replaceAll("\uff0E", ".");
Map
<
String
,
Object
>
map
=
Converter
.
ymlString2Map
(
ymlContents
);
Map
<
String
,
Object
>
map
=
Converter
.
cleanStringContents
(
ymlContents
);
PlanResponse
pr
=
new
PlanResponse
();
pr
.
setKvMap
(
map
);
pr
.
setLevel
(
level
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlaybookService.java
View file @
352deb9e
...
...
@@ -116,31 +116,7 @@ public class PlaybookService {
}
public
String
saveStringContents
(
String
playbookContents
)
throws
IOException
{
//Remove '\' and 'n' if they are together and replace them with '\n'
char
[]
array
=
playbookContents
.
toCharArray
();
StringBuilder
sb
=
new
StringBuilder
();
int
prevChar
=
-
1
;
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
int
currentChar
=
(
int
)
array
[
i
];
if
(
prevChar
>
0
&&
prevChar
==
92
&&
currentChar
==
110
)
{
sb
.
delete
(
sb
.
length
()
-
1
,
sb
.
length
());
sb
.
append
(
'\n'
);
}
else
{
sb
.
append
((
char
)
currentChar
);
}
prevChar
=
(
int
)
array
[
i
];
}
playbookContents
=
sb
.
toString
();
playbookContents
=
playbookContents
.
replaceAll
(
"(?m)^[ \t]*\r?\n"
,
""
);
for
(
int
i
=
0
;
i
<
Constants
.
BAD_CHARS
.
length
;
i
++)
{
int
hex
=
Constants
.
BAD_CHARS
[
i
];
playbookContents
=
playbookContents
.
replaceAll
(
String
.
valueOf
((
char
)
hex
),
""
);
}
playbookContents
=
playbookContents
.
replaceAll
(
"\\."
,
"\uff0E"
);
Map
<
String
,
Object
>
map
=
Converter
.
ymlString2Map
(
playbookContents
);
Map
<
String
,
Object
>
map
=
Converter
.
cleanStringContents
(
playbookContents
);
PlaybookRepresentation
t
=
new
PlaybookRepresentation
();
t
.
setKvMap
(
map
);
save
(
t
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/ToscaService.java
View file @
352deb9e
...
...
@@ -120,30 +120,8 @@ public class ToscaService {
public
String
saveStringContents
(
String
toscaContents
,
String
name
)
throws
IOException
{
//Remove '\' and 'n' if they are together and replace them with '\n'
char
[]
array
=
toscaContents
.
toCharArray
();
StringBuilder
sb
=
new
StringBuilder
();
int
prevChar
=
-
1
;
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
int
currentChar
=
(
int
)
array
[
i
];
if
(
prevChar
>
0
&&
prevChar
==
92
&&
currentChar
==
110
)
{
sb
.
delete
(
sb
.
length
()
-
1
,
sb
.
length
());
sb
.
append
(
'\n'
);
}
else
{
sb
.
append
((
char
)
currentChar
);
}
prevChar
=
(
int
)
array
[
i
];
}
toscaContents
=
sb
.
toString
();
toscaContents
=
toscaContents
.
replaceAll
(
"(?m)^[ \t]*\r?\n"
,
""
);
for
(
int
i
=
0
;
i
<
Constants
.
BAD_CHARS
.
length
;
i
++)
{
int
hex
=
Constants
.
BAD_CHARS
[
i
];
toscaContents
=
toscaContents
.
replaceAll
(
String
.
valueOf
((
char
)
hex
),
""
);
}
Map
<
String
,
Object
>
map
=
Converter
.
cleanStringContents
(
toscaContents
);
toscaContents
=
toscaContents
.
replaceAll
(
"\\."
,
"\uff0E"
);
Map
<
String
,
Object
>
map
=
Converter
.
ymlString2Map
(
toscaContents
);
ToscaRepresentation
t
=
new
ToscaRepresentation
();
t
.
setName
(
name
);
t
.
setKvMap
(
map
);
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
View file @
352deb9e
...
...
@@ -210,4 +210,32 @@ public class Converter {
return
p1
;
}
public
static
Map
<
String
,
Object
>
cleanStringContents
(
String
toscaContents
)
{
//Remove '\' and 'n' if they are together and replace them with '\n'
char
[]
array
=
toscaContents
.
toCharArray
();
StringBuilder
sb
=
new
StringBuilder
();
int
prevChar
=
-
1
;
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
int
currentChar
=
(
int
)
array
[
i
];
if
(
prevChar
>
0
&&
prevChar
==
92
&&
currentChar
==
110
)
{
sb
.
delete
(
sb
.
length
()
-
1
,
sb
.
length
());
sb
.
append
(
'\n'
);
}
else
{
sb
.
append
((
char
)
currentChar
);
}
prevChar
=
(
int
)
array
[
i
];
}
toscaContents
=
sb
.
toString
();
toscaContents
=
toscaContents
.
replaceAll
(
"(?m)^[ \t]*\r?\n"
,
""
);
for
(
int
i
=
0
;
i
<
Constants
.
BAD_CHARS
.
length
;
i
++)
{
int
hex
=
Constants
.
BAD_CHARS
[
i
];
toscaContents
=
toscaContents
.
replaceAll
(
String
.
valueOf
((
char
)
hex
),
""
);
}
toscaContents
=
toscaContents
.
replaceAll
(
"\\."
,
"\uff0E"
);
Map
<
String
,
Object
>
map
=
Converter
.
ymlString2Map
(
toscaContents
);
return
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