Search in sources :

Example 1 with ListFacetsCommand

use of edu.harvard.iq.dataverse.engine.command.impl.ListFacetsCommand in project dataverse by IQSS.

the class Dataverses method listFacets.

@GET
@Path("{identifier}/facets/")
public /**
 * return list of facets for the dataverse with alias `dvIdtf`
 */
Response listFacets(@PathParam("identifier") String dvIdtf) {
    try {
        User u = findUserOrDie();
        DataverseRequest r = createDataverseRequest(u);
        Dataverse dataverse = findDataverseOrDie(dvIdtf);
        JsonArrayBuilder fs = Json.createArrayBuilder();
        for (DataverseFacet f : execCommand(new ListFacetsCommand(r, dataverse))) {
            fs.add(f.getDatasetFieldType().getName());
        }
        return allowCors(ok(fs));
    } catch (WrappedResponse e) {
        return e.getResponse();
    }
}
Also used : DataverseRequest(edu.harvard.iq.dataverse.engine.command.DataverseRequest) AuthenticatedUser(edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser) User(edu.harvard.iq.dataverse.authorization.users.User) ListFacetsCommand(edu.harvard.iq.dataverse.engine.command.impl.ListFacetsCommand) JsonArrayBuilder(javax.json.JsonArrayBuilder) Dataverse(edu.harvard.iq.dataverse.Dataverse) DataverseFacet(edu.harvard.iq.dataverse.DataverseFacet) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

Dataverse (edu.harvard.iq.dataverse.Dataverse)1 DataverseFacet (edu.harvard.iq.dataverse.DataverseFacet)1 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)1 User (edu.harvard.iq.dataverse.authorization.users.User)1 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)1 ListFacetsCommand (edu.harvard.iq.dataverse.engine.command.impl.ListFacetsCommand)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1