Example usage for org.apache.commons.lang3 StringUtils replace

List of usage examples for org.apache.commons.lang3 StringUtils replace

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils replace.

Prototype

public static String replace(final String text, final String searchString, final String replacement) 

Source Link

Document

Replaces all occurrences of a String within another String.

A null reference passed to this method is a no-op.

 StringUtils.replace(null, *, *)        = null StringUtils.replace("", *, *)          = "" StringUtils.replace("any", null, *)    = "any" StringUtils.replace("any", *, null)    = "any" StringUtils.replace("any", "", *)      = "any" StringUtils.replace("aba", "a", null)  = "aba" StringUtils.replace("aba", "a", "")    = "b" StringUtils.replace("aba", "a", "z")   = "zbz" 

Usage

From source file:me.ryanhamshire.griefprevention.command.CommandHelper.java

public static FlagResult applyFlagPermission(CommandSource src, Subject subject, String subjectName,
        GPClaim claim, String flagPermission, String source, String target, Tristate value, Context context,
        FlagType flagType, Text reason, boolean clicked) {
    // Remove "any" in source
    if (source != null) {
        if (source.equalsIgnoreCase("any")) {
            source = "";
        } else {/*from  w  w w.j  ava 2 s .c o  m*/
            String[] parts = source.split(":");
            if (parts[1].equalsIgnoreCase("any")) {
                source = parts[0];
            }
        }
    }

    String basePermission = flagPermission.replace(GPPermissions.FLAG_BASE + ".", "");
    int endIndex = basePermission.indexOf(".");
    if (endIndex != -1) {
        basePermission = basePermission.substring(0, endIndex);
    }

    // Check if player can manage flag
    if (src instanceof Player) {
        Player player = (Player) src;
        GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore
                .getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
        Tristate result = Tristate.UNDEFINED;
        if (playerData.canManageAdminClaims) {
            result = Tristate
                    .fromBoolean(src.hasPermission(GPPermissions.ADMIN_CLAIM_FLAGS + "." + basePermission));
        } else if (GriefPreventionPlugin.getActiveConfig(player.getWorld().getProperties()).getConfig().flags
                .getUserClaimFlags().contains(basePermission)) {
            result = Tristate
                    .fromBoolean(src.hasPermission(GPPermissions.USER_CLAIM_FLAGS + "." + basePermission));
        }

        if (result != Tristate.TRUE) {
            GriefPreventionPlugin.sendMessage(src,
                    GriefPreventionPlugin.instance.messageData.permissionFlagUse.toText());
            return new GPFlagResult(FlagResultType.NO_PERMISSION);
        }
    }

    Set<Context> contexts = new HashSet<>();
    if (context != claim.getContext()) {
        // validate perms
        if (context == ClaimContexts.ADMIN_DEFAULT_CONTEXT || context == ClaimContexts.BASIC_DEFAULT_CONTEXT
                || context == ClaimContexts.TOWN_DEFAULT_CONTEXT
                || context == ClaimContexts.WILDERNESS_DEFAULT_CONTEXT) {
            if (!src.hasPermission(GPPermissions.MANAGE_FLAG_DEFAULTS)) {
                GriefPreventionPlugin.sendMessage(src,
                        GriefPreventionPlugin.instance.messageData.permissionFlagDefaults.toText());
                return new GPFlagResult(FlagResultType.NO_PERMISSION);
            }
            if (flagType == null) {
                flagType = FlagType.DEFAULT;
            }
        } else if (context == ClaimContexts.ADMIN_OVERRIDE_CONTEXT
                || context == ClaimContexts.TOWN_OVERRIDE_CONTEXT
                || context == ClaimContexts.BASIC_OVERRIDE_CONTEXT
                || context == ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT) {
            if (!src.hasPermission(GPPermissions.MANAGE_FLAG_OVERRIDES)) {
                GriefPreventionPlugin.sendMessage(src,
                        GriefPreventionPlugin.instance.messageData.permissionFlagOverrides.toText());
                return new GPFlagResult(FlagResultType.NO_PERMISSION);
            }
            if (flagType == null) {
                flagType = FlagType.OVERRIDE;
            }
        }
        contexts.add(context);
    } else {
        if (flagType == null) {
            flagType = FlagType.CLAIM;
        }
    }

    Text flagTypeText = Text.of();
    if (flagType == FlagType.OVERRIDE) {
        flagTypeText = Text.of(TextColors.RED, "OVERRIDE");
    } else if (flagType == FlagType.DEFAULT) {
        flagTypeText = Text.of(TextColors.LIGHT_PURPLE, "DEFAULT");
    } else if (flagType == FlagType.CLAIM) {
        flagTypeText = Text.of(TextColors.GOLD, "CLAIM");
    }

    if (source != null) {
        Pattern p = Pattern.compile("\\.[\\d+]*$");
        Matcher m = p.matcher(flagPermission);
        String targetMeta = "";
        if (m.find()) {
            targetMeta = m.group(0);
            flagPermission = flagPermission.replace(targetMeta, "");
        }
        flagPermission += ".source." + source + targetMeta;
        flagPermission = StringUtils.replace(flagPermission, ":", ".");
    }

    if (context == ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT) {
        if (reason != null && !reason.isEmpty()) {
            GriefPreventionPlugin.getGlobalConfig().getConfig().bans.addBan(flagPermission, reason);
            GriefPreventionPlugin.getGlobalConfig().save();
        }
    }

    if (subject == GriefPreventionPlugin.GLOBAL_SUBJECT) {
        if (context == claim.getContext() || !ClaimContexts.CONTEXT_LIST.contains(context)) {
            contexts.add(claim.getContext());
        } else {
            // wilderness overrides affect all worlds
            if (context != ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT) {
                contexts.add(claim.world.getContext());
            }
        }

        GriefPreventionPlugin.GLOBAL_SUBJECT.getSubjectData().setPermission(contexts, flagPermission, value);
        if (!clicked) {
            src.sendMessage(Text.of(
                    Text.builder()
                            .append(Text.of(TextColors.WHITE, "\n[", TextColors.AQUA, "Return to flags",
                                    TextColors.WHITE, "]\n"))
                            .onClick(TextActions.executeCallback(createCommandConsumer(src, "claimflag", "")))
                            .build(),
                    TextColors.GREEN, "Set ", flagTypeText, " permission ", TextColors.AQUA,
                    flagPermission.replace(GPPermissions.FLAG_BASE + ".", ""), TextColors.GREEN, "\n to ",
                    TextColors.LIGHT_PURPLE,
                    getClickableText(src, GriefPreventionPlugin.GLOBAL_SUBJECT, subjectName, contexts,
                            flagPermission, value, flagType),
                    TextColors.GREEN, " on ", TextColors.GOLD, "ALL"));
        }
    } else {
        if (context == claim.getContext() || !ClaimContexts.CONTEXT_LIST.contains(context)) {
            contexts.add(claim.getContext());
        } else {
            // wilderness overrides affect all worlds
            if (context != ClaimContexts.WILDERNESS_OVERRIDE_CONTEXT) {
                contexts.add(claim.world.getContext());
            }
        }

        subject.getSubjectData().setPermission(contexts, flagPermission, value);
        if (!clicked) {
            src.sendMessage(Text.of(
                    Text.builder()
                            .append(Text.of(TextColors.WHITE, "\n[", TextColors.AQUA, "Return to flags",
                                    TextColors.WHITE, "]\n"))
                            .onClick(TextActions.executeCallback(createCommandConsumer(src,
                                    subject instanceof User ? "claimflagplayer" : "claimflaggroup",
                                    subjectName)))
                            .build(),
                    TextColors.GREEN, "Set ", flagTypeText, " permission ", TextColors.AQUA,
                    flagPermission.replace(GPPermissions.FLAG_BASE + ".", ""), TextColors.GREEN, "\n to ",
                    TextColors.LIGHT_PURPLE,
                    getClickableText(src, subject, subjectName, contexts, flagPermission, value, flagType),
                    TextColors.GREEN, " on ", TextColors.GOLD, subjectName));
        }
    }

    return new GPFlagResult(FlagResultType.SUCCESS);
}

