diff options
author | Maciej Bendkowski <maciej.bendkowski@pl.ibm.com> | 2014-07-14 13:41:27 +0200 |
---|---|---|
committer | Maciej Bendkowski <maciej.bendkowski@pl.ibm.com> | 2014-07-17 13:05:26 +0200 |
commit | 8944fb74659570648f8354df26e529eb7b1882d9 (patch) | |
tree | 96629f464dbe16a106096c91643a1ce4bba77551 | |
parent | eb3c9a00aeb3eda0da59f3276c451e7a0c852ec2 (diff) | |
download | org.eclipse.orion.client-origin/bug428353.zip org.eclipse.orion.client-origin/bug428353.tar.gz org.eclipse.orion.client-origin/bug428353.tar.bz2 |
Manifest semantic analysis should depend on the application type origin/bug428353
-rw-r--r-- | bundles/org.eclipse.orion.client.cf/web/cfui/deploy.js | 129 | ||||
-rw-r--r-- | bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js | 8 |
2 files changed, 111 insertions, 26 deletions
diff --git a/bundles/org.eclipse.orion.client.cf/web/cfui/deploy.js b/bundles/org.eclipse.orion.client.cf/web/cfui/deploy.js index 19670a1..34bbe9b 100644 --- a/bundles/org.eclipse.orion.client.cf/web/cfui/deploy.js +++ b/bundles/org.eclipse.orion.client.cf/web/cfui/deploy.js @@ -13,7 +13,6 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred var deployResource = decodeURIComponent(pageParams.resource);
var serviceRegistry = core.serviceRegistry;
-// var preferences = core.preferences;
var cFService = new CFClient.CFService(serviceRegistry);
// initial message
@@ -26,6 +25,17 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred var okButton = document.getElementById('okbutton'); //$NON-NLS-0$
var explorer;
+ /* uses the last segment as application name */
+ function extractApplicationName(contentLocation){
+
+ if(/\/$/.test(contentLocation)){
+ contentLocation = contentLocation.substring(0, contentLocation.length - 1);
+ }
+
+ var segments = contentLocation.split('/');
+ return (segments.length > 0) ? segments[segments.length - 1] : null;
+ }
+
function showMessage(message){
msgNode = msgLabel.appendChild(document.createTextNode(message)); //$NON-NLS-0$
progressPane.classList.add("running");
@@ -55,7 +65,7 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred return;
}
selection.getSelection(function(selection) {
- if(selection===null || selection.length===0){
+ if(selection === null || selection.length === 0){
setValid(false);
return;
}
@@ -127,21 +137,22 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred source: "org.eclipse.orion.client.cf.deploy.uritemplate", cancelled: true}), "*");
};
- var doAction = function() {
+ var doAction = function(event, nonManifest, persist) {
showMessage("Deploying...");
setValid(false);
selection.getSelection(
function(selection) {
- if(selection===null || selection.length===0){
+ if(selection === null || selection.length === 0){
closeFrame();
return;
}
explorer.getNavHandler().setSelectionPolicy("readonlySelection");
-
var deployResourceJSON = JSON.parse(deployResource);
- cFService.pushApp(selection, null, decodeURIComponent(deployResourceJSON.ContentLocation + deployResourceJSON.AppPath)).then(
+ var applicationName = (nonManifest) ? extractApplicationName(deployResourceJSON.ContentLocation) : null;
+
+ cFService.pushApp(selection, applicationName, decodeURIComponent(deployResourceJSON.ContentLocation + deployResourceJSON.AppPath), nonManifest, persist).then(
function(result){
var appName = result.App.name || result.App.entity.name;
var host = (result.Route !== undefined ? (result.Route.host || result.Route.entity.host) : undefined);
@@ -166,30 +177,98 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred }
});
}, function(error){
-// if (error.HttpCode === 404){
-// postError({
-// State: "NOT_DEPLOYED",
-// Message: error.Message
-// });
-// } else if (error.JsonData && error.JsonData.error_code) {
-// var err = error.JsonData;
-// if (err.error_code === "CF-InvalidAuthToken"){
-// error.Retry = {
-// parameters: [{id: "user", type: "text", name: "User:"}, {id: "password", type: "password", name: "Password:"}]
-// };
-// } else if (err.error_code === "CF-TargetNotSet"){
-// var cloudSettingsPageUrl = new URITemplate("{+OrionHome}/settings/settings.html#,category=Cloud").expand({OrionHome : PageLinks.getOrionHome()});
-// error.Message = "Set up your Cloud. Go to [Settings](" + cloudSettingsPageUrl + ").";
-// }
-// postError(error);
-// } else {
+
+ if (error.JsonData && error.JsonData.error_code) {
+ var err = error.JsonData;
+ if (err.error_code === "CF-MissingManifest"){
+ handleNonManifest(err);
+ }
+ } else {
postError(error);
-// }
+ }
}
);
}
);
};
+
+ var handleNonManifest = function(resp){
+
+ /* gather the application type */
+ var applicationType = resp.applicationType;
+ var description = "Your application contents indicate a well-known application type. " +
+ "Do you wish to continue deploying your application with a default deployment description?";
+
+ /* craft UI */
+ var titleNode = document.getElementById('title');
+ lib.empty(titleNode);
+
+ titleNode.appendChild(document.createTextNode("Missing application manifest"));
+ msgLabel.appendChild(document.createTextNode("Could not find the application manifest."));
+
+ var container = orgsDropdownNode.parentNode;
+ lib.empty(container);
+ hideMessage();
+
+ var message = document.createElement("div");
+ message.appendChild(document.createTextNode(description));
+ container.appendChild(message);
+
+ var table = document.createElement("div");
+ table.style = "display: table; margin: 10px auto 0 auto; border-spacing: 14px; ";
+
+ var row2 = document.createElement("div");
+ row2.style = "display: table-row;";
+
+ var appTypeCell = document.createElement("div");
+ appTypeCell.style = "display: table-cell;";
+
+ var appType = document.createElement("label");
+ appType.appendChild(document.createTextNode("Deteted type:"));
+ appTypeCell.appendChild(appType);
+
+ var appType2Cell = document.createElement("div");
+ appType2Cell.style = "display: table-cell; font-weight: bold;";
+
+ var appType2 = document.createTextNode(applicationType);
+ appType2Cell.appendChild(appType2);
+
+ row2.appendChild(appTypeCell);
+ row2.appendChild(appType2Cell);
+
+ var row = document.createElement("div");
+ row.style = "display: table-row;";
+
+ var labelCell = document.createElement("div");
+ labelCell.style = "display: table-cell;";
+
+ var label = document.createElement("label");
+ label.title = "Persist the deployment description as a manifest.yml file.";
+ label.appendChild(document.createTextNode("Persist the manifest?"));
+ labelCell.appendChild(label);
+
+ var checkboxCell = document.createElement("div");
+ checkboxCell.style = "display: table-cell;";
+
+ var checkbox = document.createElement("input");
+ checkbox.id = "nonManifest-Persist";
+ checkbox.type = "checkbox";
+ checkboxCell.appendChild(checkbox);
+
+ row.appendChild(labelCell);
+ row.appendChild(checkboxCell);
+
+ table.appendChild(row2);
+ table.appendChild(row);
+ container.appendChild(table);
+ setValid(true);
+
+ document.getElementById('okbutton').onclick = function(event){
+ lib.empty(msgLabel);
+ var persist = document.getElementById("nonManifest-Persist").checked;
+ return doAction(event, true, persist);
+ };
+ };
document.getElementById('okbutton').onclick = doAction;
document.getElementById('closeDialog').onclick = closeFrame;
@@ -404,4 +483,4 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred }
};
-});
\ No newline at end of file +}); diff --git a/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js b/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js index b846089..e372c1c 100644 --- a/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js +++ b/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js @@ -150,7 +150,7 @@ define(['require', 'orion/xhr', 'orion/Deferred', 'orion/operation'], function(r // Apps CF v2 operations
- pushApp: function(target, name, contentLocation) {
+ pushApp: function(target, name, contentLocation, nonManifest, persist) {
var pushReq = {};
if (name)
@@ -162,6 +162,12 @@ define(['require', 'orion/xhr', 'orion/Deferred', 'orion/operation'], function(r if (target)
pushReq.Target = target;
+ if(nonManifest)
+ pushReq['Non-Manifest'] = true;
+
+ if(persist)
+ pushReq['Persist'] = true;
+
return this._xhrV1("PUT", require.toUrl("cfapi/apps"), pushReq);
},
|