Example usage for java.lang NumberFormatException getMessage

List of usage examples for java.lang NumberFormatException getMessage

Introduction

In this page you can find the example usage for java.lang NumberFormatException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.krawler.formbuilder.servlet.ModuleBuilderController.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 * @param request servlet request//from w ww .ja  v  a  2 s .  c o m
 * @param response servlet response
 */
public ModelAndView form(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, SQLException {
    String result = "";
    boolean isFormSubmit = false;
    boolean commit = false;
    //Create transaction
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("JE_Tx");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED);
    TransactionStatus status = txnManager.getTransaction(def);
    try {
        int action = Integer.parseInt(request.getParameter("action"));
        switch (action) {
        case 0:
            commit = true;
            String formid = request.getParameter("formid");
            String moduleid = request.getParameter("moduleid");
            String formjson = request.getParameter("formjson");
            String parentmodule = request.getParameter("parentmodule");
            String jsondata = request.getParameter("jsondata");
            String tbar = request.getParameter("tbar");
            String bbar = request.getParameter("bbar");

            // TODO add company id in param
            result = moduleDao.saveForm(formid, moduleid, formjson, parentmodule, jsondata, tbar, bbar);
            break;
        case 1:
            isFormSubmit = true;
            result = moduleDao.getAllForms(request.getParameter("moduleid"));
            break;
        //                    case 2:
        //                        result = getForm(session, request.getParameter("formid"),request);
        //                        break;
        case 3:
            commit = true;
            isFormSubmit = true;
            result = moduleDao.deleteForm(request.getParameter("id"));
            break;
        case 4:
            // TODO add company check
            int start = Integer.parseInt(request.getParameter("start"));
            int limit = Integer.parseInt(request.getParameter("limit"));

            result = moduleDao.getAllModules(request.getParameter("ss"), request.getParameter("sort"),
                    request.getParameter("dir"), start, limit);
            break;
        case 5:
            isFormSubmit = true;
            commit = true;
            // TODO add company check
            result = moduleDao.createModule(request);
            break;
        /*case 6:
        //                    result = moduleBuilderGenerateTable.deleteFields(conn,request);
            break;
        */case 7:
            // TODO add company check
            result = moduleDao.getAllModulesForCombo(request);
            break;
        case 8:
            isFormSubmit = true;
            result = moduleDao.moduleData(request.getParameter("moduleid"));
            break;
        case 9:
            commit = true;
            isFormSubmit = true;
            result = moduleDao.deleteModule(request.getParameter("moduleid"));
            break;
        case 10:
            //result = moduleDao.getGridData(request);
            String tname = request.getParameter("tablename");
            moduleid = request.getParameter("moduleid");
            Object modObj = Class.forName("com.krawler.esp.hibernate.impl." + tname).newInstance();

            result = moduleDao.getModuleRecords(moduleid, modObj, prepareClauses(request), DATE_FORMAT);
            break;
        case 11:
            result = moduleDao.getModuleConfig(request.getParameter("moduleid"));
            break;
        /*case 12:
            result = getSearchFieldSet(session,request);
            break;*/
        case 13:
            commit = true;
            result = moduleDao.saveModuleGridConfig(request.getParameter("jsondata"));
            break;
        /*case 14:
            result = setSearchField(session,request);
            break;*/
        case 15:
            result = moduleDao.getComboField(request.getParameter("moduleid"));
            break;
        case 21:
            result = moduleDao.getComboData(request.getParameter("moduleid"), request.getParameter("name"));
            break;
        case 22:
            commit = true;
            isFormSubmit = true;
            result = "{'success':false, 'msg':'Error occured at server.'}";
            //this function will not be called (Parto of old modulebuilder)

            List fileItems = new ArrayList();
            Map arrParams = prepareData(request, fileItems);
            List modInfo = moduleDao.getModuleInfo((String) arrParams.get("moduleid"));

            result = moduleDao.createNewRecord(filterData(arrParams, modInfo), fileItems,
                    (String) arrParams.get("moduleid"));//moduleBuilderMethods.createNewRecord(session,request);
            break;
        case 23:
            commit = true;
            isFormSubmit = true;
            result = "{'success':false, 'msg':'Error occured at server.'}";

            List fileItems1 = new ArrayList();
            Map arrParams1 = prepareData(request, fileItems1);
            List modInfo1 = moduleDao.getModuleInfo((String) arrParams1.get("moduleid"));

            result = moduleDao.editRecord(filterData(arrParams1, modInfo1), fileItems1, "id",
                    (String) arrParams1.get("moduleid"));//moduleBuilderMethods.editRecord(session,request);
            break;
        case 24:
            commit = true;
            //                        isFormSubmit=true;
            result = moduleDao.deleteRecord("id", request.getParameter("id"), request.getParameter("moduleid"));//moduleBuilderMethods.deleteRecord(session,request);
            break;
        case 25:
            String basemode = request.getParameter("basemode");
            String mdlid = request.getParameter("moduleid");
            String reportid = request.getParameter("reportid");
            String taskid = request.getParameter("taskid");
            result = moduleDao.openSubModules(basemode, mdlid, reportid, taskid);
            break;
        case 26:
            result = moduleDao.getOtherModules(request.getParameter("moduleid"), request.getParameter("mode"));
            break;
        case 27:
            commit = true;
            result = moduleDao.configSubtabModules(request.getParameter("basemodule"),
                    request.getParameter("submodule"), request.getParameter("mode"),
                    request.getParameter("columnname"));
            break;
        case 29:
            commit = true;
            isFormSubmit = true;
            result = moduleDao.uploadFile(request);//moduleBuilderMethods.uploadFile(session,request);
            break;
        case 30:
            result = moduleDao.getAttachment(request);//moduleBuilderMethods.getAttachment(session, request);
            break;
        case 31:
            result = moduleDao.getStdCongifType(request.getParameter("reportid"));
            break;
        case 32:
            commit = true;
            int configid = 0;
            try {
                configid = Integer.parseInt(request.getParameter("configid"));
            } catch (Exception ex) {
                logger.warn(ex.getMessage(), ex);
            }
            result = moduleDao.getModuleCongifType(configid, request.getParameter("add"),
                    request.getParameter("reportid"), request.getParameter("deleteconfig"));
            break;
        case 33:
            String comboValueId = request.getParameter("comboValueId");
            List<ModuleClause> clauses = new ArrayList<ModuleClause>();
            clauses.add(new ModuleClause("id", "=", comboValueId));

            result = moduleDao.getReadOnlyFields(request.getParameter("moduleid"),
                    request.getParameterValues("appenid"), clauses, DATE_FORMAT);
            break;
        case 34:
            result = moduleDao.getModuleForCombo(request);
            break;
        case 35:
            commit = true;
            result = deployProject();
            break;
        case 36:
            commit = true;
            isFormSubmit = true;
            result = moduleDao.editModule(request);
            break;
        case 37:
            //                        isFormSubmit=true;
            result = moduleDao.getAllModules1(request.getParameter("moduleid"));
            break;
        case 38:
            result = moduleDao.getTableColumn(request.getParameter("moduleid"));
            break;
        case 39:
            isFormSubmit = true;
            result = moduleDao.getformWithParentvalue(request.getParameter("parentmodule"),
                    request.getParameter("childmodule"), request.getParameter("modulevar"));
            break;
        case 40:
            commit = true;
            String moduleidParam = request.getParameter("moduleid");
            String tablename1 = request.getParameter(PARAM_TABLE_NAME);
            result = moduleDao.buildModule(moduleidParam, tablename1);

            break;
        case 45:// Not find any reference
            String tablename = request.getParameter(PARAM_TABLE_NAME);
            Object moduleObj = Class.forName("com.krawler.esp.hibernate.impl." + tablename).newInstance();

            result = moduleDao.getModuleRecords(moduleObj, DATE_FORMAT);
            break;
        case 46:
            moduleid = request.getParameter("moduleid");
            result = moduleDao.getModuleRecords(moduleid, request.getParameter("tablename"),
                    prepareClauses(request), DATE_FORMAT);
            break;
        case 47:
            moduleid = request.getParameter("moduleid");
            result = moduleDao.getModuleRecords(moduleid, request.getParameter("tablename"),
                    prepareClauses(request), DATE_FORMAT);
            break;
        case 48:
            isFormSubmit = true;
            result = moduleDao.getPortletData(request);
            break;
        }
        if (commit) {
            txnManager.commit(status);
        } else {
            txnManager.rollback(status);
        }
    } catch (NumberFormatException e) {
        logger.warn(e.getMessage(), e);
        txnManager.rollback(status);
    } catch (ServiceException ex) {
        logger.warn(ex.getMessage(), ex);
        txnManager.rollback(status);
    } catch (Exception ex) {
        logger.warn(ex.getMessage(), ex);
        txnManager.rollback(status);
    }
    if (isFormSubmit) {
        return new ModelAndView("jsonView-ex", "model", result);
    }
    return new ModelAndView("jsonView", "model", result);
}

