Mercurial > hg > AnnotationManager
view src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/TripleStoreConnection.java @ 23:a3e324009990
now Mavenified!
removed tiny-mce javascript from html frontend.
still needs TripleStoreManager project in Eclipse.
jsontoken 1.1 has to be built manually.
author | casties |
---|---|
date | Tue, 03 Apr 2012 13:05:05 +0200 |
parents | src/de/mpiwg/itgroup/annotationManager/RDFHandling/TripleStoreConnection.java@b0ef5c860464 |
children |
line wrap: on
line source
/** * */ package de.mpiwg.itgroup.annotationManager.RDFHandling; import org.apache.log4j.Logger; import org.restlet.Context; import org.restlet.engine.component.ChildContext; import de.mpiwg.itgroup.annotationManager.Errors.TripleStoreStoreError; import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException; import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler; /** * @author casties * */ public class TripleStoreConnection { protected static Logger logger = Logger.getRootLogger(); private String user; private String password; private String url = "jdbc:virtuoso://virtuoso.mpiwg-berlin.mpg.de:1111"; /** * Creates TripleStoreConnection with parameters from web context. */ public TripleStoreConnection() { ChildContext context = (ChildContext)Context.getCurrent(); user = context.getParameters().getFirstValue("de.mpiwg.itgroup.annotationManager.virtuoso.tripleStoreUser", true); password = context.getParameters().getFirstValue("de.mpiwg.itgroup.annotationManager.virtuoso.tripleStoreUserPassword", true); url = context.getParameters().getFirstValue("de.mpiwg.itgroup.annotationManager.virtuoso.tripleStoreConnectionURL", true, url); } /** * @param user * @param password * @param url */ public TripleStoreConnection(String user, String password, String url) { super(); this.user = user; this.password = password; this.url = url; } /** * returns TripleStoreHandler. * * @return * @throws TripleStoreHandlerException */ public TripleStoreHandler getTripleStoreHandler() throws TripleStoreHandlerException { if (user == null || password == null || url == null) { logger.error(String.format("Missing triplestore parameters! (user=%s pw=%s url=%s)", user, password, url)); throw new TripleStoreStoreError(); } TripleStoreHandler th = new TripleStoreHandler(url, user, password); return th; } /** * returns new TripleStoreHandler. * * uses parameters from web context. * * @return * @throws TripleStoreStoreError * @throws TripleStoreHandlerException */ public static TripleStoreHandler newTripleStoreHandler() throws TripleStoreStoreError, TripleStoreHandlerException { ChildContext context = (ChildContext)Context.getCurrent(); String user = context.getParameters().getFirstValue("de.mpiwg.itgroup.annotationManager.virtuoso.tripleStoreUser"); String password = context.getParameters().getFirstValue("de.mpiwg.itgroup.annotationManager.virtuoso.tripleStoreUserPassword"); String url = context.getParameters().getFirstValue("de.mpiwg.itgroup.annotationManager.virtuoso.tripleStoreConnectionURL"); if (user == null || password == null || url == null) { logger.error(String.format("Missing triplestore parameters! (user=%s pw=%s url=%s)", user, password, url)); throw new TripleStoreStoreError(); } TripleStoreHandler th = new TripleStoreHandler(url, user, password); return th; } }