org.restlet.ext.jackson.JacksonRepresentation Java Examples
The following examples show how to use
org.restlet.ext.jackson.JacksonRepresentation.
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: SwaggerResource.java From geowave with Apache License 2.0 | 6 votes |
/** This resource returns the swagger.json */ @Get("json") public String listResources() { final ServletContext servlet = (ServletContext) getContext().getAttributes().get("org.restlet.ext.servlet.ServletContext"); final String realPath = servlet.getRealPath("/"); final JacksonRepresentation<ApiDeclaration> result = new JacksonRepresentation<>( new FileRepresentation(realPath + "swagger.json", MediaType.APPLICATION_JSON), ApiDeclaration.class); try { return result.getText(); } catch (final IOException e) { LOGGER.warn("Error building swagger json", e); } return "Not Found: swagger.json"; }
Example #2
Source File: PostBDMEventHandler.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void execute(final Event event) { final String fileContent = (String) event.getProperty(FILE_CONTENT); Map<String, String> content = new HashMap<>(); content.put("bdmXml", fileContent); try { new ClientResource(String.format("http://%s:%s/bdm", InetAddress.getByName(null).getHostAddress(), InstanceScope.INSTANCE.getNode(BonitaStudioPreferencesPlugin.PLUGIN_ID) .get(BonitaPreferenceConstants.DATA_REPOSITORY_PORT, "-1"))) .post(new JacksonRepresentation<Object>(content)); BonitaStudioLog.info("BDM has been publish into Data Repository service", UIDesignerPlugin.PLUGIN_ID); } catch (ResourceException | UnknownHostException e) { BonitaStudioLog.error("An error occured while publishing the BDM into Data Repository service", e); } }
Example #3
Source File: CreateFormFromContractOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(Messages.creatingNewForm, IProgressMonitor.UNKNOWN); try { setArtifactName(getNewName()); URL url = pageDesignerURLBuilder.newPageFromContract(formScope, artifactName); Pool parentPool = new ModelSearch(Collections::emptyList).getDirectParentOfType(contract, Pool.class); BusinessDataStore businessDataStore = new BusinessDataStore(parentPool, getRepositoryAccessor()); ContractToBusinessDataResolver contractToBusinessDataResolver = new ContractToBusinessDataResolver( businessDataStore); Contract tmpContract = EcoreUtil.copy(contract); // will contains unwanted contractInput for readOnly attributes openReadOnlyAttributeDialog(tmpContract, businessDataStore); TreeResult treeResult = contractToBusinessDataResolver.resolve(tmpContract, buildReadOnlyAttributes); Representation body = new JacksonRepresentation<>(new ToWebContract(treeResult).apply(tmpContract)); responseObject = createArtifact(url, body); } catch (MalformedURLException e) { throw new InvocationTargetException(e, "Failed to create new form url."); } }
Example #4
Source File: RestApiServer.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
public void run(FloodlightModuleContext fmlContext, String restHost, int restPort) { setStatusService(new StatusService() { @Override public Representation getRepresentation(Status status, Request request, Response response) { return new JacksonRepresentation<Status>(status); } }); // Add everything in the module context to the rest for (Class<? extends IFloodlightService> s : fmlContext.getAllServices()) { if (logger.isTraceEnabled()) { logger.trace("Adding {} for service {} into context", s.getCanonicalName(), fmlContext.getServiceImpl(s)); } context.getAttributes().put(s.getCanonicalName(), fmlContext.getServiceImpl(s)); } // Start listening for REST requests try { final Component component = new Component(); if (restHost == null) { component.getServers().add(Protocol.HTTP, restPort); } else { component.getServers().add(Protocol.HTTP, restHost, restPort); } component.getClients().add(Protocol.CLAP); component.getDefaultHost().attach(this); component.start(); } catch (Exception e) { throw new RuntimeException(e); } }
Example #5
Source File: JacksonCustomConverter.java From microservices-comparison with Apache License 2.0 | 5 votes |
@Override protected <T> JacksonRepresentation<T> create(MediaType mediaType, T source) { ObjectMapper mapper = createMapper(); JacksonRepresentation<T> jr = new JacksonRepresentation<>(mediaType, source); jr.setObjectMapper(mapper); return jr; }
Example #6
Source File: JacksonCustomConverter.java From microservices-comparison with Apache License 2.0 | 5 votes |
@Override protected <T> JacksonRepresentation<T> create(Representation source, Class<T> objectClass) { ObjectMapper mapper = createMapper(); JacksonRepresentation<T> jr = new JacksonRepresentation<>(source, objectClass); jr.setObjectMapper(mapper); return jr; }
Example #7
Source File: OntopiaStatusService.java From ontopia with Apache License 2.0 | 5 votes |
@Override public Representation getRepresentation(Status status, Request request, Response response) { //if (status.isClientError()) { return new JacksonRepresentation<>(new Error(status)); //} //return null; }
Example #8
Source File: FoxbpmStatusService.java From FoxBPM with Apache License 2.0 | 5 votes |
public Representation getRepresentation(Status status, Request request, Response response) { if (status != null && status.isError()) { RestError error = new RestError(); error.setStatusCode(status.getCode()); error.setErrorMessage(status.getDescription()); return new JacksonRepresentation<RestError>(error); } else { return super.getRepresentation(status, request, response); } }
Example #9
Source File: FoxbpmConverService.java From FoxBPM with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") public Representation toRepresentation(Object source, Variant target, UniformResource resource) { Representation representation = super.toRepresentation(source, target, resource); if(representation instanceof JacksonRepresentation){ ((JacksonRepresentation)representation).getObjectMapper().setDateFormat(df); } return representation; }
Example #10
Source File: AsyncOperationStatusResource.java From geowave with Apache License 2.0 | 5 votes |
@Get("json") public Representation getStatus(final Representation request) { final RestOperationStatusMessage status = new RestOperationStatusMessage(); ConcurrentHashMap<String, Future<?>> opStatuses = null; final String id = getQueryValue("id"); try { // look up the operation status opStatuses = (ConcurrentHashMap<String, Future<?>>) getApplication().getContext().getAttributes().get( "asyncOperationStatuses"); if (opStatuses.get(id) != null) { final Future<?> future = opStatuses.get(id); if (future.isDone()) { status.status = RestOperationStatusMessage.StatusType.COMPLETE; status.message = "operation success"; status.data = future.get(); opStatuses.remove(id); } else { status.status = RestOperationStatusMessage.StatusType.RUNNING; } return new JacksonRepresentation<>(status); } } catch (final Exception e) { LOGGER.error("Error exception: ", e); status.status = RestOperationStatusMessage.StatusType.ERROR; status.message = "exception occurred"; status.data = e; if (opStatuses != null) { opStatuses.remove(id); } return new JacksonRepresentation<>(status); } status.status = RestOperationStatusMessage.StatusType.ERROR; status.message = "no operation found for ID: " + id; return new JacksonRepresentation<>(status); }
Example #11
Source File: JacksonConverterImpl.java From ontopia with Apache License 2.0 | 4 votes |
@Override protected <T> JacksonRepresentation<T> create(MediaType mediaType, T source) { return new JacksonRepresentationImpl<>(mediaType, source); }
Example #12
Source File: JacksonConverterImpl.java From ontopia with Apache License 2.0 | 4 votes |
@Override protected <T> JacksonRepresentation<T> create(Representation source, Class<T> objectClass) { return new JacksonRepresentationImpl<>(source, objectClass); }