Package org.openrdf.repository

Examples of org.openrdf.repository.RepositoryConnection.begin()


    @GET
    public Response getContentRemote(@QueryParam("uri") @NotNull String uri) throws UnsupportedEncodingException {
        try {
            final RepositoryConnection conn = sesameService.getConnection();
            try {
                conn.begin();
                URI resource = conn.getValueFactory().createURI(uri);
                conn.commit();
                final String mimeType = contentService.getContentType(resource);
                if (mimeType != null) {
                    return Response
View Full Code Here


    @DELETE
    public Response deleteContentRemote(@QueryParam("uri") @NotNull String uri) throws UnsupportedEncodingException {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                conn.begin();
                Resource resource = conn.getValueFactory().createURI(uri);
                if (resource != null) {
                    if (contentService.deleteContent(resource)) return Response.ok().build();
                    else
                        return ResourceWebServiceHelper.buildErrorPage(uri, configurationService.getBaseUri(), Response.Status.NOT_FOUND, "no content found for this resource in LMF right now, but may be available again in the future", configurationService, templatingService);
View Full Code Here

        try {
            // FIXME String appendix = uuid == null ? "?uri=" + URLEncoder.encode(uri, "utf-8") :
            // "/" + uuid;
            final RepositoryConnection conn = sesameService.getConnection();
            try {
                conn.begin();
                URI resource = conn.getValueFactory().createURI(uri);
                conn.commit();
                if (mimetype == null) {
                    mimetype = contentService.getContentType(resource);
                }
View Full Code Here

    public Response putContent(String uri, String mimetype, HttpServletRequest request) {
        try {
            final RepositoryConnection conn = sesameService.getConnection();
            try {
                conn.begin();
                URI resource = conn.getValueFactory().createURI(uri);
                conn.commit();
                return putContent(resource, mimetype, request);
            } finally {
                conn.close();
View Full Code Here

        String uriArticle = "http://en.wikipedia.org/wiki/Marmot";
        ClientResponse respArticle = ldclient.retrieveResource(uriArticle);

        RepositoryConnection conArticle = respArticle.getTriples().getConnection();
        conArticle.begin();
        Assert.assertTrue(conArticle.size() > 0);

        // run a SPARQL test to see if the returned data is correct
        InputStream sparql = this.getClass().getResourceAsStream("wikipedia-marmot.sparql");
        BooleanQuery testLabel = conArticle.prepareBooleanQuery(QueryLanguage.SPARQL, IOUtils.toString(sparql));
View Full Code Here

    @Test
    public void testStoreTriples() throws Exception {

        RepositoryConnection con = backend.getCacheConnection("http://localhost/resource/1");
        try {
            con.begin();

            URI subject    = con.getValueFactory().createURI("http://localhost/resource/1");
            URI predicate  = con.getValueFactory().createURI("http://localhost/resource/" + RandomStringUtils.randomAlphanumeric(8));
            Literal object1 = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
            Literal object2 = con.getValueFactory().createLiteral(RandomStringUtils.random(64));
View Full Code Here

        Assert.assertEquals(1,asList(ldcache.listCacheEntries()).size());

        RepositoryConnection con1 = ldcache.getCacheConnection(uri1);
        try {
            con1.begin();
            Assert.assertEquals(3, asList(con1.getStatements(con1.getValueFactory().createURI(uri1), null, null, false)).size());
            con1.commit();
        } finally {
            con1.close();
        }
View Full Code Here

        if(cacheSailProvider.isEnabled()) {
            try {
                ClientResponse response = cacheSailProvider.getLDClient().retrieveResource(uri);

                RepositoryConnection con = response.getTriples().getConnection();
                con.begin();

                ByteArrayOutputStream out = new ByteArrayOutputStream();
                RDFHandler handler = new RDFXMLPrettyWriter(out);
                con.export(handler);
View Full Code Here

    @Override
    public InputStream getContentStream(Resource resource, String mimetype) throws IOException {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                conn.begin();
                MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);

                String path = mci.getContentPath();
                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
                    try {
View Full Code Here

    @Override
    public boolean hasContent(Resource resource, String mimetype) {
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                conn.begin();
                MediaContentItem mci = FacadingFactory.createFacading(conn).createFacade(resource, MediaContentItem.class);

                String path = mci.getContentPath();
                if(path == null && resource instanceof KiWiUriResource && resource.stringValue().startsWith("file:")) {
                    try {
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.