import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager;
import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Current state of this XACML PDP.
*/
public class XacmlState {
- // The logger for this class
- private static final Logger LOGGER = LoggerFactory.getLogger(XacmlState.class);
-
/**
* The application manager.
*/
PdpStatus status2 = makeResponse(message, "");
- // start/stop rest controller based on state change
- handleXacmlRestController();
-
// these fields aren't needed in the response, so clear them out to avoid sending
status2.setPolicies(null);
status2.setResponse(resp);
return status2;
}
-
- /**
- * Manages the Xacml-Pdp rest controller based on the Xacml-Pdp State.
- * Current supported states:
- * ACTIVE - rest service is running and handling requests
- * PASSIVE - rest service is not running
- */
- private void handleXacmlRestController() {
- if (status.getState() == PdpState.ACTIVE) {
- LOGGER.info("State change: {} - Starting rest controller", status.getState());
- XacmlPdpActivator.getCurrent().startXacmlRestController();
- } else if (status.getState() == PdpState.PASSIVE) {
- LOGGER.info("State change: {} - Stopping rest controller", status.getState());
- XacmlPdpActivator.getCurrent().stopXacmlRestController();
- } else {
- // unsupported state
- LOGGER.warn("Unsupported state: {}", status.getState());
- }
- }
}