use of com.dexels.navajo.script.api.UserException in project navajo by Dexels.
the class ProxyMap method store.
@Override
public void store() throws MappableException, UserException {
if (server == null)
throw new UserException(-1, "ProxyMap error: no server URI specified, e.g. localhost/servlet/Postman");
try {
ClientInterface nc = NavajoClientFactory.createClient();
inMessage.removeHeader();
nc.setUsername(username == null ? access.rpcUser : username);
nc.setPassword(password == null ? access.rpcPwd : password);
nc.setAllowCompression(true);
nc.setServerUrl(server);
Navajo out = nc.doSimpleSend(inMessage, (method == null ? access.rpcName : method));
access.setOutputDoc(out);
} catch (Exception e) {
throw new UserException(-1, e.getMessage());
}
}
use of com.dexels.navajo.script.api.UserException in project navajo by Dexels.
the class RESTAdapter method setDoSend.
@Override
public void setDoSend(String method) throws UserException, ConditionErrorException, SystemException {
if (messagesPerRequest < 1 || useCurrentMessages == null) {
setDoSend(method, prepareOutDoc());
serviceCalled = true;
} else {
String[] messages = useCurrentMessages.split(",");
Navajo copy = outDoc.copy();
Navajo indoc = null;
if (inDoc == null) {
indoc = NavajoFactory.getInstance().createNavajo();
} else {
indoc = inDoc.copy();
}
for (String msgName : messages) {
Message msg = access.getOutputDoc().getMessage(msgName);
if (msg != null && msg.isArrayMessage()) {
Message outMsg = NavajoFactory.getInstance().createMessage(outDoc, msgName);
outMsg.setType("array");
int counter = 0;
int totalCounter = 0;
for (Message element : msg.getElements()) {
outMsg.addElement(element);
counter++;
totalCounter++;
if (counter >= messagesPerRequest || totalCounter >= msg.getArraySize()) {
outDoc.addMessage(outMsg);
setDoSend(method, outDoc);
indoc.merge(inDoc);
// Going to clear data
outDoc = copy.copy();
outMsg = NavajoFactory.getInstance().createMessage(outDoc, msgName);
outMsg.setType("array");
counter = 0;
}
}
inDoc = indoc.copy();
} else {
throw new UserException(2, "Message " + msgName + "not found or not array message!");
}
}
serviceCalled = true;
}
}
use of com.dexels.navajo.script.api.UserException in project navajo by Dexels.
the class AsyncProxyMap method run.
@Override
public void run() throws UserException {
Header h = outDoc.getHeader();
if (h == null) {
h = NavajoFactory.getInstance().createHeader(outDoc, method, username, password, -1);
outDoc.addHeader(h);
} else {
h.setRPCName(method);
h.setRPCPassword(password);
h.setRPCUser(username);
}
// Clear request id.
h.setRequestId(null);
try {
inDoc = DispatcherFactory.getInstance().handle(outDoc);
} catch (Exception e) {
throw new UserException(-1, e.getMessage(), e);
} finally {
logger.info("Setting set is finished.");
setIsFinished();
}
}
use of com.dexels.navajo.script.api.UserException in project navajo by Dexels.
the class AccessMap method setAccessId.
public void setAccessId(String id) throws UserException {
this.accessId = id;
if (accessId == null) {
throw new UserException(-1, "Set accessId first");
}
Set<Access> all = com.dexels.navajo.server.DispatcherFactory.getInstance().getAccessSet();
Iterator<Access> iter = all.iterator();
while (iter.hasNext()) {
Access a = iter.next();
if (a.accessID.equals(accessId)) {
this.myAccess = a;
showDetails = true;
}
}
if (!(showDetails)) {
// Try async store
myAccess = com.dexels.navajo.mapping.AsyncStore.getInstance().accessStore.get(id);
if (myAccess != null) {
showDetails = true;
}
}
}
use of com.dexels.navajo.script.api.UserException in project navajo by Dexels.
the class CSVMap method store.
@Override
public void store() throws MappableException, UserException {
if (draftEntries != null) {
entries = new CSVEntryMap[draftEntries.size()];
int i = 0;
for (CSVEntryMap ce : draftEntries) {
entries[i++] = ce;
}
}
if (update && entries != null) {
try (FileWriter writer = new FileWriter(fileName)) {
// Write CSV.
for (int i = 0; i < entries.length; i++) {
CSVEntryMap e = entries[i];
for (int j = 0; j < e.entries.length; j++) {
writer.write(e.getEntry(Integer.valueOf(j)));
if (j < (e.entries.length - 1))
writer.write(separator);
}
if (i < (entries.length - 1))
writer.write("\n");
}
writer.close();
} catch (IOException ioe) {
throw new UserException(-1, ioe.getMessage());
}
}
}
Aggregations