Example usage for java.lang IllegalStateException getLocalizedMessage

List of usage examples for java.lang IllegalStateException getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang IllegalStateException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.geoserver.cluster.impl.handlers.DocumentFileHandler.java

@Override
public boolean synchronize(DocumentFile event) throws Exception {
    try (OutputStream fout = Resources.fromPath(event.getResourcePath()).out()) {
        xstream.toXML(event.getBody(), fout);
        return true;
    } catch (IllegalStateException e) {
        if (LOGGER.isLoggable(java.util.logging.Level.SEVERE))
            LOGGER.severe(e.getLocalizedMessage());
        throw e;/*from w  ww  . j  av  a 2 s  .c om*/
    }
}

From source file:it.geosolutions.tools.io.CopyTreeTest.java

@Test
public void stopCopyTest() throws Exception {
    LOGGER.info("BEGIN: stopCopyTest");
    File srcMount = TestData.file(this, ".");
    final CopyTree act = new CopyTree(
            FileFilterUtils.or(FileFilterUtils.directoryFileFilter(), FileFilterUtils.fileFileFilter()), cs,
            srcMount, destMount);//from w  w  w.  ja  v a  2s. co  m

    final Thread copier = new Thread(new Runnable() {
        public void run() {
            act.setCancelled();
            try {
                Assert.assertEquals("Returned list should be null", 0, act.copy());
            } catch (IllegalStateException e) {
                e.printStackTrace();
                Assert.fail(e.getLocalizedMessage());
            } catch (IOException e) {
                e.printStackTrace();
                Assert.fail(e.getLocalizedMessage());
            }
        }
    });

    copier.start();

    try {
        copier.join();
    } catch (InterruptedException e) {
        LOGGER.info(e.getLocalizedMessage(), e);
        Assert.fail();
    }

    LOGGER.info("STOP: stopCopyTest");
}

From source file:org.apache.juneau.rest.test.RestClientTest.java

@Test
public void testCaptureResponse() throws Exception {
    RestClient c = TestMicroservice.DEFAULT_CLIENT;
    RestCall rc = c.doPost(URL, new StringEntity("xxx")).captureResponse();

    try {//ww w. j  a  v a  2 s .co  m
        rc.getCapturedResponse();
        fail();
    } catch (IllegalStateException e) {
        assertEquals("This method cannot be called until the response has been consumed.",
                e.getLocalizedMessage());
    }
    rc.run();
    assertEquals("xxx", rc.getCapturedResponse());
    assertEquals("xxx", rc.getCapturedResponse());

    rc = c.doPost(URL, new StringEntity("xxx")).captureResponse();
    assertEquals("xxx", rc.getResponseAsString());
    assertEquals("xxx", rc.getCapturedResponse());
    assertEquals("xxx", rc.getCapturedResponse());

    try {
        rc.getResponseAsString();
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Method cannot be called.  Response has already been consumed.", e.getLocalizedMessage());
    }
}

From source file:org.abhinav.alfresco.publishing.s3.S3ChannelType.java

@Override
public void unpublish(final NodeRef nodeToUnpublish, final Map<QName, Serializable> channelProperties) {

    LOG.info("unpublish() invoked...");
    S3RESTService s3RestServ = null;/* ww  w. j a  v  a 2 s .co  m*/
    try {
        LOG.debug("Unpublishing object: " + nodeToUnpublish);
        s3RestServ = publishingHelper.getS3Service(channelProperties);
        s3RestServ.deleteObject(nodeToUnpublish.toString());
    } catch (NoSuchAlgorithmException | ServiceException excp) {
        LOG.error("Exception in Unpublish(): ", excp);
        throw new AlfrescoRuntimeException(excp.getLocalizedMessage());
    } catch (IllegalStateException illegalEx) {
        LOG.error("Exception in Unpublish(): ", illegalEx);
        throw new AlfrescoRuntimeException(illegalEx.getLocalizedMessage());
    } catch (IOException ioex) {
        LOG.error("Exception in Unpublish(): ", ioex);
        throw new AlfrescoRuntimeException(ioex.getLocalizedMessage());
    } finally {
        try {
            if (s3RestServ != null) {
                s3RestServ.shutDownS3Service();
            }
        } catch (ServiceException servExcp) {
            LOG.error("Exception in Unpublish() while shutting down s3 service: ", servExcp);
        }
    }
}

