Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
acdc
repository-extension-services
Commits
e02ef460
Commit
e02ef460
authored
Sep 25, 2015
by
acoburn
Browse files
simplified implementation
parent
ad52095c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
acrepo-jsonld-service/src/main/java/edu/amherst/acdc/jsonld/JsonLdServiceImpl.java
.../main/java/edu/amherst/acdc/jsonld/JsonLdServiceImpl.java
+21
-21
No files found.
acrepo-jsonld-service/src/main/java/edu/amherst/acdc/jsonld/JsonLdServiceImpl.java
View file @
e02ef460
...
...
@@ -67,22 +67,15 @@ public class JsonLdServiceImpl implements JsonLdService {
LOGGER
.
info
(
"using context from: {}"
,
contextUrl
);
try
{
final
List
<
Map
<
String
,
Object
>>
document
=
((
List
<
Map
<
String
,
Object
>>)
fromInputStream
(
input
)).
stream
()
.
filter
(
filterExport:
:
test
)
.
collect
(
Collectors
.
toList
());
return
JsonUtils
.
toString
(
JsonLdProcessor
.
compact
(
document
,
fromURL
(
new
URL
(
contextUrl
)),
options
));
return
doCompact
(
input
,
fromURL
(
new
URL
(
contextUrl
)));
}
catch
(
final
MalformedURLException
ex
)
{
throw
new
RuntimeException
(
"Invalid URL
: "
+
ex
.
getMessage
()
);
throw
new
RuntimeException
(
"Invalid URL
"
,
ex
);
}
catch
(
final
JsonParseException
ex
)
{
throw
new
RuntimeException
(
"Error parsing JSON
: "
+
ex
.
getMessage
()
);
throw
new
RuntimeException
(
"Error parsing JSON
"
,
ex
);
}
catch
(
final
JsonGenerationException
ex
)
{
throw
new
RuntimeException
(
"Error generating JSON: "
+
ex
.
getMessage
());
}
catch
(
final
JsonLdError
ex
)
{
throw
new
RuntimeException
(
"Error converting JsonLd: "
+
ex
.
getMessage
());
throw
new
RuntimeException
(
"Error generating JSON"
,
ex
);
}
catch
(
final
IOException
ex
)
{
throw
new
RuntimeException
(
"Error reading/writing JSON document
: "
+
ex
.
getMessage
()
);
throw
new
RuntimeException
(
"Error reading/writing JSON document
"
,
ex
);
}
}
...
...
@@ -95,18 +88,11 @@ public class JsonLdServiceImpl implements JsonLdService {
*/
public
String
compact
(
final
InputStream
input
,
final
InputStream
context
)
{
try
{
final
List
<
Map
<
String
,
Object
>>
document
=
((
List
<
Map
<
String
,
Object
>>)
fromInputStream
(
input
)).
stream
()
.
filter
(
filterExport:
:
test
)
.
collect
(
Collectors
.
toList
());
return
JsonUtils
.
toString
(
JsonLdProcessor
.
compact
(
document
,
fromInputStream
(
context
),
options
));
return
doCompact
(
input
,
fromInputStream
(
context
));
}
catch
(
final
JsonParseException
ex
)
{
throw
new
RuntimeException
(
"Error parsing JSON"
,
ex
);
}
catch
(
final
JsonGenerationException
ex
)
{
throw
new
RuntimeException
(
"Error generating JSON"
,
ex
);
}
catch
(
final
JsonLdError
ex
)
{
throw
new
RuntimeException
(
"Error converting JsonLd: "
+
ex
.
getMessage
());
}
catch
(
final
IOException
ex
)
{
throw
new
RuntimeException
(
"Error reading/writing JSON document"
,
ex
);
}
...
...
@@ -127,12 +113,26 @@ public class JsonLdServiceImpl implements JsonLdService {
}
catch
(
final
JsonGenerationException
ex
)
{
throw
new
RuntimeException
(
"Error generating JSON"
,
ex
);
}
catch
(
final
JsonLdError
ex
)
{
throw
new
RuntimeException
(
"Error converting JsonLd
: "
+
ex
.
getMessage
()
);
throw
new
RuntimeException
(
"Error converting JsonLd
"
,
ex
);
}
catch
(
final
IOException
ex
)
{
throw
new
RuntimeException
(
"Error reading/writing JSON document"
,
ex
);
}
}
@SuppressWarnings
(
"unchecked"
)
private
String
doCompact
(
final
InputStream
input
,
final
Object
context
)
throws
IOException
{
try
{
final
List
<
Map
<
String
,
Object
>>
document
=
((
List
<
Map
<
String
,
Object
>>)
fromInputStream
(
input
)).
stream
()
.
filter
(
filterExport:
:
test
)
.
collect
(
Collectors
.
toList
());
return
JsonUtils
.
toString
(
JsonLdProcessor
.
compact
(
document
,
context
,
options
));
}
catch
(
final
JsonLdError
ex
)
{
throw
new
RuntimeException
(
"Error converting JsonLd"
,
ex
);
}
}
private
Predicate
<
Map
<
String
,
Object
>>
filterExport
=
x
->
{
return
x
.
containsKey
(
"@id"
)
&&
!(
x
.
get
(
"@id"
).
toString
().
endsWith
(
"/fcr:export?format=jcr/xml"
)
||
x
.
get
(
"@id"
).
toString
().
equals
(
"http://fedora.info/definitions/v4/repository#jcr/xml"
));
...
...
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