Package org.apache.stanbol.enhancer.servicesapi

Examples of org.apache.stanbol.enhancer.servicesapi.ContentItemFactory


                }
            } catch (FileUploadException e) {
                throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
            }
        } else { //normal content
            ContentItemFactory ciFactory = getContentItemFactory();
            contentItem = ciFactory.createContentItem(contentItemId,
                new StreamSource(entityStream, mediaType.toString()));
            //add the URI of the main content
            parsedContentIds.add(contentItem.getPartUri(0).getUnicodeString());
        }
        //set the parsed contentIDs to the EnhancementProperties
View Full Code Here


     * encoded Multipoart MIME
     */
    private ContentItem createContentItem(UriRef id, MGraph metadata, FileItemStream content,Set<String> parsedContentParts) throws IOException, FileUploadException {
        MediaType partContentType = MediaType.valueOf(content.getContentType());
        ContentItem contentItem = null;
        ContentItemFactory ciFactory = getContentItemFactory();
        if(MULTIPART.isCompatible(partContentType)){
            //multiple contentParts are parsed
            FileItemIterator contentPartIterator = fu.getItemIterator(
                new MessageBodyReaderContext(
                    content.openStream(), partContentType));
            while(contentPartIterator.hasNext()){
                FileItemStream fis = contentPartIterator.next();
                if(contentItem == null){
                    log.debug("create ContentItem {} for content (type:{})",
                        id,content.getContentType());
                    contentItem = ciFactory.createContentItem(id,
                        new StreamSource(fis.openStream(),fis.getContentType()),
                        metadata);
                } else {
                    Blob blob = ciFactory.createBlob(new StreamSource(fis.openStream(), fis.getContentType()));
                    UriRef contentPartId = null;
                    if(fis.getFieldName() != null && !fis.getFieldName().isEmpty()){
                        contentPartId = new UriRef(fis.getFieldName());
                    } else {
                        //generating a random ID might break metadata
                        //TODO maybe we should throw an exception instead
                        contentPartId = new UriRef("urn:contentpart:"+ randomUUID());
                    }
                    log.debug("  ... add Blob {} to ContentItem {} with content (type:{})",
                        new Object[]{contentPartId, id, fis.getContentType()});
                    contentItem.addPart(contentPartId, blob);
                    parsedContentParts.add(contentPartId.getUnicodeString());
                }
            }
        } else {
            log.debug("create ContentItem {} for content (type:{})",
                id,content.getContentType());
            contentItem = ciFactory.createContentItem(id,
                new StreamSource(content.openStream(),content.getContentType()),
                metadata);
        }
        //add the URI of the main content to the parsed contentParts
        parsedContentParts.add(contentItem.getPartUri(0).getUnicodeString());
View Full Code Here

TOP

Related Classes of org.apache.stanbol.enhancer.servicesapi.ContentItemFactory

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.