From source file:org.collectionspace.chain.csp.webui.misc.WebLoginStatus.java

private void addPermsToCache(String userId, String tenantId, JSONObject perms) {
    // Update cache with the permissions for this user and tenant.
    try {/*  www. j  ava  2s  .  co  m*/
        userPermsCache.put(new Element(buildUserPermsCacheKey(userId, tenantId), perms));
    } catch (IllegalStateException ise) {
        log.warn("WebLoginStatus - userperms cache not active: " + ise.getLocalizedMessage());
    } catch (CacheException ce) {
        log.warn("WebLoginStatus - userperms cache exception:" + ce.getLocalizedMessage());
    } catch (IllegalArgumentException iae) {
        throw new RuntimeException(
                "WebLoginStatus - tried to cache with null perms!:" + iae.getLocalizedMessage());
    }
}

From source file:org.collectionspace.chain.csp.webui.misc.WebLoginStatus.java

private JSONObject findPermsInCache(String userId, String tenantId) {
    JSONObject perms = null;//from   ww  w.j  a  v a2  s. c  o m
    // See if there is a cache of the permissions for this user and tenant.
    try {
        Element cacheHit = userPermsCache.get(buildUserPermsCacheKey(userId, tenantId));
        if (cacheHit != null) {
            perms = (JSONObject) cacheHit.getObjectValue();
        }
    } catch (IllegalStateException ise) {
        log.warn("WebLoginStatus - userperms cache not active: " + ise.getLocalizedMessage());
    } catch (CacheException ce) {
        log.warn("WebLoginStatus - userperms cache exception:" + ce.getLocalizedMessage());
    }
    return perms;
}

From source file:org.abhinav.alfresco.publishing.s3.S3ChannelType.java

@Override
public void publish(final NodeRef nodeToPublish, final Map<QName, Serializable> channelProperties) {
    LOG.info("publish() invoked...");

    final ContentReader contentReader = contentService.getReader(nodeToPublish, ContentModel.PROP_CONTENT);
    if (contentReader.exists()) {
        File contentFile = null;/* w  w w  .ja v  a 2  s .  c om*/
        boolean deleteContentFrmTempFlag = false;
        if (FileContentReader.class.isAssignableFrom(contentReader.getClass())) {
            contentFile = ((FileContentReader) contentReader).getFile();
        } else {
            // Otherwise clone the content to temp and use it
            final File tempDir = TempFileProvider.getLongLifeTempDir(ID);
            contentFile = TempFileProvider.createTempFile(ID, "", tempDir);
            contentReader.getContent(contentFile);
            deleteContentFrmTempFlag = true;
        }

        S3RESTService s3RestServ = null;
        try {
            final String mimeType = contentReader.getMimetype();
            final String nodeUri = nodeToPublish.toString();
            LOG.info("Publishing object: " + nodeUri);
            LOG.info("Content_MIMETYPE: " + mimeType);
            s3RestServ = publishingHelper.getS3Service(channelProperties);
            s3RestServ.putObject(nodeUri, S3PublishingHelper.getBytes(contentFile));
        } catch (NoSuchAlgorithmException | ServiceException excp) {
            LOG.error("Exception in Unpublish(): ", excp);
            throw new AlfrescoRuntimeException(excp.getLocalizedMessage());
        } catch (IllegalStateException illegalEx) {
            LOG.error("Exception in publish(): ", illegalEx);
            throw new AlfrescoRuntimeException(illegalEx.getLocalizedMessage());
        } catch (IOException ioex) {
            LOG.error("Exception in publish(): ", ioex);
            throw new AlfrescoRuntimeException(ioex.getLocalizedMessage());
        } finally {
            try {
                if (s3RestServ != null) {
                    s3RestServ.shutDownS3Service();
                }
            } catch (ServiceException servExcp) {
                LOG.error("Exception in publish() while shutting down s3 service: ", servExcp);
            }
            if (deleteContentFrmTempFlag) {
                contentFile.delete();
            }
        }
    }
}

From source file:com.amazonaws.mturk.cmd.AbstractCmd.java

