Example usage for java.lang String subSequence

List of usage examples for java.lang String subSequence

Introduction

In this page you can find the example usage for java.lang String subSequence.

Prototype

public CharSequence subSequence(int beginIndex, int endIndex) 

Source Link

Document

Returns a character sequence that is a subsequence of this sequence.

Usage

From source file:com.bluexml.xforms.controller.navigation.NavigationManager.java

/**
 * Send image.//from   w  w w .j a v a  2  s .co m
 * 
 * @param req
 *            the req
 * @param resp
 *            the resp
 */
public void sendImage(HttpServletRequest req, HttpServletResponse resp) {
    String location = req.getParameter("location");
    InputStream in = null;
    if (StringUtils.trimToNull(location) != null) {
        boolean isImage = false;
        int lastIndexOf = location.lastIndexOf('.');
        if (lastIndexOf != -1) {
            String extension = location.substring(lastIndexOf).toUpperCase();
            if (extension.endsWith("JPEG") || extension.endsWith("JPG") || extension.endsWith("PNG")
                    || extension.endsWith("BMP") || extension.endsWith("GIF")) {
                isImage = true;
            }
        }
        if (isImage) {
            File sourceFile = null;
            if (location.startsWith("file:")) {
                try {
                    // location = URLEncoder.encode(location, "UTF-8");
                    // URI fileURI = URI.create(location);
                    location = location.replace("file:", "");
                    if (location.charAt(2) == ':') {
                        location = location.subSequence(1, location.length()).toString();
                    }
                    sourceFile = new File(location);
                } catch (Exception e) {
                    sourceFile = null;
                    if (logger.isErrorEnabled()) {
                        logger.error(e);
                    }
                }
            } else {
                sourceFile = new File(AlfrescoController.UPLOAD_DIRECTORY, location);
            }

            try {
                in = new FileInputStream(sourceFile);
            } catch (FileNotFoundException e) {
                if (logger.isErrorEnabled()) {
                    logger.error(e);
                }
            }

        }
    }
    if (in == null) {
        in = NavigationSessionListener.getContext().getResourceAsStream("/resources/images/blank.png");
    }

    ServletOutputStream out = null;

    try {
        out = resp.getOutputStream();
        byte[] bytes = new byte[1024];
        int bytesRead;

        while ((bytesRead = in.read(bytes)) != -1) {
            out.write(bytes, 0, bytesRead);
        }
    } catch (Exception e) {
        if (logger.isErrorEnabled()) {
            logger.error(e);
        }
    } finally {

        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                if (logger.isErrorEnabled()) {
                    logger.error(e);
                }
            }
        }
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
                if (logger.isErrorEnabled()) {
                    logger.error(e);
                }
            }
        }
    }

}

From source file:com.netcrest.pado.tools.pado.PadoShell.java

public Object getQueryKey(List<?> queryPredicateList, int startIndex) throws Exception {
    // See if key is a primitive
    String input = (String) queryPredicateList.get(startIndex);
    Object key = null;// w  ww  . ja v a  2s. co  m
    if (input.startsWith("'")) {
        int lastIndex = -1;
        if (input.endsWith("'") == false) {
            lastIndex = input.length();
        } else {
            lastIndex = input.lastIndexOf("'");
        }
        if (lastIndex <= 1) {
            PadoShell.printlnError("Invalid key. Empty string not allowed.");
            return null;
        }
        key = input.subSequence(1, lastIndex); // lastIndex exclusive
    } else {
        key = ObjectUtil.getPrimitive(this, input, false);
    }
    if (key != null) {
        return key;
    }

    // Key is an object

    // query key class must be defined
    if (keyClass == null) {
        PadoShell.printlnError("Key undefined. Use the key command to specify the key class.");
        return null;
    }

    // f1=v1 and f2='v2' and f3=v3

    // Build the query predicate from the argument list
    String queryPredicate = "";
    for (int i = startIndex; i < queryPredicateList.size(); i++) {
        queryPredicate += queryPredicateList.get(i) + " ";
    }
    String[] split = queryPredicate.split("and");

    // Create the query key by invoking setters for each
    // parameter listed in the queryPredicate
    Object queryKey = keyClass.newInstance();
    // Map<String, Method> setterMap =
    // ReflectionUtil.getAllSettersMap(queryKey.getClass());
    Map<String, String> fieldsMap = new HashMap<String, String>();
    for (int i = 0; i < split.length; i++) {
        String token = split[i];
        String[] tokenSplit = token.split("=");
        if (tokenSplit.length < 2) {
            printlnError(token + ": Invalid query.");
            return null;
        }
        String field = tokenSplit[0].trim();
        String value = tokenSplit[1].trim();
        fieldsMap.put(field, value);
        queryKey = ObjectUtil.generateObject(keyClass.getName(), fieldsMap, this);
    }

    return queryKey;
}