From source file:net.duckling.ddl.web.controller.LynxDDocController.java

/**
 * uri???//from w ww  .j a  v a  2s  .  co m
 * @param html
 * @param cachePath
 * @param teamName
 * @param imagePathList
 * @return
 */
private String processImagePath(String html, String teamName, List<String> imagePathList,
        HttpServletRequest request) {
    String cachePath = getImageCachePath(request);
    String baseAddress = config.getProperty("duckling.baseAddress");
    String patternString = "src=\"((" + baseAddress + request.getContextPath() + "/|/)" + teamName
            + "/downloadResource/(\\d+))\"";

    Pattern pattern = Pattern.compile(patternString);
    Matcher matcher = pattern.matcher(html);
    StringBuffer sb = new StringBuffer();
    while (matcher.find()) {
        String imageUri = matcher.group(1);
        int rid;
        try {
            rid = Integer.valueOf(matcher.group(3));
        } catch (NumberFormatException e) {
            LOG.warn("parse rid error.{uri:" + imageUri + "} :" + e.getMessage());
            continue;
        }
        ;
        String path = createCacheImage(rid, cachePath);
        matcher.appendReplacement(sb, "src=\"" + path.replace("\\", "/") + "\"");
        imagePathList.add(path);
    }
    matcher.appendTail(sb);
    return sb.toString();
}

