Search in sources :

Example 1 with JaxbList

use of org.pentaho.platform.web.http.api.resources.JaxbList in project data-access by pentaho.

the class JDBCDatasourceResource method getConnectionIDs.

/**
 * Get a list of JDBC datasource IDs.
 *
 * <p><b>Example Request:</b><br />
 *    GET pentaho/plugin/data-access/api/datasource/jdbc/connection
 * </p>
 *
 * @return A list of JDBC datasource IDs.
 *
 * <p><b>Example Response:</b></p>
 *    <pre function="syntax.xml">
 *      {
 *        "Item": [
 *          {
 *            "@type": "xs:string",
 *            "$": "AgileBI"
 *          },
 *          {
 *            "@type": "xs:string",
 *            "$": "Audit"
 *          },
 *          {
 *            "@type": "xs:string",
 *            "$": "SampleData"
 *          },
 *          {
 *            "@type": "xs:string",
 *            "$": "TestDataSourceResource"
 *          },
 *          {
 *            "@type": "xs:string",
 *            "$": "baseball connection"
 *          },
 *          {
 *            "@type": "xs:string",
 *            "$": "baseball connection"
 *          },
 *          {
 *            "@type": "xs:string",
 *            "$": "live_logging_info"
 *          },
 *          {
 *            "@type": "xs:string",
 *            "$": "pentaho_operations_mart"
 *          }
 *        ]
 *      }
 *    </pre>
 */
@GET
@Path("/")
@Produces({ APPLICATION_JSON, APPLICATION_XML })
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully retrieved the list of JDBC datasource IDs"), @ResponseCode(code = 500, condition = "Internal error retrieving JDBC datasource IDs") })
public JaxbList<String> getConnectionIDs() {
    List<String> connStrList = new ArrayList<String>();
    try {
        List<IDatabaseConnection> conns = service.getConnections();
        for (IDatabaseConnection conn : conns) {
            conn.setPassword(null);
            connStrList.add(conn.getName());
        }
    } catch (ConnectionServiceException e) {
        logger.error("Error " + e.getMessage());
        throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
    JaxbList<String> connections = new JaxbList<String>(connStrList);
    return connections;
}
Also used : ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) WebApplicationException(javax.ws.rs.WebApplicationException) ArrayList(java.util.ArrayList) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) JaxbList(org.pentaho.platform.web.http.api.resources.JaxbList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) StatusCodes(org.codehaus.enunciate.jaxrs.StatusCodes)

Example 2 with JaxbList

use of org.pentaho.platform.web.http.api.resources.JaxbList in project data-access by pentaho.

the class DataSourcePublishIT method checkMetadata.

private void checkMetadata(WebResource webResource, String domainID, boolean hasAccess) {
    final JaxbList metadataDatasourceIds = webResource.path(DATA_ACCESS_API_DATASOURCE_METADATA + "ids").get(JaxbList.class);
    final List list = metadataDatasourceIds.getList();
    if (hasAccess) {
        assertTrue(list != null && list.contains(domainID));
    } else if (list != null) {
        assertFalse(list.contains(domainID));
    }
}
Also used : JaxbList(org.pentaho.platform.web.http.api.resources.JaxbList) List(java.util.List) ArrayList(java.util.ArrayList) JaxbList(org.pentaho.platform.web.http.api.resources.JaxbList)

Example 3 with JaxbList

use of org.pentaho.platform.web.http.api.resources.JaxbList in project data-access by pentaho.

the class DataSourcePublishIT method checkAnalysis.

private void checkAnalysis(WebResource webResource, String catalogID, boolean hasAccess) {
    final JaxbList analysisDatasourceIds = webResource.path(DATA_ACCESS_API_DATASOURCE_ANALYSIS + "ids").get(JaxbList.class);
    final List list = analysisDatasourceIds.getList();
    if (hasAccess) {
        assertTrue(list != null && list.contains(catalogID));
    } else if (list != null) {
        assertFalse(list.contains(catalogID));
    }
}
Also used : JaxbList(org.pentaho.platform.web.http.api.resources.JaxbList) List(java.util.List) ArrayList(java.util.ArrayList) JaxbList(org.pentaho.platform.web.http.api.resources.JaxbList)

Example 4 with JaxbList

use of org.pentaho.platform.web.http.api.resources.JaxbList in project data-access by pentaho.

the class DataSourcePublishIT method checkDSW.

private void checkDSW(WebResource webResource, String domainID, boolean hasAccess) {
    final JaxbList dswIds = webResource.path(DATA_ACCESS_API_DATASOURCE_DSW + "ids").get(JaxbList.class);
    final List list = dswIds.getList();
    if (hasAccess) {
        assertTrue(list != null && list.contains(domainID));
    } else if (list != null) {
        assertFalse(list.contains(domainID));
    }
}
Also used : JaxbList(org.pentaho.platform.web.http.api.resources.JaxbList) List(java.util.List) ArrayList(java.util.ArrayList) JaxbList(org.pentaho.platform.web.http.api.resources.JaxbList)

Aggregations

ArrayList (java.util.ArrayList)4 JaxbList (org.pentaho.platform.web.http.api.resources.JaxbList)4 List (java.util.List)3 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 StatusCodes (org.codehaus.enunciate.jaxrs.StatusCodes)1 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)1 ConnectionServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException)1