use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.
the class PlainTextSignature method preModify.
@Override
public void preModify(CallbackContext context, String attrName, Object value, Map attrsToModify, Entry entry) throws ServiceException {
SingleValueMod mod = singleValueMod(attrName, value);
if (mod.unsetting())
return;
Account account;
if (entry instanceof Account) {
account = (Account) entry;
} else if (entry instanceof Identity) {
account = ((Identity) entry).getAccount();
} else if (entry instanceof DataSource) {
account = ((DataSource) entry).getAccount();
} else {
return;
}
Signature sig = Provisioning.getInstance().get(account, Key.SignatureBy.id, mod.value());
if (sig == null) {
throw ServiceException.INVALID_REQUEST("No such signature " + mod.value() + " for account " + account.getName(), null);
}
String sigAttr = SignatureUtil.mimeTypeToAttrName(MimeConstants.CT_TEXT_PLAIN);
String plainSig = sig.getAttr(sigAttr, null);
if (StringUtil.isNullOrEmpty(plainSig)) {
throw ServiceException.INVALID_REQUEST("Signature " + mod.value() + " must have plain text content", null);
}
}
use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.
the class CalendarMailSender method getSignatureText.
private static String getSignatureText(Account acct, Identity identity, String signatureKey) throws ServiceException {
String sigId = identity.getAttr(signatureKey);
if (sigId == null)
return null;
Signature sig = Provisioning.getInstance().get(acct, Key.SignatureBy.id, sigId);
if (sig == null) {
ZimbraLog.calendar.warn("No such signature " + sigId + " for account " + acct.getName());
return null;
}
String attr = SignatureUtil.mimeTypeToAttrName(MimeConstants.CT_TEXT_PLAIN);
return sig.getAttr(attr, null);
}
use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.
the class TestLdapProvSearchDirectory method accountsOnServerAndCosHasSubordinates.
@Test
public void accountsOnServerAndCosHasSubordinates() throws Exception {
/*
* X.501: 14.4.4 Has Subordinates operational attribute
* is not supported in ubid InMemoryLdapServer
*/
SKIP_FOR_INMEM_LDAP_SERVER(SkipTestReason.SUBORDINATES_OPERTIONAL_ATTRIBUTE);
String COS_ID = prov.get(CosBy.name, Provisioning.DEFAULT_COS_NAME).getId();
Account acct = createAccount(genAcctNameLocalPart());
Signature sig1 = prov.createSignature(acct, "sig1", new HashMap<String, Object>());
Signature sig2 = prov.createSignature(acct, "sig2", new HashMap<String, Object>());
SearchAccountsOptions searchOpts = new SearchAccountsOptions();
ZLdapFilter filter = ZLdapFilterFactory.getInstance().accountsOnServerAndCosHasSubordinates(prov.getLocalServer().getServiceHostname(), COS_ID);
searchOpts.setFilter(filter);
List<NamedEntry> accounts = prov.searchDirectory(searchOpts);
Verify.verifyEquals(Lists.newArrayList(acct), accounts, false);
deleteAccount(acct);
}
use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.
the class TestLdapProvRenameDomain method createSignatures.
private String[] createSignatures(Account acct) throws Exception {
String[] sigIds = new String[NUM_SIGNATURES];
for (int i = 0; i < NUM_SIGNATURES; i++) {
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraPrefMailSignature, SIGNATURE_CONTENT(acct, i));
Signature entry = prov.createSignature(acct, SIGNATURE_NAME(acct, i), attrs);
sigIds[i] = entry.getId();
}
return sigIds;
}
use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.
the class TestLdapProvSignature method createSignature.
private Signature createSignature(Account acct, String signatureName) throws Exception {
Signature signature = prov.get(acct, Key.SignatureBy.name, signatureName);
assertNull(signature);
createSignatureRaw(acct, signatureName);
signature = prov.get(acct, Key.SignatureBy.name, signatureName);
assertNotNull(signature);
assertEquals(signatureName, signature.getName());
return signature;
}
Aggregations