10-29-2010 09:42 AM
Huh, what is the rest2 webapp?
11-02-2010 06:01 AM
11-02-2010 06:30 AM
11-02-2010 10:28 AM
11-02-2010 04:52 PM
11-05-2010 11:48 AM
<bean id="jsonObjectTemplateProcessor" class="org.activiti.rest.builder.JSONTemplateProcessor">
<property name="templateProcessorRegistry" ref="webscripts.web.templateregistry" />
<property name="defaultEncoding" value="UTF-8" />
<property name="templateNamePrefix" value="org/activiti/rest/api/" />
<property name="indentFactor" value="2" />
</bean>
<bean id="org.activiti.rest.api.repository.deployments.get.json.builder"
class="org.activiti.rest.builder.repository.DeploymentsObjectBuilder">
<property name="templateName" value="repository/deployments.get.json" />
</bean>
public interface JSONObjectBuilder {
String getTemplateName();
JSONObject createJsonObject(Object model) throws JSONException;
}
private DeploymentJSONConverter converter = new DeploymentJSONConverter();
@Override
@SuppressWarnings("unchecked")
public JSONObject createJsonObject(Object modelObject) throws JSONException {
JSONObject result = new JSONObject();
Map<String, Object> model = getModelAsMap(modelObject);
List<Deployment> deployments = (List<Deployment>) model.get("deployments");
JSONUtil.putPagingInfo(result, model);
JSONArray deploymentsArray = JSONUtil.putNewArray(result, "data");
if (deployments != null) {
for (Deployment deployment : deployments) {
deploymentsArray.put(converter.getJSONObject(deployment));
}
}
return result;
}
public class DeploymentJSONConverter implements JSONConverter<Deployment> {
public JSONObject getJSONObject(Deployment deployment) throws JSONException {
JSONObject json = new JSONObject();
JSONUtil.putRetainNull(json, "id", deployment.getId());
JSONUtil.putRetainNull(json, "name", deployment.getName());
String deploymentTime = JSONUtil.formatISO8601Date(deployment.getDeploymentTime());
JSONUtil.putRetainNull(json, "deploymentTime", deploymentTime);
return json;
}
…
11-09-2010 05:12 AM
11-09-2010 05:51 AM
11-09-2010 06:32 AM
Once we are confident about the solution, the ftl's are removed and JSONObject stuff kicks in.
[…]
WDYT?
{
"id": "${processDefinition.id}",
"key": "${processDefinition.key}",
"name": <#if processDefinition.name??>"${processDefinition.name}"<#else>null</#if>,
"version": ${processDefinition.version},
"deploymentId": "${processDefinition.deploymentId}",
"resourceName": "${processDefinition.resourceName}",
"startFormResourceKey": <#if processDefinition.startFormResourceKey??>"${processDefinition.startFormResourceKey}"<#else>null</#if>
}
11-09-2010 10:25 AM
11-09-2010 12:09 PM
B. The amount of code lines needed are much greater, just consider the condition examples below to be written in java.* LOC's don't mean anything. With auto-completion, auto-import, etc that every IDE has, I dont think you claim that LOC = productivity. We're not the eighties anymore.
C. The benefit of getting a toJSON method in all pojos and use them in the rest api is not realistic since the pojo model will never match the services methods in 100%, some examples:These were just hacks introduced as a last-minute fix in the last release. There are jira issues to replace these with proper handling.
- Task (resourceName isn't included anymore therefore needing a whole new class RestTask on some objects but not all, confusing an creates even more code to maintain)
- RestProcessDefinition (same story as line above)
E. "modern" frameworks like rails, django use templates making it easier to use.* 'modern' frameworks such as (G)Rails *do not* have templating as their primary rendering method as you state.
F. Freemarker is a robust framework with very good documentation: http://freemarker.sourceforge.net/docs/index.htmlSo is Java.
G. We don't use the webscripts framework in a way its not intended.Why not? Who decides on that? For me, it is a natural addition to webscripts.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.