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

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


    public void createSolrCore(String coreName, ArchiveInputStream coreArchive) throws StoreException {
        if (managedSolrServer.isManagedIndex(coreName)) {
            String msg = String.format("Solr index already exists with name: %s", coreName);
            log.error(msg);
            throw new StoreException(msg);
        }

        try {
            managedSolrServer.createSolrIndex(coreName, coreArchive);
        } catch (IOException e) {
            log.error("", e);
            throw new StoreException(e);
        } catch (SAXException e) {
            String msg = "ManagedSolrServer cannot parse the related XML files.";
            log.error(msg, e);
            throw new StoreException(msg, e);
        }
    }
View Full Code Here


            } catch (InvalidSyntaxException e) {
                String message = e.getMessage();
                if (message == null || message.isEmpty()) {
                    message = "Failed to create a RegisteredSolrServerTracker";
                }
                throw new StoreException(message, e);
            }
            tracker.open();
            solrServer = tracker.getService();
            tracker.close();
            if (solrServer != null || i == SECONDS_TO_WAITFOR_CORE_TO_BEREADY) break;
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // do nothing
            }
        }
        if (solrServer == null) {
            log.error("SolrServer specified by '{}' cannot be retrieved from RegisteredSolrServerTracker",
                coreName);
            throw new StoreException(
                    String.format(
                        "SolrServer specified by '%s' cannot be retrieved from RegisteredSolrServerTracker",
                        coreName));
        }
        return solrServer;
View Full Code Here

            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>();
        Lock l = enhancementGraph.getLock().writeLock();
        l.lock();
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

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.