List of usage examples for java.lang IllegalStateException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:org.eclipse.gemini.blueprint.test.internal.util.jar.JarCreator.java
/** * Transform the pattern and rootpath into actual resources. * /* www .j a va 2 s . c om*/ * @return * @throws Exception */ private Resource[][] resolveResources() { ResourcePatternResolver resolver = getPatternResolver(); String[] patterns = getContentPattern(); Resource[][] resources = new Resource[patterns.length][]; // transform Strings into Resources for (int i = 0; i < patterns.length; i++) { StringBuilder buffer = new StringBuilder(rootPath); // do checking on lost slashes if (!rootPath.endsWith(JarUtils.SLASH) && !patterns[i].startsWith(JarUtils.SLASH)) buffer.append(JarUtils.SLASH); buffer.append(patterns[i]); try { resources[i] = resolver.getResources(buffer.toString()); } catch (IOException ex) { IllegalStateException re = new IllegalStateException("cannot resolve pattern " + buffer.toString()); re.initCause(ex); throw re; } } return resources; }
From source file:com.limegroup.gnutella.archive.ArchiveContribution.java
/** * @throws IllegalStateException/* w w w . j a v a 2 s .c om*/ * If java's DOMImplementationLS class is screwed up or * this code is buggy * @param document * @return */ private String serializeDocument(Document document) { try { System.setProperty(DOMImplementationRegistry.PROPERTY, "org.apache.xerces.dom.DOMImplementationSourceImpl"); final DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); final DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS"); final LSSerializer writer = impl.createLSSerializer(); final String str = writer.writeToString(document); return str; } catch (final ClassNotFoundException e) { final IllegalStateException ise = new IllegalStateException(); ise.initCause(e); throw ise; } catch (final InstantiationException e) { final IllegalStateException ise = new IllegalStateException(); ise.initCause(e); throw ise; } catch (final IllegalAccessException e) { final IllegalStateException ise = new IllegalStateException(); ise.initCause(e); throw ise; } }
From source file:com.limegroup.gnutella.archive.ArchiveContribution.java
/** * @throws IllegalStateException/*from w w w . j av a 2 s.c o m*/ * If java's xml configuration is bad * @return */ private Document getFilesDocument() { /* * Sample _files.xml file: * * <files> * <file name="MyHomeMovie.mpeg" source="original"> * <runtime>2:30</runtime> * <format>MPEG2</format> * </file> * </files> * */ final String FILES_ELEMENT = "files"; try { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); final DocumentBuilder db = dbf.newDocumentBuilder(); final Document document = db.newDocument(); final Element filesElement = document.createElement(FILES_ELEMENT); document.appendChild(filesElement); Collection files = getFiles(); for (final Iterator i = files.iterator(); i.hasNext();) { final File file = (File) i.next(); final Element fileElement = file.getElement(document); filesElement.appendChild(fileElement); } return document; } catch (final ParserConfigurationException e) { final IllegalStateException ise = new IllegalStateException(); ise.initCause(e); throw ise; } }
From source file:com.limegroup.gnutella.archive.ArchiveContribution.java
/** * @throws IllegalStateException/*from w ww. jav a 2 s . c om*/ * If java's xml parser configuration is bad */ private Document getMetaDocument() { /* * Sample _meta.xml file: * * <metadata> * <collection>opensource_movies</collection> * <mediatype>movies</mediatype> * <title>My Home Movie</title> * <runtime>2:30</runtime> * <director>Joe Producer</director> * </metadata> * */ final String METADATA_ELEMENT = "metadata"; final String COLLECTION_ELEMENT = "collection"; final String MEDIATYPE_ELEMENT = "mediatype"; final String TITLE_ELEMENT = "title"; final String DESCRIPTION_ELEMENT = "description"; final String LICENSE_URL_ELEMENT = "licenseurl"; final String UPLOAD_APPLICATION_ELEMENT = "upload_application"; final String APPID_ATTR = "appid"; final String APPID_ATTR_VALUE = "LimeWire"; final String VERSION_ATTR = "version"; final String UPLOADER_ELEMENT = "uploader"; final String IDENTIFIER_ELEMENT = "identifier"; final String TYPE_ELEMENT = "type"; try { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); final DocumentBuilder db = dbf.newDocumentBuilder(); final Document document = db.newDocument(); final Element metadataElement = document.createElement(METADATA_ELEMENT); document.appendChild(metadataElement); final Element collectionElement = document.createElement(COLLECTION_ELEMENT); metadataElement.appendChild(collectionElement); collectionElement.appendChild(document.createTextNode(Archives.getCollectionString(getCollection()))); final Element mediatypeElement = document.createElement(MEDIATYPE_ELEMENT); metadataElement.appendChild(mediatypeElement); mediatypeElement.appendChild(document.createTextNode(Archives.getMediaString(getMedia()))); final Element typeElement = document.createElement(TYPE_ELEMENT); metadataElement.appendChild(typeElement); typeElement.appendChild(document.createTextNode(Archives.getTypeString(getType()))); final Element titleElement = document.createElement(TITLE_ELEMENT); metadataElement.appendChild(titleElement); titleElement.appendChild(document.createTextNode(getTitle())); final Element descriptionElement = document.createElement(DESCRIPTION_ELEMENT); metadataElement.appendChild(descriptionElement); descriptionElement.appendChild(document.createTextNode(getDescription())); final Element identifierElement = document.createElement(IDENTIFIER_ELEMENT); metadataElement.appendChild(identifierElement); identifierElement.appendChild(document.createTextNode(getIdentifier())); final Element uploadApplicationElement = document.createElement(UPLOAD_APPLICATION_ELEMENT); metadataElement.appendChild(uploadApplicationElement); uploadApplicationElement.setAttribute(APPID_ATTR, APPID_ATTR_VALUE); uploadApplicationElement.setAttribute(VERSION_ATTR, CommonUtils.getLimeWireVersion()); final Element uploaderElement = document.createElement(UPLOADER_ELEMENT); metadataElement.appendChild(uploaderElement); uploaderElement.appendChild(document.createTextNode(getUsername())); //take licenseurl from the first File final Iterator filesIterator = getFiles().iterator(); if (filesIterator.hasNext()) { final File firstFile = (File) filesIterator.next(); final String licenseUrl = firstFile.getLicenseUrl(); if (licenseUrl != null) { final Element licenseUrlElement = document.createElement(LICENSE_URL_ELEMENT); metadataElement.appendChild(licenseUrlElement); licenseUrlElement.appendChild(document.createTextNode(licenseUrl)); } } // now build user-defined elements final Map userFields = getFields(); for (final Iterator i = userFields.keySet().iterator(); i.hasNext();) { final Object field = i.next(); final Object value = userFields.get(field); if (field instanceof String) { final Element e = document.createElement((String) field); metadataElement.appendChild(e); if (value != null && value instanceof String) { e.appendChild(document.createTextNode((String) value)); } } } return document; } catch (final ParserConfigurationException e) { final IllegalStateException ise = new IllegalStateException(); ise.initCause(e); throw ise; } }
From source file:org.eclipse.gemini.blueprint.test.AbstractOnTheFlyBundleCreatorTests.java
protected void postProcessBundleContext(BundleContext context) throws Exception { logger.debug("Post processing: creating test bundle"); Resource jar;//from www . j a v a 2s. c o m Manifest mf = getManifest(); // if the jar content hasn't been discovered yet (while creating the manifest) // do so now if (jarEntries == null) { // set root path jarCreator.setRootPath(getRootPath()); // add the content pattern jarCreator.setContentPattern(getBundleContentPattern()); // use jar creator for pattern discovery jar = jarCreator.createJar(mf); } // otherwise use the cached resources else { jar = jarCreator.createJar(mf, jarEntries); } try { installAndStartBundle(context, jar); } catch (Exception e) { IllegalStateException ise = new IllegalStateException( "Unable to dynamically start generated unit test bundle"); ise.initCause(e); throw ise; } // now do the delegation super.postProcessBundleContext(context); }
From source file:de.ingrid.ibus.comm.registry.Registry.java
private void joinGroup(String proxyServiceUrl) { if (this.fCommunication == null) { // for tests return;/* ww w .ja va 2 s .c o m*/ } try { WetagURL wetagURL = new WetagURL(proxyServiceUrl); this.fCommunication.subscribeGroup(wetagURL.getGroupPath()); } catch (Exception e) { IllegalStateException exception = new IllegalStateException( "could not join plug group of plug '" + proxyServiceUrl + '\''); exception.initCause(e); throw exception; } }
From source file:de.ingrid.ibus.comm.registry.Registry.java
private void createPlugProxy(PlugDescription plugDescription) { String plugId = plugDescription.getPlugId(); IPlug plugProxy;//from w w w. j a v a 2s . co m try { plugProxy = this.fProxyFactory.createPlugProxy(plugDescription, this.fBusUrl); synchronized (this.fPlugProxyByPlugId) { this.fPlugProxyByPlugId.put(plugDescription.getPlugId(), plugProxy); } synchronized (this.iPlugsNotUsingCentralIndex) { Object useRemoteElasticsearch = plugDescription.get("useRemoteElasticsearch"); if (useRemoteElasticsearch == null || !((boolean) useRemoteElasticsearch)) { this.iPlugsNotUsingCentralIndex.add(plugDescription.getPlugId()); } } } catch (Exception e) { if (fLogger.isErrorEnabled()) { fLogger.error("(REMOVING IPLUG '" + plugId + "' !): could not create proxy object: ", e); } removePlug(plugId); closeConnectionToIplug(plugDescription); IllegalStateException iste = new IllegalStateException( "plug with id '" + plugId + "' currently not available"); iste.initCause(e); throw iste; } // establish connection try { fLogger.info("establish connection [" + plugId + "] ..."); plugProxy.toString(); fLogger.info("... success [" + plugId + "]"); } catch (Exception e) { fLogger.error("... fails [" + plugId + "]", e); } }
From source file:org.hdiv.webflow.mvc.servlet.ServletMvcViewHDIV.java
@Override public void render() throws IOException { Map model = new HashMap(); model.putAll(flowScopes());/*from w w w . ja va 2s .c o m*/ exposeBindingModel(model); model.put("flowRequestContext", requestContext); FlowExecutionKey key = requestContext.getFlowExecutionContext().getKey(); if (key != null) { model.put("flowExecutionKey", requestContext.getFlowExecutionContext().getKey().toString()); model.put("flowExecutionUrl", requestContext.getFlowExecutionUrl()); } model.put("currentUser", requestContext.getExternalContext().getCurrentUser()); try { if (logger.isDebugEnabled()) { logger.debug("Rendering MVC [" + view + "] with model map [" + model + "]"); } doRender(model); } catch (IOException e) { throw e; } catch (Exception e) { IllegalStateException ise = new IllegalStateException("Exception occurred rendering view " + view); ise.initCause(e); throw ise; } }
From source file:org.apache.activemq.jms.pool.PooledSession.java
@Override public void close() throws JMSException { if (ignoreClose) { return;/* w ww . j a v a 2 s. c o m*/ } if (closed.compareAndSet(false, true)) { boolean invalidate = false; try { // lets reset the session getInternalSession().setMessageListener(null); // Close any consumers and browsers that may have been created. for (Iterator<MessageConsumer> iter = consumers.iterator(); iter.hasNext();) { MessageConsumer consumer = iter.next(); consumer.close(); } for (Iterator<QueueBrowser> iter = browsers.iterator(); iter.hasNext();) { QueueBrowser browser = iter.next(); browser.close(); } if (transactional && !isXa) { try { getInternalSession().rollback(); } catch (JMSException e) { invalidate = true; LOG.warn( "Caught exception trying rollback() when putting session back into the pool, will invalidate. " + e, e); } } } catch (JMSException ex) { invalidate = true; LOG.warn( "Caught exception trying close() when putting session back into the pool, will invalidate. " + ex, ex); } finally { consumers.clear(); browsers.clear(); for (PooledSessionEventListener listener : this.sessionEventListeners) { listener.onSessionClosed(this); } sessionEventListeners.clear(); } if (invalidate) { // lets close the session and not put the session back into the pool // instead invalidate it so the pool can create a new one on demand. if (sessionHolder != null) { try { sessionHolder.close(); } catch (JMSException e1) { LOG.trace("Ignoring exception on close as discarding session: " + e1, e1); } } try { sessionPool.invalidateObject(key, sessionHolder); } catch (Exception e) { LOG.trace("Ignoring exception on invalidateObject as discarding session: " + e, e); } } else { try { sessionPool.returnObject(key, sessionHolder); } catch (Exception e) { javax.jms.IllegalStateException illegalStateException = new javax.jms.IllegalStateException( e.toString()); illegalStateException.initCause(e); throw illegalStateException; } } sessionHolder = null; } }
From source file:org.apache.aries.transaction.jms.internal.PooledSession.java
@Override public void close() throws JMSException { if (!ignoreClose) { boolean invalidate = false; try {//from w w w. j a va 2 s . c om // lets reset the session getInternalSession().setMessageListener(null); // Close any consumers and browsers that may have been created. for (Iterator<MessageConsumer> iter = consumers.iterator(); iter.hasNext();) { MessageConsumer consumer = iter.next(); consumer.close(); } for (Iterator<QueueBrowser> iter = browsers.iterator(); iter.hasNext();) { QueueBrowser browser = iter.next(); browser.close(); } if (transactional && !isXa) { try { getInternalSession().rollback(); } catch (JMSException e) { invalidate = true; LOG.warn( "Caught exception trying rollback() when putting session back into the pool, will invalidate. " + e, e); } } } catch (JMSException ex) { invalidate = true; LOG.warn( "Caught exception trying close() when putting session back into the pool, will invalidate. " + ex, ex); } finally { consumers.clear(); browsers.clear(); for (PooledSessionEventListener listener : this.sessionEventListeners) { listener.onSessionClosed(this); } sessionEventListeners.clear(); } if (invalidate) { // lets close the session and not put the session back into the pool // instead invalidate it so the pool can create a new one on demand. if (session != null) { try { session.close(); } catch (JMSException e1) { LOG.trace("Ignoring exception on close as discarding session: " + e1, e1); } session = null; } try { sessionPool.invalidateObject(key, this); } catch (Exception e) { LOG.trace("Ignoring exception on invalidateObject as discarding session: " + e, e); } } else { try { sessionPool.returnObject(key, this); } catch (Exception e) { javax.jms.IllegalStateException illegalStateException = new javax.jms.IllegalStateException( e.toString()); illegalStateException.initCause(e); throw illegalStateException; } } } }