use of com.zimbra.client.ZIdentity in project zm-mailbox by Zimbra.
the class TestSaveDraft method testIdentityId.
/**
* Confirms that we update the identity id during a SaveDraft operation (bug 60066).
*/
@Test
public void testIdentityId() throws Exception {
TestUtil.createAccount(USER_NAME);
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
// Save initial draft.
ZOutgoingMessage outgoing = TestUtil.getOutgoingMessage(USER_NAME, NAME_PREFIX + " testIdentityId", "testIdentityId", null);
ZIdentity ident = TestUtil.getDefaultIdentity(mbox);
outgoing.setIdentityId(ident.getId());
ZMessage msg = mbox.saveDraft(outgoing, null, Integer.toString(Mailbox.ID_FOLDER_DRAFTS));
Assert.assertEquals(ident.getId(), msg.getIdentityId());
// Save another draft with a new identity id.
outgoing.setIdentityId("xyz");
msg = mbox.saveDraft(outgoing, msg.getId(), Integer.toString(Mailbox.ID_FOLDER_DRAFTS));
Assert.assertEquals("xyz", msg.getIdentityId());
// Unset identity id.
outgoing.setIdentityId("");
msg = mbox.saveDraft(outgoing, msg.getId(), Integer.toString(Mailbox.ID_FOLDER_DRAFTS));
Assert.assertEquals(null, msg.getIdentityId());
}
use of com.zimbra.client.ZIdentity in project zm-mailbox by Zimbra.
the class ZMailboxUtil method execute.
public ExecuteStatus execute(String[] argsIn) throws ServiceException, IOException {
mCommand = lookupCommand(argsIn[0]);
// shift them over for parser
String[] args = new String[argsIn.length - 1];
System.arraycopy(argsIn, 1, args, 0, args.length);
if (mCommand == null)
throw ZClientException.CLIENT_ERROR("Unknown command: (" + argsIn[0] + ") Type: 'help commands' for a list", null);
try {
mCommandLine = mParser.parse(mCommand.getOptions(), args, true);
args = mCommandLine.getArgs();
} catch (ParseException e) {
usage();
return ExecuteStatus.OK;
}
if (!mCommand.checkArgsLength(args)) {
usage();
return ExecuteStatus.OK;
}
if (mCommand != Command.EXIT && mCommand != Command.HELP && mCommand != Command.AUTHENTICATE && mCommand != Command.ADMIN_AUTHENTICATE && mCommand != Command.SELECT_MAILBOX && mCommand != Command.WHOAMI) {
if (mMbox == null) {
throw ZClientException.CLIENT_ERROR("no mailbox opened. select one with authenticate/adminAuthenticate/selectMailbox", null);
}
}
switch(mCommand) {
case AUTO_COMPLETE:
doAutoComplete(args);
break;
case AUTO_COMPLETE_GAL:
doAutoCompleteGal(args);
break;
case AUTHENTICATE:
doAuth(args);
break;
case ADD_INCOMING_FILTER_RULE:
doAddIncomingFilterRule(args);
break;
case ADD_OUTGOING_FILTER_RULE:
doAddOutgoingFilterRule(args);
break;
case ADD_MESSAGE:
doAddMessage(args);
break;
case ADMIN_AUTHENTICATE:
doAdminAuth(args);
break;
case CHECK_RIGHT:
doCheckRight(args);
break;
case CREATE_CONTACT:
String ccId = mMbox.createContact(lookupFolderId(folderOpt()), tagsOpt(), getContactMap(args, 0, !ignoreOpt())).getId();
stdout.println(ccId);
break;
case CREATE_IDENTITY:
mMbox.createIdentity(new ZIdentity(args[0], getMultiMap(args, 1)));
break;
case CREATE_FOLDER:
doCreateFolder(args);
break;
case CREATE_MOUNTPOINT:
doCreateMountpoint(args);
break;
case CREATE_SEARCH_FOLDER:
doCreateSearchFolder(args);
break;
case CREATE_SIGNATURE:
doCreateSignature(args);
break;
case CREATE_TAG:
ZTag ct = mMbox.createTag(args[0], tagColorOpt());
stdout.println(ct.getId());
break;
case DELETE_CONTACT:
mMbox.deleteContact(args[0]);
break;
case DELETE_CONVERSATION:
mMbox.deleteConversation(id(args[0]), param(args, 1));
break;
case DELETE_INCOMING_FILTER_RULE:
doDeleteIncomingFilterRule(args);
break;
case DELETE_OUTGOING_FILTER_RULE:
doDeleteOutgoingFilterRule(args);
break;
case DELETE_FOLDER:
mMbox.deleteFolder(lookupFolderId(args[0]));
break;
case DELETE_IDENTITY:
mMbox.deleteIdentity(args[0]);
break;
case DELETE_ITEM:
mMbox.deleteItem(id(args[0]), param(args, 1));
break;
case DELETE_MESSAGE:
mMbox.deleteMessage(id(args[0]));
break;
case DELETE_SIGNATURE:
mMbox.deleteSignature(lookupSignatureId(args[0]));
break;
case DELETE_TAG:
mMbox.deleteTag(lookupTag(args[0]).getId());
break;
case DUMPSTER_DELETE_ITEM:
mMbox.dumpsterDeleteItem(id(args[0]));
break;
case EMPTY_DUMPSTER:
mMbox.emptyDumpster();
break;
case EMPTY_FOLDER:
mMbox.emptyFolder(lookupFolderId(args[0]));
break;
case EXIT:
return ExecuteStatus.EXIT;
//break;
case FLAG_CONTACT:
mMbox.flagContact(id(args[0]), paramb(args, 1, true));
break;
case FLAG_CONVERSATION:
mMbox.flagConversation(id(args[0]), paramb(args, 1, true), param(args, 2));
break;
case FLAG_ITEM:
mMbox.flagItem(id(args[0]), paramb(args, 1, true), param(args, 2));
break;
case FLAG_MESSAGE:
mMbox.flagMessage(id(args[0]), paramb(args, 1, true));
break;
case GET_ALL_CONTACTS:
doGetAllContacts(args);
break;
case GET_CONTACTS:
doGetContacts(args);
break;
case GET_IDENTITIES:
doGetIdentities();
break;
case GET_SIGNATURES:
doGetSignatures();
break;
case GET_ALL_FOLDERS:
doGetAllFolders();
break;
case GET_ALL_TAGS:
doGetAllTags();
break;
case GET_APPOINTMENT_SUMMARIES:
doGetAppointmentSummaries(args);
break;
case GET_CONVERSATION:
doGetConversation(args);
break;
case GET_INCOMING_FILTER_RULES:
doGetIncomingFilterRules();
break;
case GET_OUTGOING_FILTER_RULES:
doGetOutgoingFilterRules();
break;
case GET_FOLDER:
doGetFolder(args);
break;
case GET_FOLDER_REQUEST:
doGetFolderRequest(args);
break;
case GET_FOLDER_GRANT:
doGetFolderGrant(args);
break;
case GET_MAILBOX_SIZE:
if (verboseOpt())
stdout.format("%d%n", mMbox.getSize());
else
stdout.format("%s%n", formatSize(mMbox.getSize()));
break;
case GET_MESSAGE:
doGetMessage(args);
break;
case GET_RIGHTS:
doGetRights(args);
break;
case GET_REST_URL:
doGetRestURL(args);
break;
case GRANT_RIGHT:
doGrantRight(args);
break;
case HELP:
doHelp(args);
break;
case IMPORT_URL_INTO_FOLDER:
mMbox.importURLIntoFolder(lookupFolderId(args[0]), args[1]);
break;
case LIST_RIGHTS:
doListRights();
break;
case MARK_CONVERSATION_READ:
mMbox.markConversationRead(id(args[0]), paramb(args, 1, true), param(args, 2));
break;
case MARK_ITEM_READ:
mMbox.markItemRead(id(args[0]), paramb(args, 1, true), param(args, 2));
break;
case MARK_FOLDER_READ:
mMbox.markFolderRead(lookupFolderId(args[0]));
break;
case MARK_MESSAGE_READ:
mMbox.markMessageRead(id(args[0]), paramb(args, 1, true));
break;
case MARK_CONVERSATION_SPAM:
mMbox.markConversationSpam(id(args[0]), paramb(args, 1, true), lookupFolderId(param(args, 2)), param(args, 3));
break;
case MARK_MESSAGE_SPAM:
mMbox.markMessageSpam(id(args[0]), paramb(args, 1, true), lookupFolderId(param(args, 2)));
break;
case MARK_TAG_READ:
mMbox.markTagRead(lookupTag(args[0]).getId());
break;
case MODIFY_CONTACT:
doModifyContact(args);
break;
case MODIFY_INCOMING_FILTER_RULE:
doModifyIncomingFilterRule(args);
break;
case MODIFY_OUTGOING_FILTER_RULE:
doModifyOutgoingFilterRule(args);
break;
case MODIFY_FOLDER_CHECKED:
mMbox.modifyFolderChecked(lookupFolderId(args[0]), paramb(args, 1, true));
break;
case MODIFY_FOLDER_COLOR:
mMbox.modifyFolderColor(lookupFolderId(args[0]), ZFolder.Color.fromString(args[1]));
break;
case MODIFY_FOLDER_EXCLUDE_FREE_BUSY:
mMbox.modifyFolderExcludeFreeBusy(lookupFolderId(args[0]), paramb(args, 1, true));
break;
case MODIFY_FOLDER_GRANT:
doModifyFolderGrant(args);
break;
case MODIFY_FOLDER_FLAGS:
mMbox.updateFolder(lookupFolderId(args[0]), null, null, null, null, args[1], null);
break;
case MODIFY_FOLDER_URL:
mMbox.modifyFolderURL(lookupFolderId(args[0]), args[1]);
break;
case MODIFY_IDENTITY:
mMbox.modifyIdentity(new ZIdentity(args[0], getMultiMap(args, 1)));
break;
case MODIFY_ITEM_FLAGS:
mMbox.updateItem(id(args[0]), null, null, args[1], null);
break;
case MODIFY_MOUNTPOINT_ENABLE_SHARED_REMINDER:
mMbox.enableSharedReminder(lookupFolderId(args[0]), paramb(args, 1, false));
break;
case MODIFY_SIGNATURE:
doModifySignature(args);
break;
case MODIFY_TAG_COLOR:
mMbox.modifyTagColor(lookupTag(args[0]).getId(), Color.fromString(args[1]));
break;
case MOVE_CONVERSATION:
mMbox.moveConversation(id(args[0]), lookupFolderId(param(args, 1)), param(args, 2));
break;
case MOVE_ITEM:
mMbox.moveItem(id(args[0]), lookupFolderId(param(args, 1)), param(args, 2));
break;
case MOVE_MESSAGE:
mMbox.moveMessage(id(args[0]), lookupFolderId(param(args, 1)));
break;
case MOVE_CONTACT:
mMbox.moveContact(id(args[0]), lookupFolderId(param(args, 1)));
break;
case NOOP:
doNoop(args);
break;
case POST_REST_URL:
doPostRestURL(args);
break;
case RECOVER_ITEM:
mMbox.recoverItem(id(args[0]), lookupFolderId(param(args, 1)));
break;
case RENAME_FOLDER:
mMbox.renameFolder(lookupFolderId(args[0]), args[1]);
break;
case RENAME_SIGNATURE:
doRenameSignature(args);
break;
case RENAME_TAG:
mMbox.renameTag(lookupTag(args[0]).getId(), args[1]);
break;
case REVOKE_RIGHT:
doRevokeRight(args);
break;
case SEARCH:
doSearch(args);
break;
case SEARCH_CONVERSATION:
doSearchConv(args);
break;
case SELECT_MAILBOX:
doSelectMailbox(args);
break;
case SYNC_FOLDER:
mMbox.syncFolder(lookupFolderId(args[0]));
break;
case TAG_CONTACT:
mMbox.tagContact(id(args[0]), lookupTag(args[1]).getId(), paramb(args, 2, true));
break;
case TAG_CONVERSATION:
mMbox.tagConversation(id(args[0]), lookupTag(args[1]).getId(), paramb(args, 2, true), param(args, 3));
break;
case TAG_ITEM:
mMbox.tagItem(id(args[0]), lookupTag(args[1]).getId(), paramb(args, 2, true), param(args, 3));
break;
case TAG_MESSAGE:
mMbox.tagMessage(id(args[0]), lookupTag(args[1]).getId(), paramb(args, 2, true));
break;
case WHOAMI:
dumpMailboxConnect();
break;
default:
throw ZClientException.CLIENT_ERROR("Unhandled command: (" + mCommand.name() + ")", null);
}
return ExecuteStatus.OK;
}
use of com.zimbra.client.ZIdentity in project zm-mailbox by Zimbra.
the class ZMailboxUtil method dumpIdentities.
private void dumpIdentities(List<ZIdentity> identities) {
if (verboseOpt()) {
stdout.println("[");
boolean first = true;
for (ZIdentity identity : identities) {
if (first)
first = false;
else
stdout.println(",");
stdout.println(identity.dump());
}
stdout.println("]");
} else {
if (identities.size() == 0)
return;
for (ZIdentity identity : identities) {
stdout.println(identity.getName());
}
}
}
Aggregations