From source file:analysis.postRun.PostRunWindow.java

/**
 * Method which iterates through dataList building series to use in graphs.
 *///w  w w  . j  a v  a  2 s  .c  om
private void makeSeries() {
    //      System.out.println("in makeSeries, readStats is "+readStats+ " stats is "+stats);
    //reinitialise datasets
    failureSet = new DefaultXYDataset();
    costSet = new DefaultXYDataset();
    cpuSet = new DefaultXYDataset();
    servSet = new DefaultXYDataset();
    conSet = new DefaultXYDataset();

    int l = dataList.size();
    String fails, cpus, costs, cons;
    String[] buffer, sFails, sCPUs, sServs, sCosts, test, servS, sErrs, sCons;
    double ts;

    //find out how many datacentres there are by doing a trial split
    test = dataList.get(0)[1].split(" ");
    int dcs = test.length;
    if (dcs > 1) {
        dcLegend = true;
    }

    double[][][] failureSeries = new double[dcs][2][l];
    double[][][] costSeries = new double[dcs][2][l];
    double[][][] cpuSeries = new double[dcs][2][l];
    double[][][] servSeries = new double[dcs * 4][2][l];
    double[][][] conSeries = new double[dcs][2][l];

    //iterate through list
    for (int k = 0; k < l; k++) {
        buffer = dataList.get(k);
        ts = Double.parseDouble(buffer[0]);

        //Split into useful data & add to series. May be multiple space-separated datacentres.
        sFails = buffer[1].split(" ");
        sCosts = buffer[2].split(" ");
        sCPUs = buffer[3].split(" ");
        sServs = buffer[4].split(" ");
        sCons = buffer[5].split(" ");
        sErrs = new String[dcs];
        if (readStats == true) {
            sErrs = buffer[6].split("'");
        }

        for (int i = 0; i < dcs; i++) { //add a value to the series for each datacentre
            fails = sFails[i];
            fails = (String) fails.subSequence(1, fails.length() - 1);
            failureSeries[i][0][k] = ts;
            failureSeries[i][1][k] = (Double.parseDouble(fails));

            costs = sCosts[i];
            costs = (String) costs.subSequence(1, costs.length() - 1);
            costSeries[i][0][k] = ts;
            costSeries[i][1][k] = Double.parseDouble(costs);

            cpus = sCPUs[i];
            cpus = (String) cpus.subSequence(1, cpus.length() - 1);
            cpuSeries[i][0][k] = ts;
            cpuSeries[i][1][k] = (Double.parseDouble(cpus));

            //services have multiple values
            servS = sServs[i].split("'");
            for (int x = 0; x < 4; x++) {
                servSeries[i + x][0][k] = ts;
                servSeries[i + x][1][k] = Double.parseDouble(servS[x + 1]);
            }

            cons = sCons[0];
            cons = (String) cons.subSequence(1, cons.length() - 1);
            conSeries[i][0][k] = ts;
            conSeries[i][1][k] = (Double.parseDouble(cons));

            failErrSeries = new double[dcs][2][l];
            costErrSeries = new double[dcs][2][l];
            cpuErrSeries = new double[dcs][2][l];
            servErrSeries = new double[dcs * 4][2][l];
            conErrSeries = new double[dcs][2][l];

            if (readStats == true) {
                failErrSeries[i][1][k] = Double.parseDouble(sErrs[1]);
                failErrSeries[i][0][k] = ts;
                costErrSeries[i][1][k] = Double.parseDouble(sErrs[2]);
                costErrSeries[i][0][k] = ts;
                cpuErrSeries[i][1][k] = Double.parseDouble(sErrs[3]);
                cpuErrSeries[i][0][k] = ts;

                servErrSeries[i][1][k] = Double.parseDouble(sErrs[4]);
                servErrSeries[i][0][k] = ts;
                servErrSeries[dcs + i][1][k] = Double.parseDouble(sErrs[5]);
                servErrSeries[dcs + i][0][k] = ts;
                servErrSeries[(2 * dcs) + i][1][k] = Double.parseDouble(sErrs[6]);
                servErrSeries[(2 * dcs) + i][0][k] = ts;
                servErrSeries[(3 * dcs) + i][1][k] = Double.parseDouble(sErrs[7]);
                servErrSeries[(3 * dcs) + i][0][k] = ts;

                conErrSeries[i][1][k] = Double.parseDouble(sErrs[8]);
                conErrSeries[i][0][k] = ts;
                //System.out.println(sErrs[8]);
            }

        }
    }

    for (int j = 0; j < dcs; j++) {
        failureSet.addSeries("Datacentre " + j, failureSeries[j]);
        costSet.addSeries("Datacentre " + j, costSeries[j]);
        cpuSet.addSeries("Datacentre " + j, cpuSeries[j]);
        servSet.addSeries("Total - Dc " + j, servSeries[j * 4]);
        servSet.addSeries("Complete - Dc " + j, servSeries[(j * 4) + 1]);
        servSet.addSeries("Failed - Dc " + j, servSeries[(j * 4) + 2]);
        servSet.addSeries("Running - Dc " + j, servSeries[(j * 4) + 3]);
        conSet.addSeries("Consistency - Dc " + j, conSeries[j]);
    }

    failureStatSeries = new double[failureSeries.length][failureSeries[0].length][failureSeries[0][0].length];
    costStatSeries = new double[costSeries.length][costSeries[0].length][costSeries[0][0].length];
    cpuStatSeries = new double[cpuSeries.length][cpuSeries[0].length][cpuSeries[0][0].length];
    servStatSeries = new double[servSeries.length][servSeries[0].length * 4][servSeries[0][0].length];
    conStatSeries = new double[conSeries.length][conSeries[0].length * 4][conSeries[0][0].length];

    if (readStats == true) {
        failureStatSeries = failureSeries;
        costStatSeries = costSeries;
        cpuStatSeries = cpuSeries;
        servStatSeries = servSeries;
        conStatSeries = conSeries;
    }
}