From source file:com.blackducksoftware.integration.hub.bamboo.tasks.HubScanTaskConfigurator.java

private void checkBomWaitTime(final String bomWaitTime, final ErrorCollection errorCollection) {
    if (StringUtils.isBlank(bomWaitTime)) {
        return;/*from   w ww .j av  a  2  s  . co m*/
    }
    int bomWaitTimeInt = 0;
    try {
        final String integerString = StringUtils.trimToNull(bomWaitTime);
        if (integerString != null) {
            try {
                bomWaitTimeInt = Integer.valueOf(integerString);
            } catch (final NumberFormatException e) {
                errorCollection.addError(HubScanConfigFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE.getKey(),
                        "The String : " + bomWaitTime + " , is not an Integer.");
                return;
            }
        } else {
            errorCollection.addError(HubScanConfigFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE.getKey(),
                    "The String : " + bomWaitTime + " , is not an Integer.");
        }
    } catch (final IllegalArgumentException e) {
        errorCollection.addError(HubScanConfigFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE.getKey(), e.getMessage());
        return;
    }
    if (bomWaitTimeInt <= 0) {
        errorCollection.addError(HubScanConfigFieldEnum.MAX_WAIT_TIME_FOR_BOM_UPDATE.getKey(),
                "The maximum wait time for the BOM Update must be greater than 0.");
    }
}

From source file:InlineSchemaValidator.java

