use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class IncludeMap method store.
@Override
public void store() throws MappableException, UserException {
try {
File f = new File(navajoObject);
if (type == null || type.equals("tml") || type.equals("tsl")) {
Navajo n = (type != null && type.equals("tsl") ? NavajoFactory.getInstance().createNavaScript(new FileInputStream(f)) : NavajoFactory.getInstance().createNavajo(new FileInputStream(f)));
Message current = access.getCurrentOutMessage();
List<Message> msgList = n.getAllMessages();
for (int i = 0; i < msgList.size(); i++) {
Message tbc = msgList.get(i);
Message copy = tbc.copy(access.getOutputDoc());
if (current != null) {
current.addMessage(copy);
} else {
access.getOutputDoc().addMessage(copy);
}
}
}
} catch (Exception e) {
throw new UserException(-1, e.getMessage(), e);
}
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class NavajoMap method setDeleteProperty.
public final void setDeleteProperty(String fullName) throws UserException {
setPropertyName(fullName);
if (currentProperty != null) {
Message m = currentProperty.getParentMessage();
deletedProperties.add(fullName);
if (m != null) {
m.removeProperty(currentProperty);
}
}
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class NavajoMap method processSuppressedProperties.
private final void processSuppressedProperties(Message m) {
Iterator<Property> allProps = new ArrayList<Property>(m.getAllProperties()).iterator();
while (allProps.hasNext()) {
Property p = allProps.next();
if (isPropertyInList(p, this.suppressProperties, m.getType().equals(Message.MSG_TYPE_ARRAY_ELEMENT))) {
m.removeProperty(p);
}
}
Iterator<Message> subMessages = m.getAllMessages().iterator();
while (subMessages.hasNext()) {
processSuppressedProperties(subMessages.next());
}
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class NavajoMap method getMessage.
public Message getMessage(String fullName) throws UserException {
waitForResult();
Message msg = null;
if (msgPointer != null)
msg = msgPointer.getMessage(fullName);
else
msg = inDoc.getMessage(fullName);
if (msg == null)
throw new UserException(-1, "Message " + fullName + " does not exists in response document");
return msg;
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class NavajoMap method setAppendParms.
/**
* @param b
* @throws UserException
*
* if messageOffset is '/', the messages of the received Doc will be appended to the root param block or to the current param message.
*/
public final void setAppendParms(String messageOffset) throws UserException {
waitForResult();
try {
Message parm = (access.getCompiledScript().getCurrentParamMsg() == null ? access.getInDoc().getMessage("__parms__") : access.getCompiledScript().getCurrentParamMsg());
List<Message> list = null;
// If append message equals '/'.
if (messageOffset.equals(Navajo.MESSAGE_SEPARATOR)) {
list = inDoc.getAllMessages();
} else if (inDoc.getMessage(messageOffset) == null) {
return;
} else if (inDoc.getMessage(messageOffset).getType().equals(Message.MSG_TYPE_ARRAY)) {
list = new ArrayList<>();
list.add(inDoc.getMessage(messageOffset));
} else {
list = inDoc.getMessages(messageOffset);
}
for (int i = 0; i < list.size(); i++) {
Message inMsg = list.get(i);
// Clone message and append it to currentMsg if it exists, else
// directly under currentDoc.
// currentDoc.importMessage(inMsg)
Message clone = inDoc.copyMessage(inMsg, parm.getRootDoc());
parm.addMessage(clone, true);
}
} catch (NavajoException ne) {
throw new UserException(-1, ne.getMessage());
}
}
Aggregations