package com.perforce.spark.deploy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import spark.ModelAndView; import spark.Request; import spark.Response; import com.perforce.p4java.exception.P4JavaException; import com.perforce.p4java.server.IOptionsServer; import com.perforce.spark.artifact.ArtifactFactory; import com.perforce.spark.artifact.ArtifactInterface; import com.perforce.spark.artifact.ArtifactType; import com.perforce.spark.common.AbstractControl; import com.perforce.spark.connection.ConnectionSession; import com.perforce.spark.depot.DepotFactory; import com.perforce.spark.navigation.NavBar; public class DeployControl extends AbstractControl { public static ModelAndView getDeploy(Request request, Response response) { Map<String, Object> model; model = NavBar.attributes("deploy", request); // get type from request parameters ArtifactType type = getType(request); model.put("type", type); try { IOptionsServer p4 = ConnectionSession.get(request, response); model.put("depots", DepotFactory.listDeployable(p4, type)); p4.disconnect(); } catch (P4JavaException e) { return error(e); } return new ModelAndView(model, "/deploy/page-upload.html"); } public static String postDeploy(Request request, Response response) { try { // get type from request parameters ArtifactType type = getType(request); ArtifactInterface artifact = ArtifactFactory.getArtifact(request, response); int pending = artifact.userUpload(request); artifact.disconnect(); // pending change return "/submit/" + type.getId() + "?pending=" + pending; } catch (Exception e) { e.printStackTrace(); } return ""; } public static ModelAndView getSubmit(Request request, Response response) { Map<String, Object> model; model = NavBar.attributes("deploy", request); model.put("type", getType(request)); String pending = request.queryParams("pending"); model.put("pending", pending); try { IOptionsServer p4 = ConnectionSession.get(request, response); model.put("files", DeployFactory.listFiles(p4, pending)); p4.disconnect(); } catch (P4JavaException e) { return error(e); } return new ModelAndView(model, "/submit/page-submit.html"); } public static String postSubmit(Request request, Response response) { try { // get type from request parameters ArtifactType type = getType(request); // get pending parameter String pendingStr = request.queryParams("pending"); int pending = Integer.parseInt(pendingStr); // get description String desc = request.queryParams("descID"); ArtifactInterface artifact = ArtifactFactory.getArtifact(request, response); ChangeModel change = artifact.userSubmit(pending, desc); artifact.index(); artifact.disconnect(); response.redirect("/report/" + type.getId() + "/" + change.getPath() + "?submitted=" + change.getChange()); } catch (Exception e) { e.printStackTrace(); } return ""; } public static ModelAndView getReport(Request request, Response response) { Map<String, Object> model; model = NavBar.attributes("deploy", request); model.put("type", getType(request)); String submitted = request.queryParams("submitted"); model.put("submitted", submitted); String base = request.pathInfo(); base = (base.endsWith("/")) ? base : base + "/"; model.put("path", toBrowsePath(base)); try { IOptionsServer p4 = ConnectionSession.get(request, response); model.put("files", DeployFactory.listFiles(p4, submitted)); p4.disconnect(); } catch (P4JavaException e) { return error(e); } return new ModelAndView(model, "/submit/page-report.html"); } private static String toBrowsePath(String base) { List<String> parts = new ArrayList<>(); parts.addAll(Arrays.asList(base.split("/"))); parts.remove(0); parts.remove(0); parts.remove(0); String path = String.join("/", parts); path = "/browse/" + path; return path; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#14 | 15782 | Paul Allen |
Update to UX - deploy has 3 process steps (including a submit report) |
||
#13 | 15313 | Paul Allen |
Added Client Workspace pool to manage parallel upload requests by the proxy (configuration set to 50). User uploads are restricted to only one per user. |
||
#12 | 15221 | Paul Allen | Generate Gem index and submit after a deploy or proxy fetch event. | ||
#11 | 15181 | Paul Allen | Maven/Generic search results. | ||
#10 | 15012 | Paul Allen | Proxy configuration. | ||
#9 | 14884 | Paul Allen | Moved create depot type into path and not a param. | ||
#8 | 14883 | Paul Allen | Submit via preview and redirect to asset | ||
#7 | 14882 | Paul Allen | Refactor static html pages | ||
#6 | 14866 | Paul Allen |
Create different Depot types. - Display site types |
||
#5 | 14863 | Paul Allen | Change File/Dir browse to support extended options | ||
#4 | 14741 | Paul Allen | Fix upload for multiple files. | ||
#3 | 14726 | Paul Allen | Limit deploy control path, and remove AssetHelper | ||
#2 | 14725 | Paul Allen | Generic deploy/upload | ||
#1 | 14723 | Paul Allen | Tidy up deploy/upload |