synchronized void fromElement(Element element) throws ServiceException {
   super.fromElement(element);
   mRejectFrom = new ArrayList<String>();
   for (Element fromEl : element.listElements(VoiceConstants.E_PHONE)) {
     mRejectFrom.add(fromEl.getAttribute(VoiceConstants.A_PHONE_NUMBER));
   }
 }
Exemple #2
0
 public void reload(SoapProvisioning prov) throws ServiceException {
   XMLElement req = new XMLElement(AdminConstants.GET_DOMAIN_REQUEST);
   Element a = req.addElement(AdminConstants.E_DOMAIN);
   a.setText(getId());
   a.addAttribute(AdminConstants.A_BY, Key.DomainBy.id.name());
   setAttrs(SoapProvisioning.getAttrs(prov.invoke(req).getElement(AdminConstants.E_DOMAIN)));
 }
Exemple #3
0
  public Element handle(Element request, Map<String, Object> context) throws ServiceException {

    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();

    boolean applyConfig = request.getAttributeBool(AdminConstants.A_APPLY_CONFIG, true);
    Set<String> reqAttrs = getReqAttrs(request, AttributeClass.server);

    Element d = request.getElement(AdminConstants.E_SERVER);
    String method = d.getAttribute(AdminConstants.A_BY);
    String name = d.getText();

    if (name == null || name.equals(""))
      throw ServiceException.INVALID_REQUEST("must specify a value for a server", null);

    Server server = prov.get(ServerBy.fromString(method), name);

    if (server == null) throw AccountServiceException.NO_SUCH_SERVER(name);

    AdminAccessControl aac = checkRight(zsc, context, server, AdminRight.PR_ALWAYS_ALLOW);

    // reload the server
    prov.reload(server);

    Element response = zsc.createElement(AdminConstants.GET_SERVER_RESPONSE);
    encodeServer(response, server, applyConfig, reqAttrs, aac.getAttrRightChecker(server));

    return response;
  }
  Entry getTargetEntry(Provisioning prov, Element eTarget, TargetType targetType)
      throws ServiceException {
    TargetBy targetBy = TargetBy.fromString(eTarget.getAttribute(AdminConstants.A_BY));
    String target = eTarget.getText();

    return TargetType.lookupTarget(prov, targetType, targetBy, target);
  }
Exemple #5
0
 private static void addAttr(Element response, String name, String value) {
   if (value != null && !value.equals("")) {
     Element e = response.addElement(AdminConstants.E_A);
     e.addAttribute(AdminConstants.A_N, name);
     e.setText(value);
   }
 }
  @Override
  public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);

    Element mreq = request.getElement(AdminConstants.E_MAILBOX);
    String accountId = mreq.getAttribute(AdminConstants.A_ACCOUNTID);

    Provisioning prov = Provisioning.getInstance();
    Account account = prov.get(AccountBy.id, accountId, zsc.getAuthToken());
    if (account == null) {
      throw AccountServiceException.NO_SUCH_ACCOUNT(accountId);
    }
    checkAdminLoginAsRight(zsc, prov, account);

    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
    if (mbox == null) {
      throw MailServiceException.NO_SUCH_MBOX(accountId);
    }

    mbox.recalculateFolderAndTagCounts();

    Element response = zsc.createElement(AdminConstants.RECALCULATE_MAILBOX_COUNTS_RESPONSE);
    response
        .addElement(AdminConstants.E_MAILBOX)
        .addAttribute(AdminConstants.A_ACCOUNTID, accountId)
        .addAttribute(AdminConstants.A_QUOTA_USED, mbox.getSize());
    return response;
  }
Exemple #7
0
 SoapDomain(Element e, Provisioning prov) throws ServiceException {
   super(
       e.getAttribute(AdminConstants.A_NAME),
       e.getAttribute(AdminConstants.A_ID),
       SoapProvisioning.getAttrs(e),
       null,
       prov);
 }
