mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
Closes #632: validate POST /app/config_inbox and update documentation
This commit is contained in:
parent
bd23f14792
commit
e6cfd899e5
@ -85,7 +85,7 @@ public class InboxService extends AbstractScheduledService {
|
||||
lastSyncDate = new Date();
|
||||
lastSyncMessageCount = 0;
|
||||
try {
|
||||
HashMap<String, String> tagsNameToId = getAllTags();
|
||||
Map<String, String> tagsNameToId = getAllTags();
|
||||
|
||||
inbox = openInbox();
|
||||
Message[] messages = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
|
||||
@ -192,7 +192,7 @@ public class InboxService extends AbstractScheduledService {
|
||||
* @param message Message
|
||||
* @throws Exception e
|
||||
*/
|
||||
private void importMessage(Message message, HashMap<String, String> tags) throws Exception {
|
||||
private void importMessage(Message message, Map<String, String> tags) throws Exception {
|
||||
log.info("Importing message: " + message.getSubject());
|
||||
|
||||
// Parse the mail
|
||||
@ -273,16 +273,16 @@ public class InboxService extends AbstractScheduledService {
|
||||
/**
|
||||
* Fetches a HashMap with all tag names as keys and their respective ids as values.
|
||||
*
|
||||
* @return HashMap with all tags or null if not enabled
|
||||
* @return Map with all tags or null if not enabled
|
||||
*/
|
||||
private HashMap<String, String> getAllTags() {
|
||||
private Map<String, String> getAllTags() {
|
||||
if (!ConfigUtil.getConfigBooleanValue(ConfigType.INBOX_AUTOMATIC_TAGS)) {
|
||||
return null;
|
||||
}
|
||||
TagDao tagDao = new TagDao();
|
||||
List<TagDto> tags = tagDao.findByCriteria(new TagCriteria().setTargetIdList(null), new SortCriteria(1, true));
|
||||
|
||||
HashMap<String, String> tagsNameToId = new HashMap<>();
|
||||
Map<String, String> tagsNameToId = new HashMap<>();
|
||||
for (TagDto tagDto : tags) {
|
||||
tagsNameToId.put(tagDto.getName(), tagDto.getId());
|
||||
}
|
||||
|
@ -396,6 +396,8 @@ public class AppResource extends BaseResource {
|
||||
* @apiName PostAppConfigInbox
|
||||
* @apiGroup App
|
||||
* @apiParam {Boolean} enabled True if the inbox scanning is enabled
|
||||
* @apiParam {Boolean} autoTagsEnabled If true automatically add tags to document (prefixed by #)
|
||||
* @apiParam {Boolean} deleteImported If true delete message from mailbox after import
|
||||
* @apiParam {String} hostname IMAP hostname
|
||||
* @apiParam {Integer} port IMAP port
|
||||
* @apiParam {String} username IMAP username
|
||||
@ -432,6 +434,8 @@ public class AppResource extends BaseResource {
|
||||
}
|
||||
checkBaseFunction(BaseFunction.ADMIN);
|
||||
ValidationUtil.validateRequired(enabled, "enabled");
|
||||
ValidationUtil.validateRequired(autoTagsEnabled, "autoTagsEnabled");
|
||||
ValidationUtil.validateRequired(deleteImported, "deleteImported");
|
||||
if (!Strings.isNullOrEmpty(portStr)) {
|
||||
ValidationUtil.validateInteger(portStr, "port");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user