Example usage for java.io IOException getLocalizedMessage

List of usage examples for java.io IOException getLocalizedMessage

Introduction

In this page you can find the example usage for java.io IOException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:keel.Algorithms.Neural_Networks.NNEP_Common.problem.ProblemEvaluator.java

/**
 * <p> //from ww w  .  j av a  2  s  . c o m
 * Read and normalize evaluator datasets
 * </p>
 * @throws IOException Data not correct
 * @throws NumberFormatException Format of data not correct
 */
public void readData() throws IOException, NumberFormatException {

    // Read trainData
    try {
        unscaledTrainData.read();
    } catch (IOException e) {
        throw new IOException("trainData IOException: " + e.getLocalizedMessage());
    } catch (NumberFormatException e) {
        throw new NumberFormatException("trainData NumberFormatException: " + e.getLocalizedMessage());
    }

    // Read testData
    try {
        unscaledTestData.read();
    } catch (IOException e) {
        throw new IOException("testData IOException: " + e.getLocalizedMessage());
    } catch (NumberFormatException e) {
        throw new NumberFormatException("testData NumberFormatException: " + e.getLocalizedMessage());
    }

    normalizeData();
}

From source file:com.photon.phresco.plugins.xcode.XcodeBuild.java

private void init() throws MojoExecutionException, MojoFailureException {

    try {// w  w  w.  j ava2  s  .  c  o m
        // To Delete the buildDirectory if already exists
        if (buildDirectory.exists()) {
            FileUtils.deleteDirectory(buildDirectory);
            buildDirectory.mkdirs();
        }

        buildInfoList = new ArrayList<BuildInfo>(); // initialization
        // srcDir = new File(baseDir.getPath() + File.separator +
        // sourceDirectory);
        buildDirFile = new File(baseDir, DO_NOT_CHECKIN_BUILD);
        if (!buildDirFile.exists()) {
            buildDirFile.mkdirs();
            getLog().info("Build directory created..." + buildDirFile.getPath());
        }
        buildInfoFile = new File(buildDirFile.getPath() + "/build.info");
        System.out.println("file created " + buildInfoFile);
        nextBuildNo = generateNextBuildNo();
        currentDate = Calendar.getInstance().getTime();
    } catch (IOException e) {
        throw new MojoFailureException("APP could not initialize " + e.getLocalizedMessage());
    }
}

From source file:it.geosolutions.geobatch.actions.ds2ds.Ds2dsAction.java

/**
 * Does the actual import on the given file event.
 *
 * @param fileEvent/*  w w w. jav  a 2  s. c  o m*/
 * @return ouput EventObject (an xml describing the output feature)
 * @throws ActionException
 */
private EventObject importFile(FileSystemEvent fileEvent) throws ActionException {
    DataStore sourceDataStore = null;
    DataStore destDataStore = null;

    final Transaction transaction = new DefaultTransaction("create");
    boolean error = false;
    try {
        updateTask("Setting Source");
        // source
        sourceDataStore = createSourceDataStore(fileEvent);
        updateTask("Setting Source query");
        Query query = buildSourceQuery(sourceDataStore);
        updateTask("Creating FeatureSource");
        // TODO: check input write permissions before casting to FeatureStore
        FeatureSource<SimpleFeatureType, SimpleFeature> featureReader = createSourceReader(sourceDataStore,
                transaction, query);

        updateTask("Getting Source Schema");
        SimpleFeatureType sourceSchema = featureReader.getSchema();
        FeatureSource<SimpleFeatureType, SimpleFeature> inputFeatureWriter = null;
        if (featureReader instanceof FeatureStore) {
            inputFeatureWriter = createWriter(sourceDataStore, sourceSchema, transaction);
        }
        updateTask("Setting Output");
        // output
        destDataStore = createOutputDataStore();
        SimpleFeatureType schema = buildDestinationSchema(featureReader.getSchema());

        FeatureStore<SimpleFeatureType, SimpleFeature> featureWriter = createWriter(destDataStore, schema,
                transaction);
        SimpleFeatureType destSchema = featureWriter.getSchema();

        updateTask("Checking schema");
        // check for schema case differences from input to output
        Map<String, String> schemaDiffs = compareSchemas(destSchema, schema);
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(destSchema);

        purgeData(featureWriter);

        updateTask("Reading data");
        int total = featureReader.getCount(query);
        FeatureIterator<SimpleFeature> iterator = createSourceIterator(query, featureReader);
        int count = 0;
        try {
            while (iterator.hasNext()) {
                SimpleFeature feature = buildFeature(builder, iterator.next(), schemaDiffs, sourceDataStore);
                featureWriter.addFeatures(DataUtilities.collection(feature));
                count++;
                if (count % 100 == 0) {
                    updateImportProgress(count, total, "Importing data");
                }
            }
            listenerForwarder.progressing(100F, "Data import completed");

        } finally {
            iterator.close();
        }
        updateTask("Data imported (" + count + " features)");

        if (featureReader instanceof FeatureStore) {
            moveData(inputFeatureWriter);
        }

        transaction.commit();
        listenerForwarder.completed();
        return buildOutputEvent();
    } catch (Exception ioe) {
        error = true;
        try {
            transaction.rollback();
        } catch (IOException e1) {
            final String message = "Transaction rollback unsuccessful: " + e1.getLocalizedMessage();
            if (LOGGER.isErrorEnabled()) {
                LOGGER.error(message);
            }
            throw new ActionException(this, message);
        }
        String cause = ioe.getCause() == null ? null : ioe.getCause().getMessage();
        String msg = "MESSAGE: " + ioe.getMessage() + " - CAUSE: " + cause;
        throw new ActionException(this, msg);

    } finally {
        if (error) {
            updateTask("Import Failed");
        } else {
            updateTask("Import Completed");
        }
        closeResource(sourceDataStore);
        closeResource(destDataStore);
        closeResource(transaction);
    }

}