Exemple #8
0
 static void doCos(Account acct, Element response) throws ServiceException {
   Cos cos = Provisioning.getInstance().getCOS(acct);
   if (cos != null) {
     Element eCos = response.addUniqueElement(AdminConstants.E_COS);
     eCos.addAttribute(AdminConstants.A_ID, cos.getId());
     eCos.addAttribute(AdminConstants.A_NAME, cos.getName());
   }
 }
Exemple #9
0
 @Override
 Element toElement(Element parent) {
   Element test = parent.addElement(MailConstants.E_ATTACHMENT_TEST);
   if (!mExists) {
     test.addAttribute(MailConstants.A_NEGATIVE, true);
   }
   return test;
 }
 void toElement(Element element) throws ServiceException {
   super.toElement(element);
   for (String name : mRejectFrom) {
     Element fromEl = element.addElement(VoiceConstants.E_PHONE);
     fromEl.addAttribute(VoiceConstants.A_PHONE_NUMBER, name);
     fromEl.addAttribute(VoiceConstants.A_ACTIVE, "true");
   }
 }
Exemple #11
0
 /**
  * Add remote tags attribute corresponding to list of local tags
  *
  * @throws ServiceException
  */
 public Element addOutboundTagsAttr(Element req, String tagStr) throws ServiceException {
   if (mappingRequired) {
     req.addAttribute(MailConstants.A_TAGS, remoteAttrFromTags(tagStr));
   } else {
     req.addAttribute(MailConstants.A_TAGS, tagStr);
   }
   return req;
 }
Exemple #12
0
 @Override
 Element toElement(Element parent) {
   Element test = parent.addElement(MailConstants.E_CURRENT_DAY_OF_WEEK_TEST);
   test.addAttribute(MailConstants.A_VALUE, days);
   if (op == SimpleOp.NOT_IS) {
     test.addAttribute(MailConstants.A_NEGATIVE, true);
   }
   return test;
 }
Exemple #13
0
 @Override
 Element toElement(Element parent) {
   Element test = parent.addElement(MailConstants.E_HEADER_EXISTS_TEST);
   test.addAttribute(MailConstants.A_HEADER, mHeaderName);
   if (!mExists) {
     test.addAttribute(MailConstants.A_NEGATIVE, true);
   }
   return test;
 }
Exemple #14
0
 @Override
 Element toElement(Element parent) {
   Element test = parent.addElement(MailConstants.E_ADDRESS_BOOK_TEST);
   test.addAttribute(MailConstants.A_HEADER, mHeader);
   test.addAttribute(MailConstants.A_FOLDER_PATH, "contacts");
   if (mAddressBookOp == AddressBookOp.NOT_IN) {
     test.addAttribute(MailConstants.A_NEGATIVE, true);
   }
   return test;
 }
Exemple #15
0
 @Override
 Element toElement(Element parent) {
   Element test = parent.addElement(MailConstants.E_DATE_TEST);
   test.addAttribute(MailConstants.A_DATE_COMPARISON, mDateOp.toDateComparison().toString());
   if (mDateOp.isNegative()) {
     test.addAttribute(MailConstants.A_NEGATIVE, true);
   }
   test.addAttribute(MailConstants.A_DATE, mDate.getTime() / 1000);
   return test;
 }
Exemple #16
0
 @Override
 Element toElement(Element parent) {
   Element test = parent.addElement(MailConstants.E_CURRENT_TIME_TEST);
   test.addAttribute(MailConstants.A_DATE_COMPARISON, dateOp.toDateComparison().toString());
   if (dateOp.isNegative()) {
     test.addAttribute(MailConstants.A_NEGATIVE, true);
   }
   test.addAttribute(MailConstants.A_TIME, timeStr);
   return test;
 }