From source file:demo.config.PropertyConverter.java

/**
 * Escapes the delimiters that might be contained in the given string. This
 * method works like {@link #escapeListDelimiter(String, char)}. In
 * addition, a single backslash will also be escaped.
 * /*from  w  w w .j  a  va2 s  . c o  m*/
 * @param s
 *            the string with the value
 * @param delimiter
 *            the list delimiter to use
 * @return the correctly escaped string
 */
public static String escapeDelimiters(String s, char delimiter) {
    String s1 = StringUtils.replace(s, LIST_ESCAPE, LIST_ESCAPE + LIST_ESCAPE);
    return escapeListDelimiter(s1, delimiter);
}

From source file:com.gargoylesoftware.htmlunit.WebTestCase.java

/**
 * @param expectedAlerts the list of the expected alerts
 * @return the script to be included at the beginning of the generated HTML file
 * @throws IOException in case of problem
 *//*from  w w w . j  a  v a 2 s.  c o m*/
private String createInstrumentationScript(final List<String> expectedAlerts) throws IOException {
    // generate the js code
    final String baseJS = getFileContent("alertVerifier.js");

    final StringBuilder sb = new StringBuilder();
    sb.append("\n<script type='text/javascript'>\n");
    sb.append("var htmlunitReserved_tab = [");
    for (final ListIterator<String> iter = expectedAlerts.listIterator(); iter.hasNext();) {
        if (iter.hasPrevious()) {
            sb.append(", ");
        }
        String message = iter.next();
        message = StringUtils.replace(message, "\\", "\\\\");
        message = message.replaceAll("\n", "\\\\n").replaceAll("\r", "\\\\r");
        sb.append("{expected: \"").append(message).append("\"}");
    }
    sb.append("];\n\n");
    sb.append(baseJS);
    sb.append("</script>\n");
    return sb.toString();
}

