2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.mdsal.connector.ops;
10 import org.opendaylight.netconf.api.DocumentedException;
11 import org.opendaylight.netconf.api.xml.XmlElement;
12 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
13 import org.opendaylight.netconf.server.api.operations.AbstractSingletonNetconfOperation;
14 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
15 import org.opendaylight.yangtools.yang.common.ErrorTag;
16 import org.opendaylight.yangtools.yang.common.ErrorType;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19 import org.w3c.dom.Document;
20 import org.w3c.dom.Element;
22 public class Unlock extends AbstractSingletonNetconfOperation {
23 private static final Logger LOG = LoggerFactory.getLogger(Unlock.class);
24 private static final String OPERATION_NAME = "unlock";
26 public Unlock(final String netconfSessionIdForReporting) {
27 super(netconfSessionIdForReporting);
31 protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
32 throws DocumentedException {
33 final Datastore targetDatastore = Lock.extractTargetParameter(operationElement);
34 if (targetDatastore == Datastore.candidate) {
35 LOG.debug("Unlocking candidate datastore on session: {}", getNetconfSessionIdForReporting());
36 return document.createElement(XmlNetconfConstants.OK);
39 throw new DocumentedException("Unable to unlock " + targetDatastore + " datastore",
40 ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED, ErrorSeverity.ERROR);
44 protected String getOperationName() {
45 return OPERATION_NAME;