55 */
66package cz .vutbr .fit .layout .web .services ;
77
8- import java .io .IOException ;
9- import java .util .Scanner ;
10-
118import javax .inject .Inject ;
129import javax .ws .rs .GET ;
1310import javax .ws .rs .Path ;
1411import javax .ws .rs .core .Response ;
1512
1613import org .eclipse .rdf4j .model .Value ;
1714import org .eclipse .rdf4j .model .vocabulary .RDF ;
18- import org .eclipse .rdf4j .repository .RepositoryException ;
19- import org .eclipse .rdf4j .rio .RDFParseException ;
2015
2116import cz .vutbr .fit .layout .ontology .BOX ;
2217import cz .vutbr .fit .layout .web .data .ResultErrorMessage ;
3025@ Path ("admin" )
3126public class AdminResource
3227{
33- private static String [] owls = new String [] {"render.owl" , "segmentation.owl" , "fitlayout.owl" , "mapping.owl" };
34-
3528 @ Inject
3629 private StorageService storage ;
3730
@@ -51,33 +44,10 @@ public Response checkRepo()
5144 @ Path ("/initRepo" )
5245 public Response initRepo ()
5346 {
54- int cnt = 0 ;
55- //load the ontologies
56- for (String owl : owls )
57- {
58- String owlFile = loadResource ("/rdf/" + owl );
59- try
60- {
61- storage .getStorage ().importXML (owlFile );
62- cnt ++;
63- } catch (RDFParseException e ) {
64- return Response .serverError ().entity (new ResultErrorMessage (e .getMessage ())).build ();
65- } catch (RepositoryException e ) {
66- return Response .serverError ().entity (new ResultErrorMessage (e .getMessage ())).build ();
67- } catch (IOException e ) {
68- return Response .serverError ().entity (new ResultErrorMessage (e .getMessage ())).build ();
69- }
70- }
71- return Response .ok (new ResultValue (cnt )).build ();
72- }
73-
74- private static String loadResource (String filePath )
75- {
76- try (Scanner scanner = new Scanner (AdminResource .class .getResourceAsStream (filePath ), "UTF-8" )) {
77- scanner .useDelimiter ("\\ A" );
78- return scanner .next ();
79- }
47+ if (storage .getArtifactRepository ().isInitialized ())
48+ return Response .ok (new ResultValue ("ok" )).build ();
49+ else
50+ return Response .serverError ().entity ("error during repository initialization" ).build ();
8051 }
81-
8252
8353}
0 commit comments