From source file:com.oncore.calorders.core.utils.FormatHelper.java

/**
 * The <code>stripCurrencyChars</code> method removes all $ and , characters
 * from a String//from w ww.  ja v  a2s.  c  om
 *
 * @author OnCore Consulting LLC
 *
 * @param currencyValue a currency value
 *
 * @return a new String with any $ or , characters removed
 */
public static String stripCurrencyChars(String currencyValue) {
    String result = StringUtils.replace(currencyValue, "$", "");
    result = StringUtils.replace(result, ",", "");

    return result;
}

From source file:demo.config.PropertyConverter.java

/**
 * Escapes the list delimiter if it is contained in the given string. This
 * method ensures that list delimiter characters that are part of a
 * property's value are correctly escaped when a configuration is saved to a
 * file. Otherwise when loaded again the property will be treated as a list
 * property.//from  ww w  .  j a va2  s.  com
 * 
 * @param s
 *            the string with the value
 * @param delimiter
 *            the list delimiter to use
 * @return the escaped string
 * @since 1.7
 */
public static String escapeListDelimiter(String s, char delimiter) {
    return StringUtils.replace(s, String.valueOf(delimiter), LIST_ESCAPE + delimiter);
}

From source file:io.cloudslang.lang.tools.build.tester.SlangTestRunner.java

private Set<SystemProperty> getTestSystemProperties(SlangTestCase testCase, String projectPath) {
    String systemPropertiesFile = testCase.getSystemPropertiesFile();
    if (StringUtils.isEmpty(systemPropertiesFile)) {
        return new HashSet<>();
    }/*  w  ww . j  av  a  2s.  c o  m*/
    systemPropertiesFile = StringUtils.replace(systemPropertiesFile, PROJECT_PATH_TOKEN, projectPath);
    return parser.parseProperties(systemPropertiesFile);
}

From source file:it.wami.map.mongodeploy.OsmSaxHandler.java

/**
 *
 * need refactoring//from  w ww  . j  a va2s. c o m
 * @param atts
 */
