All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.yawp.servlet.rest.ShowRestAction Maven / Gradle / Ivy

There is a newer version: 2.08alpha
Show newest version
package io.yawp.servlet.rest;

import io.yawp.commons.http.HttpException;
import io.yawp.repository.query.NoResultException;
import io.yawp.repository.query.QueryBuilder;

public class ShowRestAction extends RestAction {

    public ShowRestAction() {
        super("show");
    }

    @Override
    public void shield() {
        shield.protectShow();
    }

    @Override
    public Object action() {
        QueryBuilder query = query();

        try {
            if (hasTransformer()) {
                Object object = query.transform(getTransformerName()).fetch(id);
                applyGetFacade(object);
                return object;
            }

            if (hasShieldCondition()) {
                query.and(shield.getWhere());
            }

            Object object = query.fetch(id);
            applyGetFacade(object);
            return object;

        } catch (NoResultException e) {
            throw new HttpException(404);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy