This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
WSO2 Cloud
committed
Jul 29, 2015
1 parent
b49dc38
commit 424b22a
Showing
12 changed files
with
794 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
91 changes: 91 additions & 0 deletions
91
modules/jaggery-apps/appmgt/src/site/blocks/urlmapper/get/ajax/get.jag
This file contains 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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<% | ||
/* | ||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
include("/jagg/jagg.jag"); | ||
include("/jagg/constants.jag"); | ||
include("/jagg/config_reader.jag"); | ||
|
||
var lifeCycleModule = jagg.module("lifecycle"); | ||
var log=new Log(); | ||
var mod = jagg.module("urlmapper"); | ||
var permission = jagg.module("permission"); | ||
var manager = jagg.module("manager"); | ||
|
||
(function () { | ||
action = request.getParameter("action"), | ||
site = require("/site/conf/site.json"); | ||
if (!jagg.getUser()) { | ||
print(UNAUTHORIZED_ERROR_RESPONSE); | ||
return; | ||
} | ||
if(action == "addNewCustomUrl"){ | ||
var newCustomUrl = request.getParameter("newCustomUrl"); | ||
newCustomUrl = newCustomUrl.toLowerCase(); | ||
var applicationKey = request.getParameter("applicationKey"); | ||
if (permission.isUserAccessGranted(applicationKey, PERMISSION_DOMAIN_MAPPING)){ | ||
var stage = getProperty(FINE_GRAINED_DOMAIN_MAPPING); | ||
try { | ||
mod.addNewCustomUrl(stage, newCustomUrl, applicationKey, null, true); | ||
} catch (e) { | ||
// we are logging this as warn messages since this is caused, due a to user error. For example if the | ||
// user entered a rubbish custom url(Or a url which CNAME record is not propagated at the time of | ||
// adding the url), then url validation will fail but it is not an system error | ||
var msg = "Error while adding new customer url: "+ newCustomUrl +" for application: "+applicationKey | ||
+" in stage: " + stage+". New custom url: "+newCustomUrl+" might not a valid url(or non existing)"; | ||
log.warn(msg); | ||
log.warn(e); | ||
response.status = 400; | ||
response.content = e; | ||
} | ||
|
||
} else { | ||
response.status = 401; | ||
response.content = "Unauthorized!!! Only Application Owner has permission to complete this action"; | ||
} | ||
} else if (action == "addDefaultProdUrl") { | ||
var appKey = request.getParameter("applicationKey"); | ||
var version = null; | ||
var applicationType = manager.getApplicationType(appKey); | ||
var isUploadableAppType = manager.getApplicationTypeBean(applicationType).isUploadableAppType(); | ||
if (isUploadableAppType) { | ||
version = UPLOADABLE_APPLICATION_INITIAL_VERSION; | ||
} | ||
try { | ||
if(manager.getApplicationTypeBean(applicationType).isAllowDomainMapping()) { | ||
mod.addDefaultProdUrl(appKey, version); | ||
print(true); | ||
} | ||
print(false); | ||
} catch (e) { | ||
var msg = "Error while adding default production url"; | ||
log.error(msg); | ||
log.error(e); | ||
response.status = 400; | ||
response.content = e; | ||
} | ||
} | ||
else { | ||
throw new Error("No action specified"); | ||
} | ||
}()); | ||
|
||
|
||
|
||
%> | ||
|
This file contains 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
Oops, something went wrong.