Java Code Examples for org.restlet.data.Status#SERVER_ERROR_INTERNAL
The following examples show how to use
org.restlet.data.Status#SERVER_ERROR_INTERNAL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestManager.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Locates the RestManager using ThreadLocal SolrRequestInfo. */ public static RestManager getRestManager(SolrRequestInfo solrRequestInfo) { if (solrRequestInfo == null) throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "No SolrRequestInfo in this Thread!"); SolrQueryRequest req = solrRequestInfo.getReq(); RestManager restManager = (req != null) ? req.getCore().getRestManager() : null; if (restManager == null) throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "No RestManager found!"); return restManager; }
Example 2
Source File: FoxbpmStatusService.java From FoxBPM with Apache License 2.0 | 6 votes |
public Status getStatus(Throwable throwable, Request request, Response response) { Status status = null; if (throwable instanceof JsonMappingException && throwable.getCause() != null) { status = getSpecificStatus(throwable.getCause(), request, response); } if (status == null) { Throwable causeThrowable = null; if (throwable.getCause() != null && throwable.getCause() instanceof FoxBPMException) { causeThrowable = throwable.getCause(); } else { causeThrowable = throwable; } status = getSpecificStatus(causeThrowable, request, response); } return status != null ? status : Status.SERVER_ERROR_INTERNAL; }
Example 3
Source File: RestManager.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Returns the {@link ManagedResource} subclass instance corresponding * to the given resourceId from the registry. * * @throws ResourceException if no managed resource is registered with * the given resourceId. */ public ManagedResource getManagedResource(String resourceId) { ManagedResource res = getManagedResourceOrNull(resourceId); if (res == null) { throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "No ManagedResource registered for path: "+resourceId); } return res; }
Example 4
Source File: ManagedResource.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Persists managed data to the configured storage IO as a JSON object. */ public synchronized void storeManagedData(Object managedData) { Map<String,Object> toStore = buildMapToStore(managedData); String resourceId = getResourceId(); try { storage.store(resourceId, toStore); // keep track that the managed data has been updated lastUpdateSinceInitialization = new Date(); } catch (Throwable storeErr) { // store failed, so try to reset the state of this object by reloading // from storage and then failing the store request, but only do that // if we've successfully initialized before if (initializedOn != null) { try { reloadFromStorage(); } catch (Exception reloadExc) { // note: the data we're managing now remains in a dubious state // however the text analysis component remains unaffected // (at least until core reload) log.error("Failed to load data from storage due to: {}", reloadExc); } } String errMsg = String.format(Locale.ROOT, "Failed to store data for %s due to: %s", resourceId, storeErr.toString()); log.error(errMsg, storeErr); throw new ResourceException(Status.SERVER_ERROR_INTERNAL, errMsg, storeErr); } }
Example 5
Source File: ManagedResourceStorage.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public OutputStream openOutputStream(String storedResourceId) throws IOException { final String znodePath = getZnodeForResource(storedResourceId); final boolean retryOnConnLoss = this.retryOnConnLoss; ByteArrayOutputStream baos = new ByteArrayOutputStream() { @Override public void close() { byte[] znodeData = toByteArray(); try { if (zkClient.exists(znodePath, retryOnConnLoss)) { zkClient.setData(znodePath, znodeData, retryOnConnLoss); log.info("Wrote {} bytes to existing znode {}", znodeData.length, znodePath); } else { zkClient.makePath(znodePath, znodeData, retryOnConnLoss); log.info("Wrote {} bytes to new znode {}", znodeData.length, znodePath); } } catch (Exception e) { // have to throw a runtimer here as we're in close, // which doesn't throw IOException if (e instanceof RuntimeException) { throw (RuntimeException)e; } else { throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "Failed to save data to ZooKeeper znode: "+znodePath+" due to: "+e, e); } } } }; return baos; }
Example 6
Source File: ContextResource.java From attic-polygene-java with Apache License 2.0 | 5 votes |
private void result( Object resultValue ) throws Exception { if( resultValue != null ) { if( !responseWriter.writeResponse( resultValue, Response.getCurrent() ) ) { throw new ResourceException( Status.SERVER_ERROR_INTERNAL, "No result writer for type " + resultValue.getClass() .getName() ); } } }
Example 7
Source File: EntitiesResource.java From attic-polygene-java with Apache License 2.0 | 5 votes |
private Representation representRdf() throws ResourceException { try { final Stream<EntityReference> query = entityFinder.findEntities( EntityComposite.class, null, null, null, null, Collections.emptyMap() ); WriterRepresentation representation = new WriterRepresentation( MediaType.APPLICATION_RDF_XML ) { @Override public void write( Writer writer ) throws IOException { PrintWriter out = new PrintWriter( writer ); out.println( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<rdf:RDF\n" + "\txmlns=\"urn:polygene:\"\n" + "\txmlns:polygene=\"http://polygene.apache.org/rdf/model/1.0/\"\n" + "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + "\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">" ); query.forEach( qualifiedIdentity -> out.println( "<polygene:entity rdf:about=\"" + getRequest().getResourceRef().getPath() + "/" + qualifiedIdentity.identity() + ".rdf\"/>" ) ); out.println( "</rdf:RDF>" ); } }; representation.setCharacterSet( CharacterSet.UTF_8 ); return representation; } catch( EntityFinderException e ) { throw new ResourceException( Status.SERVER_ERROR_INTERNAL, e ); } }
Example 8
Source File: OntopiaServerException.java From ontopia with Apache License 2.0 | 4 votes |
public OntopiaServerException(String description, Throwable cause) { super(Status.SERVER_ERROR_INTERNAL, description, cause); }
Example 9
Source File: ResourceException.java From DeviceConnect-Android with MIT License | 2 votes |
/** * Constructor that set the status to * {@link org.restlet.data.Status#SERVER_ERROR_INTERNAL} including the * related error or exception. * * @param cause * The wrapped cause error or exception. */ public ResourceException(Throwable cause) { this(new Status(Status.SERVER_ERROR_INTERNAL, cause), cause); }