Example usage for java.lang StringBuffer substring

List of usage examples for java.lang StringBuffer substring

Introduction

In this page you can find the example usage for java.lang StringBuffer substring.

Prototype

@Override
public synchronized String substring(int start, int end) 

Source Link

Usage

From source file:org.esco.grouperui.web.controllers.groupmodifications.GroupModificationsAttributesController.java

/**
 * Allow to retrieve incompatibilities of a context for a custom type from a
 * group.//from  w  ww  .  j  a  v  a 2 s . c o m
 * 
 * @return the XML data.
 */
public String getIncompatibilities() {
    StringBuffer buffer = new StringBuffer();
    String incompatibilities = null;
    String customType = this.getParam("customType");
    String useContext = this.getParam("context");
    String value = null;
    List<String> listContext = null;

    FacesContext context = FacesContext.getCurrentInstance();
    IParameterService parameterService = (IParameterService) context.getApplication()
            .createValueBinding(ESCOConstantes.PARAMETER_SERVICE).getValue(context);

    List<Parameter> listParameters = parameterService
            .findParametersByGroup(ESCOConstantes.GROUP_GROUP_CONTEXT_INCOMPATIBILITIES
                    + ESCOConstantes.GROUP_NAME_SEPARATOR + customType)
            .getParameters();

    if (null != listParameters) {
        for (Parameter parameter : listParameters) {
            value = parameter.getValue();
            listContext = Arrays.asList(value.split("[|]+"));
            int index = listContext.indexOf(useContext);
            switch (index) {
            case -1:
                // context is not in this rule
                // do nothing
                break;
            case 0:
                // context is the first element, so the second element
                // is incompatible
                buffer.append(listContext.get(1));
                buffer.append("|");
                break;
            case 1:
                // context is the second element, so the first element
                // is incompatible
                buffer.append(listContext.get(0));
                buffer.append("|");
                break;
            default:
                // there are only two contexts by rule
                // do nothing
                break;
            }
        }
        if (buffer.length() > 0) {
            incompatibilities = buffer.substring(0, buffer.length() - 1);
        } else {
            incompatibilities = buffer.toString();
        }
    }

    XmlProducer producer = new XmlProducer();
    producer.setTarget(new XMLResultString(incompatibilities));
    producer.setTypesOfTarget(XMLResultString.class);

    return this.xmlProducerWrapper.wrap(producer);
}

From source file:com.juce.JuceAppActivity.java

public static final HTTPStream createHTTPStream (String address, boolean isPost, byte[] postData,
                                                 String headers, int timeOutMs, int[] statusCode,
                                                 StringBuffer responseHeaders, int numRedirectsToFollow,
                                                 String httpRequestCmd)
{
    // timeout parameter of zero for HttpUrlConnection is a blocking connect (negative value for juce::URL)
    if (timeOutMs < 0)
        timeOutMs = 0;/*from  w w  w .  jav a2s . com*/
    else if (timeOutMs == 0)
        timeOutMs = 30000;

    // headers - if not empty, this string is appended onto the headers that are used for the request. It must therefore be a valid set of HTML header directives, separated by newlines.
    // So convert headers string to an array, with an element for each line
    String headerLines[] = headers.split("\\n");

    for (;;)
    {
        try
        {
            HttpURLConnection connection = (HttpURLConnection) (new URL(address).openConnection());

            if (connection != null)
            {
                try
                {
                    connection.setInstanceFollowRedirects (false);
                    connection.setConnectTimeout (timeOutMs);
                    connection.setReadTimeout (timeOutMs);

                    // Set request headers
                    for (int i = 0; i < headerLines.length; ++i)
                    {
                        int pos = headerLines[i].indexOf (":");

                        if (pos > 0 && pos < headerLines[i].length())
                        {
                            String field = headerLines[i].substring (0, pos);
                            String value = headerLines[i].substring (pos + 1);

                            if (value.length() > 0)
                                connection.setRequestProperty (field, value);
                        }
                    }

                    connection.setRequestMethod (httpRequestCmd);
                    if (isPost)
                    {
                        connection.setDoOutput (true);

                        if (postData != null)
                        {
                            OutputStream out = connection.getOutputStream();
                            out.write(postData);
                            out.flush();
                        }
                    }

                    HTTPStream httpStream = new HTTPStream (connection, statusCode, responseHeaders);

                    // Process redirect & continue as necessary
                    int status = statusCode[0];

                    if (--numRedirectsToFollow >= 0
                         && (status == 301 || status == 302 || status == 303 || status == 307))
                    {
                        // Assumes only one occurrence of "Location"
                        int pos1 = responseHeaders.indexOf ("Location:") + 10;
                        int pos2 = responseHeaders.indexOf ("\n", pos1);

                        if (pos2 > pos1)
                        {
                            String newLocation = responseHeaders.substring(pos1, pos2);
                            // Handle newLocation whether it's absolute or relative
                            URL baseUrl = new URL (address);
                            URL newUrl = new URL (baseUrl, newLocation);
                            String transformedNewLocation = newUrl.toString();

                            if (transformedNewLocation != address)
                            {
                                address = transformedNewLocation;
                                // Clear responseHeaders before next iteration
                                responseHeaders.delete (0, responseHeaders.length());
                                continue;
                            }
                        }
                    }

                    return httpStream;
                }
                catch (Throwable e)
                {
                    connection.disconnect();
                }
            }
        }
        catch (Throwable e) {}

        return null;
    }
}

From source file:org.etudes.component.app.melete.ModuleDB.java

private String getAllSectionIds(Map deletedSections) {
    StringBuffer allIds = null;
    String a = null;/*  w  w w . j  av a  2 s.co m*/
    if (deletedSections != null) {
        allIds = new StringBuffer("(");
        for (Iterator i = deletedSections.keySet().iterator(); i.hasNext();) {
            Object obj = i.next();
            allIds.append(obj + ",");
        }
    }
    if (allIds != null && allIds.lastIndexOf(",") != -1)
        a = allIds.substring(0, allIds.lastIndexOf(",")) + " )";
    return a;
}

From source file:cn.jsprun.struts.action.BasicSettingsAction.java

private String encapsulationInitcredits(String initcredits, Integer creditid, Map<String, String> settingMap) {
    String initString = settingMap.get("initcredits");
    String[] init = initString.split(",");
    StringBuffer initValue = new StringBuffer();
    if (init != null) {
        for (int i = 0; i < init.length; i++) {
            if (i == creditid) {
                initValue.append(initcredits + ",");
            } else {
                initValue.append(init[i] + ",");
            }//w w w  .  jav  a2  s.c  om
        }
    }
    int initValueLen = initValue.length();
    return initValueLen > 0 ? initValue.substring(0, initValueLen - 1) : "";
}