private void processTag(Attributes atts) {

    BasicDBObject obj;
    String key = atts.getValue(Node.Tag.K);
    String value = atts.getValue(Node.Tag.V);

    if (StringUtils.contains(key, "capacity:")) { //key.contains("capacity:")){
        String[] tmp = StringUtils.split(key, ":");//key.split(":");
        BasicDBObject o = new BasicDBObject(tmp[1], value);
        obj = new BasicDBObject("capacity", o);
        //entry.append(key, obj);
        if (entry.containsField("tags")) {
            BasicDBObject tags = (BasicDBObject) entry.get("tags");
            if (tags.containsField("capacity") && tags.get("capacity") instanceof BasicDBObject) {

                ((BasicDBObject) tags.get("capacity")).append(tmp[1], value);

            } else {
                tags.append("capacity", o);
            }
        } else {
            entry.append(Node.TAGS, obj);
        }
    } else {
        key = StringUtils.replace(key, ".", "[dot]");
        //key = key.replace(".", "[dot]");
        obj = new BasicDBObject(key, value);
        if (entry.containsField(Node.TAGS)) {
            ((BasicDBObject) entry.get(Node.TAGS)).append(key, value);
        } else {
            entry.append(Node.TAGS, obj);
        }
    }

    // create the tag and save it inside the DB.
    saveTag(key, value);
}

From source file:com.oncore.calorders.core.utils.FormatHelper.java

/**
 * Use this method to remove dollar signs and comma separators from dollar
 * amount fields and dashes and dots from phone numbers and zip codes
 *
 * @param value A dollar amount such as $392,302
 * @return value without the $ and , characters such as 392302
 *//*from  w  w w. jav a2s  .  co  m*/
public static String stripNonNumerics(String value) {
    if (StringUtils.isBlank(value)) {
        return value;
    } else {
        value = StringUtils.replace(value, "$", "");
        value = StringUtils.replace(value, ",", "");
        value = StringUtils.replace(value, "-", "");
        value = StringUtils.replace(value, ".", "");

        if (StringUtils.contains(value, "(")) {
            value = StringUtils.replace(value, "(", "");
            value = StringUtils.replace(value, ")", "");
            value = "-" + value;
        }

        return value;
    }
}

From source file:biz.taoconsulting.oxf.processor.converter.FromPdfConverter.java

private String MassageTextResult(String rawString) {
    // Removes unwanted characters
    // Currently we need to get rid of chr(13);
    String oldChar = new Character((char) 13).toString();
    return StringUtils.replace(rawString, oldChar, "");
    //return rawString.replace(oldChar, ""); // this only works with Java 5
}

From source file:ching.icecreaming.action.ViewAction.java

@Action(value = "view", results = { @Result(name = "login", location = "edit.jsp"),
        @Result(name = "input", location = "view.jsp"), @Result(name = "success", location = "view.jsp"),
        @Result(name = "error", location = "error.jsp") })
