Skip to content

Commit

Permalink
GH-4492 route all deprecated endpoints through new controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
abrokenjester committed Apr 23, 2023
1 parent ad1f46e commit ca28feb
Show file tree
Hide file tree
Showing 5 changed files with 784 additions and 593 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.springframework.web.servlet.mvc.AbstractController;

/**
* Handles requests for transaction creation on a repository.
* Handles requests for transaction operations on a repository.
*
* @author Jeen Broekstra
*/
Expand Down Expand Up @@ -86,6 +86,11 @@ protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpSer

}

// Comes from disposableBean interface so to be able to stop the ActiveTransactionRegistry scheduler
@Override
public void destroy() throws Exception {
ActiveTransactionRegistry.INSTANCE.destroyScheduler();
}
/**
* Handle the specific action as part of the supplied {@link Transaction} object.
*
Expand All @@ -96,30 +101,6 @@ protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpSer
protected abstract ModelAndView handleAction(HttpServletRequest request, HttpServletResponse response,
Transaction transaction) throws Exception;

/* private methods */

private UUID getTransactionID(HttpServletRequest request) throws ClientHTTPException {
String pathInfoStr = request.getPathInfo();

UUID txnID = null;

if (pathInfoStr != null && !pathInfoStr.equals("/")) {
String[] pathInfo = pathInfoStr.substring(1).split("/");
// should be of the form: /<Repository>/transactions/<txnID>
if (pathInfo.length == 3) {
try {
txnID = UUID.fromString(pathInfo[2]);
logger.debug("txnID is '{}'", txnID);
} catch (IllegalArgumentException e) {
throw new ClientHTTPException(SC_BAD_REQUEST, "not a valid transaction id: " + pathInfo[2]);
}
} else {
logger.warn("could not determine transaction id from path info {} ", pathInfoStr);
}
}

return txnID;
}

static RDFFormat getRDFFormat(HttpServletRequest request) {
return Rio.getParserFormatForMIMEType(request.getContentType())
Expand Down Expand Up @@ -149,10 +130,30 @@ static ModelAndView emptyOkResponse() {
return new ModelAndView(SimpleResponseView.getInstance(), model);
}

// Comes from disposableBean interface so to be able to stop the ActiveTransactionRegistry scheduler
@Override
public void destroy() throws Exception {
ActiveTransactionRegistry.INSTANCE.destroyScheduler();
/* private methods */

private UUID getTransactionID(HttpServletRequest request) throws ClientHTTPException {
String pathInfoStr = request.getPathInfo();

UUID txnID = null;

if (pathInfoStr != null && !pathInfoStr.equals("/")) {
String[] pathInfo = pathInfoStr.substring(1).split("/");
// should be of the form: /<Repository>/transactions/<txnID>
if (pathInfo.length == 3) {
try {
txnID = UUID.fromString(pathInfo[2]);
logger.debug("txnID is '{}'", txnID);
} catch (IllegalArgumentException e) {
throw new ClientHTTPException(SC_BAD_REQUEST, "not a valid transaction id: " + pathInfo[2]);
}
} else {
logger.warn("could not determine transaction id from path info {} ", pathInfoStr);
}
}

return txnID;
}


}
Loading

0 comments on commit ca28feb

Please sign in to comment.