From source file:com.yuwang.pinju.web.module.shop.action.ShopOpenFlowAction.java

/**
 * ?B?//from   w ww. j av  a  2s .  c  o m
 * 
 * @return
 */
public String saveBusinessShopInfo() {
    try {
        long userId = queryUserId();
        String nickname = queryNickName();
        String errorRedirect = validateSaveBusinessShopInfo(fillStep, userId);
        if (errorRedirect != null && errorRedirect.length() > 0) {
            return errorRedirect;
        }
        String picNames[] = null;
        //??
        if (myFile != null && myFile.length > 0) {
            picNames = saveFile(myFile);
            // 
            if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_STEP1.intValue()) {
                if (picNames != null && picNames.length > 0) {
                    shopBusinessInfoDO.setShopLogo(picNames[0]);
                }
            }
            // 
            else if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_STEP2.intValue()) {
                if (picNames != null && picNames.length > 0) {
                    shopBusinessInfoDO.setBusinessLicense(picNames[0]);
                    shopBusinessInfoDO.setOrganizationCode(picNames[1]);
                    shopBusinessInfoDO.setTaxPass(picNames[2]);
                }
            }
            // 
            else if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_STEP3.intValue()) {
                StringBuffer logo = new StringBuffer();
                StringBuffer brandCertificate = new StringBuffer();
                StringBuffer qualityCertificate = new StringBuffer();
                if (picNames != null && picNames.length > 0) {
                    for (int i = 0; i < picNames.length; i++) {
                        if (i % 3 == 0) {
                            logo.append(picNames[i]).append(",");
                        } else if (i % 3 == 1) {
                            brandCertificate.append(picNames[i]).append(",");
                        } else if (i % 3 == 2) {
                            qualityCertificate.append(picNames[i]).append(",");
                        }

                    }
                    String logoStr = logo.substring(0, logo.length() - 1);
                    String brandCertificateStr = brandCertificate.substring(0, brandCertificate.length() - 1);
                    String qualityCertificateStr = qualityCertificate.substring(0,
                            qualityCertificate.length() - 1);
                    shopBusinessInfoDO.setBrandLogo(logoStr);
                    shopBusinessInfoDO.setBrandCertificate(brandCertificateStr);
                    shopBusinessInfoDO.setQualityCertificate(qualityCertificateStr);
                }

            }
        } else {
            if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_STEP1.intValue()) {
                shopBusinessInfoDO.setShopLogo("");
            }
        }
        //??--?
        if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_STEP1.intValue()
                && (shopBusinessInfoDO.getDescription() == null
                        || shopBusinessInfoDO.getDescription().trim().equals(""))) {
            shopBusinessInfoDO.setDescription(" ");
        }
        //??--??
        if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_STEP1.intValue()
                && shopBusinessInfoDO.getGoodsSource() == null) {
            shopBusinessInfoDO.setGoodsSource(-1);
        }
        //?
        if (businessLicenseEndDate != null && businessLicenseEndDate.length() > 0) {
            DateFormat format1 = null;
            if (businessLicenseEndDate.split("-").length > 1) {
                format1 = new SimpleDateFormat("yyyy-MM-dd");
            } else {
                String str[] = businessLicenseEndDate.split("/");
                businessLicenseEndDate = str[2] + "-" + str[0] + "-" + str[1];
                format1 = new SimpleDateFormat("yyyy-MM-dd");
            }
            shopBusinessInfoDO.setBusinessLicenseEndDate(format1.parse(businessLicenseEndDate));
        }
        shopBusinessInfoDO.setUserId(userId);
        shopBusinessInfoDO.setNickname(nickname);
        shopBusinessInfoDO.setSellerType(String.valueOf(sellerType));
        shopBusinessInfoDO.setApproveStatus(ShopConstant.APPROVE_STATUS_NO);
        //?,??
        List<ShopBusinessInfoDO> resultList = shopOpenAO.queryShopBusinessInfo(userId);
        if (resultList != null && resultList.size() > 0) {
            if (isHaveOuterShop == 1) {
                shopBusinessInfoDO.setOuterShopAddressUrl("");
                shopBusinessInfoDO.setOuterShopLevel(null);
                shopBusinessInfoDO.setOuterShopSaleScope(null);
                shopBusinessInfoDO.setIsEnterB2c(null);
            } else if (2 == isHaveOuterShop) {
                shopBusinessInfoDO.setOuterShopAddressUrl(
                        ((ShopBusinessInfoDO) resultList.get(0)).getOuterShopAddressUrl());
                shopBusinessInfoDO
                        .setOuterShopLevel(((ShopBusinessInfoDO) resultList.get(0)).getOuterShopLevel());
                shopBusinessInfoDO.setOuterShopSaleScope(
                        ((ShopBusinessInfoDO) resultList.get(0)).getOuterShopSaleScope());
                shopBusinessInfoDO.setIsEnterB2c(((ShopBusinessInfoDO) resultList.get(0)).getIsEnterB2c());
            }
            //
            shopOpenAO.updateShopBusinessInfo(userId, shopBusinessInfoDO);
        } else {
            //?
            shopOpenAO.saveShopInfo(sellerType, shopBusinessInfoDO);
        }
        resultList = shopOpenAO.queryShopBusinessInfo(userId);
        shopBusinessInfoDO = (ShopBusinessInfoDO) resultList.get(0);

        //?
        if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_NO.intValue()) {
            //            String cookieString = PinjuCookieManager.getShop1();
            //            log.error(cookieString);
            //            setShopBusinessCookie(fillStep);
            return "FILL_SHOP_INFO_B_SETP1";
        } else if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_STEP1.intValue()) {
            initOutShopInfoParam();
            //            setShopBusinessCookie(fillStep);
            //            PinjuCookieManager.clearShop1();
            return "FILL_SHOP_INFO_B_SETP2";
        } else if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_STEP2.intValue()) {
            //            setShopBusinessCookie(fillStep);
            //            PinjuCookieManager.clearShop2();
            return "FILL_SHOP_INFO_B_SETP3";
        } else if (fillStep == ShopConstant.IS_FILL_SHOP_INFO_STEP3.intValue()) {
            //            setShopBusinessCookie(fillStep);
            //            PinjuCookieManager.clearShop3();
            return "FILL_SHOP_INFO_B_SETP4";
        }
        //???
        //         if (null != shopOpenFlowDO) {
        //            List<ShopOpenFlowDO> shopOpenFlowList = shopOpenAO.queryShopOpenFlow(userId);
        //            if (shopOpenFlowList != null && shopOpenFlowList.size() > 0) {
        //               shopOpenFlowDO = (ShopOpenFlowDO) shopOpenFlowList.get(0);
        //               shopOpenFlowDO
        //                     .setAuditCount(shopOpenFlowDO.getAuditCount() + 1);
        //               shopOpenFlowDO
        //                     .setIsAgreement(ShopConstant.IS_AGREEMENT_TRUE);
        //               shopOpenFlowDO.setNoPassReason("");
        //               shopOpenFlowDO
        //                     .setAuditStatus(ShopConstant.AUDIT_STATUS_WAIT);
        //               shopOpenFlowDO.setAuditProgress("");
        //               shopOpenFlowDO.setGmtModified(new Date());
        //               shopOpenFlowDO.setUserId(userId);
        //               shopOpenFlowDO.setSellerType(sellerType);
        //               shopOpenFlowDO
        //                     .setIsFillInfo(ShopConstant.IS_FILL_SHOP_INFO_STEP4);
        //               shopOpenManager.updateShopOpenFlow(shopOpenFlowDO);
        //            } else {
        //               shopOpenFlowDO = new ShopOpenFlowDO();
        //               shopOpenFlowDO.setUserId(userId);
        //               shopOpenFlowDO.setConfiguration("USER_NAME="+nickname);
        //               shopOpenFlowDO
        //                     .setIsAgreement(ShopConstant.IS_AGREEMENT_TRUE);
        //               shopOpenFlowDO.setSellerType(sellerType);
        //               shopOpenFlowDO.setAuditCount(1);
        //               shopOpenFlowDO.setAuditProgress("");
        //               shopOpenFlowDO.setAuditStatus(ShopConstant.AUDIT_STATUS_WAIT);
        //               //shopOpenFlowDO.setConfiguration("");
        //               shopOpenFlowDO.setIsBlack(0);
        //               shopOpenFlowDO.setIsKa(ShopConstant.IS_KA_NO);
        //               shopOpenFlowDO.setIsOnlineAuditEnd(0);
        //               shopOpenFlowDO.setIsPostalAuditEnd(0);
        //               shopOpenFlowDO.setNoPassReason("");
        //               shopOpenFlowDO.setReviewer("");
        //               shopOpenFlowDO.setGmtCreate(new Date());
        //               shopOpenFlowDO.setGmtModified(new Date());
        //               shopOpenFlowDO
        //                     .setIsFillInfo(ShopConstant.IS_FILL_SHOP_INFO_STEP4);
        //               shopOpenManager.agreement(shopOpenFlowDO);
        //            }
        //            PinjuCookieManager.clearShop4();
        //            return "SHOP_OPEN_BEGIN";
        //         }
        //      } catch (ManagerException e) {
        //         log.error(e.getMessage());
    } catch (ParseException e) {
    }
    return "success";
}