From source file:it.geosolutions.geoserver.jms.impl.web.ClusterPage.java

public ClusterPage() {

    final FeedbackPanel fp = getFeedbackPanel();

    // setup the JMSContainer exception handler
    getJMSContainerExceptionHandler().setFeedbackPanel(fp);
    getJMSContainerExceptionHandler().setSession(fp.getSession());

    fp.setOutputMarkupId(true);/*from   w  ww. j  av a  2 s .  c om*/

    // form and submit
    final Form<Properties> form = new Form<Properties>("form",
            new CompoundPropertyModel<Properties>(getConfig().getConfigurations()));

    // add broker URL setting
    final TextField<String> brokerURL = new TextField<String>(BrokerConfiguration.BROKER_URL_KEY);
    // https://issues.apache.org/jira/browse/WICKET-2426
    brokerURL.setType(String.class);
    form.add(brokerURL);

    // add group name setting
    final TextField<String> instanceName = new TextField<String>(JMSConfiguration.INSTANCE_NAME_KEY);
    // https://issues.apache.org/jira/browse/WICKET-2426
    instanceName.setType(String.class);
    form.add(instanceName);

    // add instance name setting
    final TextField<String> group = new TextField<String>(JMSConfiguration.GROUP_KEY);
    // https://issues.apache.org/jira/browse/WICKET-2426
    group.setType(String.class);
    form.add(group);

    // add topic name setting
    final TextField<String> topicName = new TextField<String>(TopicConfiguration.TOPIC_NAME_KEY);
    // https://issues.apache.org/jira/browse/WICKET-2426
    topicName.setType(String.class);
    form.add(topicName);

    // add connection status info
    final TextField<String> connectionInfo = new TextField<String>(ConnectionConfiguration.CONNECTION_KEY);

    // https://issues.apache.org/jira/browse/WICKET-2426
    connectionInfo.setType(String.class);

    connectionInfo.setOutputMarkupId(true);
    connectionInfo.setOutputMarkupPlaceholderTag(true);
    connectionInfo.setEnabled(false);
    form.add(connectionInfo);

    final AjaxButton connection = new AjaxButton("connectionB",
            new StringResourceModel(ConnectionConfiguration.CONNECTION_KEY, this, null)) {
        /** serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            // the container to use
            final JMSContainer c = getJMSContainer();
            if (c.isRunning()) {
                fp.info("Disconnecting...");
                if (c.disconnect()) {
                    fp.info("Succesfully un-registered from the destination topic");
                    fp.warn("You will (probably) loose next incoming events from other instances!!! (depending on how you have configured the broker)");
                    connectionInfo.getModel().setObject(ConnectionConfigurationStatus.disabled.toString());
                } else {
                    fp.error("Disconnection error!");
                    connectionInfo.getModel().setObject(ConnectionConfigurationStatus.enabled.toString());
                }
            } else {
                fp.info("Connecting...");
                if (c.connect()) {
                    fp.info("Now GeoServer is registered with the destination");
                    connectionInfo.getModel().setObject(ConnectionConfigurationStatus.enabled.toString());
                } else {
                    fp.error("Connection error!");
                    fp.error("Registration aborted due to a connection problem");
                    connectionInfo.getModel().setObject(ConnectionConfigurationStatus.disabled.toString());
                }
            }
            target.addComponent(connectionInfo);
            target.addComponent(fp);
        }

    };
    connection.setOutputMarkupId(true);
    connection.setOutputMarkupPlaceholderTag(true);
    form.add(connection);

    // add MASTER toggle
    addToggle(ToggleConfiguration.TOGGLE_MASTER_KEY, ToggleType.MASTER, ToggleConfiguration.TOGGLE_MASTER_KEY,
            "toggleMasterB", form, fp);

    // add SLAVE toggle
    addToggle(ToggleConfiguration.TOGGLE_SLAVE_KEY, ToggleType.SLAVE, ToggleConfiguration.TOGGLE_SLAVE_KEY,
            "toggleSlaveB", form, fp);

    // add Read Only switch
    final TextField<String> readOnlyInfo = new TextField<String>(ReadOnlyConfiguration.READ_ONLY_KEY);

    // https://issues.apache.org/jira/browse/WICKET-2426
    readOnlyInfo.setType(String.class);

    readOnlyInfo.setOutputMarkupId(true);
    readOnlyInfo.setOutputMarkupPlaceholderTag(true);
    readOnlyInfo.setEnabled(false);
    form.add(readOnlyInfo);

    final AjaxButton readOnly = new AjaxButton("readOnlyB",
            new StringResourceModel(ReadOnlyConfiguration.READ_ONLY_KEY, this, null)) {
        /** serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            ReadOnlyGeoServerLoader loader = getReadOnlyGeoServerLoader();
            if (loader.isEnabled()) {
                readOnlyInfo.getModel().setObject("disabled");
                loader.enable(false);
            } else {
                readOnlyInfo.getModel().setObject("enabled");
                loader.enable(true);
            }
            target.addComponent(this.getParent());
        }
    };
    form.add(readOnly);

    final Button save = new Button("saveB", new StringResourceModel("save", this, null)) {
        /** serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            try {
                getConfig().storeConfig();
                fp.info("Configuration saved");
            } catch (IOException e) {
                if (LOGGER.isLoggable(java.util.logging.Level.SEVERE))
                    LOGGER.severe(e.getLocalizedMessage());
                fp.error(e.getLocalizedMessage());
            }
        }
    };
    form.add(save);

    // add Read Only switch
    final TextField<String> embeddedBrokerInfo = new TextField<String>(
            EmbeddedBrokerConfiguration.EMBEDDED_BROKER_KEY);

    // https://issues.apache.org/jira/browse/WICKET-2426
    embeddedBrokerInfo.setType(String.class);

    embeddedBrokerInfo.setOutputMarkupId(true);
    embeddedBrokerInfo.setOutputMarkupPlaceholderTag(true);
    embeddedBrokerInfo.setEnabled(false);
    form.add(embeddedBrokerInfo);

    final AjaxButton embeddedBroker = new AjaxButton("embeddedBrokerB",
            new StringResourceModel(EmbeddedBrokerConfiguration.EMBEDDED_BROKER_KEY, this, null)) {
        /** serialVersionUID */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            JMSFactory factory = getJMSFactory();
            if (!factory.isEmbeddedBrokerStarted()) {
                try {
                    if (factory.startEmbeddedBroker(getConfig().getConfigurations())) {
                        embeddedBrokerInfo.getModel().setObject("enabled");
                    }
                } catch (Exception e) {
                    if (LOGGER.isLoggable(java.util.logging.Level.SEVERE))
                        LOGGER.severe(e.getLocalizedMessage());
                    fp.error(e.getLocalizedMessage());
                }
            } else {
                try {
                    if (factory.stopEmbeddedBroker()) {
                        embeddedBrokerInfo.getModel().setObject("disabled");
                    }
                } catch (Exception e) {
                    if (LOGGER.isLoggable(java.util.logging.Level.SEVERE))
                        LOGGER.severe(e.getLocalizedMessage());
                    fp.error(e.getLocalizedMessage());
                }
            }
            target.addComponent(this.getParent());
        }
    };
    form.add(embeddedBroker);

    // TODO change status if it is changed due to reset
    // final Button reset = new Button("resetB", new StringResourceModel("reset", this, null)) {
    // @Override
    // public void onSubmit() {
    // try {
    // getConfig().loadTempConfig();
    // fp.info("Configuration reloaded");
    // } catch (FileNotFoundException e) {
    // LOGGER.error(e.getLocalizedMessage(), e);
    // fp.error(e.getLocalizedMessage());
    // } catch (IOException e) {
    // LOGGER.error(e.getLocalizedMessage(), e);
    // fp.error(e.getLocalizedMessage());
    // }
    // }
    // };
    // form.add(reset);

    // add the form
    add(form);

    // add the status monitor
    add(fp);

}