From source file:org.wso2.developerstudio.eclipse.general.project.refactor.RegistryMetadataFileChange.java

private void identifyReplaces() throws IOException {
    int fullIndex = 0;
    FileReader fileReader = new FileReader(metaDataFile.getLocation().toFile());
    BufferedReader reader = new BufferedReader(fileReader);
    String case1String = null;
    String originalResourceName = originalName.getName();
    String originalFileNameWOExt = GeneralProjectUtils.getFilenameWOExtension(originalResourceName);
    String newFileNameWOExt = GeneralProjectUtils.getFilenameWOExtension(newName);
    if (originalName instanceof IFile) {
        case1String = "\"" + originalFileNameWOExt + "\"";
    } else if (originalName instanceof IFolder) {
        case1String = "\"" + originalResourceName + "\"";
    }//  w w  w  .  ja  va2 s.  co m
    String nameElement = "name=";
    String line = reader.readLine();
    String case2String = originalResourceName;
    while (line != null) {
        //            There can be only 2 occurrences. Pls have a look below.
        //             <artifact name="proxy1" version="1.0.0" type="synapse/proxy-service" serverRole="EnterpriseServiceBus">
        //              <file>src/main/synapse-config/proxy-services/proxy1.xml</file>
        //              </artifact>
        String[] stringArray = line.split(" ");
        if (line.contains(case1String) && stringArray[getarrayIndexWithString(nameElement, stringArray)]
                .equals(nameElement + case1String)) {
            //CASE 1 => <artifact name="proxy1" version="1.0.0" type="synapse/proxy-service" serverRole="EnterpriseServiceBus">
            //Swapping 1 element for "\""
            int case1LineIndex = line.indexOf(case1String) + 1;
            addEdit(new ReplaceEdit(fullIndex + case1LineIndex, originalFileNameWOExt.length(),
                    newFileNameWOExt));
        } else {
            if (type == RegistryArtifactType.Resource && line.contains(case2String)
                    && line.endsWith(originalResourceName + "</file>")) {
                //CASE 2 => <file>src/main/synapse-config/proxy-services/proxy1.xml</file>
                int case2LineIndex = line.indexOf(case2String);
                addEdit(new ReplaceEdit(fullIndex + case2LineIndex, originalResourceName.length(), newName));

            } else {
                String directoryStart = "<directory>";
                String directoryEnd = "</directory>";
                if (type == RegistryArtifactType.Collection && line.trim().startsWith(directoryStart)
                        && line.contains(case2String) && line.endsWith(originalResourceName + directoryEnd)) {

                    int directoryStartIndex = line.indexOf(directoryStart) + directoryStart.length();
                    String directoryString = line.substring(directoryStartIndex, line.indexOf(directoryEnd));
                    String[] array = directoryString.split(Pattern.quote(File.separator));
                    int case2LineIndex = line.subSequence(0, directoryStartIndex).length()
                            + generateString(array).length() + array[array.length - 1].indexOf(case2String);
                    addEdit(new ReplaceEdit(fullIndex + case2LineIndex, originalResourceName.length(),
                            newName));

                } else {
                    String pathStart = "<path>";
                    String pathEnd = "</path>";
                    if (type == RegistryArtifactType.Collection && line.trim().startsWith(pathStart)
                            && line.contains(case2String) && line.endsWith(originalResourceName + pathEnd)) {

                        int pathStartIndex = line.indexOf(pathStart) + pathStart.length();
                        String directoryString = line.substring(pathStartIndex, line.indexOf(pathEnd));
                        String[] array = directoryString.split("/");
                        int case2LineIndex = line.subSequence(0, pathStartIndex).length()
                                + generateString(array).length() + array[array.length - 1].indexOf(case2String);
                        addEdit(new ReplaceEdit(fullIndex + case2LineIndex, originalResourceName.length(),
                                newName));
                    }
                }
            }
        }
        fullIndex += charsOnTheLine(line);
        line = reader.readLine();
    }
    fileReader.close();
    reader.close();
}

