Package com.elasticinbox.core.model

Examples of com.elasticinbox.core.model.Label


        // add counters for each of the labels
        for (int labelId : message.getLabels())
        {
          if (!labels.containsId(labelId)) {
            Label label = new Label(labelId).setCounters(message.getLabelCounters());
            labels.put(label);
          } else {
            labels.get(labelId).incrementCounters(message.getLabelCounters());
          }
View Full Code Here


        Set<Integer> messageLabels = this.messages.get(messageId).getLabels();
 
        for (int labelId : messageLabels)
        {
          if (!labels.containsId(labelId)) {
            Label label = new Label(labelId).
                setCounters(this.messages.get(messageId).getLabelCounters());
            labels.put(label);
          } else {
            labels.get(labelId).getCounters().add(
                this.messages.get(messageId).getLabelCounters());
View Full Code Here

        String labelName = (String) a.getValue();
       
        if (labels.containsId(labelId)) {
          labels.get(labelId).setName(labelName);
        } else {
          Label label = new Label(labelId, labelName);
          labels.put(label);
        }
      }
      else if (a.getKey().startsWith(CN_LABEL_ATTRIBUTE_PREFIX))
      {
        // set label custom attribute
        String[] attrKeys = a.getKey().split(CN_SEPARATOR);
        Integer labelId = Integer.parseInt(attrKeys[1]);
        String attrName = attrKeys[2];
        String attrValue = (String) a.getValue();
       
        if (labels.containsId(labelId)) {
          labels.get(labelId).addAttribute(attrName, attrValue);
        } else {
          Label label = new Label(labelId);
          label.addAttribute(attrName, attrValue);
          labels.put(label);
        }
      }
    }

    // add default reserved labels
    for (Label l : ReservedLabels.getAll())
    {
      Label label = new Label(l.getId(), l.getName());
      labels.put(label);
    }

    return labels;
  }
View Full Code Here

      @PathParam("id") Integer labelId,
      @QueryParam("name") String labelName,
      String requestJSONContent)
  {
    Mailbox mailbox = new Mailbox(user, domain);
    Label label;

    if (requestJSONContent.isEmpty())
    {
      // if request body is empty, use path param
      label = new Label();
      label.setName(labelName);
    }
    else
    {
      // deserialize request body to Label
      try {
        ObjectMapper mapper = new ObjectMapper();
        label = mapper.readValue(requestJSONContent, Label.class);
      } catch (Exception e) {
        logger.info("Malformed JSON request: {}", e.getMessage());
        throw new BadRequestException("Malformed JSON request");
      }

      if (label.getName() == null && labelName != null) {
        label.setName(labelName);
      }
    }

    label.setId(labelId);

    try {
      labelDAO.update(mailbox, label);
    } catch (IllegalLabelException ile) {
      throw new BadRequestException(ile.getMessage());
View Full Code Here

      @PathParam("domain") String domain,
      @QueryParam("name") String labelName,
      String requestJSONContent)
  {
    Mailbox mailbox = new Mailbox(user, domain);
    Label label;

    if (requestJSONContent.isEmpty())
    {
      // if request body is empty, use path param
      label = new Label();
      label.setName(labelName);
    }
    else
    {
      // deserialize request body to Label
      try {
        ObjectMapper mapper = new ObjectMapper();
        label = mapper.readValue(requestJSONContent, Label.class);
      } catch (Exception e) {
        logger.info("Malformed JSON request: {}", e.getMessage());
        throw new BadRequestException("Malformed JSON request");
      }
    }

    if (label.getName() == null && labelName == null) {
      throw new BadRequestException("Label name must be specified");
    }

    Integer newLabelId = null;
View Full Code Here

TOP

Related Classes of com.elasticinbox.core.model.Label

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.