-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #44 - DELETE Document API does not work unless a corresponding file exists in S3 * #40 - Add last modified to GET documents and GET document/{id} * #45 - Metadata records with no corresponding S3 object are causing issues on GET /documents * #46 - 500 Error in /search endpoint when using large "limit" with "responseFields" * #48 - File downloads are named using the document ID rather than the original filename * added POST /documents/{documentId}/actions * POST /searchFulltext - added pagination
- Loading branch information
Showing
97 changed files
with
4,122 additions
and
1,313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
actions/src/main/java/com/formkiq/module/actions/services/ActionsValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* MIT License | ||
* | ||
* Copyright (c) 2018 - 2020 FormKiQ | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.formkiq.module.actions.services; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import com.formkiq.module.actions.Action; | ||
import com.formkiq.validation.ValidationError; | ||
|
||
/** | ||
* | ||
* {@link Action} Validator. | ||
* | ||
*/ | ||
public interface ActionsValidator { | ||
|
||
/** | ||
* Validates {@link Action}. | ||
* | ||
* @param action {@link Action} | ||
* @return {@link Collection} {@link ValidationError} | ||
*/ | ||
Collection<ValidationError> validation(Action action); | ||
|
||
/** | ||
* Validates {@link List} {@link Action}. | ||
* | ||
* @param action {@link Action} | ||
* @return {@link List} {@link Collection} {@link ValidationError} | ||
*/ | ||
List<Collection<ValidationError>> validation(List<Action> action); | ||
} |
78 changes: 78 additions & 0 deletions
78
actions/src/main/java/com/formkiq/module/actions/services/ActionsValidatorImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* MIT License | ||
* | ||
* Copyright (c) 2018 - 2020 FormKiQ | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.formkiq.module.actions.services; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import com.formkiq.module.actions.Action; | ||
import com.formkiq.module.actions.ActionType; | ||
import com.formkiq.validation.ValidationError; | ||
import com.formkiq.validation.ValidationErrorImpl; | ||
|
||
/** | ||
* | ||
* {@link ActionsValidator}. | ||
* | ||
*/ | ||
public class ActionsValidatorImpl implements ActionsValidator { | ||
|
||
@Override | ||
public Collection<ValidationError> validation(final Action action) { | ||
Collection<ValidationError> errors = new ArrayList<>(); | ||
|
||
if (action == null) { | ||
|
||
errors.add(new ValidationErrorImpl().error("action is required")); | ||
|
||
} else { | ||
|
||
if (action.type() == null) { | ||
|
||
errors.add(new ValidationErrorImpl().key("type").error("'type' is required")); | ||
|
||
} else { | ||
|
||
Map<String, String> parameters = | ||
action.parameters() != null ? action.parameters() : Collections.emptyMap(); | ||
if (ActionType.WEBHOOK.equals(action.type()) && !parameters.containsKey("url")) { | ||
errors.add( | ||
new ValidationErrorImpl().key("parameters.url").error("'url' parameter is required")); | ||
} | ||
} | ||
} | ||
|
||
return errors; | ||
} | ||
|
||
@Override | ||
public List<Collection<ValidationError>> validation(final List<Action> actions) { | ||
List<Collection<ValidationError>> errors = new ArrayList<>(); | ||
actions.forEach(a -> errors.add(validation(a))); | ||
return errors; | ||
} | ||
|
||
} |
115 changes: 115 additions & 0 deletions
115
actions/src/test/java/com/formkiq/module/actions/services/ActionsValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/** | ||
* MIT License | ||
* | ||
* Copyright (c) 2018 - 2020 FormKiQ | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.formkiq.module.actions.services; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import com.formkiq.module.actions.Action; | ||
import com.formkiq.module.actions.ActionType; | ||
import com.formkiq.validation.ValidationError; | ||
|
||
class ActionsValidatorTest { | ||
|
||
/** {@link ActionsValidator}. */ | ||
private ActionsValidator validator = new ActionsValidatorImpl(); | ||
|
||
@Test | ||
void testValidation01() { | ||
// given | ||
Action action = null; | ||
|
||
// when | ||
Collection<ValidationError> errors = this.validator.validation(action); | ||
|
||
// then | ||
assertEquals(1, errors.size()); | ||
ValidationError error = errors.iterator().next(); | ||
assertNull(error.key()); | ||
assertEquals("action is required", error.error()); | ||
} | ||
|
||
@Test | ||
void testValidation02() { | ||
// given | ||
Action action = new Action(); | ||
|
||
// when | ||
Collection<ValidationError> errors = this.validator.validation(action); | ||
|
||
// then | ||
assertEquals(1, errors.size()); | ||
ValidationError error = errors.iterator().next(); | ||
assertEquals("type", error.key()); | ||
assertEquals("'type' is required", error.error()); | ||
} | ||
|
||
@Test | ||
void testValidation03() { | ||
// given | ||
Action action = new Action().type(ActionType.WEBHOOK); | ||
|
||
// when | ||
Collection<ValidationError> errors = this.validator.validation(action); | ||
|
||
// then | ||
assertEquals(1, errors.size()); | ||
ValidationError error = errors.iterator().next(); | ||
assertEquals("parameters.url", error.key()); | ||
assertEquals("'url' parameter is required", error.error()); | ||
} | ||
|
||
@Test | ||
void testValidation04() { | ||
// given | ||
Action action = new Action(); | ||
List<Action> actions = Arrays.asList(action); | ||
|
||
// when | ||
List<Collection<ValidationError>> errorList = this.validator.validation(actions); | ||
|
||
// then | ||
assertEquals(1, errorList.size()); | ||
|
||
Collection<ValidationError> errors = errorList.get(0); | ||
ValidationError error = errors.iterator().next(); | ||
assertEquals("type", error.key()); | ||
assertEquals("'type' is required", error.error()); | ||
} | ||
|
||
@Test | ||
void testValidation05() { | ||
// given | ||
Action action = new Action().type(ActionType.OCR); | ||
|
||
// when | ||
Collection<ValidationError> errorList = this.validator.validation(action); | ||
|
||
// then | ||
assertEquals(0, errorList.size()); | ||
} | ||
} |
Oops, something went wrong.