Search in sources :

Example 16 with Facet

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

the class AnalysisDatasourceService method postMondrainSchema.

/**
 * This is used by PUC to use a form post to import a Mondrian Schema XML into PUR
 *
 * @param dataInputStream
 * @param schemaFileInfo
 * @param catalogName
 * @param datasourceName
 * @param overwrite
 * @param xmlaEnabledFlag
 * @param parameters
 * @param acl acl information for the data source. This parameter is optional.
 * @return this method returns a response of "SUCCESS" for success, 8 if exists, 2 for general error,etc.
 * @throws PentahoAccessControlException
 */
@POST
@Path("/postAnalysis")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ "text/plain", "text/html" })
@Facet(name = "Unsupported")
public Response postMondrainSchema(@FormDataParam(UPLOAD_ANALYSIS) InputStream dataInputStream, @FormDataParam(UPLOAD_ANALYSIS) FormDataContentDisposition schemaFileInfo, // Optional
@FormDataParam(CATALOG_NAME) String catalogName, // Optional
@FormDataParam(ORIG_CATALOG_NAME) String origCatalogName, // Optional
@FormDataParam(DATASOURCE_NAME) String datasourceName, @FormDataParam(OVERWRITE_IN_REPOS) String overwrite, @FormDataParam(XMLA_ENABLED_FLAG) String xmlaEnabledFlag, @FormDataParam(PARAMETERS) String parameters, @FormDataParam(DATASOURCE_ACL) RepositoryFileAclDto acl) throws PentahoAccessControlException {
    // use existing Jersey post method - but translate into text/html for PUC Client
    ResponseBuilder responseBuilder;
    Response response = this.putMondrianSchema(dataInputStream, schemaFileInfo, catalogName, origCatalogName, datasourceName, overwrite, xmlaEnabledFlag, parameters, acl);
    responseBuilder = Response.ok();
    responseBuilder.entity(String.valueOf(response.getStatus()));
    responseBuilder.status(200);
    return responseBuilder.build();
}
Also used : Response(javax.ws.rs.core.Response) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Facet(org.codehaus.enunciate.Facet)

Example 17 with Facet

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

the class ConnectionService method getConnectionIdByNameWithResponse.

/**
 * Returns a response with id of a database connection
 *
 * @param name
 *          String representing the name of the database to search
 * @return Response based on the string value of the connection id
 *
 * @throws ConnectionServiceException
 */
@GET
@Path("/getid")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getConnectionIdByNameWithResponse(@QueryParam("name") String name) throws ConnectionServiceException {
    IDatabaseConnection conn = null;
    Response response;
    try {
        conn = connectionService.getConnectionByName(name);
        if (conn != null) {
            response = Response.ok().entity(conn.getId()).build();
        } else {
            response = Response.notModified().build();
        }
    } catch (Exception ex) {
        response = Response.serverError().entity(ex.getMessage()).build();
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 18 with Facet

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

the class ConnectionService method getPoolingParameters.

/**
 * Returns a list of the database connection pool parameters
 *
 * @return IDatabaseConnectionPoolParameterList a list of the pooling parameters
 */
@GET
@Path("/poolingParameters")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public IDatabaseConnectionPoolParameterList getPoolingParameters() {
    IDatabaseConnectionPoolParameterList value = new DefaultDatabaseConnectionPoolParameterList();
    List<IDatabaseConnectionPoolParameter> paramList = new ArrayList<IDatabaseConnectionPoolParameter>();
    for (DatabaseConnectionPoolParameter param : poolingParameters) {
        paramList.add(param);
    }
    value.setDatabaseConnectionPoolParameters(paramList);
    return value;
}
Also used : IDatabaseConnectionPoolParameterList(org.pentaho.ui.database.event.IDatabaseConnectionPoolParameterList) DatabaseConnectionPoolParameter(org.pentaho.database.model.DatabaseConnectionPoolParameter) IDatabaseConnectionPoolParameter(org.pentaho.database.model.IDatabaseConnectionPoolParameter) ArrayList(java.util.ArrayList) DefaultDatabaseConnectionPoolParameterList(org.pentaho.ui.database.event.DefaultDatabaseConnectionPoolParameterList) IDatabaseConnectionPoolParameter(org.pentaho.database.model.IDatabaseConnectionPoolParameter) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 19 with Facet

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

the class ConnectionService method getConnectionByNameWithResponse.

/**
 * this is a method to return a response object with an error message use getEntity(Connection.class) and getStatus()
 * to determine success
 */
@GET
@Path("/getresponse")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getConnectionByNameWithResponse(@QueryParam("name") String name) throws ConnectionServiceException {
    IDatabaseConnection conn = null;
    Response response;
    try {
        conn = connectionService.getConnectionByName(name);
        sanitizer.unsanitizeConnectionParameters(conn);
        hidePassword(conn);
        response = Response.ok().entity(conn).build();
    } catch (Exception ex) {
        response = Response.serverError().entity(ex.getMessage()).build();
    }
    return response;
}
Also used : Response(javax.ws.rs.core.Response) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 20 with Facet

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

the class ConnectionService method getConnectionByName.

/**
 * Returns the list of database connections
 *
 * @param name
 *          String representing the name of the database to return
 * @return Database connection by name
 *
 * @throws ConnectionServiceException
 */
@GET
@Path("/get")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public IDatabaseConnection getConnectionByName(@QueryParam("name") String name) throws ConnectionServiceException {
    IDatabaseConnection conn = connectionService.getConnectionByName(name);
    hidePassword(conn);
    return conn;
}
Also used : 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)

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