public AbstractCmd() {
    if (config == null) {
        try {/* ww w .  j a  va2  s  .c  o  m*/
            config = new PropertiesClientConfig();
        } catch (IllegalStateException ex) {
            log.error("The Mechanical Turk command line tool is not configured correctly: "
                    + ex.getLocalizedMessage());
            log.error(
                    "Please open the configuration file (mturk.properties) and correct this setting before proceeding.");
            System.exit(-1);
        }
    }

    if (formatter == null) {
        formatter = new HelpFormatter();
    }

    opt = new Options();
    initOptions();
    opt.addOption(ARG_HELP, false, "Print help for this application");
    opt.addOption(ARG_HELP_SHORT, false, "Print help for this application");
    opt.addOption(ARG_SANDBOX, false,
            "Run the command in the Mechanical Turk Sandbox (used for testing purposes)");
}

From source file:com.dropbox.android.sample.DBRoulette.java

@Override
protected void onResume() {
    super.onResume();
    AndroidAuthSession session = mApi.getSession();

    // The next part must be inserted in the onResume() method of the
    // activity from which session.startAuthentication() was called, so
    // that Dropbox authentication completes properly.
    if (session.authenticationSuccessful()) {
        try {//w  w w. java2s  . com
            // Mandatory call to complete the auth
            session.finishAuthentication();

            // Store it locally in our app for later use
            storeAuth(session);
            setLoggedIn(true);
        } catch (IllegalStateException e) {
            showToast("Couldn't authenticate with Dropbox:" + e.getLocalizedMessage());
            Log.i(TAG, "Error authenticating", e);
        }
    }
}

From source file:de.incoherent.suseconferenceclient.app.ConferenceCacher.java

