Examples of MetadataService


Examples of org.restlet.service.MetadataService

            this.extensionLanguage = null;
            this.extensionMedia = null;
            this.extensionOthers = null;
            return this;
        }
        MetadataService metadataService;
        metadataService = Application.getCurrent().getMetadataService();
        StringTokenizer stt = new StringTokenizer(extensions, ".");
        while (stt.hasMoreTokens()) {
            String extension = stt.nextToken();
            Metadata metadata = metadataService.getMetadata(extension);
            if (metadata instanceof Language) {
                this.extensionLanguage = extension;
            } else if (metadata instanceof MediaType) {
                this.extensionMedia = extension;
            } else {
View Full Code Here

Examples of org.restlet.service.MetadataService

     * 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;
    }
View Full Code Here

Examples of org.restlet.service.MetadataService

     *            The server resource to describe.
     */
    public static void describeAnnotations(MethodInfo info,
            ServerResource resource) {
        // Loop over the annotated Java methods
        MetadataService metadataService = resource.getMetadataService();
        List<AnnotationInfo> annotations = resource.isAnnotated() ? AnnotationUtils
                .getAnnotations(resource.getClass()) : null;

        if (annotations != null && metadataService != null) {
            for (AnnotationInfo annotationInfo : annotations) {
View Full Code Here

Examples of org.restlet.service.MetadataService

         String u = target.feed.toString();
         if (u.charAt(u.length()-1)!='/') {
            u += "/";
         }
         final String feedBase = u;
         final MetadataService metadataService = new MetadataService();
         target.dir.listFiles(new FileFilter() {
            public boolean accept(File file) {
               if (file.isDirectory()) {
                  URI subFeed = URI.create(feedBase+file.getName()+"/");
                  targets.add(new Target(file,subFeed));
               } else {
                  if (!excludeDot || file.getName().charAt(0)!='.') {
                     // Sync content
                     Entry entry = entries.get(file.getName());
                     Status status = null;
                     if (entry!=null) {
                        log.info("Updating "+file);
                        // update existing media
                        try {
                           FileInputStream is = new FileInputStream(file);
                           EntryClient client = feedClient.getEntryClient(entry);
                           status = client.updateMedia(new InputRepresentation(is,entry.getMediaContent().getMediaType()));
                           is.close();
                        } catch (IOException ex) {
                           log.log(Level.SEVERE,"Cannot update "+file+" due to I/O exception.",ex);
                        }
                        entries.remove(file.getName());
                     } else {
                        log.info("Creating "+file);
                        // create new media
                        try {
                           FileInputStream is = new FileInputStream(file);
                           int extPos = file.getName().lastIndexOf('.');
                           String ext = extPos<0 ? null : file.getName().substring(extPos+1);
                           Metadata metadata = ext==null ? null : metadataService.getMetadata(ext);
                           MediaType type = metadata==null ? MediaType.APPLICATION_OCTET_STREAM : MediaType.valueOf(metadata.getName());
                           Entry mediaEntry = feedClient.createMedia(file.getName(),new InputRepresentation(is,type));
                           is.close();
                        } catch (StatusException ex) {
                           log.log(Level.SEVERE,"Cannot create media entry from "+file+" due to status "+ex.getStatus().getCode(),ex);
View Full Code Here

Examples of org.restlet.service.MetadataService

    {
        Energy4Java is = new Energy4Java(  );

        Server server = new Server( Protocol.HTTP, 8888 );

        Application app = is.newApplication( new ForumAssembler(), new MetadataService() );

        app.activate();

        ContextRestlet restlet = app.findModule( "REST", "Restlet" ).newObject( ContextRestlet.class, new org.restlet.Context() );
View Full Code Here

Examples of org.restlet.service.MetadataService

    }

    @Override
    protected Application newApplicationInstance( ApplicationDescriptor applicationModel )
    {
        return applicationModel.newInstance( qi4j.api(), new MetadataService() );
    }
View Full Code Here

Examples of org.restlet.service.MetadataService

            if( idx != -1 )
            {
                extensions = extensions.substring( idx + 1 );
            }

            MetadataService metadataService = getApplication().getMetadataService();
            Metadata metadata = metadataService.getMetadata( extensions );
            if( metadata != null && metadata instanceof MediaType )
            {
                request.getClientInfo()
                    .setAcceptedMediaTypes( Collections.singletonList( new Preference<MediaType>( (MediaType) metadata ) ) );
                String path = request.getResourceRef().getPath();
View Full Code Here

Examples of org.restlet.service.MetadataService

            if( idx != -1 )
            {
                extensions = extensions.substring( idx + 1 );
            }

            MetadataService metadataService = getApplication().getMetadataService();
            Metadata metadata = metadataService.getMetadata( extensions );
            if( metadata != null && metadata instanceof MediaType )
            {
                request.getClientInfo()
                    .setAcceptedMediaTypes( Collections.singletonList( new Preference<MediaType>( (MediaType) metadata ) ) );
                String path = request.getResourceRef().getPath();
View Full Code Here

Examples of org.restlet.service.MetadataService

    }

    @Override
    protected Application newApplicationInstance( ApplicationDescriptor applicationModel )
    {
        return applicationModel.newInstance( qi4j.api(), new MetadataService() );
    }
View Full Code Here

Examples of org.restlet.service.MetadataService

     * @param response
     *            The response to update.
     */
    protected void handleClassLoader(Request request, Response response,
            ClassLoader classLoader) {
        MetadataService metadataService = getMetadataService(request);

        if (request.getMethod().equals(Method.GET)
                || request.getMethod().equals(Method.HEAD)) {
            String path = request.getResourceRef().getPath();

            // Prepare a classloader URI, removing the leading slash
            if ((path != null) && path.startsWith("/"))
                path = path.substring(1);
            // As the path may be percent-encoded, it has to be percent-decoded.
            URL url = classLoader.getResource(Reference.decode(path));

            // The ClassLoader returns a directory listing in some cases.
            // As this listing is partial, it is of little value in the context
            // of the CLAP client, so we have to ignore them.
            if (url != null) {
                if (url.getProtocol().equals("file")) {
                    File file = new File(url.getFile());
                    if (file.isDirectory()) {
                        url = null;
                    }
                }
            }

            if (url != null) {
                try {
                    Representation output = new InputRepresentation(url
                            .openStream(), metadataService
                            .getDefaultMediaType());
                    output.setIdentifier(request.getResourceRef());

                    // Update the metadata based on file extensions
                    String name = path.substring(path.lastIndexOf('/') + 1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.