diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2019-12-04 19:43:32 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2019-12-04 19:43:32 +0100 |
commit | 759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f (patch) | |
tree | 2132024fc058b1ef5338bf50df575a3244cc3f9f /eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java | |
parent | 4f15bdc45b08724d20c66c9fd74ea6a43a03c32f (diff) | |
download | EAAF-Components-759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f.tar.gz EAAF-Components-759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f.tar.bz2 EAAF-Components-759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f.zip |
common EGIZ code-style refactoring
Diffstat (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java')
-rw-r--r-- | eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java | 179 |
1 files changed, 0 insertions, 179 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java deleted file mode 100644 index dde5ab70..00000000 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/gui/AbstractGUIFormBuilderConfiguration.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright 2017 Graz University of Technology - * EAAF-Core Components has been developed in a cooperation between EGIZ, - * A-SIT Plus, A-SIT, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * https://joinup.ec.europa.eu/news/understanding-eupl-v12 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - *******************************************************************************/ -/******************************************************************************* - *******************************************************************************/ -/******************************************************************************* - *******************************************************************************/ -package at.gv.egiz.eaaf.core.impl.gui; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.gv.egiz.eaaf.core.api.gui.GroupDefinition; -import at.gv.egiz.eaaf.core.api.gui.GroupDefinition.TYPE; -import at.gv.egiz.eaaf.core.api.gui.IGUIBuilderConfiguration; - -/** - * @author tlenz - * - */ -public abstract class AbstractGUIFormBuilderConfiguration implements IGUIBuilderConfiguration { - private static final Logger log = LoggerFactory.getLogger(AbstractGUIFormBuilderConfiguration.class); - - public static final GroupDefinition PARAM_GROUP_FORM = GroupDefinition.getInstance("form", TYPE.MAP); - public static final GroupDefinition PARAM_GROUP_ACTIONS = GroupDefinition.getInstance("actions", TYPE.LIST); - public static final GroupDefinition PARAM_GROUP_PARAMS = GroupDefinition.getInstance("params", TYPE.MAP); - public static final GroupDefinition PARAM_GROUP_UIOPTIONS = GroupDefinition.getInstance("uiOptions", TYPE.MAP); - public static final GroupDefinition PARAM_GROUP_MSG = GroupDefinition.getInstance("msg", TYPE.MAP); - - - public static final String PARAM_VIEWNAME = "viewName"; - public static final String PARAM_AUTHCONTEXT = "contextPath"; - public static final String PARAM_FORMSUBMITENDPOINT = "submitEndpoint"; - @Deprecated public static final String PARAM_PENDINGREQUESTID_DEPRECATED = "pendingReqID"; - public static final String PARAM_PENDINGREQUESTID = "pendingid"; - - private String authURL = null; - private String viewName = null; - private String formSubmitEndpoint = null; - - private final Map<String, Object> params = new HashMap<String, Object>(); - - /** - * @param authURL IDP PublicURL-Prefix which should be used, but never null - * @param viewName Name of the template (with suffix) but never null - * @param formSubmitEndpoint EndPoint on which the form should be submitted, - * or null if the form must not submitted - * - */ - public AbstractGUIFormBuilderConfiguration(String authURL, String viewName, String formSubmitEndpoint) { - if (viewName.startsWith("/")) - this.viewName = viewName.substring(1); - else - this.viewName = viewName; - - if (authURL.endsWith("/")) - this.authURL = authURL.substring(0, authURL.length() - 1); - else - this.authURL = authURL; - - if (StringUtils.isNotEmpty(formSubmitEndpoint)) { - if (formSubmitEndpoint.startsWith("/")) - this.formSubmitEndpoint = formSubmitEndpoint; - else - this.formSubmitEndpoint = "/" + formSubmitEndpoint; - } - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.auth.frontend.builder.IGUIBuilderConfiguration#getViewName() - */ - @Override - public final String getViewName() { - return this.viewName; - - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.auth.frontend.builder.IGUIBuilderConfiguration#getViewParameters() - */ - @Override - public final Map<String, Object> getViewParameters() { - //set generic parameters - setViewParameter(getFromGroup(), PARAM_AUTHCONTEXT, this.authURL); - setViewParameter(getFromGroup(), PARAM_FORMSUBMITENDPOINT, this.formSubmitEndpoint); - setViewParameter(getFromGroup(), PARAM_VIEWNAME, this.viewName); - - //get parameters from detail implementation - putSpecificViewParameters(); - - try { - log.trace("Full view parameters: {}", StringUtils.join(params, ",")); - } catch (final Exception e) { - log.info("Can NOT trace view parameters. Reason: {}", e.getMessage() ); - } - - return params; - - } - - /** - * Define the parameters, which should be evaluated in the template <br> - * <b>IMPORTANT:</b> external HTML escapetion is required, because it is NOT done internally during the building process - * - */ - abstract protected void putSpecificViewParameters(); - - /** - * Get the Group for generic form elements - * - * @return {@link GroupDefinition} or <code>null</code> if no groups are used - */ - abstract protected GroupDefinition getFromGroup(); - - @SuppressWarnings("unchecked") - protected void setViewParameter(GroupDefinition groupDefinition, String key, Object value) { - - if (groupDefinition != null) { - log.trace("Adding group object ... "); - Object groupMap = params.get(groupDefinition.getName()); - if (groupMap == null) { - if (groupDefinition.getType().equals(TYPE.MAP)) { - groupMap = new HashMap<String, Object>();; - log.trace("Build new MAP based group element"); - - } else if (groupDefinition.getType().equals(TYPE.LIST)) { - groupMap = new ArrayList<Object>(); - log.trace("Build new List based group element"); - - } else - log.warn("GroupDefinition contains an unknown type: {}", groupDefinition.getType().name()); - - } - - params.put(groupDefinition.getName(), groupMap); - if (groupMap instanceof Map<?,?>) - ((Map<String, Object>) groupMap).put(key, value); - - else if (groupMap instanceof List<?>) - ((List<Object>)groupMap).add(value); - - else - log.warn("Can NOT add element: {} to group: {}, because group is of type: {}", - key, groupDefinition.getName(), groupMap.getClass().getName()); - - } else { - log.trace("Add root object ... "); - params.put(key, value); - - } - - } -} |