Package org.apache.stanbol.contenthub.servicesapi.store

Examples of org.apache.stanbol.contenthub.servicesapi.store.StoreException


            enhancementGraph = tcManager.createMGraph(graphUri);
            registerEnhancementGraph(graphUri, enhancementGraph);

        } catch (InvalidSyntaxException e) {
            log.error("Failed to get ServiceReference for TripleCollection");
            throw new StoreException("Failed to get ServiceReference for TripleCollection", e);
        }
    }
View Full Code Here


        ContentItem ci = null;
        try {
            ci = ciFactory.createContentItem(uri, new ByteArraySource(content, contentType), g);
        } catch (IOException e) {
            log.error("Failed to create contentitem with uri: {}", uri.getUnicodeString());
            throw new StoreException(String.format("Failed to create contentitem with uri: %s",
                uri.getUnicodeString()));
        }
        if (title != null && !title.trim().isEmpty()) {
            ci.addPart(TITLE_URI, title.trim());
        }
View Full Code Here

            } else {
                Chain chain = chainManager.getChain(chainName.trim());
                if (chain == null) {
                    String msg = String.format("Failed to get chain with name: %s", chainName);
                    log.error(msg);
                    throw new StoreException(msg);
                }
                jobManager.enhanceContent(ci, chain);
            }
        } catch (EnhancementException e) {
            String msg = String.format("Cannot enhance content with id: %s", ci.getUri().getUnicodeString());
            log.error(msg, e);
            throw new StoreException(msg, e);
        }
    }
View Full Code Here

        try {
            selectQuery = (SelectQuery) QueryParser.getInstance().parse(enhancementQuery);
        } catch (ParseException e) {
            String msg = "Cannot parse the SPARQL while trying to delete the enhancements of the ContentItem";
            log.error(msg, e);
            throw new StoreException(msg, e);
        }

        List<Triple> willBeRemoved = new ArrayList<Triple>();
        ResultSet resultSet = tcManager.executeSparqlQuery(selectQuery, enhancementGraph);
        while (resultSet.hasNext()) {
View Full Code Here

            solrServer.add(doc);
            solrServer.commit();
            log.debug("Documents are committed to Solr Server successfully.");
        } catch (SolrServerException e) {
            log.error("Solr Server Exception", e);
            throw new StoreException(e.getMessage(), e);
        } catch (IOException e) {
            log.error("IOException", e);
            throw new StoreException(e.getMessage(), e);
        }
        return ci.getUri().getUnicodeString();
    }
View Full Code Here

            try {
                content = ContentItemHelper.getText(contentPart.getValue());
            } catch (IOException ex) {
                String msg = "Cannot read the stream of the ContentItem.";
                log.error(msg, ex);
                throw new StoreException(msg, ex);
            }
        }
        InputStream binaryContent = ci.getStream();

        if (content.equals("") && binaryContent == null) {
            throw new StoreException("No textual or binary content for the ContentItem");
        }

        try {
            doc.addField(SolrFieldName.CONTENT.toString(), content);
            doc.addField(SolrFieldName.BINARYCONTENT.toString(), IOUtils.toByteArray(binaryContent));
        } catch (IOException e) {
            throw new StoreException("Failed to get bytes of conten item stream", e);
        }

        doc.addField(SolrFieldName.ID.toString(), ci.getUri().getUnicodeString());
        doc.addField(SolrFieldName.MIMETYPE.toString(), ci.getMimeType());
View Full Code Here

                log.warn("No matching item in Solr for the given id {}.", id);
                return null;
            }
        } catch (SolrServerException ex) {
            log.error("", ex);
            throw new StoreException(ex.getMessage(), ex);
        }

        String enhancementQuery = QueryGenerator.getEnhancementsOfContent(id);
        SelectQuery selectQuery = null;
        try {
            selectQuery = (SelectQuery) QueryParser.getInstance().parse(enhancementQuery);
        } catch (ParseException e) {
            String msg = "Cannot parse the SPARQL while trying to retrieve the enhancements of the ContentItem";
            log.error(msg, e);
            throw new StoreException(msg, e);
        }

        ResultSet resultSet = tcManager.executeSparqlQuery(selectQuery, this.getEnhancementGraph());
        MGraph metadata = new IndexedMGraph();
        while (resultSet.hasNext()) {
            SolutionMapping mapping = resultSet.next();
            UriRef ref = (UriRef) mapping.get("enhID");
            Iterator<Triple> tripleItr = this.getEnhancementGraph().filter(ref, null, null);
            while (tripleItr.hasNext()) {
                Triple triple = tripleItr.next();
                metadata.add(triple);
            }
        }
        ContentItem ci = null;
        try {
            ci = ciFactory
                    .createContentItem(new UriRef(id), new ByteArraySource(content, mimeType), metadata);
        } catch (IOException e) {
            log.error("Failed to create contentitem with uri: {}", id);
            throw new StoreException(String.format("Failed to create contentitem with uri: %s", id));
        }
        return ci;
    }
View Full Code Here

        try {
            solrServer.deleteById(id);
            solrServer.commit();
        } catch (SolrServerException e) {
            log.error("Solr Server Exception", e);
            throw new StoreException(e.getMessage(), e);
        } catch (IOException e) {
            log.error("IOException", e);
            throw new StoreException(e.getMessage(), e);
        }
    }
View Full Code Here

        try {
            solrServer.deleteById(idList);
            solrServer.commit();
        } catch (SolrServerException e) {
            log.error("Solr Server Exception", e);
            throw new StoreException(e.getMessage(), e);
        } catch (IOException e) {
            log.error("IOException", e);
            throw new StoreException(e.getMessage(), e);
        }
    }
View Full Code Here

                    managedSolrServer.createSolrIndex(CONTENTHUB_DEFAULT_INDEX_NAME,
                        CONTENTHUB_DEFAULT_INDEX_NAME, null);
                } catch (IOException e) {
                    String msg = "Error while creating default solr index";
                    log.error(msg, e);
                    throw new StoreException(msg, e);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.contenthub.servicesapi.store.StoreException

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.