/** Main program entry point. */
public static void main(String[] argv) {

    // is there anything to do?
    if (argv.length == 0) {
        printUsage();/*w  w  w. j  a  v a2 s.c  o  m*/
        System.exit(1);
    }

    // variables
    Vector schemas = null;
    Vector instances = null;
    HashMap prefixMappings = null;
    HashMap uriMappings = null;
    String docURI = argv[argv.length - 1];
    String schemaLanguage = DEFAULT_SCHEMA_LANGUAGE;
    int repetition = DEFAULT_REPETITION;
    boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
    boolean honourAllSchemaLocations = DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS;
    boolean validateAnnotations = DEFAULT_VALIDATE_ANNOTATIONS;
    boolean generateSyntheticAnnotations = DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS;
    boolean memoryUsage = DEFAULT_MEMORY_USAGE;

    // process arguments
    for (int i = 0; i < argv.length - 1; ++i) {
        String arg = argv[i];
        if (arg.startsWith("-")) {
            String option = arg.substring(1);
            if (option.equals("l")) {
                // get schema language name
                if (++i == argv.length) {
                    System.err.println("error: Missing argument to -l option.");
                } else {
                    schemaLanguage = argv[i];
                }
                continue;
            }
            if (option.equals("x")) {
                if (++i == argv.length) {
                    System.err.println("error: Missing argument to -x option.");
                    continue;
                }
                String number = argv[i];
                try {
                    int value = Integer.parseInt(number);
                    if (value < 1) {
                        System.err.println("error: Repetition must be at least 1.");
                        continue;
                    }
                    repetition = value;
                } catch (NumberFormatException e) {
                    System.err.println("error: invalid number (" + number + ").");
                }
                continue;
            }
            if (arg.equals("-a")) {
                // process -a: xpath expressions for schemas
                if (schemas == null) {
                    schemas = new Vector();
                }
                while (i + 1 < argv.length - 1 && !(arg = argv[i + 1]).startsWith("-")) {
                    schemas.add(arg);
                    ++i;
                }
                continue;
            }
            if (arg.equals("-i")) {
                // process -i: xpath expressions for instance documents
                if (instances == null) {
                    instances = new Vector();
                }
                while (i + 1 < argv.length - 1 && !(arg = argv[i + 1]).startsWith("-")) {
                    instances.add(arg);
                    ++i;
                }
                continue;
            }
            if (arg.equals("-nm")) {
                String prefix;
                String uri;
                while (i + 2 < argv.length - 1 && !(prefix = argv[i + 1]).startsWith("-")
                        && !(uri = argv[i + 2]).startsWith("-")) {
                    if (prefixMappings == null) {
                        prefixMappings = new HashMap();
                        uriMappings = new HashMap();
                    }
                    prefixMappings.put(prefix, uri);
                    HashSet prefixes = (HashSet) uriMappings.get(uri);
                    if (prefixes == null) {
                        prefixes = new HashSet();
                        uriMappings.put(uri, prefixes);
                    }
                    prefixes.add(prefix);
                    i += 2;
                }
                continue;
            }
            if (option.equalsIgnoreCase("f")) {
                schemaFullChecking = option.equals("f");
                continue;
            }
            if (option.equalsIgnoreCase("hs")) {
                honourAllSchemaLocations = option.equals("hs");
                continue;
            }
            if (option.equalsIgnoreCase("va")) {
                validateAnnotations = option.equals("va");
                continue;
            }
            if (option.equalsIgnoreCase("ga")) {
                generateSyntheticAnnotations = option.equals("ga");
                continue;
            }
            if (option.equalsIgnoreCase("m")) {
                memoryUsage = option.equals("m");
                continue;
            }
            if (option.equals("h")) {
                printUsage();
                continue;
            }
            System.err.println("error: unknown option (" + option + ").");
            continue;
        }
    }

    try {
        // Create new instance of inline schema validator.
        InlineSchemaValidator inlineSchemaValidator = new InlineSchemaValidator(prefixMappings, uriMappings);

        // Parse document containing schemas and validation roots
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setErrorHandler(inlineSchemaValidator);
        Document doc = db.parse(docURI);

        // Create XPath factory for selecting schema and validation roots
        XPathFactory xpf = XPathFactory.newInstance();
        XPath xpath = xpf.newXPath();
        xpath.setNamespaceContext(inlineSchemaValidator);

        // Select schema roots from the DOM
        NodeList[] schemaNodes = new NodeList[schemas != null ? schemas.size() : 0];
        for (int i = 0; i < schemaNodes.length; ++i) {
            XPathExpression xpathSchema = xpath.compile((String) schemas.elementAt(i));
            schemaNodes[i] = (NodeList) xpathSchema.evaluate(doc, XPathConstants.NODESET);
        }

        // Select validation roots from the DOM
        NodeList[] instanceNodes = new NodeList[instances != null ? instances.size() : 0];
        for (int i = 0; i < instanceNodes.length; ++i) {
            XPathExpression xpathInstance = xpath.compile((String) instances.elementAt(i));
            instanceNodes[i] = (NodeList) xpathInstance.evaluate(doc, XPathConstants.NODESET);
        }

        // Create SchemaFactory and configure
        SchemaFactory factory = SchemaFactory.newInstance(schemaLanguage);
        factory.setErrorHandler(inlineSchemaValidator);

        try {
            factory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
        } catch (SAXNotRecognizedException e) {
            System.err.println("warning: SchemaFactory does not recognize feature ("
                    + SCHEMA_FULL_CHECKING_FEATURE_ID + ")");
        } catch (SAXNotSupportedException e) {
            System.err.println("warning: SchemaFactory does not support feature ("
                    + SCHEMA_FULL_CHECKING_FEATURE_ID + ")");
        }
        try {
            factory.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaLocations);
        } catch (SAXNotRecognizedException e) {
            System.err.println("warning: SchemaFactory does not recognize feature ("
                    + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")");
        } catch (SAXNotSupportedException e) {
            System.err.println(
                    "warning: SchemaFactory does not support feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")");
        }
        try {
            factory.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations);
        } catch (SAXNotRecognizedException e) {
            System.err.println(
                    "warning: SchemaFactory does not recognize feature (" + VALIDATE_ANNOTATIONS_ID + ")");
        } catch (SAXNotSupportedException e) {
            System.err.println(
                    "warning: SchemaFactory does not support feature (" + VALIDATE_ANNOTATIONS_ID + ")");
        }
        try {
            factory.setFeature(GENERATE_SYNTHETIC_ANNOTATIONS_ID, generateSyntheticAnnotations);
        } catch (SAXNotRecognizedException e) {
            System.err.println("warning: SchemaFactory does not recognize feature ("
                    + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")");
        } catch (SAXNotSupportedException e) {
            System.err.println("warning: SchemaFactory does not support feature ("
                    + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")");
        }

        // Build Schema from sources
        Schema schema;
        {
            DOMSource[] sources;
            int size = 0;
            for (int i = 0; i < schemaNodes.length; ++i) {
                size += schemaNodes[i].getLength();
            }
            sources = new DOMSource[size];
            if (size == 0) {
                schema = factory.newSchema();
            } else {
                int count = 0;
                for (int i = 0; i < schemaNodes.length; ++i) {
                    NodeList nodeList = schemaNodes[i];
                    int nodeListLength = nodeList.getLength();
                    for (int j = 0; j < nodeListLength; ++j) {
                        sources[count++] = new DOMSource(nodeList.item(j));
                    }
                }
                schema = factory.newSchema(sources);
            }
        }

        // Setup validator and input source.
        Validator validator = schema.newValidator();
        validator.setErrorHandler(inlineSchemaValidator);

        try {
            validator.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
        } catch (SAXNotRecognizedException e) {
            System.err.println(
                    "warning: Validator does not recognize feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")");
        } catch (SAXNotSupportedException e) {
            System.err.println(
                    "warning: Validator does not support feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")");
        }
        try {
            validator.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaLocations);
        } catch (SAXNotRecognizedException e) {
            System.err.println(
                    "warning: Validator does not recognize feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")");
        } catch (SAXNotSupportedException e) {
            System.err.println(
                    "warning: Validator does not support feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")");
        }
        try {
            validator.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations);
        } catch (SAXNotRecognizedException e) {
            System.err
                    .println("warning: Validator does not recognize feature (" + VALIDATE_ANNOTATIONS_ID + ")");
        } catch (SAXNotSupportedException e) {
            System.err.println("warning: Validator does not support feature (" + VALIDATE_ANNOTATIONS_ID + ")");
        }
        try {
            validator.setFeature(GENERATE_SYNTHETIC_ANNOTATIONS_ID, generateSyntheticAnnotations);
        } catch (SAXNotRecognizedException e) {
            System.err.println("warning: Validator does not recognize feature ("
                    + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")");
        } catch (SAXNotSupportedException e) {
            System.err.println(
                    "warning: Validator does not support feature (" + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")");
        }

        // Validate instance documents
        for (int i = 0; i < instanceNodes.length; ++i) {
            NodeList nodeList = instanceNodes[i];
            int nodeListLength = nodeList.getLength();
            for (int j = 0; j < nodeListLength; ++j) {
                DOMSource source = new DOMSource(nodeList.item(j));
                source.setSystemId(docURI);
                inlineSchemaValidator.validate(validator, source, docURI, repetition, memoryUsage);
            }
        }
    } catch (SAXParseException e) {
        // ignore
    } catch (Exception e) {
        System.err.println("error: Parse error occurred - " + e.getMessage());
        if (e instanceof SAXException) {
            Exception nested = ((SAXException) e).getException();
            if (nested != null) {
                e = nested;
            }
        }
        e.printStackTrace(System.err);
    }
}

