Package org.joget.apps.app.model

Examples of org.joget.apps.app.model.HashVariablePlugin


                    for (String var : varList) {
                        String tempVar = var.replaceAll("#", "");

                        for (Plugin p : pluginList) {
                            HashVariablePlugin hashVariablePlugin = (HashVariablePlugin) p;
                            if (tempVar.startsWith(hashVariablePlugin.getPrefix() + ".")) {
                                tempVar = tempVar.replaceFirst(hashVariablePlugin.getPrefix() + ".", "");

                                HashVariablePlugin cachedPlugin = hashVariablePluginCache.get(hashVariablePlugin.getClassName());
                                if (cachedPlugin == null) {
                                    cachedPlugin = (HashVariablePlugin) pluginManager.getPlugin(hashVariablePlugin.getClassName());
                                    //get default plugin properties

                                    if (appDef == null) {
                                        appDef = AppUtil.getCurrentAppDefinition();
                                    }
                                    PluginDefaultProperties pluginDefaultProperties = pluginDefaultPropertiesDao.loadById(cachedPlugin.getClassName(), appDef);
                                    if (pluginDefaultProperties != null && pluginDefaultProperties.getPluginProperties() != null && pluginDefaultProperties.getPluginProperties().trim().length() > 0) {
                                        cachedPlugin.setProperties(PropertyUtil.getPropertiesValueFromJson(pluginDefaultProperties.getPluginProperties()));
                                    }

                                    //put appDef & wfAssignment to properties
                                    cachedPlugin.setProperty("appDefinition", appDef);
                                    cachedPlugin.setProperty("workflowAssignment", wfAssignment);
                                    hashVariablePluginCache.put(hashVariablePlugin.getClassName(), cachedPlugin);
                                }

                                String nestedHashVar = tempVar;
                                       
                                //process nested hash
                                while (nestedHashVar.contains("{") && nestedHashVar.contains("}")) {
                                    Pattern nestedPattern = Pattern.compile("\\{([^\\{^\\}])*\\}");
                                    Matcher nestedMatcher = nestedPattern.matcher(nestedHashVar);
                                    while (nestedMatcher.find()) {
                                        String nestedHash = nestedMatcher.group();
                                        String nestedHashString = nestedHash.replace("{", "#");
                                        nestedHashString = nestedHashString.replace("}", "#");

                                        String processedNestedHashValue = processHashVariable(nestedHashString, wfAssignment, escapeFormat, replaceMap, appDef);
                                       
                                        //if being process
                                        if (!nestedHashString.equals(processedNestedHashValue)) {
                                            tempVar = tempVar.replaceAll(StringUtil.escapeString(nestedHash, StringUtil.TYPE_REGEX, null), StringUtil.escapeString(processedNestedHashValue, escapeFormat, replaceMap));
                                        }
                                       
                                        //remove nested hash
                                        nestedHashVar = nestedHashVar.replaceAll(StringUtil.escapeString(nestedHash, StringUtil.TYPE_REGEX, null), StringUtil.escapeString(processedNestedHashValue, escapeFormat, replaceMap));
                                    }
                                }

                                //unescape hash variable
                                tempVar = StringEscapeUtils.unescapeJavaScript(tempVar);

                                //get result from plugin
                                String value = cachedPlugin.processHashVariable(tempVar);

                                if (value != null && !StringUtil.TYPE_REGEX.equals(escapeFormat) && !StringUtil.TYPE_JSON.equals(escapeFormat)) {
                                    value = StringUtil.escapeRegex(value);
                                }

                                //escape special char in HashVariable
                                var = cachedPlugin.escapeHashVariable(var);

                                //replace
                                if (value != null) {
                                    // clean to prevent XSS
                                    value = StringUtil.stripHtmlRelaxed(value);
View Full Code Here


           
            JSONArray jsonArray = new JSONArray();
           
            List<String> syntaxs = new ArrayList<String> ();
            for (Plugin p : pluginList) {
                HashVariablePlugin hashVariablePlugin = (HashVariablePlugin) p;
                if (hashVariablePlugin.availableSyntax() != null) {
                    syntaxs.addAll(hashVariablePlugin.availableSyntax());
                }
            }
            Collections.sort(syntaxs);
            for (String key : syntaxs) {
                jsonArray.put(key);
View Full Code Here

TOP

Related Classes of org.joget.apps.app.model.HashVariablePlugin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.