Package org.apache.marmotta.platform.core.api.content

Examples of org.apache.marmotta.platform.core.api.content.ContentWriter


            String patternStr  = configurationService.getStringConfiguration("content."+configName+".pattern");
            String enabledStr  = configurationService.getStringConfiguration("content."+configName+".enabled");

            if(Boolean.parseBoolean(enabledStr)) {
                ContentReader reader = null;
                ContentWriter writer = null;
                Pattern pattern = null;
                if(readerClass != null) {
                    for(ContentReader r : readers) {
                        if(r.getClass().getCanonicalName().startsWith(readerClass)) {
                            reader = r;
                            break;
                        }
                    }
                }

                if(writerClass != null) {
                    for(ContentWriter w : writers) {
                        if(w.getClass().getCanonicalName().startsWith(writerClass)) {
                            writer = w;
                            break;
                        }
                    }
                }

                try {
                    pattern = Pattern.compile(patternStr);
                } catch(Exception ex) {
                    log.warn("pattern {} is not a valid regular expression; disabling reader/writer {} (message was {})", patternStr,configName,ex.getMessage());
                    continue;
                }

                if(pattern != null && reader != null) {
                    readerMap.put(pattern,reader);
                    log.info("enabled content reader '{}' for pattern {}",reader.getName(), pattern);
                }
                if(pattern != null && writer != null) {
                    writerMap.put(pattern,writer);
                    log.info("enabled content writer '{}' for pattern {}", writer.getName(), pattern);
                }


            } else {
                log.info("content reader/writer {} disabled",configName);
View Full Code Here


    @Override
    public void setContentData(Resource resource, byte[] data, String mimetype) throws WritingNotSupportedException {
        // iterate over all possible writers; if the pattern matches, try to store the content and return
        for(Pattern p : writerMap.keySet()) {
            if(p.matcher(resource.toString()).matches()) {
                ContentWriter writer = writerMap.get(p);
                log.debug("setting content for resource {} using writer {}",resource,writer.getName());
                try {
                    writer.setContentData(resource, data, mimetype);
                    return;
                } catch(IOException ex) {
                    log.error("could not write content, writer threw an IO Exception",ex);
                    throw new WritingNotSupportedException(ex.getMessage(),ex);
                }
View Full Code Here

    @Override
    public void setContentStream(Resource resource, InputStream in, String mimeType) throws WritingNotSupportedException {
        // iterate over all possible writers; if the pattern matches, try to store the content and return
        for(Pattern p : writerMap.keySet()) {
            if(p.matcher(resource.toString()).matches()) {
                ContentWriter writer = writerMap.get(p);
                log.debug("setting content for resource {} using writer {}",resource,writer.getName());
                try {
                    writer.setContentStream(resource,in,mimeType);
                    return;
                } catch(IOException ex) {
                    log.error("could not write content, writer threw an IO Exception",ex);
                    throw new WritingNotSupportedException(ex.getMessage(),ex);
                }
View Full Code Here

    @Override
    public boolean deleteContent(Resource resource) throws MarmottaException {
        // iterate over all possible writers; if the pattern matches, try to store the content and return
        for(Pattern p : writerMap.keySet()) {
            if(p.matcher(resource.toString()).matches()) {
                ContentWriter writer = writerMap.get(p);
                try {
                    writer.deleteContent(resource,"");
                    return true;
                } catch(IOException ex) {
                    log.error("could not write content, writer threw an IO Exception",ex);
                    throw new WritingNotSupportedException(ex.getMessage(),ex);
                }
View Full Code Here

TOP

Related Classes of org.apache.marmotta.platform.core.api.content.ContentWriter

Copyright © 2018 www.massapicom. 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.