From source file:net.sf.webphotos.gui.util.FtpClient.java

/**
 * Executa o comando FTP. Utiliza o mtodo
 * {@link net.sf.webphotos.sync.Sync#loadSyncCache() loadSyncCache}() para
 * fazer o load do arquivos com os comandos de FTP. Checa se existem
 * comandos a executar, caso positivo, tenta a conexo com FTP e executa os
 * comandos (UPLOAD, DELETE ou DOWNLOAD).
 *///  w  w w.j  a  v  a 2  s.co m
@Override
public void run() {

    String acao;
    String albumID;
    String arquivo;
    long tamanho;

    String arqOrigem;
    String arqDestino;

    Object streamOrigem = null;
    Object streamDestino = null;

    String ultimoID = "";
    int i, j = 0;

    String diretorioDownload = null;
    // loadSyncCache arquivo
    ftp.loadSyncCache();
    modeloTabela.refresh(ftp.getListaArquivos());
    modeloTabela.fireTableDataChanged();

    // tem algum comando  executar ?
    if (tabela.getRowCount() == 0) {
        ftp.disconnect("No h comandos ftp");
        return;
    }

    // tenta a conexao com FTP
    if (!ftp.connect()) {
        return;
    }
    preProcessBatch();
    modeloTabela.refresh(ftp.getListaArquivos());
    modeloTabela.fireTableDataChanged();
    barra.setMaximum(Integer.parseInt(Long.toString(totalBytes)));

    // executa os comandos
    for (i = 0; i < tabela.getRowCount(); i++) {

        lblArquivos.setText(i + 1 + " / " + tabela.getRowCount());
        tabela.setRowSelectionInterval(i, i);
        tabela.scrollRectToVisible(tabela.getCellRect(i + 1, 0, true));
        tabela.repaint();
        acao = tabela.getValueAt(i, 1).toString();
        albumID = tabela.getValueAt(i, 2).toString();
        arquivo = tabela.getValueAt(i, 4).toString();

        // ajusta o diretrio para /ftpRoot/albumID
        // recebe a lista de arquivos 
        if (!ultimoID.equals(albumID)) {
            Util.log("Mudando para o diretrio " + albumID);
            try {
                ftp.cd(albumID);
                remoteFiles = ftp.listFiles();
                diretorioDownload = null;
            } catch (IOException ioE) {
                Util.log("[FtpClient.run]/ERRO: comando no foi aceito ao listar o diretrio " + albumID
                        + " desconectando");
                ftp.disconnect("no foi possivel entrar no diretorio");
            } catch (SyncException se) {
                Util.log(se.getMessage());
                ftp.disconnect("no foi possivel entrar no diretorio");
            }
        }

        // UPLOAD
        switch (acao) {
        case "enviar":
            if (diretorioDownload == null) {
                diretorioDownload = albunsRoot.getAbsolutePath() + File.separator + albumID;
            }
            arqOrigem = diretorioDownload + File.separator + arquivo;
            Util.out.println(arqOrigem + " -> " + arquivo);
            try {
                streamOrigem = new FileInputStream(arqOrigem);
                streamDestino = new BufferedOutputStream(ftp.storeFileStream(arquivo), ftp.getBufferSize());
                this.transfereArquivo((InputStream) streamOrigem, (OutputStream) streamDestino,
                        Long.parseLong(tabela.getValueAt(i, 5).toString()));
                tabela.setValueAt("ok", i, 0);
            } catch (FileNotFoundException ioE) {
                Util.log("[FtpClient.run]/AVISO: " + arqOrigem + " no foi encontrado.");
                tabela.setValueAt("ok - ne", i, 0);
            } catch (IOException ioE) {
                Util.log("[FtpClient.run]/ERRO: erro na transmisso de " + arqOrigem);
                ioE.printStackTrace(Util.out);
                tabela.setValueAt("erro", i, 0);
            } catch (NumberFormatException e) {
                Util.err.println("Erro inexperado: " + e.getMessage());
                e.printStackTrace(Util.out);
                tabela.setValueAt("erro", i, 0);
            } finally {
                try {
                    ftp.printWorkingDirectory();
                } catch (IOException e) {
                }
                try {
                    ((OutputStream) streamDestino).close();
                    ((InputStream) streamOrigem).close();
                } catch (Exception e) {
                }
            }
            posTransfer(i);

            // DELETE
            break;
        case "apagar":
            // apaga o diretorio inteiro
            if (arquivo.equals("* todos")) {
                try {
                    for (FTPFile remote : remoteFiles) {
                        ftp.deleteFile(remote.getName());
                        Util.log("Removendo arquivo remoto " + remote.getName());
                        transmitido += remote.getSize();
                        Util.out.println("Processado " + transmitido + " de " + totalBytes);
                        barra.setValue((int) transmitido);
                        lblKbytes.setText(Math.round((float) transmitido / 1024) + " Kb");
                    }

                    // Volta para o diretrio principal
                    ftp.changeWorkingDirectory(ftpRoot);
                    // finalmente remove o diretorio
                    ftp.removeDirectory(albumID);
                    tabela.setValueAt("ok", i, 0);

                } catch (Exception e) {
                    tabela.setValueAt("erro", i, 0);
                    log.error(e);
                }
                // apaga somente uma foto
            } else {
                for (FTPFile remote : remoteFiles) {
                    if (remote.getName().equals(arquivo)) {
                        remoteFile = remote;
                        break;
                    }
                }
                //remoteFile=RemoteFile.findRemoteFile(remoteFiles,arquivo);
                if (remoteFile == null) {
                    tabela.setValueAt("ok - ne", i, 0);
                } else {
                    tabela.setValueAt(Long.toString(remoteFile.getSize()), i, 5);
                    try {
                        ftp.deleteFile(arquivo);
                        tabela.setValueAt("ok", i, 0);

                        posTransfer(i);
                    } catch (IOException | NumberFormatException e) {
                        tabela.setValueAt("erro", i, 0);
                    }
                }
            }

            // DOWNLOAD - recebe os arquivos (pr listado e calculado)
            break;
        // fim if
        case "receber":
            try {
                // cada vez que muda o diretrio, a varivel diretrioDownload  nula
                if (diretorioDownload == null) {
                    diretorioDownload = albunsRoot.getAbsolutePath() + File.separator + albumID;
                    File temp = new File(diretorioDownload);

                    if (!temp.isDirectory()) {
                        temp.mkdir();
                        Util.log("Criando diretrio " + diretorioDownload);
                    }
                    temp = null;
                }
                arqDestino = diretorioDownload + File.separator + arquivo;
                Util.out.println(arquivo + " -> " + arqDestino);

                streamOrigem = new BufferedInputStream(ftp.retrieveFileStream(arquivo), ftp.getBufferSize());

                streamDestino = new FileOutputStream(arqDestino);

                this.transfereArquivo((InputStream) streamOrigem, (OutputStream) streamDestino,
                        Long.parseLong(tabela.getValueAt(i, 5).toString()));
                tabela.setValueAt("ok", i, 0);

                // calcula porcentagem e atualiza barra
                posTransfer(i);

            } catch (IOException ioE) {
                Util.err.println("Erro de transmisso: " + ioE.getMessage() + " "
                        + ((CopyStreamException) ioE).getIOException().getMessage());
                tabela.setValueAt("erro", i, 0);
                log.error(ioE);
            } catch (NumberFormatException e) {
                Util.err.println("Erro: ");
                log.error(e);
                tabela.setValueAt("erro", i, 0);
            } finally {
                try {
                    ftp.printWorkingDirectory();
                } catch (IOException e) {
                }
                try {
                    ((InputStream) streamOrigem).close();
                    ((OutputStream) streamDestino).close();
                } catch (IOException e) {
                }
            }
            break;
        }

        ultimoID = albumID;
    } // fim for
    ftp.disconnect("transmisso terminada");
}

