All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.edit_entry.jsp Maven / Gradle / Ivy

The newest version!
<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
--%>

<%@ include file="/init.jsp" %>

<%
String redirect = ParamUtil.getString(request, "redirect");

long sapEntryId = ParamUtil.getLong(request, "sapEntryId");

SAPEntry sapEntry = null;

if (sapEntryId > 0) {
	sapEntry = SAPEntryServiceUtil.getSAPEntry(sapEntryId);
}

String[] allowedServiceSignaturesArray = {};

if (sapEntry != null) {
	allowedServiceSignaturesArray = StringUtil.splitLines(sapEntry.getAllowedServiceSignatures());
}

if (allowedServiceSignaturesArray.length == 0) {
	allowedServiceSignaturesArray = new String[] {StringPool.BLANK};
}

boolean systemSAPEntry = false;

if (sapEntry != null) {
	systemSAPEntry = sapEntry.isSystem();
}

portletDisplay.setShowBackIcon(true);
portletDisplay.setURLBack(redirect);

renderResponse.setTitle((sapEntry == null) ? LanguageUtil.get(request, "new-service-access-policy") : sapEntry.getTitle(locale));
%>


	



	
	

	
	
	

	

	
		
			
				
					function(val, fieldNode, ruleValue) {
						var allowedCharacters = '<%= HtmlUtil.escapeJS(SAPEntryConstants.NAME_ALLOWED_CHARACTERS) %>';

						val = val.trim();

						var regex = new RegExp('[^' + allowedCharacters + ']');

						return !regex.test(val);
					}
				
			

			

			

			

			

			
<% for (int i = 0; i < allowedServiceSignaturesArray.length; i++) { String serviceClassName = StringPool.BLANK; String actionMethodName = StringPool.BLANK; String[] allowedServiceSignatureArray = StringUtil.split(allowedServiceSignaturesArray[i], CharPool.POUND); if (allowedServiceSignatureArray.length > 0) { serviceClassName = GetterUtil.getString(allowedServiceSignatureArray[0], StringPool.BLANK); if (allowedServiceSignatureArray.length > 1) { actionMethodName = GetterUtil.getString(allowedServiceSignatureArray[1], StringPool.BLANK); } } %>
<% } %>
function toggleAdvancedMode(argument) { AUI.$('#advancedMode, #friendlyMode, #allowedServiceSignatures, #allowedServiceSignaturesFriendlyContentBox').toggleClass('hide'); } var REGEX_DOT = /\./g; var actionMethodNamesCache = {}; var getActionMethodNamesURL = Liferay.PortletURL.createURL('<%= getActionMethodNamesURL %>'); var serviceClassNamesToContextNames = <%= request.getAttribute(SAPWebKeys.SERVICE_CLASS_NAMES_TO_CONTEXT_NAMES) %>; var getActionMethodNames = function(contextName, serviceClassName, callback) { if (contextName && serviceClassName && callback) { var namespace = contextName.replace(REGEX_DOT, '_') + '.' + serviceClassName.replace(REGEX_DOT, '_'); var methodObj = A.namespace.call(actionMethodNamesCache, namespace); var actionMethodNames = methodObj.actionMethodNames; if (!actionMethodNames) { if (contextName == 'portal') { contextName = ''; } getActionMethodNamesURL.setParameter('contextName', contextName); getActionMethodNamesURL.setParameter('serviceClassName', serviceClassName); A.io.request( getActionMethodNamesURL.toString(), { dataType: 'JSON', method: 'GET', on: { success: function(event, id, xhr) { actionMethodNames = this.get('responseData'); methodObj.actionMethodNames = actionMethodNames; callback(actionMethodNames); } } } ); } else { callback(actionMethodNames); } } }; var getContextName = function(serviceClassName) { var serviceClassNameToContextName = A.Array.find( serviceClassNamesToContextNames, function(item, index) { return item.serviceClassName === serviceClassName; } ); return serviceClassNameToContextName && serviceClassNameToContextName.contextName || 'portal'; }; var initAutoCompleteRow = function(rowNode) { var actionMethodNameInput = rowNode.one('.action-method-name'); var serviceClassNameInput = rowNode.one('.service-class-name'); new A.AutoComplete( { inputNode: serviceClassNameInput, on: { select: function(event) { var result = event.result.raw; serviceClassNameInput.attr('data-service-class-name', result.serviceClassName); serviceClassNameInput.attr('data-context-name', result.contextName); actionMethodNameInput.attr('disabled', false); } }, resultFilters: 'phraseMatch', resultTextLocator: 'serviceClassName', source: serviceClassNamesToContextNames } ).render(); new A.AutoComplete( { inputNode: actionMethodNameInput, resultFilters: 'phraseMatch', resultTextLocator: 'actionMethodName', source: function(query, callback) { var contextName = serviceClassNameInput.attr('data-context-name'); var serviceClassName = serviceClassNameInput.attr('data-service-class-name'); if (!contextName) { contextName = getContextName(serviceClassName); serviceClassNameInput.attr('data-context-name', contextName); } getActionMethodNames(contextName, serviceClassName, callback); } } ).render(); }; var updateAdvancedModeTextarea = function() { var updatedInput = ''; A.all('#allowedServiceSignaturesFriendlyContentBox .lfr-form-row:not(.hide)').each( function(item, index) { var actionMethodName = item.one('.action-method-name').val(); var serviceClassName = item.one('.service-class-name').val(); updatedInput += serviceClassName; if (actionMethodName) { updatedInput += '#' + actionMethodName; } updatedInput += '\n'; } ); A.one('#allowedServiceSignatures').val(updatedInput); }; var updateFriendlyModeInputs = function() { var contentBox = A.one('#allowedServiceSignaturesFriendlyContentBox'); contentBox.all('.lfr-form-row:not(.hide)').remove(); var advancedInput = A.one('#allowedServiceSignatures').val(); var entries = advancedInput.split('\n'); entries = A.Array.dedupe(entries); entries.forEach( function(item, index) { var row = rowTemplate.clone(); if (item) { var actionMethodNameInput = row.one('.action-method-name'); var serviceClassNameInput = row.one('.service-class-name'); item = item.split('#'); var serviceClassName = item[0]; serviceClassNameInput.val(serviceClassName); serviceClassNameInput.attr('data-service-class-name', serviceClassName); var actionMethodName = item[1]; if (actionMethodName) { actionMethodNameInput.val(actionMethodName); } initAutoCompleteRow(row); contentBox.append(row); } } ); }; new Liferay.AutoFields( { contentBox: '#allowedServiceSignaturesFriendlyContentBox', namespace: '', on: { clone: function(event) { var rowNode = event.row; var actionMethodNameInput = rowNode.one('.action-method-name'); var serviceClassNameInput = rowNode.one('.service-class-name'); actionMethodNameInput.attr('disabled', true); serviceClassNameInput.attr( { 'data-context-name': '', 'data-service-class-name': '' } ); initAutoCompleteRow(rowNode); }, delete: updateAdvancedModeTextarea } } ).render(); var rows = A.all('#allowedServiceSignaturesFriendlyContentBox .lfr-form-row'); var rowTemplate = rows.first().clone(); rowTemplate.all('input').val(''); A.each(rows, initAutoCompleteRow); A.one('#allowedServiceSignaturesFriendlyContentBox').delegate('blur', updateAdvancedModeTextarea, '.service-class-name, .action-method-name'); A.one('#allowedServiceSignatures').on('blur', updateFriendlyModeInputs);




© 2015 - 2025 Weber Informatics LLC | Privacy Policy