Search in sources :

Example 46 with Facet

use of org.codehaus.enunciate.Facet in project data-access by pentaho.

the class ConnectionService method createDatabaseConnection.

/**
 * Create a database connection
 *
 * @param driver
 *          String name of the driver to use
 * @param url
 *          String name of the url used to create the connection.
 *
 * @return IDatabaseConnection for the given parameters
 */
@GET
@Path("/createDatabaseConnection")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public IDatabaseConnection createDatabaseConnection(@QueryParam("driver") String driver, @QueryParam("url") String url) {
    for (IDatabaseDialect dialect : dialectService.getDatabaseDialects()) {
        if (dialect.getNativeDriver() != null && dialect.getNativeDriver().equals(driver)) {
            if (dialect.getNativeJdbcPre() != null && url.startsWith(dialect.getNativeJdbcPre())) {
                return dialect.createNativeConnection(url);
            }
        }
    }
    // if no native driver was found, create a custom dialect object.
    IDatabaseConnection conn = genericDialect.createNativeConnection(url);
    conn.getAttributes().put(GenericDatabaseDialect.ATTRIBUTE_CUSTOM_DRIVER_CLASS, driver);
    return conn;
}
Also used : IDatabaseDialect(org.pentaho.database.IDatabaseDialect) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 47 with Facet

use of org.codehaus.enunciate.Facet in project data-access by pentaho.

the class ConnectionService method getConnections.

/**
 * Returns the list of database connections
 *
 * @return List of database connections
 *
 * @throws ConnectionServiceException
 */
@GET
@Path("/list")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public IDatabaseConnectionList getConnections() throws ConnectionServiceException {
    IDatabaseConnectionList databaseConnections = new DefaultDatabaseConnectionList();
    List<IDatabaseConnection> conns = connectionService.getConnections(true);
    databaseConnections.setDatabaseConnections(conns);
    return databaseConnections;
}
Also used : DefaultDatabaseConnectionList(org.pentaho.ui.database.event.DefaultDatabaseConnectionList) IDatabaseConnectionList(org.pentaho.ui.database.event.IDatabaseConnectionList) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 48 with Facet

use of org.codehaus.enunciate.Facet in project data-access by pentaho.

the class DatasourceResource method getAnalysisDatasourceInfo.

/**
 * Get the data source wizard info (parameters) for a specific data source wizard id
 *
 * @param dswId
 *          String id for a data source wizard
 *
 * @return Response containing the parameter list
 */
@GET
@Path("/{catalogId : .+}/getAnalysisDatasourceInfo")
@Produces(WILDCARD)
@Facet(name = "Unsupported")
public Response getAnalysisDatasourceInfo(@PathParam("catalogId") String catalogId) {
    IMondrianCatalogService mondrianCatalogService = PentahoSystem.get(IMondrianCatalogService.class, PentahoSessionHolder.getSession());
    MondrianCatalog catalog = mondrianCatalogService.getCatalog(catalogId, PentahoSessionHolder.getSession());
    if (catalog == null) {
        logger.warn("Catalog " + catalogId + " doesn't exist");
        return Response.status(Response.Status.BAD_REQUEST).build();
    }
    // dataSourceInfo can contain XML-escaped characters
    String parameters = prepareDataSourceInfo(catalog.getDataSourceInfo());
    // after preparation, parameters have escaped only quotes
    return Response.ok().entity(parameters).build();
}
Also used : MondrianCatalog(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog) IMondrianCatalogService(org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Aggregations

Facet (org.codehaus.enunciate.Facet)48 Path (javax.ws.rs.Path)43 Produces (javax.ws.rs.Produces)33 GET (javax.ws.rs.GET)29 ArrayList (java.util.ArrayList)12 Consumes (javax.ws.rs.Consumes)12 POST (javax.ws.rs.POST)8 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)8 PUT (javax.ws.rs.PUT)7 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)6 IUserRoleDao (org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao)6 Response (javax.ws.rs.core.Response)5 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)5 HashSet (java.util.HashSet)4 StringTokenizer (java.util.StringTokenizer)4 StatusCodes (org.codehaus.enunciate.jaxrs.StatusCodes)4 IPluginManager (org.pentaho.platform.api.engine.IPluginManager)4 IMondrianCatalogService (org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3