From source file:com.ephesoft.dcma.ibm.IBMCMExporter.java

private int getOffsetValue(final String batchInstanceID, final String docID) throws DCMAApplicationException {
    int offset = 0;
    Batch batch = batchSchemaService.getBatch(batchInstanceID);
    List<Document> documents = batch.getDocuments().getDocument();
    try {//from   w  w  w .jav a  2 s.c om
        for (Document document : documents) {
            if (document.getIdentifier().equals(docID)) {
                break;
            } else {
                offset = offset + Integer.valueOf(document.getSize());
            }
        }
    } catch (NumberFormatException e) {
        String msg = "Error in converting offset value into integer";
        LOGGER.error(msg + e.getMessage(), e);
        throw new DCMAApplicationException(msg + e.getMessage(), e);
    }
    return offset;
}

From source file:fr.paris.lutece.plugins.profiles.web.views.ViewsJspBean.java

/**
 * Reorders columns/*from w w  w.  j a va  2 s .  co m*/
 * @param request the request
 * @return url
 */
public String doReorderColumn(HttpServletRequest request) {
    String strViewKey = request.getParameter(ProfilesConstants.PARAMETER_VIEW_KEY);

    if (!RBACService.isAuthorized(View.RESOURCE_TYPE, strViewKey,
            ViewsResourceIdService.PERMISSION_MANAGE_DASHBOARDS, getUser())) {
        return AdminMessageService.getMessageUrl(request, Messages.USER_ACCESS_DENIED, AdminMessage.TYPE_STOP);
    }

    String strColumnName = request.getParameter(ProfilesConstants.PARAMETER_COLUMN);

    if (StringUtils.isBlank(strColumnName)) {
        return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP);
    }

    int nColumn = 0;

    try {
        nColumn = Integer.parseInt(strColumnName);
    } catch (NumberFormatException nfe) {
        AppLogService.error("ViewJspBean.doReorderColumn : " + nfe.getMessage(), nfe);

        return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP);
    }

    _viewsService.doReorderColumn(strViewKey, nColumn, getPlugin());

    return JSP_MANAGE_DASHBOARDS + ProfilesConstants.INTERROGATION_MARK + ProfilesConstants.PARAMETER_VIEW_KEY
            + ProfilesConstants.EQUAL + strViewKey;
}