From source file:com.bstek.dorado.view.config.attachment.JavaScriptParser.java

private JavaScriptContent parse(StringBuffer source, JavaScriptContext context) throws IOException {
    StringBuffer reserveWord = new StringBuffer(8), modifiedSource = null;
    int autoNameSeed = 0, copyStart = 0;
    Boolean isController = context.getIsController();
    CodeReader reader = new CodeReader(source);
    try {//from  w ww  . j av a  2 s . c o  m
        while (true) {
            char c = reader.read();
            if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'
                    || VALID_NAME_CHARS.indexOf(c) >= 0) {
                reserveWord.append(c);
            } else if (c == RETURN) {
                // do nothing
            } else if (c == ANONYMOUS_FUNCTION_PREFIX) {
                reserveWord.setLength(0);
                reserveWord.append(c);
            } else {
                int len = reserveWord.length();
                if (len > 0) {
                    if (len == FUNCTION_LEN && reserveWord.toString().equals(FUNCTION)) {
                        reader.moveCursor(-1);
                        String functionName = extractFunctionName(reader);
                        if (StringUtils.isNotEmpty(functionName)) {
                            if (context.isHasAnnotation()) {
                                FunctionInfo functionInfo = new FunctionInfo(functionName);
                                functionInfo.setBindingInfo(context.getCurrentBindingInfo());
                                functionInfo
                                        .setShouldRegisterToGlobal(context.getCurrentShouldRegisterToGlobal());
                                functionInfo.setShouldRegisterToView(context.getCurrentShouldRegisterToView());
                                context.addFunctionInfo(functionInfo);
                            }
                        }
                    } else if (len == ANONYMOUS_FUNCTION_LEN
                            && reserveWord.toString().equals(ANONYMOUS_FUNCTION)) {
                        reader.moveCursor(-1);
                        int copyEnd = reader.getCurrentPos() - ANONYMOUS_FUNCTION_LEN;
                        String functionName = extractFunctionName(reader);
                        if (StringUtils.isEmpty(functionName) && context.isHasAnnotation()) {
                            BindingInfo currentBindingInfo = context.getCurrentBindingInfo();
                            if (currentBindingInfo != null) {
                                functionName = AUTO_FUNCTION_NAME_PREFIX + (++autoNameSeed);

                                if (modifiedSource == null) {
                                    modifiedSource = new StringBuffer(source.length());
                                }

                                modifiedSource.append(source.substring(copyStart, copyEnd)).append(FUNCTION)
                                        .append(SPACE).append(functionName);
                                copyStart = reader.getCurrentPos() - 1;

                                FunctionInfo functionInfo = new FunctionInfo(functionName);
                                functionInfo.setBindingInfo(context.getCurrentBindingInfo());
                                context.addFunctionInfo(functionInfo);
                            }
                        }
                    }

                    if (context.isHasAnnotation()) {
                        context.reset();
                    }
                    reserveWord.setLength(0);
                } else {
                    if (c == BACKSLASH) {
                        c = reader.read();
                        if (c == BACKSLASH || c == STAR) {
                            parseComment(reader, (c == BACKSLASH), context);
                            isController = context.getIsController();
                            if (isController != null && !isController) {
                                break;
                            }
                            continue;
                        }
                    }

                    if (isController == null && c != SPACE && c != TAB && c != RETURN) {
                        context.setIsController(false);
                        break;
                    }

                    if (c == QUOTE1 || c == QUOTE2) {
                        skipString(reader, c);
                    } else if (c == BLOCK_START) {
                        skipBlock(reader, BLOCK_END);
                    } else if (c == BRACKET_START) {
                        skipBlock(reader, BRACKET_END);
                    }
                }
            }
        }
    } catch (EOFException e) {
        // do nothing
    }

    if (modifiedSource != null) {
        modifiedSource.append(source.substring(copyStart));
        source = modifiedSource;
    }

    JavaScriptContent javaScriptContent = new JavaScriptContent();
    javaScriptContent.setContent(source.toString());
    javaScriptContent.setIsController(context.getIsController());
    javaScriptContent.setFunctionInfos(context.getFunctionInfos());
    return javaScriptContent;
}

