List of usage examples for java.lang IllegalStateException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.zaizi.alfresco.publishing.marklogic.MarkLogicChannelType.java
@Override public void unpublish(final NodeRef nodeToUnpublish, final Map<QName, Serializable> channelProperties) { LOG.info("unpublish() invoked..."); final HttpClient httpclient = new DefaultHttpClient(); try {/*from w ww. j a v a 2 s . co m*/ if (LOG.isDebugEnabled()) { LOG.debug("Unpublishing node: " + nodeToUnpublish); } final URI uriDelete = publishingHelper.getDeleteURIFromNodeRefAndChannelProperties(nodeToUnpublish, channelProperties); final HttpDelete httpDelete = new HttpDelete(uriDelete); final HttpResponse response = httpclient.execute(httpDelete, publishingHelper.getHttpContextFromChannelProperties(channelProperties)); if (LOG.isDebugEnabled()) { LOG.debug("Response Status: " + response.getStatusLine().getStatusCode() + " - Message: " + response.getStatusLine().getReasonPhrase() + " - NodeRef: " + nodeToUnpublish.toString()); } if (response.getStatusLine().getStatusCode() != STATUS_DOCUMENT_DELETED) { throw new AlfrescoRuntimeException(response.getStatusLine().getReasonPhrase()); } } catch (IllegalStateException illegalEx) { if (LOG.isErrorEnabled()) { LOG.error("Exception in Unpublish(): ", illegalEx); } throw new AlfrescoRuntimeException(illegalEx.getLocalizedMessage()); } catch (IOException ioex) { if (LOG.isErrorEnabled()) { LOG.error("Exception in Unpublish(): ", ioex); } throw new AlfrescoRuntimeException(ioex.getLocalizedMessage()); } catch (URISyntaxException uriSynEx) { if (LOG.isErrorEnabled()) { LOG.error("Exception in Unpublish(): ", uriSynEx); } throw new AlfrescoRuntimeException(uriSynEx.getLocalizedMessage()); } finally { httpclient.getConnectionManager().shutdown(); } }
From source file:org.zaizi.alfresco.publishing.marklogic.MarkLogicChannelType.java
@Override public void publish(final NodeRef nodeToPublish, final Map<QName, Serializable> channelProperties) { LOG.info("publish() invoked..."); final ContentReader reader = contentService.getReader(nodeToPublish, ContentModel.PROP_CONTENT); if (reader.exists()) { File contentFile;/*from ww w . j a v a 2s. c om*/ boolean deleteContentFileOnCompletion = false; if (FileContentReader.class.isAssignableFrom(reader.getClass())) { // Grab the content straight from the content store if we can... contentFile = ((FileContentReader) reader).getFile(); } else { // ...otherwise copy it to a temp file and use the copy... final File tempDir = TempFileProvider.getLongLifeTempDir("marklogic"); contentFile = TempFileProvider.createTempFile("marklogic", "", tempDir); reader.getContent(contentFile); deleteContentFileOnCompletion = true; } HttpClient httpclient = new DefaultHttpClient(); try { final String mimeType = reader.getMimetype(); if (LOG.isDebugEnabled()) { LOG.debug("Publishing node: " + nodeToPublish); LOG.debug("ContentFile_MIMETYPE: " + mimeType); } URI uriPut = publishingHelper.getPutURIFromNodeRefAndChannelProperties(nodeToPublish, channelProperties); final HttpPut httpput = new HttpPut(uriPut); final FileEntity filenEntity = new FileEntity(contentFile, mimeType); httpput.setEntity(filenEntity); final HttpResponse response = httpclient.execute(httpput, publishingHelper.getHttpContextFromChannelProperties(channelProperties)); if (LOG.isDebugEnabled()) { LOG.debug("Response Status: " + response.getStatusLine().getStatusCode() + " - Message: " + response.getStatusLine().getReasonPhrase() + " - NodeRef: " + nodeToPublish.toString()); } if (response.getStatusLine().getStatusCode() != STATUS_DOCUMENT_INSERTED) { throw new AlfrescoRuntimeException(response.getStatusLine().getReasonPhrase()); } } catch (IllegalStateException illegalEx) { if (LOG.isErrorEnabled()) { LOG.error("Exception in publish(): ", illegalEx); } throw new AlfrescoRuntimeException(illegalEx.getLocalizedMessage()); } catch (IOException ioex) { if (LOG.isErrorEnabled()) { LOG.error("Exception in publish(): ", ioex); } throw new AlfrescoRuntimeException(ioex.getLocalizedMessage()); } catch (URISyntaxException uriSynEx) { if (LOG.isErrorEnabled()) { LOG.error("Exception in publish(): ", uriSynEx); } throw new AlfrescoRuntimeException(uriSynEx.getLocalizedMessage()); } finally { httpclient.getConnectionManager().shutdown(); if (deleteContentFileOnCompletion) { contentFile.delete(); } } } }
From source file:org.arachna.netweaver.nwdi.documenter.report.DevelopmentConfigurationConfluenceWikiGenerator.java
/** * Create wiki content for the given development component. * * @param component/*from w w w. j a v a 2s .com*/ * DC to generate wiki documentation from. * @return generated documentation */ protected String generateWikiPageContent(final DevelopmentComponent component) { final String docBook = String.format("%s/%s.xml", component.getCompartment().getName(), component.getNormalizedName("_")); String result = null; try { result = transform(createDocBookTemplateReader(docBook)); } catch (final IllegalStateException e) { final StringWriter output = new StringWriter(); try { IOUtils.copy(createDocBookTemplateReader(docBook), output); logger.append(e.getLocalizedMessage()).append(output.toString()); } catch (final IOException e1) { e1.printStackTrace(logger); } throw e; } return result; }
From source file:org.deegree.services.controller.AbstractOWS.java
/** * Sends an exception to the client.//w w w . j a va 2 s. c o m * * @param additionalHeaders * to add to the response. * @param serializer * responsible for creating the appropriate response format of the exception. Could be overridden by a * matching {@link SerializerProvider} on the classpath. * @param exception * the cause, holding relevant information. * @param response * to write to. * @throws ServletException * if the exception could not be sent. */ public void sendException(Map<String, String> additionalHeaders, ExceptionSerializer serializer, OWSException exception, HttpResponseBuffer response) throws ServletException { String userAgent = null; if (OGCFrontController.getContext() != null) { userAgent = OGCFrontController.getContext().getUserAgent(); } SerializerProviderInitializer spi = workspace.getInitializable(SerializerProviderInitializer.class); ImplementationMetadata<?> md = ((OWSProvider) metadata.getProvider()).getImplementationMetadata(); for (SerializerProvider p : spi.getExceptionSerializers()) { if (p.matches(md)) { serializer = p.getSerializer(md, serializer); } } if (!response.isCommitted()) { try { response.reset(); } catch (IllegalStateException e) { // rb: the illegal state exception occurred. throw new ServletException(e); } if (additionalHeaders != null && additionalHeaders.size() > 0) { for (String key : additionalHeaders.keySet()) { String value = additionalHeaders.get(key); if (key != null && !"".equals(key) && value != null) { response.addHeader(key, value); } } } try { serializer.serializeException(response, exception); } catch (Exception e) { LOG.error("An error occurred while trying to send an exception: " + e.getLocalizedMessage(), e); throw new ServletException(e); } response.setExceptionSent(); } if (userAgent != null && userAgent.toLowerCase().contains("mozilla")) { response.setContentType("application/xml"); } }
From source file:edu.mit.mobile.android.locast.net.NetworkClient.java
/** * @param favoritable/* ww w. jav a2s .c o m*/ * @param newState * @return the newly-set state * @throws NetworkProtocolException * @throws IOException */ public boolean setFavorite(Uri favoritable, boolean newState) throws NetworkProtocolException, IOException { try { final String newStateString = "favorite=" + (newState ? "true" : "false"); final HttpResponse hr = post(MediaProvider.getPublicPath(mContext, favoritable) + "favorite/", newStateString); final JSONObject serverStateObj = toJsonObject(hr); final boolean serverState = serverStateObj.getBoolean("is_favorite"); return serverState; } catch (final IllegalStateException e) { throw new NetworkProtocolException(e.getLocalizedMessage()); } catch (final JSONException e) { throw new NetworkProtocolException(e); } catch (final NoPublicPath e) { final NetworkProtocolException npe = new NetworkProtocolException("no known path to mark favorite"); npe.initCause(e); throw npe; } }
From source file:org.tomahawk.tomahawk_android.services.PlaybackService.java
/** * Returns the position of playback in the current Track. *///from ww w . j av a2s.co m public int getPosition() { int position = 0; if (getCurrentQuery() != null && getCurrentQuery().getMediaPlayerInterface() != null) { try { position = getCurrentQuery().getMediaPlayerInterface().getPosition(); } catch (IllegalStateException e) { Log.e(TAG, "getPosition: " + e.getClass() + ": " + e.getLocalizedMessage()); } } return position; }
From source file:org.tomahawk.tomahawk_android.services.PlaybackService.java
/** * Update the TomahawkMediaPlayer so that it reflects the current playState *//*from www .ja v a 2 s.c om*/ public void handlePlayState() { Log.d(TAG, "handlePlayState"); if (!isPreparing() && getCurrentQuery() != null && getCurrentQuery().getMediaPlayerInterface() != null) { try { switch (mPlayState) { case PLAYBACKSERVICE_PLAYSTATE_PLAYING: if (mWakeLock != null && mWakeLock.isHeld()) { mWakeLock.acquire(); } if (getCurrentQuery().getMediaPlayerInterface().isPrepared(getCurrentQuery())) { if (!getCurrentQuery().getMediaPlayerInterface().isPlaying(getCurrentQuery())) { getCurrentQuery().getMediaPlayerInterface().start(); } } else if (!isPreparing()) { prepareCurrentQuery(); } break; case PLAYBACKSERVICE_PLAYSTATE_PAUSED: if (getCurrentQuery().getMediaPlayerInterface().isPlaying(getCurrentQuery()) && getCurrentQuery().getMediaPlayerInterface().isPrepared(getCurrentQuery())) { InfoSystem.get().sendPlaybackEntryPostStruct( AuthenticatorManager.get().getAuthenticatorUtils(TomahawkApp.PLUGINNAME_HATCHET)); getCurrentQuery().getMediaPlayerInterface().pause(); } if (mWakeLock != null && mWakeLock.isHeld()) { mWakeLock.release(); } break; } } catch (IllegalStateException e1) { Log.e(TAG, "handlePlayState IllegalStateException, msg:" + e1.getLocalizedMessage() + " , preparing=" + isPreparing()); } if (mKillTimerHandler != null) { mKillTimerHandler.removeCallbacksAndMessages(null); Message msg = mKillTimerHandler.obtainMessage(); mKillTimerHandler.sendMessageDelayed(msg, DELAY_TO_KILL); } } else { Log.d(TAG, "handlePlayState couldn't do anything, isPreparing" + isPreparing()); } }
From source file:com.jkoolcloud.tnt4j.streams.inputs.TNTInputStream.java
/** * Starts input stream processing. Implementing {@link Runnable} interface makes it possible to process each stream * in separate thread.//w ww. ja v a 2 s.c o m */ @Override public void run() { notifyStatusChange(StreamStatus.NEW); logger().log(OpLevel.INFO, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "TNTInputStream.starting"), name); if (!isOwned()) { IllegalStateException e = new IllegalStateException(StreamsResources .getString(StreamsResources.RESOURCE_BUNDLE_NAME, "TNTInputStream.no.owner.thread")); notifyFailed(null, e, null); throw e; } try { startStream(); while (!isHalted()) { try { T item = getNextItem(); if (item == null) { logger().log(OpLevel.INFO, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "TNTInputStream.data.stream.ended"), name); if (!isHalted()) { halt(false); // no more data items to process } } else { if (streamExecutorService == null) { processActivityItem(item, failureFlag); } else { streamExecutorService.submit(new ActivityItemProcessingTask(item, failureFlag)); } } } catch (IllegalStateException ise) { logger().log(OpLevel.ERROR, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "TNTInputStream.failed.record.activity.at"), getActivityPosition(), ise.getLocalizedMessage(), ise); failureFlag.set(true); notifyFailed(null, ise, null); halt(false); } catch (Exception exc) { logger().log(OpLevel.ERROR, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "TNTInputStream.failed.record.activity.at"), getActivityPosition(), exc.getLocalizedMessage(), exc); } } } catch (Exception e) { logger().log(OpLevel.ERROR, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "TNTInputStream.failed.record.activity"), e.getLocalizedMessage(), e); failureFlag.set(true); notifyFailed(null, e, null); } finally { shutdownStream(); } }
From source file:csh.cryptonite.Cryptonite.java
public void finishAuthentication() { if (DropboxInterface.INSTANCE.getDBApi() != null && DropboxInterface.INSTANCE.getDBApi().getSession() != null) { if (triedLogin) { AndroidAuthSession session = DropboxInterface.INSTANCE.getDBApi().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. // Make sure we're returning from an authentication attempt at all. triedLogin = false;// w ww . j a v a 2s . c o m if (session.authenticationSuccessful()) { try { // Mandatory call to complete the auth session.finishAuthentication(); // Store it locally in our app for later use storeKeys(session.getOAuth2AccessToken()); DropboxInterface.INSTANCE.clearDBHashMap(); setLoggedIn(true); } catch (IllegalStateException e) { Toast.makeText(Cryptonite.this, getString(R.string.dropbox_auth_fail) + ": " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } else { if (!session.isLinked()) { logOut(); } } } else { mLoggedIn = DropboxInterface.INSTANCE.getDBApi().getSession().isLinked(); } } else { setLoggedIn(false); } }
From source file:mp.teardrop.LibraryActivity.java
@Override public void onResume() { super.onResume(); /* Dropbox API stuff */ AndroidAuthSession session = mApi.getSession(); if (session.authenticationSuccessful()) { try {//from ww w.j a v a 2 s. c o m // Mandatory call to complete the auth session.finishAuthentication(); // Store it locally in our app for later use storeAuth(session); updateUi(true); } catch (IllegalStateException e) { Toast.makeText(this, "Couldn't authenticate with Dropbox:" + e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } } /* end Dropbox API stuff */ }