From source file:io.ucoin.ucoinj.core.client.service.bma.BlockchainRemoteServiceImpl.java

private int[] getBlocksWithUD(long currencyId) {
    log.debug("Getting blocks with UD");

    String json = executeRequest(currencyId, URL_BLOCK_WITH_UD, String.class);

    int startIndex = json.indexOf("[");
    int endIndex = json.lastIndexOf(']');

    if (startIndex == -1 || endIndex == -1) {
        return null;
    }//from  w  ww .jav  a 2 s.com

    String blockNumbersStr = json.substring(startIndex + 1, endIndex).trim();

    if (StringUtils.isBlank(blockNumbersStr)) {
        return null;
    }

    String[] blockNumbers = blockNumbersStr.split(",");
    int[] result = new int[blockNumbers.length];
    try {
        int i = 0;
        for (String blockNumber : blockNumbers) {
            result[i++] = Integer.parseInt(blockNumber.trim());
        }
    } catch (NumberFormatException e) {
        if (log.isDebugEnabled()) {
            log.debug(String.format("Bad format of the response '%s'.", URL_BLOCK_WITH_UD));
        }
        throw new TechnicalException("Unable to read block with UD numbers: " + e.getMessage(), e);
    }

    return result;
}

From source file:fr.paris.lutece.plugins.workflow.modules.evaluation.web.EvaluationTaskComponent.java

