-
Notifications
You must be signed in to change notification settings - Fork 0
S196 delete UI #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
S196 delete UI #86
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,26 +16,24 @@ | |
|
|
||
| import com.google.appengine.tools.mapreduce.impl.shardedjob.ShardedJobRunId; | ||
| import com.google.appengine.tools.pipeline.JobRunId; | ||
| import com.google.appengine.tools.pipeline.di.DaggerJobRunServiceComponent; | ||
| import com.google.appengine.tools.pipeline.di.JobRunServiceComponent; | ||
| import com.google.appengine.tools.pipeline.di.JobRunServiceComponentContainer; | ||
| import com.google.cloud.datastore.Key; | ||
| import com.google.appengine.tools.pipeline.util.Pair; | ||
| import com.google.common.annotations.VisibleForTesting; | ||
|
|
||
| import java.io.IOException; | ||
| import lombok.Setter; | ||
|
|
||
| import javax.servlet.ServletException; | ||
| import javax.servlet.http.HttpServlet; | ||
| import javax.servlet.http.HttpServletRequest; | ||
| import javax.servlet.http.HttpServletResponse; | ||
| import lombok.Setter; | ||
| import java.io.IOException; | ||
| import java.util.Arrays; | ||
| import java.util.Optional; | ||
|
|
||
|
|
||
| /** | ||
| * Servlet that handles all requests for the Pipeline framework. | ||
| * Dispatches all requests to {@link TaskHandler}, {@link JsonTreeHandler} or | ||
| * {@link StaticContentHandler} as appropriate | ||
| * Dispatches all requests to {@link TaskHandler} or {@link JsonTreeHandler} as appropriate | ||
| * | ||
| * @author [email protected] (Mitch Rudominer) | ||
| */ | ||
|
|
@@ -66,31 +64,15 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) | |
|
|
||
| Pair<String, RequestType> pair = parseRequestType(req); | ||
| RequestType requestType = pair.getSecond(); | ||
| String path = pair.getFirst(); | ||
|
|
||
| switch (requestType) { | ||
| case HANDLE_TASK: | ||
| component.taskHandler().doPost(req); | ||
| break; | ||
| case GET_JSON: | ||
| component.jsonTreeHandler().doGet(req, resp); | ||
| break; | ||
| case GET_JSON_LIST: | ||
| component.jsonListHandler().doGet(req, resp); | ||
| break; | ||
| case GET_JSON_CLASS_FILTER: | ||
| component.jsonClassFilterHandler().doGet(req, resp); | ||
| break; | ||
| case ABORT_JOB: | ||
| component.abortJobHandler().doGet(req, resp); | ||
| break; | ||
| case DELETE_JOB: | ||
| component.deleteJobHandler().doGet(req, resp); | ||
| break; | ||
| case HANDLE_STATIC: | ||
| StaticContentHandler.doGet(resp, path); | ||
| break; | ||
| default: | ||
| throw new ServletException("Unknown request type: " + requestType); | ||
| case HANDLE_TASK -> component.taskHandler().doPost(req); | ||
| case GET_JSON -> component.jsonTreeHandler().doGet(req, resp); | ||
| case GET_JSON_LIST -> component.jsonListHandler().doGet(req, resp); | ||
| case GET_JSON_CLASS_FILTER -> component.jsonClassFilterHandler().doGet(req, resp); | ||
| case ABORT_JOB -> component.abortJobHandler().doGet(req, resp); | ||
| case DELETE_JOB -> component.deleteJobHandler().doGet(req, resp); | ||
| default -> throw new ServletException("Unknown request type: " + requestType); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -122,8 +104,7 @@ private enum RequestType { | |
| GET_JSON_LIST(JsonListHandler.PATH_COMPONENT), | ||
| GET_JSON_CLASS_FILTER(JsonClassFilterHandler.PATH_COMPONENT), | ||
| ABORT_JOB(AbortJobHandler.PATH_COMPONENT), | ||
| DELETE_JOB(DeleteJobHandler.PATH_COMPONENT), | ||
| HANDLE_STATIC(""); | ||
| DELETE_JOB(DeleteJobHandler.PATH_COMPONENT); | ||
|
|
||
| private final String pathComponent; | ||
|
|
||
|
|
@@ -137,15 +118,13 @@ public boolean matches(String path) { | |
| } | ||
|
|
||
| private Pair<String, RequestType> parseRequestType(HttpServletRequest req) { | ||
| String path = req.getPathInfo(); | ||
| path = path == null ? "" : path.substring(1); // Take off the leading '/' | ||
| RequestType requestType = RequestType.HANDLE_STATIC; | ||
| for (RequestType rt : RequestType.values()) { | ||
| if (rt.matches(path)) { | ||
| requestType = rt; | ||
| break; | ||
| } | ||
| } | ||
| String path = Optional.ofNullable(req.getPathInfo()).map( p -> p.substring(1)).orElse(""); | ||
|
|
||
| RequestType requestType = Arrays.stream(RequestType.values()) | ||
| .filter( rt -> rt.matches(path)) | ||
| .findFirst() | ||
| .orElseThrow(() -> new RuntimeException("Unknown RequestType")); | ||
|
|
||
| return Pair.of(path, requestType); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prob include the
pathto aid debug?