NIHVIVO-1512 ReadOnlyBeansWrapper - draft implementation, not yet functioning as desired. Remove a deprecated method.
This commit is contained in:
parent
6833284706
commit
b73939fc80
3 changed files with 41 additions and 5 deletions
|
@ -298,6 +298,10 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
return wrapper.wrap(obj);
|
||||
}
|
||||
|
||||
protected TemplateModel wrap(Object obj, BeansWrapper wrapper) throws TemplateModelException {
|
||||
return wrapper.wrap(obj);
|
||||
}
|
||||
|
||||
protected BeansWrapper getBeansWrapper(int exposureLevel) {
|
||||
BeansWrapper wrapper = new DefaultObjectWrapper();
|
||||
wrapper.setExposureLevel(exposureLevel);
|
||||
|
|
|
@ -446,11 +446,6 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PropertyTemplateModel getPropertyAndRemoveFromList(String propertyUri) {
|
||||
return pullProperty(propertyUri);
|
||||
}
|
||||
|
||||
public PropertyTemplateModel pullProperty(String propertyUri) {
|
||||
|
||||
for (PropertyGroupTemplateModel pgtm : groups) {
|
||||
|
|
37
webapp/src/freemarker/ext/beans/ReadOnlyBeansWrapper.java
Normal file
37
webapp/src/freemarker/ext/beans/ReadOnlyBeansWrapper.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package freemarker.ext.beans;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/** BeansWrapper that is more restrictive than EXPOSE_SAFE, by
|
||||
* exposing getters but not setters. A setter is defined for this
|
||||
* purpose as a method that returns void, or whose name
|
||||
* starts with "set".
|
||||
*
|
||||
* @author rjy7
|
||||
*
|
||||
*/
|
||||
public class ReadOnlyBeansWrapper extends BeansWrapper {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ReadOnlyBeansWrapper.class);
|
||||
|
||||
public ReadOnlyBeansWrapper() {
|
||||
// Start by exposing all safe methods.
|
||||
setExposureLevel(EXPOSE_SAFE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finetuneMethodAppearance(Class cls, Method method, MethodAppearanceDecision decision) {
|
||||
|
||||
if ( method.getName().startsWith("set") ||
|
||||
method.getReturnType() == null ) {
|
||||
decision.setExposeMethodAs(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue