/** * Translate a delimted list of tag names to a delimited list of correponding local tagIds * * @throws ServiceException */ public String localTagsFromNames(String tagNames, String inDelim, String outDelim) throws ServiceException { if (tagNames != null && tagNames.length() > 0) { StringBuilder sb = new StringBuilder(); String[] names = tagNames.split(inDelim); for (String name : names) { if (name.trim().length() <= 0) { continue; } Integer tagId = localIdsByName.get(name); if (tagId == null) { try { Tag tag = mbox.getTagByName(null, name); tagId = tag.getId(); localIdsByName.put(name, tagId); } catch (MailServiceException mse) { if (MailServiceException.NO_SUCH_TAG.equals(mse.getCode())) { OfflineLog.offline.debug( "message has tag [" + name + "] which is not visible locally"); continue; } else { throw mse; } } } sb.append(tagId).append(outDelim); } if (sb.length() >= outDelim.length()) { sb.setLength(sb.length() - outDelim.length()); } return sb.toString(); } else { return tagNames; } }