/** * Constructor. By default, it creates the necessary services. * * @param enabled * True if the service has been enabled. * */ public StatusService(boolean enabled) { this(enabled, new ConverterService(), new MetadataService(), new ConnegService()); // this.homeRef = new Reference("/"); }
/** * Returns the application's metadata service or create a new one. * * @return The metadata service. */ public MetadataService getMetadataService() { MetadataService result = null; result = getApplication().getMetadataService(); if (result == null) { result = new MetadataService(); } return result; }
public static String convertSampleAccordingToMediaType( Object content, String mediaTypeAsString, String representationName) { MetadataService ms = new MetadataService(); MediaType mediaType = MediaType.valueOf(mediaTypeAsString); if (!supportedExtensions.contains(ms.getExtension(mediaType))) { return null; } String text; try { text = new JacksonRepresentation<>(mediaType, content).getText(); } catch (IOException e) { throw new RuntimeException(e); } if (ms.getAllMediaTypes("xml").contains(mediaType)) { text = text.replaceAll("HashMap", representationName); } return text; }
public static String convertSampleAccordingToMediaType( Object content, String mediaTypeAsString, String representationName) { MetadataService ms = new MetadataService(); MediaType mediaType = MediaType.valueOf(mediaTypeAsString); if (!supportedExtensions.contains(ms.getExtension(mediaType))) { return null; } String text; try { text = new JacksonRepresentation<>(mediaType, content).getText(); } catch (IOException e) { throw new RuntimeException(e); } if (ms.getAllMediaTypes("xml").contains(mediaType)) { text = text.replaceAll("HashMap", representationName); } return text; }
public static String convertSampleAccordingToMediaType( Object content, String mediaTypeAsString, String representationName) { MetadataService ms = new MetadataService(); MediaType mediaType = MediaType.valueOf(mediaTypeAsString); if (!supportedExtensions.contains(ms.getExtension(mediaType))) { return null; } String text; try { text = new JacksonRepresentation<>(mediaType, content).getText(); } catch (IOException e) { throw new RuntimeException(e); } if (ms.getAllMediaTypes("xml").contains(mediaType)) { text = text.replaceAll("HashMap", representationName); } return text; }
public static String convertSampleAccordingToMediaType( Object content, String mediaTypeAsString, String representationName) { MetadataService ms = new MetadataService(); MediaType mediaType = MediaType.valueOf(mediaTypeAsString); if (!supportedExtensions.contains(ms.getExtension(mediaType))) { return null; } String text; try { text = new JacksonRepresentation<>(mediaType, content).getText(); } catch (IOException e) { throw new RuntimeException(e); } if (ms.getAllMediaTypes("xml").contains(mediaType)) { text = text.replaceAll("HashMap", representationName); } return text; }
public static String convertSampleAccordingToMediaType( Object content, String mediaTypeAsString, String representationName) { MetadataService ms = new MetadataService(); MediaType mediaType = MediaType.valueOf(mediaTypeAsString); if (!supportedExtensions.contains(ms.getExtension(mediaType))) { return null; } String text; try { text = new JacksonRepresentation<>(mediaType, content).getText(); } catch (IOException e) { throw new RuntimeException(e); } if (ms.getAllMediaTypes("xml").contains(mediaType)) { text = text.replaceAll("HashMap", representationName); } return text; }
@Override protected Application newApplicationInstance( ApplicationDescriptor applicationModel ) { return applicationModel.newInstance( polygene.api(), new MetadataService() ); }
/** * Returns the metadata service. If the parent application doesn't exist, a * new instance is created. * * @return The metadata service. */ public MetadataService getMetadataService() { MetadataService result = null; if (getHelped() != null) { org.restlet.Application application = getHelped().getApplication(); if (application != null) { result = application.getMetadataService(); } } if (result == null) { result = new MetadataService(); } return result; }
@Override protected Application newApplicationInstance( ApplicationDescriptor applicationModel ) { return applicationModel.newInstance( polygene.api(), new MetadataService() ); }
metadataService = new MetadataService(); } else { connegService = app.getConnegService();
/** * Constructor. * * @param context * The context to use based on parent component context. This * context should be created using the * {@link Context#createChildContext()} method to ensure a proper * isolation with the other applications. */ @SuppressWarnings("deprecation") public Application(Context context) { super(context); if (Engine.getInstance() != null) { this.helper = Engine.getInstance().createHelper(this); } this.name = null; this.description = null; this.author = null; this.owner = null; this.root = null; this.connectorService = new ConnectorService(); this.converterService = new org.restlet.service.ConverterService(); this.decoderService = new DecoderService(); this.metadataService = new MetadataService(); this.rangeService = new RangeService(); this.statusService = new StatusService(); this.taskService = new TaskService(); this.tunnelService = new TunnelService(true, true); }
public static void main( String[] args ) throws Exception { Energy4Java polygene = new Energy4Java( ); Server server = new Server( Protocol.HTTP, 8888 ); Application app = polygene.newApplication( new ForumAssembler(), new MetadataService() ); app.activate(); ContextRestlet restlet = app.findModule( "REST", "Restlet" ).newObject( ContextRestlet.class, new org.restlet.Context() ); ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm"); MapVerifier mapVerifier = new MapVerifier(); mapVerifier.getLocalSecrets().put("rickard", "secret".toCharArray()); guard.setVerifier(mapVerifier); guard.setNext(restlet); server.setNext( restlet ); server.start(); } }
MetadataService metadataService = new MetadataService();