Exemple #17
0
 @Override
 Element toElement(Element parent) {
   Element test = parent.addElement(MailConstants.E_SIZE_TEST);
   test.addAttribute(MailConstants.A_NUMBER_COMPARISON, mSizeOp.toNumberComparison().toString());
   if (mSizeOp.isNegative()) {
     test.addAttribute(MailConstants.A_NEGATIVE, true);
   }
   test.addAttribute(MailConstants.A_SIZE, mSize);
   return test;
 }
Exemple #18
0
  NamedEntry getGranteeEntry(Provisioning prov, Element eGrantee, GranteeType granteeType)
      throws ServiceException {
    if (!granteeType.allowedForAdminRights())
      throw ServiceException.INVALID_REQUEST(
          "unsupported grantee type: " + granteeType.getCode(), null);

    GranteeBy granteeBy = GranteeBy.fromString(eGrantee.getAttribute(AdminConstants.A_BY));
    String grantee = eGrantee.getText();

    return GranteeType.lookupGrantee(prov, granteeType, granteeBy, grantee);
  }
Exemple #19
0
  public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zc = getZimbraSoapContext(context);
    Server server = Provisioning.getInstance().getLocalServer();
    Element response = zc.createElement(MailConstants.GET_SPELL_DICTIONARIES_RESPONSE);

    for (String dictionary : server.getSpellAvailableDictionary()) {
      response.addElement(MailConstants.E_DICTIONARY).setText(dictionary);
    }

    return response;
  }
 public void writeResponse(Element resp) {
   for (Map.Entry<String, Status> entry : mStatus.entrySet()) {
     Element progress = resp.addElement(AdminConstants.E_PROGRESS);
     progress.addAttribute(AdminConstants.A_SERVER, entry.getKey());
     progress.addAttribute(AdminConstants.A_STATUS, entry.getValue().value);
     Exception e = entry.getValue().error;
     if (e != null) {
       progress.addAttribute(AdminConstants.A_ERROR, e.getMessage());
     }
   }
 }
Exemple #21
0
 void toElement(Element element) throws ServiceException {
   element.addAttribute(VoiceConstants.A_SUBSCRIBED, true);
   element.addAttribute(VoiceConstants.A_ACTIVE, mIsActive);
   for (String key : mData.keySet()) {
     Element subEl = element.addElement(key);
     String value = mData.get(key);
     if (value != null) {
       subEl.setText(value);
     }
   }
 }
Exemple #22
0
 @Override
 Element toElement(Element parent) {
   Element test = parent.addElement(MailConstants.E_INVITE_TEST);
   if (!mIsInvite) {
     test.addAttribute(MailConstants.A_NEGATIVE, true);
   }
   for (String method : mMethods) {
     test.addElement(MailConstants.E_METHOD).setText(method);
   }
   return test;
 }
Exemple #23
0
 /**
  * Add the appropriate tags attribute depending on direction of request and remote version
  *
  * @throws ServiceException
  */
 public Element addTagsAttr(Element req, Element resp, boolean outbound) throws ServiceException {
   if (outbound) {
     req = addOutboundTagsAttr(req, resp.getAttribute(MailConstants.A_TAGS, ""));
   } else {
     if (mappingRequired) {
       req.addAttribute(MailConstants.A_TAGS, localTagsFromElement(resp, ""));
     } else {
       req.addAttribute(MailConstants.A_TAGS, resp.getAttribute(MailConstants.A_TAGS, ""));
     }
   }
   return req;
 }
