Search in sources :

Example 1 with IDAccessType

use of org.sirix.service.jaxrx.enums.IDAccessType in project sirix by sirixdb.

the class SirixMediator method add.

@Override
public String add(final InputStream input, final ResourcePath path) throws JaxRxException {
    final int depth = path.getDepth();
    if (depth == 1) {
        database.add(input, path.getResourcePath());
    } else if (depth == 2) {
        nodeIdResource.addSubResource(path.getResource(0), Long.valueOf(path.getResource(1)), input, IDAccessType.FIRSTCHILD);
    } else if (depth == 3) {
        final IDAccessType accessType = WorkerHelper.getInstance().validateAccessType(path.getResource(2));
        nodeIdResource.addSubResource(path.getResource(0), Long.valueOf(path.getResource(1)), input, accessType);
    }
    return null;
}
Also used : IDAccessType(org.sirix.service.jaxrx.enums.IDAccessType)

Example 2 with IDAccessType

use of org.sirix.service.jaxrx.enums.IDAccessType in project sirix by sirixdb.

the class SirixMediator method get.

@Override
public StreamingOutput get(final ResourcePath path) throws JaxRxException {
    final int depth = path.getDepth();
    StreamingOutput response;
    switch(depth) {
        case 0:
            response = database.getResourcesNames();
            break;
        case 1:
            response = database.getResource(path.getResourcePath(), path.getQueryParameter());
            break;
        case 2:
            response = nodeIdResource.getResource(path.getResource(0), Long.valueOf(path.getResource(1)), path.getQueryParameter());
            break;
        case 3:
            final IDAccessType accessType = WorkerHelper.getInstance().validateAccessType(path.getResource(2));
            if (accessType == null) {
                throw new JaxRxException(400, "The access type: " + path.getResource(2) + " is not supported.");
            } else {
                response = nodeIdResource.getResourceByAT(path.getResource(0), Long.valueOf(path.getResource(1)), path.getQueryParameter(), accessType);
            }
            break;
        default:
            throw new JaxRxException(405, NOTALLOWEDSTRING);
    }
    return response;
}
Also used : StreamingOutput(javax.ws.rs.core.StreamingOutput) IDAccessType(org.sirix.service.jaxrx.enums.IDAccessType) JaxRxException(org.jaxrx.core.JaxRxException)

Aggregations

IDAccessType (org.sirix.service.jaxrx.enums.IDAccessType)2 StreamingOutput (javax.ws.rs.core.StreamingOutput)1 JaxRxException (org.jaxrx.core.JaxRxException)1