From source file:net.sf.housekeeper.swing.MainFrame.java

/**
 * Displays this main frame.//from w  w  w.  j a v a 2  s  . c o  m
 */
public void show() {
    view.show();
    try {
        PersistenceController.instance().replaceDomainWithSaved();
    } catch (IOException e1) {
        //Nothing wrong about that
    } catch (UnsupportedFileVersionException e1) {
        LOG.error("Unsupported file format: " + e1.getVersion(), e1);
        final String error = LocalisationManager.INSTANCE.getText("gui.error");
        JOptionPane.showMessageDialog(view, e1.getLocalizedMessage(), error, JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.photon.phresco.plugins.xcode.XcodeBuild.java

private void createApp() throws MojoExecutionException {
    File outputFile = getAppName();
    if (outputFile == null) {
        getLog().error("xcodebuild failed. resultant APP not generated!");
        throw new MojoExecutionException("xcodebuild has been failed");
    }//from   w  ww .j av a 2  s. c o  m
    if (outputFile.exists()) {

        try {
            System.out.println("Completed " + outputFile.getAbsolutePath());
            getLog().info("APP created.. Copying to Build directory.....");
            String buildName = project.getBuild().getFinalName() + '_' + getTimeStampForBuildName(currentDate);
            File baseFolder = new File(baseDir + DO_NOT_CHECKIN_BUILD, buildName);
            if (!baseFolder.exists()) {
                baseFolder.mkdirs();
                getLog().info("build output direcory created at " + baseFolder.getAbsolutePath());
            }
            File destFile = new File(baseFolder, outputFile.getName());
            getLog().info("Destination file " + destFile.getAbsolutePath());
            XcodeUtil.copyFolder(outputFile, destFile);
            getLog().info("copied to..." + destFile.getName());
            appFileName = destFile.getAbsolutePath();

            getLog().info("Creating deliverables.....");
            ZipArchiver zipArchiver = new ZipArchiver();
            zipArchiver.addDirectory(baseFolder);
            File deliverableZip = new File(baseDir + DO_NOT_CHECKIN_BUILD, buildName + ".zip");
            zipArchiver.setDestFile(deliverableZip);
            zipArchiver.createArchive();

            deliverable = deliverableZip.getAbsolutePath();
            getLog().info("Deliverables available at " + deliverableZip.getName());
            writeBuildInfo(true);
        } catch (IOException e) {
            throw new MojoExecutionException("Error in writing output..." + e.getLocalizedMessage());
        }

    } else {
        getLog().info("output directory not found");
    }
}

From source file:com.photon.phresco.plugins.xcode.XcodeBuild.java

private void createdSYM() throws MojoExecutionException {
    File outputFile = getdSYMName();
    if (outputFile == null) {
        getLog().error("xcodebuild failed. resultant dSYM not generated!");
        throw new MojoExecutionException("xcodebuild has been failed");
    }// ww  w  . jav  a2  s .c  o m
    if (outputFile.exists()) {

        try {
            System.out.println("Completed " + outputFile.getAbsolutePath());
            getLog().info("dSYM created.. Copying to Build directory.....");
            String buildName = project.getBuild().getFinalName() + '_' + getTimeStampForBuildName(currentDate);
            File baseFolder = new File(baseDir + DO_NOT_CHECKIN_BUILD, buildName);
            if (!baseFolder.exists()) {
                baseFolder.mkdirs();
                getLog().info("build output direcory created at " + baseFolder.getAbsolutePath());
            }
            File destFile = new File(baseFolder, outputFile.getName());
            getLog().info("Destination file " + destFile.getAbsolutePath());
            XcodeUtil.copyFolder(outputFile, destFile);
            getLog().info("copied to..." + destFile.getName());
            dSYMFileName = destFile.getAbsolutePath();

            getLog().info("Creating deliverables.....");
            ZipArchiver zipArchiver = new ZipArchiver();
            zipArchiver.addDirectory(baseFolder);
            File deliverableZip = new File(baseDir + DO_NOT_CHECKIN_BUILD, buildName + ".zip");
            zipArchiver.setDestFile(deliverableZip);
            zipArchiver.createArchive();

            deliverable = deliverableZip.getAbsolutePath();
            getLog().info("Deliverables available at " + deliverableZip.getName());

        } catch (IOException e) {
            throw new MojoExecutionException("Error in writing output..." + e.getLocalizedMessage());
        }

    } else {
        getLog().info("output directory not found");
    }
}

From source file:com.otisbean.keyring.Ring.java

String decrypt(String cryptext) throws GeneralSecurityException {
    log("decrypt()");
    try {//ww  w .j  a  v  a 2 s.  c om
        cipher.init(Cipher.DECRYPT_MODE, key, iv);
    } catch (InvalidKeyException ike) {
        throw new GeneralSecurityException("InvalidKeyException: " + ike.getLocalizedMessage()
                + "\nYou (probably) need to " + "install the \"Java Cryptography Extension (JCE) "
                + "Unlimited Strength Jurisdiction Policy\" files.  Go to "
                + "http://java.sun.com/javase/downloads/index.jsp, download them, "
                + "and follow the instructions.");
    }
    byte[] crypted;
    try {
        crypted = Base64.decode(cryptext);
    } catch (IOException e) {
        throw new GeneralSecurityException(e.getLocalizedMessage());
    }
    byte[] decrypted = cipher.doFinal(crypted);
    String salted;
    try {
        salted = new String(decrypted, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new GeneralSecurityException(e.getLocalizedMessage());
    }
    // Remove any leading non-JSON salt characters
    return salted.replaceAll("^[^\\{]*\\{", "{");
}

From source file:com.jkoolcloud.tnt4j.streams.inputs.FeedInputStream.java

/**
 * {@inheritDoc}/*from   w  w  w  .  ja v  a 2s.c  o  m*/
 * <p>
 * This method does not actually return the next item, but the activity data feed from which the next item should be
 * read. This is useful for parsers that accept {@link InputStream}s or {@link java.io.Reader}s that are using
 * underlying classes to process the data from an input stream. The parser needs to handle all I/O, along with any
 * associated errors.
 */
@Override
public T getNextItem() throws Exception {
    while (true) {
        if (dataFeed == null) {
            try {
                startDataStream();
            } catch (IOException exc) {
                logger().log(OpLevel.WARNING, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                        "FeedInputStream.input.start.failed"), exc.getLocalizedMessage());
                return null;
            }
        }
        if (dataFeed.isClosed() || dataFeed.hasError()) {
            logger().log(OpLevel.DEBUG, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                    "FeedInputStream.reader.terminated"));
            if (feedInput.canContinue()) {
                resetDataStream();
                continue;
            }

            return null;
        }
        logger().log(OpLevel.TRACE, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                "FeedInputStream.stream.still.open"));
        return dataFeed.getInput();
    }
}

From source file:com.icesoft.jasper.compiler.TldLocationsCache.java

private void processWebDotXml() throws Exception {

    InputStream is = null;/* w w w  .j  a v  a 2s  .  c o  m*/

    try {
        // Acquire input stream to web application deployment descriptor
        is = ctxt.getResourceAsStream(WEB_XML);
        if (is == null) {
            if (log.isWarnEnabled()) {
                log.warn(Localizer.getMessage("jsp.error.internal.filenotfound", WEB_XML));
            }
            return;
        }

        // Parse the web application deployment descriptor
        TreeNode webtld = new ParserUtils().parseXMLDocument(WEB_XML, is);

        // Allow taglib to be an element of the root or jsp-config (JSP2.0)
        TreeNode jspConfig = webtld.findChild("jsp-config");
        if (jspConfig != null) {
            webtld = jspConfig;
        }
        Iterator taglibs = webtld.findChildren("taglib");
        while (taglibs.hasNext()) {

            // Parse the next <taglib> element
            TreeNode taglib = (TreeNode) taglibs.next();
            String tagUri = null;
            String tagLoc = null;
            TreeNode child = taglib.findChild("taglib-uri");
            if (child != null)
                tagUri = child.getBody();
            child = taglib.findChild("taglib-location");
            if (child != null)
                tagLoc = child.getBody();

            // Save this location if appropriate
            if (tagLoc == null)
                continue;
            if (uriType(tagLoc) == NOROOT_REL_URI)
                tagLoc = "/WEB-INF/" + tagLoc;
            String tagLoc2 = null;
            if (tagLoc.endsWith(JAR_FILE_SUFFIX)) {
                tagLoc = ctxt.getResource(tagLoc).toString();
                tagLoc2 = "META-INF/taglib.tld";
            }
            mappings.put(tagUri, new String[] { tagLoc, tagLoc2 });
        }
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                if (log.isDebugEnabled()) {
                    log.debug(e.getLocalizedMessage(), e);
                }
            }
        }
    }
}