summaryrefslogtreecommitdiffstats
path: root/dcaedt_be/src/main/java/org/onap/sdc/dcae/rule/editor/validators/LogTextValidator.java
blob: 711692f46c956c86080f90106a59b95ff8bb4fb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.onap.sdc.dcae.rule.editor.validators;

import org.onap.sdc.dcae.composition.restmodels.ruleeditor.LogTextAction;
import org.onap.sdc.dcae.errormng.ActionStatus;
import org.onap.sdc.dcae.errormng.ErrConfMgr;
import org.onap.sdc.dcae.errormng.ResponseFormat;
import org.onap.sdc.dcae.rule.editor.utils.ValidationUtils;

import java.util.List;

public class LogTextValidator implements IRuleElementValidator<LogTextAction> {

	private static LogTextValidator logTextValidator = new LogTextValidator();

	public static LogTextValidator getInstance() {
		return logTextValidator;
	}

	LogTextValidator(){}

	public boolean validate(LogTextAction action, List<ResponseFormat> errors) {
		if(!ValidationUtils.validateNotEmpty(action.getText())){
			errors.add(ErrConfMgr.INSTANCE.getResponseFormat(ActionStatus.MISSING_ACTION_FIELD, null, "text", action.getActionType(), action.strippedTarget()));
			return false;
		}
		return true;
	}
}