From source file:org.openbravo.erpCommon.businessUtility.InitialSetupUtility.java

public static ElementValue insertElementValue(Element element, Organization orgProvided, String name,
        String value, String description, String accountType, String accountSign, boolean isDocControlled,
        boolean isSummary, String elementLevel, boolean doFlush, String showValueCond, String titleNode)
        throws Exception {
    OBContext.setAdminMode();//from  w  w w .j av  a 2 s .  c  o  m
    try {
        Organization organization = null;
        if (orgProvided == null) {
            if ((organization = getZeroOrg()) == null)
                return null;
        } else
            organization = orgProvided;

        final ElementValue newElementValue = OBProvider.getInstance().get(ElementValue.class);
        newElementValue.setClient(element.getClient());
        newElementValue.setOrganization(organization);
        newElementValue.setSearchKey(value);
        newElementValue.setName(name);
        newElementValue.setDescription(description);
        newElementValue.setAccountingElement(element);
        newElementValue.setAccountType(accountType);
        newElementValue.setAccountSign(accountSign);
        newElementValue.setDocumentControlled(isDocControlled);
        newElementValue.setSummaryLevel(isSummary);
        newElementValue.setElementLevel(elementLevel);
        if (showValueCond != null && !"".equals(showValueCond))
            newElementValue.setShowValueCondition(showValueCond.substring(0, 1));
        if (titleNode != null && !"".equals(titleNode))
            newElementValue.setTitleNode("Y".equals(titleNode.subSequence(0, 1)));
        OBDal.getInstance().save(newElementValue);
        if (doFlush)
            OBDal.getInstance().flush();
        return newElementValue;
    } finally {
        OBContext.restorePreviousMode();
    }
}

