use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class TMLSerializer method parseProperty.
private final Property parseProperty(String type, boolean partOfArrayElement, int propertyIndex, int arrayEltIndex, InputStream is, boolean longLength) throws IOException {
String name = propertyIndex + "";
byte[] array = null;
if (arrayEltIndex == 0 || !partOfArrayElement) {
array = new byte[bytesToShort(is)];
is.read(array, 0, array.length);
name = new String(array);
}
int size = (longLength ? bytesToInt(is) : bytesToShort(is));
array = new byte[size];
is.read(array, 0, array.length);
if (type.equals(Property.BINARY_PROPERTY)) {
Property p = NavajoFactory.getInstance().createProperty(myNavajo, name, type, null, 0, "", "");
p.setAnyValue(new Binary(array));
return p;
} else {
String value = new String(array);
return NavajoFactory.getInstance().createProperty(myNavajo, name, type, value, 0, "", "");
}
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class BaseRequestImpl method writeOutput.
@Override
public void writeOutput(Navajo inDoc, Navajo outDoc, long scheduledAt, long startedAt, String threadStatus) throws IOException {
long finishedScriptAt = System.currentTimeMillis();
// postTime =
long postTime = scheduledAt - connectedAt;
long queueTime = startedAt - scheduledAt;
long serverTime = finishedScriptAt - startedAt;
if (dataPath != null) {
Property data = outDoc.getProperty(dataPath);
Object dataObject = data.getTypedValue();
if (dataObject instanceof Binary) {
Binary b = (Binary) dataObject;
if (contentType != null) {
response.setContentType(contentType);
} else {
response.setContentType(b.guessContentType());
}
if (this.fileName != null) {
response.setHeader("Content-Disposition", "attachment; filename=" + this.fileName);
}
OutputStream out = getOutputStream(acceptEncoding, response.getOutputStream());
CountingOutputStream cos = new CountingOutputStream(out);
b.write(cos);
cos.close();
logResponseSize(cos.getCount());
return;
} else {
response.setContentType("text/plain; charset=UTF-8");
OutputStream out = getOutputStream(acceptEncoding, response.getOutputStream());
OutputStreamWriter osw = new OutputStreamWriter(out);
osw.write("" + dataObject);
osw.close();
}
}
OutputStream out = getOutputStream(acceptEncoding, response.getOutputStream());
response.setContentType("text/xml; charset=UTF-8");
if (outDoc == null) {
logger.warn("Null outDoc. This is going to hurt");
response.sendError(500, "No response received, possible scheduling problem.");
return;
} else if (outDoc.getHeader() == null) {
logger.warn("Null outDoc header. This is going to hurt");
response.sendError(500, "No response header received, possible scheduling problem.");
return;
}
outDoc.getHeader().setHeaderAttribute("postTime", "" + postTime);
outDoc.getHeader().setHeaderAttribute("queueTime", "" + queueTime);
outDoc.getHeader().setHeaderAttribute("serverTime", "" + serverTime);
outDoc.getHeader().setHeaderAttribute("threadName", "" + Thread.currentThread().getName());
CountingOutputStream cos = new CountingOutputStream(out);
outDoc.write(cos);
cos.close();
logResponseSize(cos.getCount());
if (inDoc != null && inDoc.getHeader() != null && outDoc.getHeader() != null) {
statLogger.info("Finished {} ({}) in {}ms - {}", outDoc.getHeader().getHeaderAttribute("accessId"), inDoc.getHeader().getRPCName(), (System.currentTimeMillis() - connectedAt), threadStatus);
}
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class BirtHandler method doService.
@Override
public final Navajo doService(Access a) {
Navajo inDoc = getInDoc(a);
inDoc.removeInternalMessages();
Binary birtBinary = getBirtBinary(inDoc);
Navajo navajoBirt = makeNavajoBirt(birtBinary);
return navajoBirt;
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class BirtHandler method getBirtBinary.
public Binary getBirtBinary(Navajo n) {
Binary template = null;
BirtUtils report = new BirtUtils();
Binary result = new Binary();
try {
result = report.createEmptyReport(n, template);
} catch (Exception e) {
logger.error("Unable to create report.", e);
}
return result;
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class Security method decryptBinary.
public Binary decryptBinary(String encryptedData) throws Exception {
Key key = generateKey();
Cipher c = Cipher.getInstance(ALGO);
c.init(Cipher.DECRYPT_MODE, key);
byte[] decordedValue = Base64.decode(encryptedData);
byte[] decValue = c.doFinal(decordedValue);
Binary b = new Binary(decValue);
return b;
}
Aggregations