From source file:com.india.arunava.network.httpProxy.HTTPProxyThreadBrowser.java

@Override
public void run() {

    ByteArrayOutputStream mainBuffer = new ByteArrayOutputStream();

    long count1 = 0;
    long count2 = 0;

    if (ProxyConstants.logLevel >= 1) {
        System.out.println(new Date() + " HTTPProxyThreadBrowser ::Started  " + currentThread());
    }/*from   w  w w.  ja  va 2 s.  c om*/

    final byte[] buffer = new byte[ProxyConstants.MAX_BUFFER];
    int numberRead = 0;
    OutputStream server;
    InputStream client;

    try {

        client = incoming.getInputStream();
        server = outgoing.getOutputStream();
        String proxyAuth = "";
        // If Organization proxy required Authentication
        if (!ProxyConstants.ORGANIZATION_HTTP_PROXY_USER_NAME.equals("")) {
            final String authString = ProxyConstants.ORGANIZATION_HTTP_PROXY_USER_NAME + ":"
                    + ProxyConstants.ORGANIZATION_HTTP_PROXY_USER_PASS;
            proxyAuth = "Basic " + Base64.encodeBase64String(authString.getBytes());
        }

        int rdL;
        final StringBuffer header = new StringBuffer(9999);
        while (true) {
            rdL = client.read();
            if (rdL == -1) {
                break;
            }
            header.append((char) rdL);
            if (header.indexOf("\r\n\r\n") != -1) {
                break;
            }
        }

        if (ProxyConstants.logLevel >= 2) {
            System.out.println(new Date() + " HTTPProxyThreadBrowser :: Request header   = " + currentThread()
                    + " \n" + header);
        }

        final String allInpRequest = header.toString();

        // modify: if it is https request, resend to sslproxy
        if (ProxyConstants.HTTPS_ENABLED && allInpRequest.startsWith("CONNECT ")) {
            new SSLProxy(incoming, incoming.getInputStream(), incoming.getOutputStream(), allInpRequest)
                    .start();
            return;
        }
        // modify end

        String host = "";
        String port = "";
        String tmpHost = "";
        final int indexOf = allInpRequest.toLowerCase().indexOf("host:");
        if (indexOf != -1) {
            final int immediateNeLineChar = allInpRequest.toLowerCase().indexOf("\r\n",
                    allInpRequest.toLowerCase().indexOf("host:"));
            tmpHost = allInpRequest
                    .substring(allInpRequest.toLowerCase().indexOf("host:") + 5, immediateNeLineChar).trim();
            final int isPortThere = tmpHost.indexOf(":");
            if (isPortThere != -1) {
                host = tmpHost.substring(0, tmpHost.indexOf(":"));
                port = tmpHost.substring(tmpHost.indexOf(":") + 1);

            } else {
                port = "80";
                host = tmpHost;
            }
        }

        // ////////////////// Added since rapidshare not opening
        // Making it relative request.

        String modifyGet = header.toString().toLowerCase();

        if (modifyGet.startsWith("get http://")) {
            int i2 = modifyGet.indexOf("/", 11);
            header.replace(4, i2, "");
        }
        if (modifyGet.startsWith("post http://")) {
            int i2 = modifyGet.indexOf("/", 12);
            header.replace(5, i2, "");
        }

        // ///////////////////////////////////////////////

        final String proxyServerURL = ProxyConstants.webPHP_URL_HTTP;
        String isSecure = "";
        final String HeaderHost = ProxyConstants.webPHP_HOST_HTTP;

        if (header.indexOf("X-IS-SSL-RECURSIVE:") == -1) {
            isSecure = "N";
        } else {
            isSecure = "Y";
            // Now detect which Port 443 or 8443 ?
            // Like : abcd X-IS-SSL-RECURSIVE: 8443
            final int p1 = header.indexOf("X-IS-SSL-RECURSIVE: ");
            port = header.substring(p1 + 20, p1 + 20 + 4);
            port = "" + Integer.valueOf(port).intValue();
        }

        if (ProxyConstants.logLevel >= 1) {
            System.out.println(new Date() + " HTTPProxyThreadBrowser ::Started  " + currentThread()
                    + "URL Information :\n" + "Host=" + host + " Port=" + port + " ProxyServerURL="
                    + proxyServerURL + " HeaderHost=" + HeaderHost);
        }

        // Get Content length
        String contentLenght = "";
        final int contIndx = header.toString().toLowerCase().indexOf("content-length: ");
        if (contIndx != -1) {
            final int endI = header.indexOf("\r\n", contIndx + 17);
            contentLenght = header.substring(contIndx + 16, endI);
        }

        String data = header + "";
        data = data.replaceFirst("\r\n\r\n", "\r\nConnection: Close\r\n\r\n");

        // remove the proxy header to become high-anonymous proxy
        data = data.replaceFirst("Proxy-Connection: keep-alive\r\n", "");

        // Replace culprit KeepAlive
        // Should have used Regex
        data = data.replaceFirst("Keep-Alive: ", "X-Dummy-1: ");
        data = data.replaceFirst("keep-alive: ", "X-Dummy-1: ");
        data = data.replaceFirst("Keep-alive: ", "X-Dummy-1: ");
        data = data.replaceFirst("keep-Alive: ", "X-Dummy-1: ");

        data = data.replaceFirst("keep-alive", "Close");
        data = data.replaceFirst("Keep-Alive", "Close");
        data = data.replaceFirst("keep-Alive", "Close");
        data = data.replaceFirst("Keep-alive", "Close");

        int totallength = 0;
        if (!contentLenght.equals("")) {
            totallength = Integer.parseInt(contentLenght.trim()) + (data.length() + 61 + 1);
        } else {
            totallength = (data.length() + 61 + 1);
        }

        String header1 = "";
        header1 = header1 + "POST " + proxyServerURL + " HTTP/1.1\r\n";
        header1 = header1 + "Host: " + HeaderHost + "\r\n";
        header1 = header1 + "Connection: Close\r\n";
        header1 = header1 + "Content-Length: " + totallength + "\r\n";
        header1 = header1 + "Cache-Control: no-cache\r\n";

        if (!ProxyConstants.ORGANIZATION_HTTP_PROXY_USER_NAME.equals("")) {
            header1 = header1 + "Proxy-Authorization: " + proxyAuth + "\r\n";
        }

        count1 = totallength;

        header1 = header1 + "\r\n";
        server.write(header1.getBytes());
        server.flush();

        if (ProxyConstants.ENCRYPTION_ENABLED) {
            // Let know PHP waht are we using
            server.write(("Y".getBytes()));

            server.write(SimpleEncryptDecrypt.enc(host.getBytes()));
            // Padding with space
            for (int i = 0; i < 50 - host.length(); i++) {
                server.write(SimpleEncryptDecrypt.enc(" ".getBytes()));
            }
            server.write(SimpleEncryptDecrypt.enc(port.getBytes()));
            // Padding with space
            for (int i = 0; i < 10 - port.length(); i++) {
                server.write(SimpleEncryptDecrypt.enc(" ".getBytes()));
            }
            // Write fsockopen info
            server.write(SimpleEncryptDecrypt.enc(isSecure.getBytes()));

            // It is destination header
            server.write(SimpleEncryptDecrypt.enc(data.getBytes()));

        } else {
            // Let know PHP waht are we using
            server.write(("N".getBytes()));

            server.write(host.getBytes());
            // Padding with space
            for (int i = 0; i < 50 - host.length(); i++) {
                server.write(" ".getBytes());
            }
            server.write(port.getBytes());
            // Padding with space
            for (int i = 0; i < 10 - port.length(); i++) {
                server.write(" ".getBytes());
            }
            // Write fsockopen info
            server.write(isSecure.getBytes());

            // It is destination header
            server.write(data.getBytes());

        }
        server.flush();

        if (ProxyConstants.logLevel >= 2) {
            System.out.println(new Date() + " HTTPProxyThreadBrowser :: destination header   = "
                    + currentThread() + " \n" + data);
        }

        while (true) {
            numberRead = client.read(buffer);
            count2 = count2 + numberRead;
            if (numberRead == -1) {
                outgoing.close();
                incoming.close();
                break;
            }

            if (ProxyConstants.ENCRYPTION_ENABLED) {
                server.write(SimpleEncryptDecrypt.enc(buffer, numberRead), 0, numberRead);
            } else {
                server.write(buffer, 0, numberRead);
            }
            if (ProxyConstants.logLevel >= 3) {
                final ByteArrayOutputStream bo = new ByteArrayOutputStream();
                bo.write(buffer, 0, numberRead);
                System.out.println("::Readingbody::" + bo + "::Readingbody::");
            }
        }

        if (ProxyConstants.logLevel >= 1) {
            System.out.println(new Date() + " HTTPProxyThreadBrowser :: Finish " + currentThread());
        }
    } catch (final Exception e) {
    }
    synchronized (ProxyConstants.MUTEX) {
        ProxyConstants.TOTAL_TRANSFER = ProxyConstants.TOTAL_TRANSFER + count1 + count2;
    }
}

