| <% |
| /* |
| * |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF 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. |
| * |
| */ |
| |
| var payloadFac = require("payloadFactory.jag"); |
| var util = require("../util/utility.jag"); |
| |
| var log = new Log(); |
| var serverUrl = util.getServerUrl(); |
| |
| var ws = require('ws'); |
| var webService = new ws.WSRequest(); |
| |
| function getUserProfile(username, profileName){ |
| |
| var options = new Array(); |
| options.useSOAP = 1.1; |
| options.action = "urn:getUserProfile"; |
| |
| var payload = payloadFac.getPayload(options.action, new Array(username, profileName)); |
| var result; |
| |
| try { |
| webService.open(options, serverUrl, false, "admin", "admin"); |
| webService.send(payload); |
| |
| if(webService.readyState == 4){ |
| result = webService.responseXML; |
| result = util.E4XtoJSON(result); |
| |
| result.return.fieldValues = util.sortNumber(result.return.fieldValues, 'displayOrder', true, true); |
| |
| for(var x = 0; x < result.return.fieldValues.length; x++){ |
| var obj = result.return.fieldValues[x]; |
| if(obj.required === "false"){ |
| obj.required = ""; |
| } |
| |
| if(obj.readOnly === "false"){ |
| obj.readOnly = ""; |
| } |
| } |
| log.debug(result); |
| return result; |
| } |
| |
| } catch (e) { |
| log.error(e.toString()); |
| |
| //TODO send proper error message from i18n file |
| return ""; |
| } |
| |
| } |
| |
| |
| |
| |
| %> |