rvesse commented on code in PR #2538: URL: https://github.com/apache/jena/pull/2538#discussion_r1664072527
########## jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/prefixes/ActionPrefixesBase.java: ########## @@ -0,0 +1,47 @@ +/* + * 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.servlets.prefixes; + +import org.apache.jena.fuseki.servlets.BaseActionREST; +import org.apache.jena.fuseki.servlets.HttpAction; +import org.apache.jena.fuseki.servlets.ServletOps; +import org.apache.jena.sparql.core.DatasetGraph; + +import java.util.Iterator; + +public class ActionPrefixesBase extends BaseActionREST { + + /** Create a {@link PrefixesAccess} for this {@link HttpAction}. */ + protected static PrefixesAccess prefixes(HttpAction action) { + DatasetGraph dsg = action.getDataset(); + PrefixesMap pMap = new PrefixesMap(dsg.prefixes(), dsg); + return pMap; + } + + @Override + public void validate(HttpAction action) { + Iterator<String> paramNames = action.getRequestParameterNames().asIterator(); + while(paramNames.hasNext()) { + String check = paramNames.next(); + if(!check.equals(PrefixUtils.PREFIX) && !check.equals(PrefixUtils.URI) && !check.equals(PrefixUtils.REMOVEPREFIX)) { Review Comment: Still got one reference to the remove prefix parameter lurking here ########## jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/prefixes/ActionProcPrefixes.java: ########## @@ -0,0 +1,228 @@ +/* + * 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.servlets.prefixes; + +import com.google.gson.JsonArray; +import org.apache.jena.atlas.logging.FmtLog; +import org.apache.jena.fuseki.servlets.*; +import org.apache.jena.query.TxnType; +import org.apache.jena.riot.WebContent; +import org.apache.jena.sparql.core.Transactional; + +import java.io.IOException; +import java.util.*; + + +//validate and unpack the HTTP Get request, +//call the storage's fetch URI by the prefix function from the HTTP request + +public class ActionProcPrefixes extends BaseActionREST { Review Comment: This still seems to be duplicating behaviour from `ActionPrefixesRW` but is now inconsistent because this is still using `removeprefix` and still allows a `POST` to both edit/remove a prefix ########## jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/prefixes/ActionProcPrefixes.java: ########## @@ -0,0 +1,228 @@ +/* + * 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.servlets.prefixes; + +import com.google.gson.JsonArray; +import org.apache.jena.atlas.logging.FmtLog; +import org.apache.jena.fuseki.servlets.*; +import org.apache.jena.query.TxnType; +import org.apache.jena.riot.WebContent; +import org.apache.jena.sparql.core.Transactional; + +import java.io.IOException; +import java.util.*; + + +//validate and unpack the HTTP Get request, +//call the storage's fetch URI by the prefix function from the HTTP request + +public class ActionProcPrefixes extends BaseActionREST { Review Comment: It feels like if we made the `prefixes()` method from `ActionPrefixesBase` non-static this class could simply extend that class and override that method to return the configured storage i.e. ```java public class ActionProcPrefixes extends ActionPrefixesRW { private final PrefixesAccess storage; public ActionProcPrefixes(PrefixesAccess storage) { this.storage = storage; } @Override protected PrefixesAccess prefixes(HttpAction action) { return this.storage; } } ``` This might need some fixes to `HttpAction` because `ActionPrefixesRW` assumes a valid transaction which a plain action processor doesn't get (see https://github.com/apache/jena/pull/2563) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