From source file:es.pode.gestorFlujo.presentacion.objetosCompartidos.importarCompartidos.ImportarCompartidosControllerImpl.java

/**
 * @see es.pode.gestorFlujo.presentacion.objetosCompartidos.importarCompartidos.ImportarCompartidosController#importarODE(org.apache.struts.action.ActionMapping, es.pode.gestorFlujo.presentacion.objetosCompartidos.importarCompartidos.ImportarODEForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///from w ww  .java  2 s . c om
public final void importarODE(ActionMapping mapping,
        es.pode.gestorFlujo.presentacion.objetosCompartidos.importarCompartidos.ImportarODEForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    //       long tamaino=new Long(request.getParameter("espacioLibre"));
    //       logger.debug("De la request:"+tamaino);

    ResultadoOperacionVO unResultado = new ResultadoOperacionVO();
    String archivosSubidos = new String("(");
    int nr_archivos_subidos = 0;
    ArrayList resultado = new ArrayList();
    Long diferencia = new Long(0);
    logger.debug("Importando ode");
    if (form.getTitulo() != null && form.getTitulo().length() != 0) {

        try {
            ResultadoImportacion resultadoParcial = new ResultadoImportacion();
            resultadoParcial.setTitulo(form.getTitulo());
            unResultado = importarUnODE(form.getIdODE(), form.getTitulo(), request.getLocale().getLanguage());
            if (unResultado.getIdResultado().equals("0.0")) {
                nr_archivos_subidos++;
                resultadoParcial.setValido(null);
                archivosSubidos = archivosSubidos + form.getTitulo() + ",";
                resultado.add(resultadoParcial);
            } else {
                resultadoParcial.setValido(RESULTADO_NO);
                logger.error("El archivo no se ha podido importar: " + unResultado.getDescripcion());
                resultadoParcial.setMensajes(unResultado.getDescripcion().split(SPLITTER));
                resultado.add(resultadoParcial);
            }
            logger.error(
                    "Mensajes despues del splitter[" + (unResultado.getDescripcion().split(SPLITTER) != null
                            ? unResultado.getDescripcion().split(SPLITTER).length
                            : 0) + "] ");
            logger.debug("Los atributos que pasamos a la jsp son: Una colleccion:[" + resultado
                    + "], con titulo [" + ((ResultadoImportacion) resultado.get(0)).getTitulo()
                    + " con mensajes [" + ((ResultadoImportacion) resultado.get(0)).getMensajes()
                    + " y validacion[" + ((ResultadoImportacion) resultado.get(0)).getValido());
        } catch (Exception ex) {
            logger.error("Excepcion al importar el ode compartido: ", ex);
            throw new ValidatorException("{gestorFlujo.error.inesperado}");
        }

    }
    logger.debug("Hemos llegado hasta aqui");
    if (nr_archivos_subidos > 0) {
        logger.info("Se ha importado correctamente el archivo: " + archivosSubidos);
        if (archivosSubidos.endsWith(",")) {
            archivosSubidos = (String) archivosSubidos.subSequence(0, archivosSubidos.length() - 1);
            archivosSubidos = nr_archivos_subidos + ": " + archivosSubidos;
            archivosSubidos = archivosSubidos + ")";
        }

    }
    form.setResultado(resultado);
}

From source file:com.baasbox.Global.java

private void overrideSettings() {
    info("Override settings...");
    //takes only the settings that begin with baasbox.settings
    Configuration bbSettingsToOverride = BBConfiguration.configuration.getConfig("baasbox.settings");
    //if there is at least one of them
    if (bbSettingsToOverride != null) {
        //takes the part after the "baasbox.settings" of the key names
        Set<String> keys = bbSettingsToOverride.keys();
        Iterator<String> keysIt = keys.iterator();
        //for each setting to override
        while (keysIt.hasNext()) {
            String key = keysIt.next();
            //is it a value to override?
            if (key.endsWith(".value")) {
                //sets the overridden value
                String value = "";
                try {
                    value = bbSettingsToOverride.getString(key);
                    key = key.substring(0, key.lastIndexOf(".value"));
                    PropertiesConfigurationHelper.override(key, value);
                } catch (Exception e) {
                    error("Error overriding the setting " + key + " with the value " + value + ": "
                            + ExceptionUtils.getMessage(e));
                }/*from  w ww  .j a  va 2s .com*/
            } else if (key.endsWith(".visible")) { //or maybe we have to hide it when a REST API is called
                //sets the visibility
                Boolean value;
                try {
                    value = bbSettingsToOverride.getBoolean(key);
                    key = key.substring(0, key.lastIndexOf(".visible"));
                    PropertiesConfigurationHelper.setVisible(key, value);
                } catch (Exception e) {
                    error("Error overriding the visible attribute for setting " + key + ": "
                            + ExceptionUtils.getMessage(e));
                }
            } else if (key.endsWith(".editable")) { //or maybe we have to 
                //sets the possibility to edit the value via REST API by the admin
                Boolean value;
                try {
                    value = bbSettingsToOverride.getBoolean(key);
                    key = key.substring(0, key.lastIndexOf(".editable"));
                    PropertiesConfigurationHelper.setEditable(key, value);
                } catch (Exception e) {
                    error("Error overriding the editable attribute setting " + key + ": "
                            + ExceptionUtils.getMessage(e));
                }
            } else {
                error("The configuration key: " + key + " is invalid. value, visible or editable are missing");
            }
            key.subSequence(0, key.lastIndexOf("."));
        }
    } else
        info("...No setting to override...");
    info("...done");
}

