Migration notes for M7
This page summarizes key changes from the previous milestone.
Global Context API updates
There have been minor updates to the Global Context API for WebSphere sMash in Monaco.
Outbound request headers is a List not a First Element List (FEL)
The Outbound request headers (the headers sent back to the client in the response) is no longer a FEL. The value in the Global Context for this key is treated as a regular list. This means that code that used to look like the following
GlobalContext.zput("/request/headers/out/Content-Type#0, "text/html");
will now be just
GlobalContext.zput("/request/headers/out/Content-Type", "text/html");
The same update in PHP would be
zput('/request/headers/out/Content-Type', 'text/html');
zdump() updates for type handlers and commands
It is possible for developers who are implementing commands stored in the global context to not execute the command when the global context key is dumped, say for tracing. To allow this we have introduced the dump interface in the
zero.core.context.types.TypeHandler interface.
public interface TypeHandler<T> {
.
.
.
public <V> V dump(ParsedURI parsedUri, T storedValue);
}
All implementations of TypeHandlers need to implement this method.
Also the
zero.core.context.types.commands.Command interface has been updated to require a dump() method as well.
public interface Command {
.
.
/**
* This method returns a human readable value of the command. The default implementation executes
* the get interface of the command. Note tracing can cause the dump interface of the command to be
* invoked prior to an actual get triggering the command execution. It is recommended that this default
* behavior be overriden to avoid undesirable side effects of premature execution of the command due to
* say - tracing being enabled.
* @param <V>
* @param parsedUri
* @return
*/
public <V> V dump(ParsedURI parsedUri);
}
This means that any implementation of a Command not inheriting from zero.core.context.types.commands.BaseCommandImpl or zero.core.context.types.commands.DeferredInitCommand needs to implement this method as well.
The following is an example of such a Command
GlobalContext.zput("/tmp/foo/baz", new BaseCommandImpl() {
Object value = null;
public <T> T get(ParsedURI parsedUri) {
value = "foobaz";
return (T) value;
}
public <T> T dump(ParsedURI parsedUri){
return (T)((value == null) ? "Not Initialized" : value);
}
});
Updates for accessing data from the First Element List (FEL)
Accessing data from a First Element List such as the request parameters have been simplified. For instance it is now possible to access the FEL from Groovy code as follows.
x = request.params.foo[] // returns the first value of the request parameter named foo.
and
x = request.params.foo[2] // returns the third value of the request parameter named foo.
For more information refer to the First Element List documentation.
zdelete() returns a boolean
The zdelete() method in the Global Context now returns a boolean to indicate if the delete was successful (true) or not (false).
Zero Resource Model (ZRM) updates
Changes in CLI for ZRM
There have been changes to the Zero Resource Model's command line tasks so that they are consistent with the rest of the WebSphere sMash command line tasks.
Specifically the following no longer exist
zero model_sync
zero syndb
zero model_reset
zero model_loaddata somefile.json
and have been replaced with
zero model sync
zero model reset
zero model sql sync
zero model sql reset
zero model sql drop
zero model loaddata one.json or.json C:\more\files\any\where.json
zero model dumpdata all_in_one_file.json
zero model dumpdata --model=employees just_the_employees.json
zero model dumpdata --split
zero model dumpdata --prefix=custom_prefix --split
sMash specific Dojo updates
ZRM DataGrid and Store API updates
The specifc changes to these widgets are -
- baseZRMURL attribute in the DataStore will be replaced with the contextRoot attribute
- baseUrl attribute in the DataGrid will be removed.
- resourceCollection attribute will be added to the DataStore.
- Optional query attribute in DataGrid to filter based on ZRM query parameters
- query attribute in DataGrid should be an object (specifying the URI in the query attribute will no longer be supported).
So code that used to look like the following
<span dojoType="zero.resource.DataStore" jsId="thestore"
baseZRMURL="../" >
</span>
<div dojoType="zero.grid.DataGrid" id="thegrid"
readonly="true"
resourceCollection="suggestions"
baseUrl="../"
visibleFields="suggestion,submitter,votes"
store="thestore"
style="width: 500px; height: 300px; position: absolute; left: 9px; top: 11px;"></div>
should look like the following
<span dojoType="zero.resource.DataStore" jsId="thestore"
resourceCollection="suggestions" >
</span>
<div dojoType="zero.grid.DataGrid" id="thegrid"
readonly="true"
visibleFields="suggestion,submitter,votes"
store="thestore"
style="width: 500px; height: 300px; position: absolute; left: 9px; top: 11px;"></div>
Also the DataGrid will now support a query attribute that can use the query parameter fields specified in the
ZRM REST documentation.
For instance to filter the suggestions collection for submitters that start with the letter 'b' -
<span dojoType="zero.resource.DataStore" jsId="thestore"
contextRoot="" //optional
resourceCollection="suggestions" >
</span>
<div dojoType="zero.grid.DataGrid" id="thegrid"
readonly="true"
visibleFields="suggestion,submitter,votes"
store="thestore"
query="{submitter__startswith: 'b'}"
style="width: 500px; height: 300px; position: absolute; left: 9px; top: 11px;"></div>
It has been possible to specify a DataGrid without explicitly associating it with a DataStore. This is still be possible.
To allow this, there are optional contextRoot and resourceCollection attributes that are available in the DataGrid which will
be used by the implicit DataStore object associated with the Grid.
Miscellaneous
Configuration parser supports Boolean and Number values in "conditions" clause
We now support Boolean and Number values in the "conditions" clause of an event handler definition. So the following configuration snippet is valid.
...
"conditions" : "(/config/acf/enableByDefault == false) && (${conditions})",
...
REST documentation utiliity moved to experimental module group
The REST documentation utility (zero.restdoc) module has moved to the experimental module group. If you have an application that is associated with the stable module group that has a dependency on zero.restdoc that application will no longer resolve correctly.
The workaround is to either remove the zero.restdoc module as a dependency or to switch to the experimental module group and then resolve.
zero switch experimental
JSON encoder does not encode slashes
The WebSphere sMash JSON encoder used to escape forward slashes in the data. Since this is not required by the JSON spec, the JSON encoder no longer escapes forward slashes.