/**
 * Synthesis criteria data//from  w  w w.j av a2s. com
 * @param config the config
 * @param request request
 * @param task the task
 * @return error url
 */
private String getSynthesisCriteriaData(TaskEvaluationConfig config, HttpServletRequest request, ITask task) {
    List<SynthesisCriteria> listSynthesisCriteria = new ArrayList<SynthesisCriteria>();
    String[] tabCriterias = request.getParameterValues(PARAMETER_SYNTHESIS_CRITERIAS);

    for (int nIndex = 0; nIndex < _nNbCritere; nIndex++) {
        String strIdCriteria = request
                .getParameter(PARAMETER_ID_SYNTHESIS_CRITERIA + "_" + tabCriterias[nIndex]);

        if (StringUtils.isBlank(strIdCriteria)) {
            throw new AppException("Criteria id not found");
        }

        int nIdCriteria;

        try {
            nIdCriteria = Integer.parseInt(strIdCriteria);
        } catch (NumberFormatException nfe) {
            throw new AppException("Criteria id not found : " + nfe.getMessage(), nfe);
        }

        String strCriteriaTitle = request
                .getParameter(PARAMETER_SYNTHESIS_CRITERIA_TITLE + "_" + tabCriterias[nIndex]);

        if (StringUtils.isBlank(strCriteriaTitle)) {
            continue;
        }

        String strMandatoryCriteria = request
                .getParameter(PARAMETER_SYNTHESIS_MANDATORY_CRITERIA + "_" + tabCriterias[nIndex]);

        String strType = request.getParameter(PARAMETER_TYPE + "_" + tabCriterias[nIndex]);

        Object[] tabCriteriaNum = { nIndex + 1 };

        if (((strCriteriaTitle == null) || strCriteriaTitle.trim().equals(WorkflowUtils.EMPTY_STRING))) {
            return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_CRITERIA_TITLE, tabCriteriaNum,
                    AdminMessage.TYPE_STOP);
        }

        if (StringUtils.isBlank(strType)) {
            return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_CRITERIA_TYPE, tabCriteriaNum,
                    AdminMessage.TYPE_STOP);
        }

        Type type;

        try {
            type = Type.valueOf(strType);
        } catch (Exception e) {
            throw new AppException("Can't convert to enum for type " + strType + " " + e.getMessage(), e);
        }

        List<Pair> listValues = new ArrayList<Pair>();
        String[] tabValues = request
                .getParameterValues(tabCriterias[nIndex] + "_" + PARAMETER_FROM_ID_SYNTHESIS_CRITERIAS);

        for (String strFormValueId : tabValues) {
            String strTitle = request.getParameter(
                    tabCriterias[nIndex] + "_" + PARAMETER_SYNTHESIS_CRITERIA_TITLE + "_" + strFormValueId);

            if (StringUtils.isBlank(strTitle)) {
                continue;
            }

            String strValue = request.getParameter(
                    tabCriterias[nIndex] + "_" + PARAMETER_SYNTHESIS_CRITERIA_VALUE + "_" + strFormValueId);

            Pair pair = new Pair();

            pair.setTitle(strTitle);
            pair.setValue(strValue);

            listValues.add(pair);
        }

        SynthesisCriteria criteria = new SynthesisCriteria();
        criteria.setIdCriteria(nIdCriteria);
        criteria.setIdTask(task.getId());
        criteria.setMandatory(strMandatoryCriteria != null);
        criteria.setTitle(strCriteriaTitle);
        criteria.setAvailableValues(listValues);
        criteria.setType(type);
        listSynthesisCriteria.add(criteria);
    }

    config.setListSynthesisCriteria(listSynthesisCriteria);

    return null;
}