From source file:es.pode.gestorFlujo.presentacion.objetosPersonales.importar.ImportarControllerImpl.java

/**
 * @throws ValidatorException /*ww  w .  ja v  a 2 s  .  c  o  m*/
 * @see es.pode.gestorFlujo.presentacion.objetosPersonales.importar.ImportarController#importarODE(org.apache.struts.action.ActionMapping, es.pode.gestorFlujo.presentacion.objetosPersonales.importar.ImportarODEForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
public final void importarODE(ActionMapping mapping,
        es.pode.gestorFlujo.presentacion.objetosPersonales.importar.ImportarODEForm form,
        HttpServletRequest request, HttpServletResponse response) throws ValidatorException {
    //      ResultadoOperacionVO unResultado = new ResultadoOperacionVO();
    int nr_archivos_subidos = 0;
    String archivosSubidos = new String("(");
    boolean hemoshechoalgo = false;
    //      Long diferencia=new Long(0);
    Long diferencia = form.getEspacioLibre();
    ArrayList<ResultadoImportacion> resultado = new ArrayList<ResultadoImportacion>();

    //Wrapping
    CurrentState estadoActual = new CurrentState();
    //TODO Fusionar declaraciones anteriores con asignacin actual
    estadoActual.diferencia = diferencia;
    estadoActual.resultado = resultado;
    estadoActual.archivosSubidos = archivosSubidos;
    estadoActual.nr_archivos_subidos = nr_archivos_subidos;
    estadoActual.hemoshechoalgo = hemoshechoalgo;

    logger.debug("Importando odes");
    // comprobamos las 5 cajas:

    FormFile formFile = form.getFicheroODE1();
    String caja = "caja 1";
    String odeOrder = "primer";
    comprobarFormFile(form, request, estadoActual, formFile, caja, odeOrder);

    formFile = form.getFicheroODE2();
    caja = "caja 2";
    odeOrder = "segundo";
    comprobarFormFile(form, request, estadoActual, formFile, caja, odeOrder);

    formFile = form.getFicheroODE3();
    caja = "caja 3";
    odeOrder = "tercer";
    comprobarFormFile(form, request, estadoActual, formFile, caja, odeOrder);

    formFile = form.getFicheroODE4();
    caja = "caja 4";
    odeOrder = "cuarto";
    comprobarFormFile(form, request, estadoActual, formFile, caja, odeOrder);

    formFile = form.getFicheroODE5();
    caja = "caja 5";
    odeOrder = "quinto";
    comprobarFormFile(form, request, estadoActual, formFile, caja, odeOrder);

    //Unwrapping
    resultado = estadoActual.resultado;
    archivosSubidos = estadoActual.archivosSubidos;
    nr_archivos_subidos = estadoActual.nr_archivos_subidos;
    hemoshechoalgo = estadoActual.hemoshechoalgo;

    // si no hemos importado nada mostramos mensajito de informacin:
    if (!hemoshechoalgo) {
        logger.warn("Formfile sin longitud ");
        throw new ValidatorException("{gestorFlujo.error.vacio}");
    }
    logger.debug("ArchivosSubidos: " + archivosSubidos);
    if (nr_archivos_subidos > 0) {
        logger.info("Se han importado correctamente los archivos: " + archivosSubidos);
        if (archivosSubidos.endsWith(",")) {
            archivosSubidos = (String) archivosSubidos.subSequence(0, archivosSubidos.length() - 1);
            archivosSubidos = nr_archivos_subidos + ": " + archivosSubidos;
            archivosSubidos = archivosSubidos + ")";
        }

        //         saveSuccessMessage(request, "gestorFlujo.importar.importados", new String[] { archivosSubidos });
    }
    form.setResultado(resultado);

}

