Search in sources :

Example 1 with Delete

use of org.glassfish.config.support.Delete in project Payara by payara.

the class TemplateRestResource method getDeleteCommand.

protected String getDeleteCommand() {
    if (entity == null) {
        return null;
    }
    String result = ResourceUtil.getCommand(RestRedirect.OpType.DELETE, getEntity().model);
    if ((result == null) && (entity.parent() != null)) {
        // trying @Delete annotation that as a generic CRUD delete command, possibly...
        Class<? extends ConfigBeanProxy> cbp = null;
        try {
            cbp = (Class<? extends ConfigBeanProxy>) entity.parent().model.classLoaderHolder.loadClass(entity.parent().model.targetTypeName);
        } catch (MultiException e) {
            // 
            return null;
        }
        Delete del = null;
        for (Method m : cbp.getMethods()) {
            ConfigModel.Property pp = entity.parent().model.toProperty(m);
            if ((pp != null) && (pp.xmlName.equals(tagName)) && m.isAnnotationPresent(Delete.class)) {
                del = m.getAnnotation(Delete.class);
                break;
            }
        }
        if (del != null) {
            return del.value();
        }
    }
    return result;
}
Also used : Delete(org.glassfish.config.support.Delete) ConfigModel(org.jvnet.hk2.config.ConfigModel) Method(java.lang.reflect.Method) MultiException(org.glassfish.hk2.api.MultiException)

Aggregations

Method (java.lang.reflect.Method)1 Delete (org.glassfish.config.support.Delete)1 MultiException (org.glassfish.hk2.api.MultiException)1 ConfigModel (org.jvnet.hk2.config.ConfigModel)1