MCPcopy Create free account
hub / github.com/apache/tomcat / deploy

Method deploy

java/org/apache/catalina/manager/ManagerServlet.java:687–808  ·  view source on GitHub ↗

Deploy a web application archive (included in the current request) at the specified context path. @param writer Writer to render results to @param config URL of the context configuration file to be copied into the local config folder @param cn Name of the application to be installed @para

(PrintWriter writer, String config, ContextName cn, String tag, boolean update,
            HttpServletRequest request, StringManager smClient)

Source from the content-addressed store, hash-verified

685 * @param smClient i18n messages using the locale of the client
686 */
687 protected void deploy(PrintWriter writer, String config, ContextName cn, String tag, boolean update,
688 HttpServletRequest request, StringManager smClient) {
689
690 if (config != null && config.isEmpty()) {
691 config = null;
692 }
693
694 if (debug >= 1) {
695 if (config == null) {
696 log("deploy: Deploying web application '" + cn + "'");
697 } else {
698 log("deploy: Deploying web application '" + cn + "' " + "with context configuration at '" + config +
699 "'");
700 }
701 }
702
703 // Validate the requested context path
704 if (!validateContextName(cn, writer, smClient)) {
705 return;
706 }
707 String name = cn.getName();
708 String baseName = cn.getBaseName();
709 String displayPath = cn.getDisplayName();
710
711 // If app exists deployment can only proceed if update is true
712 // Note existing WAR will be deleted and then replaced
713 Context context = (Context) host.findChild(name);
714 if (context != null && !update) {
715 writer.println(smClient.getString("managerServlet.alreadyContext", displayPath));
716 return;
717 }
718
719 if (config != null && config.startsWith("file:")) {
720 config = config.substring("file:".length());
721 }
722
723 File deployedWar = new File(host.getAppBaseFile(), baseName + ".war");
724 if (!pathCheck(deployedWar, host.getAppBaseFile(), writer, smClient)) {
725 // Any error reported in pathCheck()
726 return;
727 }
728
729 // Determine full path for uploaded WAR
730 File uploadedWar;
731 if (tag == null) {
732 if (update) {
733 // Append ".tmp" to the file name so it won't get deployed if auto
734 // deployment is enabled. It also means the old war won't get
735 // deleted if the upload fails
736 uploadedWar = new File(deployedWar.getAbsolutePath() + ".tmp");
737 if (uploadedWar.exists() && !uploadedWar.delete()) {
738 writer.println(smClient.getString("managerServlet.deleteFail", uploadedWar));
739 }
740 } else {
741 uploadedWar = deployedWar;
742 }
743 } else {
744 File uploadPath = new File(versioned, tag);

Callers 3

doGetMethod · 0.95
doPutMethod · 0.95
deployInternalMethod · 0.45

Calls 15

validateContextNameMethod · 0.95
pathCheckMethod · 0.95
tryAddServicedMethod · 0.95
copyMethod · 0.95
uploadWarMethod · 0.95
removeServicedMethod · 0.95
checkMethod · 0.95
writeDeployResultMethod · 0.95
deleteMethod · 0.95
handleThrowableMethod · 0.95
lengthMethod · 0.80
endsWithMethod · 0.80

Tested by

no test coverage detected