Exemple #24
0
 @Override
 Element toElement(Element parent) {
   Element test = parent.addElement(MailConstants.E_BODY_TEST);
   if (caseSensitive) test.addAttribute(MailConstants.A_CASE_SENSITIVE, caseSensitive);
   if (!StringUtil.isNullOrEmpty(text)) {
     test.addAttribute(MailConstants.A_VALUE, text);
   }
   if (bodyOp == BodyOp.NOT_CONTAINS) {
     test.addAttribute(MailConstants.A_NEGATIVE, true);
   }
   return test;
 }
  public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);

    if (!canAccessAccount(zsc, account))
      throw ServiceException.PERM_DENIED("can not access account");

    Element response = zsc.createElement(AccountConstants.GET_AVAILABLE_CSV_FORMATS_RESPONSE);
    for (String format : ContactCSV.getAllFormatNames())
      response.addElement(AccountConstants.E_CSV).addAttribute(AccountConstants.A_NAME, format);
    return response;
  }
  private void doit(ZAuthToken zat, String[] accts, boolean sync)
      throws SoapFaultException, IOException, ServiceException {
    Element req = new Element.XMLElement(AdminConstants.FIX_CALENDAR_PRIORITY_REQUEST);
    if (accts == null || accts.length == 0)
      throw ServiceException.INVALID_REQUEST("Missing -" + O_ACCOUNT + " option", null);
    for (String acct : accts) {
      Element acctElem = req.addElement(AdminConstants.E_ACCOUNT);
      acctElem.addAttribute(AdminConstants.A_NAME, acct);
    }
    if (sync) req.addAttribute(AdminConstants.A_TZFIXUP_SYNC, true);

    auth(zat);
    getTransport().invokeWithoutSession(req);
  }
Exemple #27
0
 private static void parseComponentIncludeExcludeAttrs(Element backupElem, BackupParams params)
     throws ServiceException
 {
     Server server = Provisioning.getInstance().getLocalServer();
     boolean confSkipSearchIndex = server.isBackupSkipSearchIndex();
     boolean confSkipBlobs = server.isBackupSkipBlobs();
     boolean confSkipSecondaryBlobs = server.isBackupSkipHsmBlobs();
     String choice = backupElem.getAttribute("searchIndex", null);
     params.skipSearchIndex = parseIncludeExcludeAttr(choice, confSkipSearchIndex);
     choice = backupElem.getAttribute("blobs", null);
     params.skipBlobs = parseIncludeExcludeAttr(choice, confSkipBlobs);
     choice = backupElem.getAttribute("secondaryBlobs", null);
     params.skipSecondaryBlobs = parseIncludeExcludeAttr(choice, confSkipSecondaryBlobs);
 }
 /** Done like this rather than using JAXB for performance reasons */
 public Element toElement(Element parent) {
   Element mel =
       parent.addNonUniqueElement(MailConstants.E_MSG).addAttribute(MailConstants.A_ID, id);
   if (size != null) {
     mel.addAttribute(MailConstants.A_SIZE, size);
   }
   if (folderId != null) {
     mel.addAttribute(MailConstants.A_FOLDER, folderId);
   }
   if (autoSendTime != null) {
     mel.addAttribute(MailConstants.A_AUTO_SEND_TIME, autoSendTime);
   }
   return mel;
 }
Exemple #29
0
  public static void encodeServer(
      Element e,
      Server s,
      boolean applyConfig,
      Set<String> reqAttrs,
      AttrRightChecker attrRightChecker)
      throws ServiceException {
    Element server = e.addElement(AdminConstants.E_SERVER);
    server.addAttribute(AdminConstants.A_NAME, s.getName());
    server.addAttribute(AdminConstants.A_ID, s.getId());
    Map<String, Object> attrs = s.getUnicodeAttrs(applyConfig);

    ToXML.encodeAttrs(server, attrs, reqAttrs, attrRightChecker);
  }
Exemple #30
0
 synchronized void fromElement(Element element) throws ServiceException {
   Iterator<Element.Attribute> iter = element.attributeIterator();
   while (iter.hasNext()) {
     Element.Attribute attribute = iter.next();
     String key = attribute.getKey();
     String value = attribute.getValue();
     if (VoiceConstants.A_ACTIVE.equals(key)) {
       mIsActive = Element.parseBool(key, value);
     } else if (VoiceConstants.A_SUBSCRIBED.equals(key)) {
       mIsSubscribed = Element.parseBool(key, value);
     } else {
       setData(key, value);
     }
   }
 }