use of net.freeutils.tnef.RawInputStream in project zm-mailbox by Zimbra.
the class MapiPropertyId method getByteArrayValue.
public byte[] getByteArrayValue(SchedulingViewOfTnef schedView) throws IOException {
MAPIValue mpValue = getFirstValue(schedView);
if (mpValue == null) {
return null;
}
Object obj = mpValue.getValue();
if (obj == null) {
return null;
}
if (obj instanceof byte[]) {
return (byte[]) obj;
} else if (obj instanceof RawInputStream) {
RawInputStream ris = (RawInputStream) obj;
return ris.toByteArray();
}
return null;
}
use of net.freeutils.tnef.RawInputStream in project zm-mailbox by Zimbra.
the class MapiPropertyId method getStringValue.
public String getStringValue(SchedulingViewOfTnef schedView) throws IOException {
MAPIValue mpValue = getFirstValue(schedView);
if (mpValue == null) {
return null;
}
Object obj;
if (mpValue.getType() == MAPIProp.PT_STRING) {
// Assume the value is in the OEM Code Page
// The current MAPIValue code does not take account of that.
RawInputStream ris = mpValue.getRawData();
return IcalUtil.readString(ris, (int) ris.getLength(), schedView.getOEMCodePage());
} else {
// Probably PT_UNICODE_STRING but will accept anything whose value is
// a String.
obj = mpValue.getValue();
}
if (obj == null) {
return null;
}
if (obj instanceof String) {
return (String) obj;
}
return null;
}
use of net.freeutils.tnef.RawInputStream in project zm-mailbox by Zimbra.
the class TestTnefTimeZone method testTnefTimeZoneFromInputStream.
@Test
public void testTnefTimeZoneFromInputStream() throws IOException {
TimeZone tz = null;
RawInputStream ris = null;
ris = new RawInputStream(intToleByteArray(13), 0, 4);
tz = TnefTimeZone.getTimeZone(ris);
Assert.assertFalse(tz == null);
Assert.assertTrue(tz.getRawOffset() == -28800000);
Assert.assertTrue(tz.getDSTSavings() == 3600000);
// don't observe daylight saving bit is set!!
ris = new RawInputStream(new byte[] { 13, 0, 0, (byte) 128 }, 0, 4);
tz = TnefTimeZone.getTimeZone(ris);
Assert.assertFalse(tz == null);
Assert.assertTrue(tz.getRawOffset() == -28800000);
Assert.assertTrue(tz.getID().equals("Etc/GMT+8"));
}
use of net.freeutils.tnef.RawInputStream in project zm-mailbox by Zimbra.
the class SchedulingViewOfTnef method getTimeZoneStructInfo.
/**
* PidLidTimeZoneStruct Specifies time zone information for a recurring meeting.
*
* @param tzName
* @return
* @throws IOException
*/
private TimeZoneDefinition getTimeZoneStructInfo(String tzName) throws IOException {
RawInputStream tzRis = MapiPropertyId.PidLidTimeZoneStruct.getRawInputStreamValue(this);
if (tzRis == null) {
return null;
}
TimeZoneDefinition tzDef = new TimeZoneDefinition(tzRis, tzName);
if (tzDef == null) {
if (sLog.isDebugEnabled()) {
sLog.debug("Failed to load TimeZoneDefinition from PidLidTimeZoneStruct and " + tzName);
}
}
return tzDef;
}
use of net.freeutils.tnef.RawInputStream in project zm-mailbox by Zimbra.
the class SchedulingViewOfTnef method getGlobalObjectIdType.
private GlobalObjectId getGlobalObjectIdType(MapiPropertyId mpi) {
GlobalObjectId gid = null;
RawInputStream ris;
try {
ris = mpi.getRawInputStreamValue(this);
if (ris != null) {
gid = new GlobalObjectId(ris);
}
} catch (IOException e) {
sLog.debug("Problem getting value of MAPI property " + mpi.toString() + " from TNEF", e);
}
return gid;
}
Aggregations