public String execute() throws Exception {
    Enumeration enumerator = null;
    String[] array1 = null, array2 = null;
    int int1 = -1, int2 = -1, int3 = -1;
    InputStream inputStream1 = null;
    OutputStream outputStream1 = null;
    java.io.File file1 = null, file2 = null, dir1 = null;
    List<File> files = null;
    HttpHost httpHost1 = null;/*from   ww w .  j  ava 2s .  c om*/
    HttpGet httpGet1 = null, httpGet2 = null;
    HttpPut httpPut1 = null;
    URI uri1 = null;
    URL url1 = null;
    DefaultHttpClient httpClient1 = null;
    URIBuilder uriBuilder1 = null, uriBuilder2 = null;
    HttpResponse httpResponse1 = null, httpResponse2 = null;
    HttpEntity httpEntity1 = null, httpEntity2 = null;
    List<NameValuePair> nameValuePair1 = null;
    String string1 = null, string2 = null, string3 = null, string4 = null, return1 = LOGIN;
    XMLConfiguration xmlConfiguration = null;
    List<HierarchicalConfiguration> list1 = null, list2 = null;
    HierarchicalConfiguration hierarchicalConfiguration2 = null;
    DataModel1 dataModel1 = null;
    DataModel2 dataModel2 = null;
    List<DataModel1> listObject1 = null, listObject3 = null;
    org.joda.time.DateTime dateTime1 = null, dateTime2 = null;
    org.joda.time.Period period1 = null;
    PeriodFormatter periodFormatter1 = new PeriodFormatterBuilder().appendYears()
            .appendSuffix(String.format(" %s", getText("year")), String.format(" %s", getText("years")))
            .appendSeparator(" ").appendMonths()
            .appendSuffix(String.format(" %s", getText("month")), String.format(" %s", getText("months")))
            .appendSeparator(" ").appendWeeks()
            .appendSuffix(String.format(" %s", getText("week")), String.format(" %s", getText("weeks")))
            .appendSeparator(" ").appendDays()
            .appendSuffix(String.format(" %s", getText("day")), String.format(" %s", getText("days")))
            .appendSeparator(" ").appendHours()
            .appendSuffix(String.format(" %s", getText("hour")), String.format(" %s", getText("hours")))
            .appendSeparator(" ").appendMinutes()
            .appendSuffix(String.format(" %s", getText("minute")), String.format(" %s", getText("minutes")))
            .appendSeparator(" ").appendSeconds().minimumPrintedDigits(2)
            .appendSuffix(String.format(" %s", getText("second")), String.format(" %s", getText("seconds")))
            .printZeroNever().toFormatter();
    if (StringUtils.isBlank(urlString) || StringUtils.isBlank(wsType)) {
        urlString = portletPreferences.getValue("urlString", "/");
        wsType = portletPreferences.getValue("wsType", "folder");
    }
    Configuration propertiesConfiguration1 = new PropertiesConfiguration("system.properties");
    timeZone1 = portletPreferences.getValue("timeZone", TimeZone.getDefault().getID());
    enumerator = portletPreferences.getNames();
    if (enumerator.hasMoreElements()) {
        array1 = portletPreferences.getValues("server", null);
        if (array1 != null) {
            if (ArrayUtils.isNotEmpty(array1)) {
                for (int1 = 0; int1 < array1.length; int1++) {
                    switch (int1) {
                    case 0:
                        sid = array1[int1];
                        break;
                    case 1:
                        uid = array1[int1];
                        break;
                    case 2:
                        pid = array1[int1];
                        break;
                    case 3:
                        alias1 = array1[int1];
                        break;
                    default:
                        break;
                    }
                }
                sid = new String(Base64.decodeBase64(sid.getBytes()));
                uid = new String(Base64.decodeBase64(uid.getBytes()));
                pid = new String(Base64.decodeBase64(pid.getBytes()));
            }
            return1 = INPUT;
        } else {
            return1 = LOGIN;
        }
    } else {
        return1 = LOGIN;
    }

    if (StringUtils.equals(urlString, "/")) {

        if (listObject1 != null) {
            listObject1.clear();
        }
        if (session.containsKey("breadcrumbs")) {
            session.remove("breadcrumbs");
        }
    } else {
        array2 = StringUtils.split(urlString, "/");
        listObject1 = (session.containsKey("breadcrumbs")) ? (List<DataModel1>) session.get("breadcrumbs")
                : new ArrayList<DataModel1>();
        int2 = array2.length - listObject1.size();
        if (int2 > 0) {
            listObject1.add(new DataModel1(urlString, label1));
        } else {
            int2 += listObject1.size();
            for (int1 = listObject1.size() - 1; int1 >= int2; int1--) {
                listObject1.remove(int1);
            }
        }
        session.put("breadcrumbs", listObject1);
    }
    switch (wsType) {
    case "folder":
        break;
    case "reportUnit":
        try {
            dateTime1 = new org.joda.time.DateTime();
            return1 = INPUT;
            httpClient1 = new DefaultHttpClient();
            if (StringUtils.equals(button1, getText("Print"))) {
                nameValuePair1 = new ArrayList<NameValuePair>();
                if (listObject2 != null) {
                    if (listObject2.size() > 0) {
                        for (DataModel2 dataObject2 : listObject2) {
                            listObject3 = dataObject2.getOptions();
                            if (listObject3 == null) {
                                string2 = dataObject2.getValue1();
                                if (StringUtils.isNotBlank(string2))
                                    nameValuePair1.add(new BasicNameValuePair(dataObject2.getId(), string2));
                            } else {
                                for (int1 = listObject3.size() - 1; int1 >= 0; int1--) {
                                    dataModel1 = (DataModel1) listObject3.get(int1);
                                    string2 = dataModel1.getString2();
                                    if (StringUtils.isNotBlank(string2))
                                        nameValuePair1
                                                .add(new BasicNameValuePair(dataObject2.getId(), string2));
                                }
                            }
                        }
                    }
                }
                url1 = new URL(sid);
                uriBuilder1 = new URIBuilder(sid);
                uriBuilder1.setUserInfo(uid, pid);
                if (StringUtils.isBlank(format1))
                    format1 = "pdf";
                uriBuilder1.setPath(url1.getPath() + "/rest_v2/reports" + urlString + "." + format1);
                if (StringUtils.isNotBlank(locale2)) {
                    nameValuePair1.add(new BasicNameValuePair("userLocale", locale2));
                }
                if (StringUtils.isNotBlank(page1)) {
                    if (NumberUtils.isNumber(page1)) {
                        nameValuePair1.add(new BasicNameValuePair("page", page1));
                    }
                }
                if (nameValuePair1.size() > 0) {
                    uriBuilder1.setQuery(URLEncodedUtils.format(nameValuePair1, "UTF-8"));
                }
                uri1 = uriBuilder1.build();
                httpGet1 = new HttpGet(uri1);
                httpResponse1 = httpClient1.execute(httpGet1);
                int1 = httpResponse1.getStatusLine().getStatusCode();
                if (int1 == HttpStatus.SC_OK) {
                    string3 = System.getProperty("java.io.tmpdir") + File.separator
                            + httpServletRequest.getSession().getId();
                    dir1 = new File(string3);
                    if (!dir1.exists()) {
                        dir1.mkdir();
                    }
                    httpEntity1 = httpResponse1.getEntity();
                    file1 = new File(string3, StringUtils.substringAfterLast(urlString, "/") + "." + format1);
                    if (StringUtils.equalsIgnoreCase(format1, "html")) {
                        result1 = EntityUtils.toString(httpEntity1);
                        FileUtils.writeStringToFile(file1, result1);
                        array1 = StringUtils.substringsBetween(result1, "<img src=\"", "\"");
                        if (ArrayUtils.isNotEmpty(array1)) {
                            dir1 = new File(
                                    string3 + File.separator + FilenameUtils.getBaseName(file1.getName()));
                            if (dir1.exists()) {
                                FileUtils.deleteDirectory(dir1);
                            }
                            file2 = new File(FilenameUtils.getFullPath(file1.getAbsolutePath())
                                    + FilenameUtils.getBaseName(file1.getName()) + ".zip");
                            if (file2.exists()) {
                                if (FileUtils.deleteQuietly(file2)) {
                                }
                            }
                            for (int2 = 0; int2 < array1.length; int2++) {
                                try {
                                    string2 = url1.getPath() + "/rest_v2/reports" + urlString + "/"
                                            + StringUtils.substringAfter(array1[int2], "/");
                                    uriBuilder1.setPath(string2);
                                    uri1 = uriBuilder1.build();
                                    httpGet1 = new HttpGet(uri1);
                                    httpResponse1 = httpClient1.execute(httpGet1);
                                    int1 = httpResponse1.getStatusLine().getStatusCode();
                                } finally {
                                    if (int1 == HttpStatus.SC_OK) {
                                        try {
                                            string2 = StringUtils.substringBeforeLast(array1[int2], "/");
                                            dir1 = new File(string3 + File.separator + string2);
                                            if (!dir1.exists()) {
                                                dir1.mkdirs();
                                            }
                                            httpEntity1 = httpResponse1.getEntity();
                                            inputStream1 = httpEntity1.getContent();
                                        } finally {
                                            string1 = StringUtils.substringAfterLast(array1[int2], "/");
                                            file2 = new File(string3 + File.separator + string2, string1);
                                            outputStream1 = new FileOutputStream(file2);
                                            IOUtils.copy(inputStream1, outputStream1);
                                        }
                                    }
                                }
                            }
                            outputStream1 = new FileOutputStream(
                                    FilenameUtils.getFullPath(file1.getAbsolutePath())
                                            + FilenameUtils.getBaseName(file1.getName()) + ".zip");
                            ArchiveOutputStream archiveOutputStream1 = new ArchiveStreamFactory()
                                    .createArchiveOutputStream(ArchiveStreamFactory.ZIP, outputStream1);
                            archiveOutputStream1.putArchiveEntry(new ZipArchiveEntry(file1, file1.getName()));
                            IOUtils.copy(new FileInputStream(file1), archiveOutputStream1);
                            archiveOutputStream1.closeArchiveEntry();
                            dir1 = new File(FilenameUtils.getFullPath(file1.getAbsolutePath())
                                    + FilenameUtils.getBaseName(file1.getName()));
                            files = (List<File>) FileUtils.listFiles(dir1, TrueFileFilter.INSTANCE,
                                    TrueFileFilter.INSTANCE);
                            for (File file3 : files) {
                                archiveOutputStream1.putArchiveEntry(new ZipArchiveEntry(file3, StringUtils
                                        .substringAfter(file3.getCanonicalPath(), string3 + File.separator)));
                                IOUtils.copy(new FileInputStream(file3), archiveOutputStream1);
                                archiveOutputStream1.closeArchiveEntry();
                            }
                            archiveOutputStream1.close();
                        }
                        bugfixGateIn = propertiesConfiguration1.getBoolean("bugfixGateIn", false);
                        string4 = bugfixGateIn
                                ? String.format("<img src=\"%s/namespace1/file-link?sessionId=%s&fileName=",
                                        portletRequest.getContextPath(),
                                        httpServletRequest.getSession().getId())
                                : String.format("<img src=\"%s/namespace1/file-link?fileName=",
                                        portletRequest.getContextPath());
                        result1 = StringUtils.replace(result1, "<img src=\"", string4);
                    } else {
                        inputStream1 = httpEntity1.getContent();
                        outputStream1 = new FileOutputStream(file1);
                        IOUtils.copy(inputStream1, outputStream1);
                        result1 = file1.getAbsolutePath();
                    }
                    return1 = SUCCESS;
                } else {
                    addActionError(String.format("%s %d: %s", getText("Error"), int1,
                            getText(Integer.toString(int1))));
                }
                dateTime2 = new org.joda.time.DateTime();
                period1 = new Period(dateTime1, dateTime2.plusSeconds(1));
                message1 = getText("Execution.time") + ": " + periodFormatter1.print(period1);
            } else {
                url1 = new URL(sid);
                uriBuilder1 = new URIBuilder(sid);
                uriBuilder1.setUserInfo(uid, pid);
                uriBuilder1.setPath(url1.getPath() + "/rest_v2/reports" + urlString + "/inputControls");
                uri1 = uriBuilder1.build();
                httpGet1 = new HttpGet(uri1);
                httpResponse1 = httpClient1.execute(httpGet1);
                int1 = httpResponse1.getStatusLine().getStatusCode();
                switch (int1) {
                case HttpStatus.SC_NO_CONTENT:
                    break;
                case HttpStatus.SC_OK:
                    httpEntity1 = httpResponse1.getEntity();
                    if (httpEntity1 != null) {
                        inputStream1 = httpEntity1.getContent();
                        if (inputStream1 != null) {
                            xmlConfiguration = new XMLConfiguration();
                            xmlConfiguration.load(inputStream1);
                            list1 = xmlConfiguration.configurationsAt("inputControl");
                            if (list1.size() > 0) {
                                listObject2 = new ArrayList<DataModel2>();
                                for (HierarchicalConfiguration hierarchicalConfiguration1 : list1) {
                                    string2 = hierarchicalConfiguration1.getString("type");
                                    dataModel2 = new DataModel2();
                                    dataModel2.setId(hierarchicalConfiguration1.getString("id"));
                                    dataModel2.setLabel1(hierarchicalConfiguration1.getString("label"));
                                    dataModel2.setType1(string2);
                                    dataModel2.setMandatory(hierarchicalConfiguration1.getBoolean("mandatory"));
                                    dataModel2.setReadOnly(hierarchicalConfiguration1.getBoolean("readOnly"));
                                    dataModel2.setVisible(hierarchicalConfiguration1.getBoolean("visible"));
                                    switch (string2) {
                                    case "bool":
                                    case "singleValueText":
                                    case "singleValueNumber":
                                    case "singleValueDate":
                                    case "singleValueDatetime":
                                        hierarchicalConfiguration2 = hierarchicalConfiguration1
                                                .configurationAt("state");
                                        dataModel2.setValue1(hierarchicalConfiguration2.getString("value"));
                                        break;
                                    case "singleSelect":
                                    case "singleSelectRadio":
                                    case "multiSelect":
                                    case "multiSelectCheckbox":
                                        hierarchicalConfiguration2 = hierarchicalConfiguration1
                                                .configurationAt("state");
                                        list2 = hierarchicalConfiguration2.configurationsAt("options.option");
                                        if (list2.size() > 0) {
                                            listObject3 = new ArrayList<DataModel1>();
                                            for (HierarchicalConfiguration hierarchicalConfiguration3 : list2) {
                                                dataModel1 = new DataModel1(
                                                        hierarchicalConfiguration3.getString("label"),
                                                        hierarchicalConfiguration3.getString("value"));
                                                if (hierarchicalConfiguration3.getBoolean("selected")) {
                                                    dataModel2.setValue1(
                                                            hierarchicalConfiguration3.getString("value"));
                                                }
                                                listObject3.add(dataModel1);
                                            }
                                            dataModel2.setOptions(listObject3);
                                        }
                                        break;
                                    default:
                                        break;
                                    }
                                    listObject2.add(dataModel2);
                                }
                            }
                        }
                    }
                    break;
                default:
                    addActionError(String.format("%s %d: %s", getText("Error"), int1,
                            getText(Integer.toString(int1))));
                    break;
                }
                if (httpEntity1 != null) {
                    EntityUtils.consume(httpEntity1);
                }
                uriBuilder1.setPath(url1.getPath() + "/rest/resource" + urlString);
                uri1 = uriBuilder1.build();
                httpGet1 = new HttpGet(uri1);
                httpResponse1 = httpClient1.execute(httpGet1);
                int2 = httpResponse1.getStatusLine().getStatusCode();
                if (int2 == HttpStatus.SC_OK) {
                    httpEntity1 = httpResponse1.getEntity();
                    inputStream1 = httpEntity1.getContent();
                    xmlConfiguration = new XMLConfiguration();
                    xmlConfiguration.load(inputStream1);
                    list1 = xmlConfiguration.configurationsAt("resourceDescriptor");
                    for (HierarchicalConfiguration hierarchicalConfiguration4 : list1) {
                        if (StringUtils.equalsIgnoreCase(
                                StringUtils.trim(hierarchicalConfiguration4.getString("[@wsType]")), "prop")) {
                            if (map1 == null)
                                map1 = new HashMap<String, String>();
                            string2 = StringUtils.substringBetween(
                                    StringUtils.substringAfter(
                                            hierarchicalConfiguration4.getString("[@uriString]"), "_files/"),
                                    "_", ".properties");
                            map1.put(string2,
                                    StringUtils.isBlank(string2) ? getText("Default") : getText(string2));
                        }
                    }
                }
                if (httpEntity1 != null) {
                    EntityUtils.consume(httpEntity1);
                }
            }
        } catch (IOException | ConfigurationException | URISyntaxException exception1) {
            exception1.printStackTrace();
            addActionError(exception1.getLocalizedMessage());
            httpGet1.abort();
            return ERROR;
        } finally {
            httpClient1.getConnectionManager().shutdown();
            IOUtils.closeQuietly(inputStream1);
        }
        break;
    default:
        addActionError(getText("This.file.type.is.not.supported"));
        break;
    }
    if (return1 != LOGIN) {
        sid = new String(Base64.encodeBase64(sid.getBytes()));
        uid = new String(Base64.encodeBase64(uid.getBytes()));
        pid = new String(Base64.encodeBase64(pid.getBytes()));
    }
    return return1;
}