public long cacheConference(Conference conference, Database db) {

    //String url = conference.getUrl();
    String url = "https://conference.opensuse.org/osem/api/v1/conferences/gRNyOIsTbvCfJY5ENYovBA";
    String eventsUrl = url + "/events.json";
    String roomsUrl = url + "/rooms.json";
    String speakersUrl = url + "/speakers.json";
    String tracksUrl = url + "/tracks.json";
    String venueUrl = url + "/venue.json";
    Long returnVal = null;/*from w  ww  .java 2  s  .  co  m*/
    HashMap<String, Long> roomMap = new HashMap<String, Long>();
    HashMap<String, Long> trackMap = new HashMap<String, Long>();
    HashMap<String, Long> speakerMap = new HashMap<String, Long>();

    try {
        Log.d("SUSEConferences", "Venues: " + venueUrl);
        publishProgress("venues");
        JSONObject venueReply = HTTPWrapper.get(venueUrl);
        JSONObject venue = venueReply.getJSONObject("venue");
        String infoUrl = url + "/" + venue.getString("info_text");
        Log.d("Application Url", "INFO URL: " + infoUrl);
        String info = HTTPWrapper.getRawText(infoUrl);
        String venueName = venue.getString("name");
        String venueAddr = venue.getString("address");
        String offlineMap = "";
        String offlineMapBounds = "";
        if (venue.has("offline_map")) {
            offlineMap = venue.getString("offline_map");
            offlineMapBounds = venue.getString("offline_map_bounds");
        }

        long venueId = db.insertVenue(venue.getString("guid"), venueName, venueAddr, offlineMap,
                offlineMapBounds, info);
        JSONArray mapPoints = venue.getJSONArray("map_points");
        int mapLen = mapPoints.length();
        for (int i = 0; i < mapLen; i++) {
            JSONObject point = mapPoints.getJSONObject(i);
            String lat = point.getString("lat");
            String lon = point.getString("lon");
            String type = point.getString("type");
            String name = "Unknown Point";
            String addr = "Unknown Address";
            String desc = "";

            if (point.has("name")) {
                name = point.getString("name");
            }
            if (point.has("address")) {
                addr = point.getString("address");
            }
            if (point.has("description")) {
                desc = point.getString("description");
            }

            db.insertVenuePoint(venueId, lat, lon, type, name, addr, desc);
        }

        if (venue.has("map_polygons")) {
            JSONArray polygons = venue.getJSONArray("map_polygons");
            int polygonLen = polygons.length();
            for (int j = 0; j < polygonLen; j++) {
                JSONObject polygon = polygons.getJSONObject(j);
                String name = polygon.getString("name");
                String label = polygon.getString("label");
                String lineColorStr = polygon.getString("line_color");
                String fillColorStr = "#00000000";
                if (polygon.has("fill_color"))
                    fillColorStr = polygon.getString("fill_color");

                List<String> stringList = new ArrayList<String>();
                JSONArray points = polygon.getJSONArray("points");
                int pointsLen = points.length();
                for (int k = 0; k < pointsLen; k++) {
                    String newPoint = points.getString(k);
                    stringList.add(newPoint);
                }
                String joined = TextUtils.join(";", stringList);
                int lineColor = Color.parseColor(lineColorStr);
                int fillColor = Color.parseColor(fillColorStr);
                db.insertVenuePolygon(venueId, name, label, lineColor, fillColor, joined);
            }
        }

        db.setConferenceVenue(venueId, conference.getSqlId());

        Log.d("SUSEConferences", "Rooms");
        publishProgress("rooms");
        JSONObject roomsReply = HTTPWrapper.get(roomsUrl);
        Log.d("Rooms of the event", "ROOMS URL: " + roomsUrl);
        JSONArray rooms = roomsReply.getJSONArray("rooms");
        int roomsLen = rooms.length();
        for (int i = 0; i < roomsLen; i++) {
            JSONObject room = rooms.getJSONObject(i);
            String guid = room.getString("guid");
            Long roomId = db.insertRoom(guid, room.getString("name"), room.getString("description"), venueId);
            roomMap.put(guid, roomId);
        }
        Log.d("SUSEConferences", "Tracks");
        publishProgress("tracks");
        JSONObject tracksReply = HTTPWrapper.get(tracksUrl);
        Log.d("Event tracks", "Tracks: " + tracksUrl);
        JSONArray tracks = tracksReply.getJSONArray("tracks");
        int tracksLen = tracks.length();
        for (int i = 0; i < tracksLen; i++) {
            JSONObject track = tracks.getJSONObject(i);
            String guid = track.getString("guid");
            Long trackId = db.insertTrack(guid, track.getString("name"), track.getString("color"),
                    conference.getSqlId());
            trackMap.put(guid, trackId);
        }
        Log.d("SUSEConferences", "Speakers");
        publishProgress("speakers");
        JSONObject speakersReply = HTTPWrapper.get(speakersUrl);
        JSONArray speakers = speakersReply.getJSONArray("speakers");
        int speakersLen = speakers.length();
        for (int i = 0; i < speakersLen; i++) {
            JSONObject speaker = speakers.getJSONObject(i);
            String guid = speaker.getString("guid");
            Long speakerId = db.insertSpeaker(guid, speaker.getString("name"), speaker.getString("company"),
                    speaker.getString("biography"), "");
            speakerMap.put(guid, speakerId);

        }

        Log.d("SUSEConferences", "Events");
        publishProgress("events");
        JSONObject eventsReply = HTTPWrapper.get(eventsUrl);
        JSONArray events = eventsReply.getJSONArray("events");
        int eventsLen = events.length();
        for (int i = 0; i < eventsLen; i++) {
            JSONObject event = events.getJSONObject(i);
            String guid = event.getString("guid");
            String track = event.getString("track");
            Long trackId = trackMap.get(track);
            Long roomId = roomMap.get(event.getString("room"));
            if (track.equals("meta")) {
                // The "meta" track is used to insert information
                // into the schedule that automatically appears on "my schedule",
                // and also isn't clickable.
                db.insertEvent(guid, conference.getSqlId(), roomId.longValue(), trackId.longValue(),
                        event.getString("date"), event.getInt("length"), "", "", event.getString("title"), "",
                        "");
            } else {
                Long eventId = db.insertEvent(guid, conference.getSqlId(), roomId.longValue(),
                        trackId.longValue(), event.getString("date"), event.getInt("length"),
                        event.getString("type"), event.getString("language"), event.getString("title"),
                        event.getString("abstract"), "");

                JSONArray eventSpeakers = event.getJSONArray("speaker_ids");
                int eventSpeakersLen = eventSpeakers.length();
                for (int j = 0; j < eventSpeakersLen; j++) {
                    Long speakerId = speakerMap.get(eventSpeakers.getString(j));
                    if (speakerId != null)
                        db.insertEventSpeaker(speakerId, eventId);
                }
            }
        }
    } catch (IllegalStateException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    } catch (SocketException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    } catch (IOException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    } catch (JSONException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    }

    if (returnVal == null)
        returnVal = conference.getSqlId();
    return returnVal;
}