[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-07-15 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/jena/pull/82


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/82#discussion_r33451617
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java
 ---
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.jena.fuseki.mgt;
+
+import org.apache.jena.atlas.json.JsonBuilder;
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.server.FusekiServer;
+import org.apache.jena.fuseki.servlets.ServletOps;
+import org.apache.jena.web.HttpSC;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import static org.apache.jena.riot.WebContent.charsetUTF8;
+import static org.apache.jena.riot.WebContent.contentTypeTextPlain;
+
+/**
+ * A JSON API to list all the backups in the backup directory
+ * Created by Yang Yuanzhe on 6/26/15.
+ */
+public class ActionBackupList extends HttpServlet {
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
{
+doCommon(req, resp);
+}
+
+@Override
+protected void doPost(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+@Override
+protected void doHead(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+protected void doCommon(HttpServletRequest request, 
HttpServletResponse response) {
+JsonBuilder builder = new JsonBuilder() ;
+builder.startObject(top) ;
+builder.key(backups) ;
+builder.startArray() ;
+
+ArrayListString fileNames = new ArrayList();
+if (Files.isDirectory(FusekiServer.dirBackups)) {
+try (DirectoryStreamPath stream = 
Files.newDirectoryStream(FusekiServer.dirBackups)) {
+for (Path path : stream) {
+fileNames.add(path.getFileName().toString());
+}
+} catch (IOException ex) {
+Fuseki.serverLog.warn(backup file list :: IOException :: 
+ex.getMessage());
+}
+}
+
+Collections.sort(fileNames);
+for (String str : fileNames) {
+builder.value(str);
+}
--- End diff --

Given Java 8, this is a little briefer as  
`fileNames.forEach(builder::value)`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread afs
Github user afs commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116601250
  
Indeed - etags are one example of a server driven mechanism. They need more 
machinery than this PR has though. HTTP headers are not always easy to deal 
with in client libraries, either access or setting the conditional GET headers. 
 (And not all developers are aware of or are interested in details (burden) of 
all HTTP features.)

POST is the easy way for a client to force a live view.  I think we should 
leave it in because it is near zero cost.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/82#discussion_r33457733
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java
 ---
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.jena.fuseki.mgt;
+
+import org.apache.jena.atlas.json.JsonBuilder;
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.server.FusekiServer;
+import org.apache.jena.fuseki.servlets.ServletOps;
+import org.apache.jena.web.HttpSC;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import static org.apache.jena.riot.WebContent.charsetUTF8;
+import static org.apache.jena.riot.WebContent.contentTypeTextPlain;
+
+/**
+ * A JSON API to list all the backups in the backup directory
+ * Created by Yang Yuanzhe on 6/26/15.
+ */
+public class ActionBackupList extends HttpServlet {
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
{
+doCommon(req, resp);
+}
+
+@Override
+protected void doPost(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+@Override
+protected void doHead(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+protected void doCommon(HttpServletRequest request, 
HttpServletResponse response) {
+JsonBuilder builder = new JsonBuilder() ;
+builder.startObject(top) ;
+builder.key(backups) ;
+builder.startArray() ;
+
+ArrayListString fileNames = new ArrayList();
+if (Files.isDirectory(FusekiServer.dirBackups)) {
+try (DirectoryStreamPath stream = 
Files.newDirectoryStream(FusekiServer.dirBackups)) {
+for (Path path : stream) {
+fileNames.add(path.getFileName().toString());
+}
+} catch (IOException ex) {
+Fuseki.serverLog.warn(backup file list :: IOException :: 
+ex.getMessage());
+}
+}
+
+Collections.sort(fileNames);
+for (String str : fileNames) {
+builder.value(str);
+}
--- End diff --

No, I believe we are now officially at Java 8 for the main line of 
development.  We use Java 8-only idioms elsewhere. In any case, it's nothing to 
worry about. I just have a vicious yen for brevity. :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread yyz1989
Github user yyz1989 commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116636657
  
Yeah, I agree with Rob and Andy. I do think accepting POST is necessary, 
but I apologize for my negligence for HEAD. That is due to my laziness because 
I took the main structure from another service directly :D


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread afs
Github user afs commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116589395
  
I disagree a bit about POST - yes, it's not nice REST but it is 
pragmatically useful to ensure up-to-date information (the client can force it 
even if the server or proxies decide to cache).

HEAD - completely agree.  I think the body may be chopped anyway but I'd 
need to check.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116597497
  
`POST` is one way to enable a force up-to-date`, but it should also be 
possible to supply an ETag, which is a little more to the exact need. Perhaps 
Fuseki has helpers for this?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116603288
  
Okay-- do you think it's worth a separate ticket and PR for some helpers 
for ETags, so that future new Fuseki HTTP functions could offer them at low 
cost?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116628538
  
Okay, sorry to cloud the waters.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread afs
Github user afs commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116609093
  
Here, the client browser is an admin interface.The read-information 
operations are not a performance pain-point.

Helpers presume how they are being used in Fuseki is defined and it's not. 
Each use may be quite different. It's not just how to use E-Tags but deciding 
what they represent so look at in context.

e.g. JENA-626 (query caching) is a case where they would be useful. And how 
would even Jena's  own client library deal with them.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread afs
Github user afs commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116628492
  
We are agreed that it's not related to this PR. Let's discuss it on dev@ 
and not tangle this PR with that discussion.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread yyz1989
Github user yyz1989 commented on a diff in the pull request:

https://github.com/apache/jena/pull/82#discussion_r33457422
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java
 ---
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.jena.fuseki.mgt;
+
+import org.apache.jena.atlas.json.JsonBuilder;
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.server.FusekiServer;
+import org.apache.jena.fuseki.servlets.ServletOps;
+import org.apache.jena.web.HttpSC;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import static org.apache.jena.riot.WebContent.charsetUTF8;
+import static org.apache.jena.riot.WebContent.contentTypeTextPlain;
+
+/**
+ * A JSON API to list all the backups in the backup directory
+ * Created by Yang Yuanzhe on 6/26/15.
+ */
+public class ActionBackupList extends HttpServlet {
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
{
+doCommon(req, resp);
+}
+
+@Override
+protected void doPost(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+@Override
+protected void doHead(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+protected void doCommon(HttpServletRequest request, 
HttpServletResponse response) {
+JsonBuilder builder = new JsonBuilder() ;
+builder.startObject(top) ;
+builder.key(backups) ;
+builder.startArray() ;
+
+ArrayListString fileNames = new ArrayList();
+if (Files.isDirectory(FusekiServer.dirBackups)) {
+try (DirectoryStreamPath stream = 
Files.newDirectoryStream(FusekiServer.dirBackups)) {
+for (Path path : stream) {
+fileNames.add(path.getFileName().toString());
+}
+} catch (IOException ex) {
+Fuseki.serverLog.warn(backup file list :: IOException :: 
+ex.getMessage());
+}
+}
+
+Collections.sort(fileNames);
+for (String str : fileNames) {
+builder.value(str);
+}
--- End diff --

I think we are based on Java 7, no?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116612135
  
I meant something as simple as a method that accepts an identifier and 
response and adds the correctly-formatted tag.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread rvesse
Github user rvesse commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116555847
  
+1 to the idea

The implementation seems to violate REST principles though

`POST` should be used for changing data so should not be supported for a 
service that only provides information

`HEAD` should be used only to determine what the resource supports so 
should not return a body and should only return information about supported 
methods and content-types


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---