From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertMgad.java

private void setMenuIdWithCcSeriesId(Ads ads, ADSMSchedulerLogDTO categoryDataSchedulerLog) {
    // cc_series_ID?   ?
    if (ads.getCcSeriesId() == null || ads.getCcSeriesId().equals(""))
        return;/* w  w  w.ja  va2s  .  c o  m*/

    //,  ??    ?
    if (categoryDataSchedulerLog == null)
        return;

    String ccSeriesId = ads.getCcSeriesId();

    List<CategoryDataDTO> categoryDataList = tambourineConnector
            .getCategoryDataByCcSeriesId(categoryDataSchedulerLog.getId(), ccSeriesId);

    //cc_series_Id?  menu_id?  ??  ?
    // cc_series_Id? ?   ,   . ? ? .
    if (categoryDataList.size() == 0) {
        String errorMsg = "cc_series_ID(" + ccSeriesId
                + ")?    ?  .";
        throw new WrappingException(errorMsg);
    }

    StringBuffer sb = new StringBuffer();

    for (CategoryDataDTO data : categoryDataList) {
        sb.append(data.getCatId());
        sb.append("|");
    }

    ads.setMenu_ID(sb.substring(0, sb.length() - 1));
}

From source file:forseti.JUtil.java

public static synchronized String CantEnLetra(float cant, String id_moneda, String moneda) {
    String MONEDA = (moneda == null) ? "" : moneda;
    String MN;//w  w w . j av a  2  s .co  m
    if (id_moneda == null || !id_moneda.equals("1"))
        MN = "";
    else
        MN = "m.n.";

    if (cant == 0.00)
        return "cero " + MONEDA + " 00/100 " + MN;

    StringBuffer sCant;
    String sDec = "", sCen = "", sMil = "", s10Mil = "", s100Mil = "", sMillon = "", s10Millon = "",
            s100Millon = "", s1000Millon = "";
    String str, decim;
    str = Float.toString(redondear(cant, 2));

    int index = str.indexOf('.');
    if (index == -1)
        decim = "00/100";
    else {
        decim = str.substring(index + 1);
        if (decim.length() == 1)
            decim = decim + "0/100";
        else
            decim = decim + "/100";

    }

    int cantent = (int) Math.floor((double) redondear(cant, (byte) 2));
    int dec = 0, cen = 0, mil = 0, diezmil = 0, cienmil = 0, millon = 0, diezmillon = 0, cienmillon = 0,
            milmillon = 0;

    sCant = new StringBuffer(Integer.toString(cantent));
    sCant.reverse();

    int len = sCant.length();

    if (len > 0) {
        dec = Integer.parseInt(sCant.substring(0, 1));
        switch (dec) {
        case 1:
            sDec = "un";
            break;
        case 2:
            sDec = "dos";
            break;
        case 3:
            sDec = "tres";
            break;
        case 4:
            sDec = "cuatro";
            break;
        case 5:
            sDec = "cinco";
            break;
        case 6:
            sDec = "seis";
            break;
        case 7:
            sDec = "siete";
            break;
        case 8:
            sDec = "ocho";
            break;
        case 9:
            sDec = "nueve";
            break;
        default:
            sDec = "";
            break;
        }
    }

    if (len > 1) {
        cen = Integer.parseInt(sCant.substring(1, 2));
        switch (cen) {
        case 1:
            if (dec == 0)
                sCen = "diez";
            else if (dec == 1) {
                sCen = "once";
                sDec = "";
            } else if (dec == 2) {
                sCen = "doce";
                sDec = "";
            } else if (dec == 3) {
                sCen = "trece";
                sDec = "";
            } else if (dec == 4) {
                sCen = "catorce";
                sDec = "";
            } else if (dec == 5) {
                sCen = "quince";
                sDec = "";
            } else
                sCen = "dieci";
            break;
        case 2:
            if (dec == 0)
                sCen = "veinte";
            else
                sCen = "veinti";
            break;
        case 3:
            if (dec == 0)
                sCen = "treinta";
            else
                sCen = "treinta y ";
            break;
        case 4:
            if (dec == 0)
                sCen = "cuarenta";
            else
                sCen = "cuarenta y ";
            break;
        case 5:
            if (dec == 0)
                sCen = "cincuenta";
            else
                sCen = "cincuenta y ";
            break;
        case 6:
            if (dec == 0)
                sCen = "sesenta";
            else
                sCen = "sesenta y ";
            break;
        case 7:
            if (dec == 0)
                sCen = "setenta";
            else
                sCen = "setenta y ";
            break;
        case 8:
            if (dec == 0)
                sCen = "ochenta";
            else
                sCen = "ochenta y ";
            break;
        case 9:
            if (dec == 0)
                sCen = "noventa";
            else
                sCen = "noventa y ";
            break;
        default:
            sCen = "";
            break;
        }
    }

    if (len > 2) {
        mil = Integer.parseInt(sCant.substring(2, 3));
        switch (mil) {
        case 1:
            if (dec == 0 && cen == 0)
                sMil = "cien";
            else
                sMil = "ciento ";
            break;
        case 2:
            sMil = "doscientos ";
            break;
        case 3:
            sMil = "trescientos ";
            break;
        case 4:
            sMil = "cuatrocientos ";
            break;
        case 5:
            sMil = "quinientos ";
            break;
        case 6:
            sMil = "seiscientos ";
            break;
        case 7:
            sMil = "setecientos ";
            break;
        case 8:
            sMil = "ochocientos ";
            break;
        case 9:
            sMil = "novecientos ";
            break;
        default:
            sMil = "";
            break;
        }
    }

    if (len > 3) {
        diezmil = Integer.parseInt(sCant.substring(3, 4));
        switch (diezmil) {
        case 1:
            s10Mil = "un mil ";
            break;
        case 2:
            s10Mil = "dos mil ";
            break;
        case 3:
            s10Mil = "tres mil ";
            break;
        case 4:
            s10Mil = "cuatro mil ";
            break;
        case 5:
            s10Mil = "cinco mil ";
            break;
        case 6:
            s10Mil = "seis mil ";
            break;
        case 7:
            s10Mil = "siete mil ";
            break;
        case 8:
            s10Mil = "ocho mil ";
            break;
        case 9:
            s10Mil = "nueve mil ";
            break;
        default:
            s10Mil = "";
            break;
        }
    }

    if (len > 4) {
        cienmil = Integer.parseInt(sCant.substring(4, 5));
        switch (cienmil) {
        case 1:
            if (diezmil == 0)
                s100Mil = "diez mil ";
            else if (diezmil == 1) {
                s100Mil = "once mil ";
                s10Mil = "";
            } else if (diezmil == 2) {
                s100Mil = "doce mil ";
                s10Mil = "";
            } else if (diezmil == 3) {
                s100Mil = "trece mil ";
                s10Mil = "";
            } else if (diezmil == 4) {
                s100Mil = "catorce mil ";
                s10Mil = "";
            } else if (diezmil == 5) {
                s100Mil = "quince mil ";
                s10Mil = "";
            } else
                s100Mil = "dieci";
            break;
        case 2:
            if (diezmil == 0)
                s100Mil = "veinte mil ";
            else
                s100Mil = "veinti";
            break;
        case 3:
            if (diezmil == 0)
                s100Mil = "treinta mil";
            else
                s100Mil = "treinta y ";
            break;
        case 4:
            if (diezmil == 0)
                s100Mil = "cuarenta mil ";
            else
                s100Mil = "cuarenta y ";
            break;
        case 5:
            if (diezmil == 0)
                s100Mil = "cincuenta mil ";
            else
                s100Mil = "cincuenta y ";
            break;
        case 6:
            if (diezmil == 0)
                s100Mil = "sesenta mil ";
            else
                s100Mil = "sesenta y ";
            break;
        case 7:
            if (diezmil == 0)
                s100Mil = "setenta mil ";
            else
                s100Mil = "setenta y ";
            break;
        case 8:
            if (diezmil == 0)
                s100Mil = "ochenta mil ";
            else
                s100Mil = "ochenta y ";
            break;
        case 9:
            if (diezmil == 0)
                s100Mil = "noventa mil ";
            else
                s100Mil = "noventa y ";
            break;
        default:
            s100Mil = "";
            break;
        }
    }

    if (len > 5) {
        millon = Integer.parseInt(sCant.substring(5, 6));
        switch (millon) {
        case 1:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "cien mil ";
            else
                sMillon = "ciento ";
            break;
        case 2:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "doscientos mil ";
            else
                sMillon = "doscientos ";
            break;
        case 3:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "trescientos mil ";
            else
                sMillon = "trescientos ";
            break;
        case 4:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "cuatrocientos mil ";
            else
                sMillon = "cuatrocientos ";
            break;
        case 5:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "quinientos mil ";
            else
                sMillon = "quinientos ";
            break;
        case 6:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "seiscientos mil ";
            else
                sMillon = "seiscientos ";
            break;
        case 7:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "setecientos mil ";
            else
                sMillon = "setecientos ";
            break;
        case 8:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "ochocientos mil ";
            else
                sMillon = "ochocientos ";
            break;
        case 9:
            if (cienmil == 0 && diezmil == 0)
                sMillon = "novecientos mil ";
            else
                sMillon = "novecientos ";
            break;
        default:
            sMillon = "";
            break;
        }
    }

    // millones
    if (len > 6) {
        diezmillon = Integer.parseInt(sCant.substring(6, 7));
        switch (diezmillon) {
        case 1:
            s10Millon = "un millon ";
            break;
        case 2:
            s10Millon = "dos millones ";
            break;
        case 3:
            s10Millon = "tres millones ";
            break;
        case 4:
            s10Millon = "cuatro millones ";
            break;
        case 5:
            s10Millon = "cinco millones ";
            break;
        case 6:
            s10Millon = "seis millones ";
            break;
        case 7:
            s10Millon = "siete millones ";
            break;
        case 8:
            s10Millon = "ocho millones ";
            break;
        case 9:
            s10Millon = "nueve millones ";
            break;
        default:
            s10Millon = "";
            break;
        }
    }

    if (len > 7) {
        cienmillon = Integer.parseInt(sCant.substring(7, 8));
        switch (cienmillon) {
        case 1:
            if (diezmillon == 0)
                s100Millon = "diez millones ";
            else if (diezmillon == 1) {
                s100Millon = "once millones ";
                s10Millon = "";
            } else if (diezmillon == 2) {
                s100Millon = "doce millones ";
                s10Millon = "";
            } else if (diezmillon == 3) {
                s100Millon = "trece millones ";
                s10Millon = "";
            } else if (diezmillon == 4) {
                s100Millon = "catorce millones ";
                s10Millon = "";
            } else if (diezmillon == 5) {
                s100Millon = "quince millones ";
                s10Millon = "";
            } else
                s100Millon = "dieci";
            break;
        case 2:
            if (diezmillon == 0)
                s100Millon = "veinte millones ";
            else
                s100Millon = "veinti";
            break;
        case 3:
            if (diezmillon == 0)
                s100Millon = "treinta millones ";
            else
                s100Millon = "treinta y ";
            break;
        case 4:
            if (diezmillon == 0)
                s100Millon = "cuarenta millones ";
            else
                s100Millon = "cuarenta y ";
            break;
        case 5:
            if (diezmillon == 0)
                s100Millon = "cincuenta millones ";
            else
                s100Millon = "cincuenta y ";
            break;
        case 6:
            if (diezmillon == 0)
                s100Millon = "sesenta millones ";
            else
                s100Millon = "sesenta y ";
            break;
        case 7:
            if (diezmillon == 0)
                s100Millon = "setenta millones ";
            else
                s100Millon = "setenta y ";
            break;
        case 8:
            if (diezmillon == 0)
                s100Millon = "ochenta millones ";
            else
                s100Millon = "ochenta y ";
            break;
        case 9:
            if (diezmillon == 0)
                s100Millon = "noventa millones ";
            else
                s100Millon = "noventa y ";
            break;
        default:
            s100Millon = "";
            break;
        }
        if (millon == 0 && cienmil == 0 && diezmil == 0 && mil == 0 && cen == 0 && dec == 0)
            s100Millon += "de";
    }

    if (len > 8) {
        milmillon = Integer.parseInt(sCant.substring(8, 9));
        switch (milmillon) {
        case 1:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "cien millones ";
            else
                s1000Millon = "ciento ";
            break;
        case 2:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "doscientos millones ";
            else
                s1000Millon = "doscientos ";
            break;
        case 3:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "trescientos millones ";
            else
                s1000Millon = "trescientos ";
            break;
        case 4:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "cuatrocientos millones ";
            else
                s1000Millon = "cuatrocientos ";
            break;
        case 5:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "quinientos millones ";
            else
                s1000Millon = "quinientos ";
            break;
        case 6:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "seiscientos millones ";
            else
                s1000Millon = "seiscientos ";
            break;
        case 7:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "setecientos millones ";
            else
                s1000Millon = "setecientos ";
            break;
        case 8:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "ochocientos millones ";
            else
                s1000Millon = "ochocientos ";
            break;
        case 9:
            if (cienmillon == 0 && diezmillon == 0)
                s1000Millon = "novecientos millones ";
            else
                s1000Millon = "novecientos ";
            break;
        default:
            s1000Millon = "";
            break;
        }
    }

    String res = s1000Millon + s100Millon + s10Millon + sMillon + s100Mil + s10Mil + sMil + sCen + sDec;
    res += " " + MONEDA + " " + decim + " " + MN;

    //sCant.MakeUpper();

    return res;

}

