use of freemarker.template.TemplateModelException in project openj9 by eclipse.
the class Flag method get.
public TemplateModel get(String arg0) throws TemplateModelException {
if (arg0.equals("name")) {
return new SimpleScalar(flag);
}
if (arg0.equals("enabled")) {
return new BooleanModel(UMA.getUma().getConfiguration().isFlagSet(flag), new BeansWrapper());
}
try {
TemplateModel platformExtension = com.ibm.uma.UMA.getUma().getPlatform().getDataModelExtension("uma.spec.flags." + flag, arg0);
if (platformExtension != null)
return platformExtension;
TemplateModel configurationExtension = com.ibm.uma.UMA.getUma().getConfiguration().getDataModelExtension("uma.spec.flags." + flag, arg0);
if (configurationExtension != null)
return configurationExtension;
} catch (UMAException e) {
throw new TemplateModelException(e);
}
return null;
}
use of freemarker.template.TemplateModelException in project openj9 by eclipse.
the class Spec method get.
public TemplateModel get(String arg0) throws TemplateModelException {
if (arg0.equals("flags")) {
return new Flags();
}
if (arg0.equals("tools")) {
return new Tools();
}
if (arg0.equals("properties")) {
return new Properties();
}
if (arg0.equals("artifacts")) {
return new Artifacts(UMA.getUma().getArtifacts());
}
if (arg0.equals("type")) {
return new Type();
}
if (arg0.equals("processor")) {
return new Processor();
}
try {
TemplateModel platformExtension = com.ibm.uma.UMA.getUma().getPlatform().getDataModelExtension("uma.spec", arg0);
if (platformExtension != null)
return platformExtension;
TemplateModel configurationExtension = com.ibm.uma.UMA.getUma().getConfiguration().getDataModelExtension("uma.spec", arg0);
if (configurationExtension != null)
return configurationExtension;
} catch (UMAException e) {
throw new TemplateModelException(e);
}
return null;
}
use of freemarker.template.TemplateModelException in project wombat by PLOS.
the class TemplateModelUtil method getAsMap.
static ImmutableMap<String, TemplateModel> getAsMap(TemplateModel value) throws TemplateModelException {
if (value == null)
return ImmutableMap.of();
if (value instanceof TemplateHashModelEx) {
TemplateHashModelEx ftlHash = (TemplateHashModelEx) value;
ImmutableMap.Builder<String, TemplateModel> builder = ImmutableMap.builder();
for (TemplateModelIterator iterator = ftlHash.keys().iterator(); iterator.hasNext(); ) {
String key = iterator.next().toString();
builder.put(key, ftlHash.get(key));
}
return builder.build();
}
throw new TemplateModelException("Hash type expected");
}
use of freemarker.template.TemplateModelException in project wombat by PLOS.
the class TemplateModelUtil method getAsMultimap.
static ImmutableListMultimap<String, TemplateModel> getAsMultimap(TemplateModel value) throws TemplateModelException {
if (value == null)
return ImmutableListMultimap.of();
if (value instanceof TemplateHashModelEx) {
TemplateHashModelEx ftlHash = (TemplateHashModelEx) value;
ImmutableListMultimap.Builder<String, TemplateModel> builder = ImmutableListMultimap.builder();
for (TemplateModelIterator iterator = ftlHash.keys().iterator(); iterator.hasNext(); ) {
String key = iterator.next().toString();
TemplateModel model = ftlHash.get(key);
if (model instanceof TemplateSequenceModel) {
TemplateSequenceModel sequenceModel = (TemplateSequenceModel) model;
int size = sequenceModel.size();
for (int i = 0; i < size; i++) {
builder.put(key, sequenceModel.get(i));
}
} else {
builder.put(key, model);
}
}
return builder.build();
}
throw new TemplateModelException("Hash type expected");
}
use of freemarker.template.TemplateModelException in project solo by b3log.
the class FillTagArticles method exec.
@Override
public Object exec(final List arguments) throws TemplateModelException {
if (arguments.size() != ARG_SIZE) {
LOGGER.debug("FillTagArticles with wrong arguments!");
throw new TemplateModelException("Wrong arguments!");
}
final String tagTitle = (String) arguments.get(0);
final int currentPageNum = Integer.parseInt((String) arguments.get(1));
final int pageSize = Integer.parseInt((String) arguments.get(2));
try {
final JSONObject result = tagQueryService.getTagByTitle(tagTitle);
if (null == result) {
return new ArrayList<JSONObject>();
}
final JSONObject tag = result.getJSONObject(Tag.TAG);
final String tagId = tag.getString(Keys.OBJECT_ID);
final List<JSONObject> list = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize);
return list;
} catch (final ServiceException e) {
e.printStackTrace();
} catch (final JSONException e) {
e.printStackTrace();
}
return null;
}
Aggregations