use of com.hp.oo.sdk.content.plugin.GlobalSessionObject in project cs-actions by CloudSlang.
the class CounterProcessor method init.
public void init(String to, String from, String by, boolean reset, GlobalSessionObject<Map<String, Object>> session) throws CounterImplException {
/*
* If the session resource is not ini
*/
if (session.get() == null) {
session.setResource(new CounterSessionResource(new HashMap<String, Object>()));
}
Map<String, Object> sessionMap = session.get();
try {
start = Long.parseLong(from.trim());
end = Long.parseLong(to.trim());
if (by == null || by.length() == 0)
increment = 1;
else
try {
increment = Integer.parseInt(by);
} catch (Exception e) {
increment = 1;
}
} catch (Exception e) {
throw new CounterImplException("Start or end is not a long integer, or by is not an integer.\nfrom: " + from + "\nto: " + to + "\nby:" + by);
}
try {
index = (Integer) sessionMap.get(INDEX);
} catch (Exception e) {
index = 0;
}
if (index == 0 && initialized(session)) {
sessionMap.put(INDEX, 0);
}
// ok, now push data into context
if (!initialized(session)) {
sessionMap.put(INDEX, 0);
}
// pull data from context
this.index = (Integer) sessionMap.get(INDEX);
}
Aggregations