From source file:org.kuali.ole.service.impl.OLEEResourceSearchServiceImpl.java

public void getNewInstance(OLEEResourceRecordDocument oleERSDoc, String documentNumber) throws Exception {

    if (OleDocstoreResponse.getInstance().getEditorResponse() != null) {
        HashMap<String, OLEEditorResponse> oleEditorResponses = OleDocstoreResponse.getInstance()
                .getEditorResponse();//  w  w w  .  j a va2 s . c  o m
        OLEEditorResponse oleEditorResponse = oleEditorResponses.get(documentNumber);
        String separator = getParameter(OLEConstants.OLEEResourceRecord.COMMA_SEPARATOR);
        String isbnAndissn = "";
        List<String> instanceId = new ArrayList<String>();
        List<OLEEResourceInstance> oleeResourceInstances = oleERSDoc.getOleERSInstances();
        if (oleeResourceInstances.size() == 0) {
            oleeResourceInstances = new ArrayList<OLEEResourceInstance>();
        }
        // List<OleCopy> copyList = new ArrayList<>();
        //getDocstoreClientLocator().getDocstoreClient().retrieveBibTree(oleEditorResponse.getBib().getId());

        if (oleEditorResponse != null && StringUtils.isNotEmpty(oleEditorResponse.getLinkedInstanceId())) {
            instanceId.add(oleEditorResponse.getLinkedInstanceId());
        }
        Holdings holdings = null;
        if (oleEditorResponse != null && oleERSDoc.getSelectInstance() != null
                && (oleERSDoc.getSelectInstance().equals(OLEConstants.OLEEResourceRecord.LINK_EXIST_INSTANCE))
                || oleERSDoc.getSelectInstance().equals(OLEConstants.OLEEResourceRecord.CREATE_NEW_INSTANCE)) {
            holdings = getDocstoreClientLocator().getDocstoreClient()
                    .retrieveHoldings(oleEditorResponse.getLinkedInstanceId());

        }
        int index = -1;
        if (holdings != null && holdings.getId() != null) {
            HoldingOlemlRecordProcessor holdingOlemlRecordProcessor = new HoldingOlemlRecordProcessor();
            OleHoldings oleHoldings = holdingOlemlRecordProcessor.fromXML(holdings.getContent());
            if (holdings instanceof org.kuali.ole.docstore.common.document.EHoldings) {
                if (oleEditorResponse != null
                        && oleEditorResponse.getLinkedInstanceId().equalsIgnoreCase(holdings.getId())) {
                    OLEEResourceInstance oleeResourceInstance = new OLEEResourceInstance();
                    if (oleERSDoc.getOleERSInstances() != null && oleERSDoc.getOleERSInstances().size() > 0) {
                        for (OLEEResourceInstance eResourceInstance : oleeResourceInstances) {
                            if (eResourceInstance.getInstanceId()
                                    .equals(oleEditorResponse.getLinkedInstanceId())) {
                                index = oleeResourceInstances.indexOf(eResourceInstance);
                                oleeResourceInstance = eResourceInstance;
                            }
                        }
                    }
                    oleeResourceInstance.setInstanceTitle(holdings.getBib().getTitle());
                    getHoldingsField(oleeResourceInstance, oleHoldings);
                    oleeResourceInstance.setInstancePublisher(oleHoldings.getPublisher());
                    oleeResourceInstance.setPlatForm(oleHoldings.getPlatform().getPlatformName());
                    // oleeResourceInstance.setPublicDisplayNote(workEInstanceDocument.getPublicDisplayNote());
                    StringBuffer urls = new StringBuffer();
                    for (Link link : oleHoldings.getLink()) {
                        urls.append(link.getUrl());
                        urls.append(",");
                    }
                    if (urls.toString().contains(",")) {
                        String url = urls.substring(0, urls.lastIndexOf(","));
                        oleeResourceInstance.setUrl(url);
                    }

                    SearchParams searchParams = new SearchParams();
                    searchParams.getSearchConditions()
                            .add(searchParams.buildSearchCondition(null,
                                    searchParams.buildSearchField(OLEConstants.BIB_DOC_TYPE,
                                            OLEConstants.BIB_SEARCH, holdings.getBib().getId()),
                                    null));
                    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(
                            OLEConstants.BIB_DOC_TYPE, OLEConstants.OLEEResourceRecord.ERESOURCE_ISBN));
                    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(
                            OLEConstants.BIB_DOC_TYPE, OLEConstants.OLEEResourceRecord.ERESOURCE_ISSN));
                    SearchResponse searchResponse = getDocstoreClientLocator().getDocstoreClient()
                            .search(searchParams);
                    SearchResult searchResult;
                    if (searchResponse.getSearchResults().size() > 0) {
                        searchResult = searchResponse.getSearchResults().get(0);
                        searchResult.getSearchResultFields();
                        for (SearchResultField searchResultField : searchResult.getSearchResultFields()) {
                            isbnAndissn += searchResultField.getFieldValue();
                            isbnAndissn += separator;
                        }
                    }
                    if (StringUtils.isNotEmpty(isbnAndissn)) {
                        isbnAndissn = isbnAndissn.substring(0, isbnAndissn.lastIndexOf(separator));
                    }
                    oleeResourceInstance.setIsbn(isbnAndissn);
                    oleeResourceInstance.setStatus(oleHoldings.getAccessStatus());
                    oleeResourceInstance.setSubscriptionStatus(oleHoldings.getSubscriptionStatus());
                    oleeResourceInstance.setBibId(holdings.getBib().getId());
                    oleeResourceInstance.setInstanceId(holdings.getId());
                    oleeResourceInstance.setInstanceFlag("false");
                    if (index >= 0) {
                        oleeResourceInstances.add(index, oleeResourceInstance);
                    } else {
                        oleeResourceInstances.add(oleeResourceInstance);
                    }
                    updateEResInOleCopy(holdings, oleERSDoc);
                }
            }
            if (holdings instanceof org.kuali.ole.docstore.common.document.PHoldings) {
                if (oleEditorResponse != null
                        && oleEditorResponse.getLinkedInstanceId().equalsIgnoreCase(holdings.getId())) {
                    OLEEResourceInstance oleeResourceInstance = new OLEEResourceInstance();
                    if (oleERSDoc.getOleERSInstances() != null && oleERSDoc.getOleERSInstances().size() > 0) {
                        for (OLEEResourceInstance eResourceInstance : oleeResourceInstances) {
                            if (eResourceInstance.getInstanceId()
                                    .equals(oleEditorResponse.getLinkedInstanceId())) {
                                index = oleeResourceInstances.indexOf(eResourceInstance);
                                oleeResourceInstance = eResourceInstance;
                            }
                        }
                    }
                    oleeResourceInstance.setInstanceTitle(holdings.getBib().getTitle());
                    oleeResourceInstance.setInstancePublisher(holdings.getBib().getPublisher());
                    SearchParams searchParams = new SearchParams();
                    searchParams.getSearchConditions()
                            .add(searchParams.buildSearchCondition(null,
                                    searchParams.buildSearchField(OLEConstants.BIB_DOC_TYPE,
                                            OLEConstants.BIB_SEARCH, holdings.getBib().getId()),
                                    null));
                    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(
                            OLEConstants.BIB_DOC_TYPE, OLEConstants.OLEEResourceRecord.ERESOURCE_ISBN));
                    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField(
                            OLEConstants.BIB_DOC_TYPE, OLEConstants.OLEEResourceRecord.ERESOURCE_ISSN));
                    SearchResponse searchResponse = getDocstoreClientLocator().getDocstoreClient()
                            .search(searchParams);
                    SearchResult searchResult;
                    if (searchResponse.getSearchResults().size() > 0) {
                        searchResult = searchResponse.getSearchResults().get(0);
                        searchResult.getSearchResultFields();
                        for (SearchResultField searchResultField : searchResult.getSearchResultFields()) {
                            isbnAndissn += searchResultField.getFieldValue();
                            isbnAndissn += separator;
                        }
                    }
                    if (StringUtils.isNotEmpty(isbnAndissn)) {
                        isbnAndissn = isbnAndissn.substring(0, isbnAndissn.lastIndexOf(separator));
                    }
                    oleeResourceInstance.setIsbn(isbnAndissn);
                    oleeResourceInstance.setBibId(holdings.getBib().getId());
                    oleeResourceInstance.setInstanceId(holdings.getId());
                    oleeResourceInstance.setHoldingsId(oleHoldings.getHoldingsIdentifier());
                    oleeResourceInstance.setInstanceFlag("true");
                    if (index >= 0) {
                        oleeResourceInstances.add(index, oleeResourceInstance);
                    } else {
                        oleeResourceInstances.add(oleeResourceInstance);
                    }
                    updateEResInOleCopy(holdings, oleERSDoc);
                }
            }
        }
        oleERSDoc.setOleERSInstances(oleeResourceInstances);
        OleDocstoreResponse.getInstance().setEditorResponse(null);
    }
}