From source file:org.wso2.carbon.logging.util.LoggingReader.java

private LogMessage[] getTenantLogMessages(String logFile, int maxLogs, int start, int end, int tenantId,
        String serviceName) throws LogViewerException {
    ArrayList<LogMessage> logsList = new ArrayList<LogMessage>();
    String errorLine = "";
    InputStream logStream;//from   w w  w .j a  v a2  s.c  o  m
    if (end > maxLogs) {
        end = maxLogs;
    }
    try {
        logStream = getInputStream(logFile, tenantId, serviceName);
    } catch (Exception e) {
        throw new LogViewerException("Cannot find the specified file location to the log file", e);
    }
    BufferedReader dataInput = new BufferedReader(new InputStreamReader(logStream));
    int index = 1;
    String line;
    boolean isSyslogFile;
    try {
        isSyslogFile = isSyslogOn();
    } catch (Exception e1) {
        throw new LogViewerException("Cannot validate syslog appender", e1);
    }
    try {
        while ((line = dataInput.readLine()) != null) {
            if (isSyslogFile) {// remove unwanted characters which are
                // generated by the syslog server.
                line = removeSyslogHeader(line);
            }
            line = cleanLogHeader(line, tenantId);
            if ((index <= end && index > start)) {
                // When if a log entry has multiple lines (ie exception ect)
                // it waits for valid log header,
                // and add the multiple log lines to the specific log header
                // (since we are reading from bottom up
                // those multiple lines belongs to the next valid log
                // header.
                LogMessage logMessage = null;
                if (isErrorHeader(line)) {
                    if (!errorLine.equals("")) {
                        errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
                        logMessage = getLogMessageForType(errorLine);
                        if (logMessage != null) {
                            logsList.add(logMessage);
                        }
                        errorLine = "";
                    }
                    // when there are log messages with multiple lines one
                    // after the other
                    // next line is also considered as a error line
                    errorLine = line;
                } else if (isFatalHeader(line)) {
                    if (!errorLine.equals("")) {
                        errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
                        logMessage = getLogMessageForType(errorLine);
                        if (logMessage != null) {
                            logsList.add(logMessage);
                        }
                        errorLine = "";
                    }
                    errorLine = line;
                } else if (isTraceHeader(line)) {
                    if (!errorLine.equals("")) {
                        errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
                        logMessage = getLogMessageForType(errorLine);
                        if (logMessage != null) {
                            logsList.add(logMessage);
                        }
                        errorLine = "";
                    }
                    errorLine = line;
                } else if (isInfoHeader(line)) {
                    if (!errorLine.equals("")) {
                        errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
                        logMessage = getLogMessageForType(errorLine);
                        if (logMessage != null) {
                            logsList.add(logMessage);
                        }
                        errorLine = "";
                    }
                    errorLine = line;
                } else if (isWarnHeader(line)) {
                    if (!errorLine.equals("")) {
                        errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
                        logMessage = getLogMessageForType(errorLine);
                        if (logMessage != null) {
                            logsList.add(logMessage);
                        }
                        errorLine = "";
                    }
                    errorLine = line;
                } else if (isDebugHeader(line)) {
                    if (!errorLine.equals("")) {
                        errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
                        logMessage = getLogMessageForType(errorLine);
                        if (logMessage != null) {
                            logsList.add(logMessage);
                        }
                        errorLine = "";
                    }
                    errorLine = line;
                } else if (!isLogHeader(line)) {
                    // if a log line has no valid log header that log line
                    // is considered as a error line.
                    errorLine = errorLine + line + LoggingConstants.RegexPatterns.NEW_LINE;
                } else if (isLogHeader(line)) {
                    if (!errorLine.equals("")) {
                        errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
                        logMessage = getLogMessageForType(errorLine);
                        if (logMessage != null) {
                            logsList.add(logMessage);
                        }
                        errorLine = "";
                    }
                    logMessage = getLogMessageForType(line);
                    if (logMessage != null) {
                        logsList.add(logMessage);
                    }
                } else {
                    log.warn("The log message  " + line + " is ignored.");
                }
            }
            index++;
        }
        if (!errorLine.equals("")) {
            LogMessage logMessage = getLogMessageForType(errorLine);
            if (logMessage != null) {
                logsList.add(logMessage);
            } else {
                log.warn("The log message " + errorLine + " is ignored.");
            }
        }
        dataInput.close();
    } catch (IOException e) {
        throw new LogViewerException("Cannot read the log file", e);
    }
    return logsList.toArray(new LogMessage[logsList.size()]);
}

