Skip to content

Commit ed8431f

Browse files
committed
Simplified CSVGraphStoreRowProcessor::add method
1 parent ac16323 commit ed8431f

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/main/java/com/atomgraph/linkeddatahub/imports/stream/csv/CSVGraphStoreRowProcessor.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,12 @@ public void rowProcessed(String[] row, ParsingContext context)
110110
*
111111
* @param entity request entity
112112
* @param graphURI the graph URI
113-
* @return JAX-RS response
114113
*/
115-
protected Response add(Entity entity, String graphURI)
114+
protected void add(Entity entity, String graphURI)
116115
{
117116
try (Response headResponse = getLinkedDataClient().head(URI.create(graphURI)))
118117
{
119-
if (headResponse.getStatus() == Response.Status.OK.getStatusCode()) // POST if graph already exists
118+
if (headResponse.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) // POST if graph already exists
120119
{
121120
try (Response cr = getLinkedDataClient().post(URI.create(graphURI), getLinkedDataClient().getReadableMediaTypes(Model.class), entity))
122121
{
@@ -125,10 +124,6 @@ protected Response add(Entity entity, String graphURI)
125124
if (log.isErrorEnabled()) log.error("RDF document with URI <{}> could not be successfully created using POST. Status code: {}", graphURI, cr.getStatus());
126125
throw new ImportException(new IOException("RDF document with URI <" + graphURI + "> could not be successfully created using POST. Status code: " + cr.getStatus()));
127126
}
128-
129-
return Response.status(cr.getStatus()).
130-
entity(cr.readEntity(Model.class)).
131-
build();
132127
}
133128
}
134129
else // PUT to create graph
@@ -140,10 +135,6 @@ protected Response add(Entity entity, String graphURI)
140135
if (log.isErrorEnabled()) log.error("RDF document with URI <{}> could not be successfully created using PUT. Status code: {}", graphURI, cr.getStatus());
141136
throw new RuntimeException(new IOException("RDF document with URI <" + graphURI + "> could not be successfully created using PUT. Status code: " + cr.getStatus()));
142137
}
143-
144-
return Response.status(cr.getStatus()).
145-
entity(cr.readEntity(Model.class)).
146-
build();
147138
}
148139
}
149140
}

0 commit comments

Comments
 (0)