package org.opennaas.extensions.router.junos.actionssets.actions.queue; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.opennaas.core.resources.action.ActionException; import org.opennaas.core.resources.action.ActionResponse; import org.opennaas.core.resources.command.Response; import org.opennaas.core.resources.protocol.IProtocolSession; import org.opennaas.core.resources.queue.QueueConstants; import org.opennaas.extensions.router.junos.actionssets.actions.JunosAction; import org.opennaas.extensions.router.junos.commandsets.commands.DiscardNetconfCommand; import org.opennaas.extensions.router.junos.commandsets.commands.UnlockNetconfCommand; public class RestoreAction extends JunosAction { Log log = LogFactory.getLog(RestoreAction.class); public RestoreAction() { super(); initialize(); } @Override public void executeListCommand(ActionResponse actionResponse, IProtocolSession protocol) throws ActionException { try { /* discard incorrect changes */ DiscardNetconfCommand discardCommand = new DiscardNetconfCommand(); discardCommand.initialize(); Response response = sendCommandToProtocol(discardCommand, protocol); actionResponse.addResponse(response); // TODO test unlock command UnlockNetconfCommand unlockCommand = new UnlockNetconfCommand("candidate"); unlockCommand.initialize(); Response responseUnlock = sendCommandToProtocol(unlockCommand, protocol); actionResponse.addResponse(responseUnlock); } catch (Exception e) { throw new ActionException(this.actionID, e); } validateAction(actionResponse); } @Override public void parseResponse(Object responseMessage, Object model) { // TODO Auto-generated method stub } protected void initialize() { this.actionID = QueueConstants.RESTORE; this.protocolName = "netconf"; } @Override public boolean checkParams(Object params) throws ActionException { // For this Action params are not allowed if (params == null) return true; else { throw new ActionException("The Action " + getActionID() + " don't accept params"); } } @Override public void prepareMessage() throws ActionException { // TODO implements if is necessary if not delete } }