From source file:com.photon.phresco.framework.impl.ProjectAdministratorImpl.java

private void deleteBuildArchive(Project project, List<BuildInfo> selectedInfos) throws IOException {
    S_LOGGER.debug(/*from  ww w  .  j  av a2s . co  m*/
            "Entering Method ProjectAdministratorImpl.deleteBuildArchive(Project project, List<BuildInfo> selectedInfos)");
    File file = null;
    String delFilename = null;
    for (BuildInfo selectedInfo : selectedInfos) {
        if (TechnologyTypes.IPHONES.contains(project.getProjectInfo().getTechnology().getId())) {
            String deleivarables = selectedInfo.getDeliverables();
            String buildNameSubstring = deleivarables.substring(deleivarables.lastIndexOf("/") + 1);
            delFilename = buildNameSubstring;
            // Delete build folder
            deleteBuilFolder(project, delFilename.subSequence(0, delFilename.length() - 4).toString());
            //Delete zip file
            file = new File(getBuildInfoHome(project) + delFilename);
            file.delete();
        } else if (TechnologyTypes.ANDROIDS.contains(project.getProjectInfo().getTechnology().getId())) {
            // Delete zip file
            String deleivarables = selectedInfo.getDeliverables();
            delFilename = deleivarables;
            file = new File(getBuildInfoHome(project) + delFilename);
            file.delete();
            //Delete apk file
            delFilename = selectedInfo.getBuildName();
            file = new File(getBuildInfoHome(project) + delFilename);
            file.delete();
        } else {
            //Delete zip file
            delFilename = selectedInfo.getBuildName();
            file = new File(getBuildInfoHome(project) + delFilename);
            file.delete();
        }
    }
}