use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class TestImapThrottle method search.
@Test
public void search() throws IOException {
Flags flags = Flags.fromSpec("afs");
for (int i = 0; i < 3; i++) {
Date date = new Date(System.currentTimeMillis());
Literal msg = message(1000 + i * 1000);
try {
connection.append("INBOX", flags, date, msg);
} finally {
msg.dispose();
}
}
for (int i = 0; i < LOOP_LIMIT; i++) {
connection.search((Object[]) new String[] { "TEXT", "\"XXXXX\"" });
}
try {
connection.search((Object[]) new String[] { "TEXT", "\"XXXXX\"" });
Assert.fail("should have been rejected");
} catch (CommandFailedException e) {
Assert.assertTrue(connection.isClosed());
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class TestImapThrottle method append.
@Test
public void append() throws Exception {
assertTrue(connection.hasCapability("UIDPLUS"));
Date date = new Date(System.currentTimeMillis());
Flags flags = Flags.fromSpec("afs");
for (int i = 0; i < LOOP_LIMIT; i++) {
Literal msg = message(100000);
try {
connection.append("INBOX", flags, date, msg);
} finally {
msg.dispose();
}
}
Literal msg = message(100000);
try {
connection.append("INBOX", flags, date, msg);
Assert.fail("expected exception here...");
} catch (Exception e) {
Assert.assertTrue(connection.isClosed());
} finally {
msg.dispose();
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class TestImap method testAppend.
@Test
public void testAppend() throws Exception {
assertTrue(connection.hasCapability("UIDPLUS"));
Flags flags = Flags.fromSpec("afs");
Date date = new Date(System.currentTimeMillis());
Literal msg = message(100000);
try {
AppendResult res = connection.append("INBOX", flags, date, msg);
assertNotNull(res);
byte[] b = fetchBody(res.getUid());
assertArrayEquals("content mismatch", msg.getBytes(), b);
} finally {
msg.dispose();
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class ImapSync method getLocalPath.
/*
* Returns the path to the Zimbra folder that stores messages for the given
* IMAP folder. The Zimbra folder has the same path as the IMAP folder,
* but is relative to the root folder specified by the DataSource.
*/
String getLocalPath(ListData ld) throws ServiceException {
String remotePath = ld.getMailbox();
char localDelimiter = ld.getDelimiter();
String relativePath = ld.getMailbox();
Flags flags = ld.getFlags();
if (localDelimiter != '/' && (remotePath.indexOf(localDelimiter) >= 0 || remotePath.indexOf('/') >= 0)) {
// Change remote path to use our separator
String[] parts = remotePath.split("\\" + localDelimiter);
for (int i = 0; i < parts.length; i++) {
// TODO Handle case where separator is not valid in Zimbra folder name
parts[i] = parts[i].replace('/', localDelimiter);
}
relativePath = StringUtil.join("/", parts);
}
relativePath = ILLEGAL_FOLDER_CHARS.matcher(relativePath).replaceAll("_");
if (dataSource.ignoreRemotePath(relativePath, flags)) {
// Do not synchronize folder
return null;
}
String localPath = joinPath(localRootFolder.getPath(), coalesce(dataSource.mapRemoteToLocalPath(relativePath, flags), relativePath));
if (isUniqueLocalPathNeeded(localPath)) {
int count = 1;
for (; ; ) {
String path = String.format("%s-%d", localPath, count++);
if (LocalFolder.fromPath(mbox, path) == null) {
return path;
}
}
} else {
return localPath;
}
}
use of com.zimbra.cs.mailclient.imap.Flags in project zm-mailbox by Zimbra.
the class RemoteFolder method getFlags.
/*
* Fetch message flags for specific UID sequence. Exclude messages which
* have been flagged \Deleted.
*/
public List<MessageData> getFlags(long startUid, long endUid) throws IOException {
final List<MessageData> mds = new ArrayList<MessageData>();
String end = endUid > 0 ? String.valueOf(endUid) : "*";
connection.uidFetch(startUid + ":" + end, "FLAGS", new FetchResponseHandler() {
public void handleFetchResponse(MessageData md) {
Flags flags = md.getFlags();
if (flags != null && !flags.isDeleted()) {
mds.add(md);
}
}
});
// result.
if (endUid <= 0 && mds.size() == 1 && mds.get(0).getUid() < startUid) {
return Collections.emptyList();
}
return mds;
}
Aggregations