import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
import org.opendaylight.controller.sal.rest.doc.impl.BaseYangSwaggerGenerator;
import org.opendaylight.controller.sal.rest.doc.swagger.Api;
import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration;
import org.opendaylight.controller.sal.rest.doc.swagger.Resource;
import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
private static final String DATASTORES_LABEL = "Datastores";
private MountProvisionService mountService;
- private final Map<InstanceIdentifier, Long> instanceIdToLongId = new TreeMap<>(
- new Comparator<InstanceIdentifier>() {
+ private final Map<YangInstanceIdentifier, Long> instanceIdToLongId = new TreeMap<>(
+ new Comparator<YangInstanceIdentifier>() {
@Override
- public int compare(InstanceIdentifier o1, InstanceIdentifier o2) {
+ public int compare(final YangInstanceIdentifier o1, final YangInstanceIdentifier o2) {
return o1.toString().compareToIgnoreCase(o2.toString());
}
});
- private final Map<Long, InstanceIdentifier> longIdToInstanceId = new HashMap<>();
+ private final Map<Long, YangInstanceIdentifier> longIdToInstanceId = new HashMap<>();
private final Object lock = new Object();
private final AtomicLong idKey = new AtomicLong(0);
Map<String, Long> urlToId = new HashMap<>();
synchronized (lock) {
SchemaContext context = globalSchema.getGlobalContext();
- for (Entry<InstanceIdentifier, Long> entry : instanceIdToLongId.entrySet()) {
+ for (Entry<YangInstanceIdentifier, Long> entry : instanceIdToLongId.entrySet()) {
String modName = findModuleName(entry.getKey(), context);
urlToId.put(generateUrlPrefixFromInstanceID(entry.getKey(), modName),
entry.getValue());
return urlToId;
}
- public void setGlobalSchema(SchemaService globalSchema) {
+ public void setGlobalSchema(final SchemaService globalSchema) {
this.globalSchema = globalSchema;
}
- private String findModuleName(InstanceIdentifier id, SchemaContext context) {
- PathArgument rootQName = id.getPath().get(0);
+ private String findModuleName(final YangInstanceIdentifier id, final SchemaContext context) {
+ PathArgument rootQName = id.getPathArguments().iterator().next();
for (Module mod : context.getModules()) {
if (mod.getDataChildByName(rootQName.getNodeType()) != null) {
return mod.getName();
return null;
}
- private String generateUrlPrefixFromInstanceID(InstanceIdentifier key, String moduleName) {
- List<PathArgument> path = key.getPath();
+ private String generateUrlPrefixFromInstanceID(final YangInstanceIdentifier key, final String moduleName) {
StringBuilder builder = new StringBuilder();
if (moduleName != null) {
builder.append(moduleName);
- builder.append(":");
+ builder.append(':');
}
boolean first = true;
- for (PathArgument arg : path) {
+ for (PathArgument arg : key.getPathArguments()) {
String name = arg.getNodeType().getLocalName();
if (first) {
first = false;
} else {
- builder.append("/");
+ builder.append('/');
}
builder.append(name);
- if (arg instanceof InstanceIdentifier.NodeIdentifierWithPredicates) {
+ if (arg instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) {
NodeIdentifierWithPredicates nodeId = (NodeIdentifierWithPredicates) arg;
for (Entry<QName, Object> entry : nodeId.getKeyValues().entrySet()) {
- builder.append("/").append(entry.getValue());
+ builder.append('/').append(entry.getValue());
}
}
}
- return builder.append("/").toString();
+ return builder.append('/').toString();
}
- private String getYangMountUrl(InstanceIdentifier key) {
+ private String getYangMountUrl(final YangInstanceIdentifier key) {
String modName = findModuleName(key, globalSchema.getGlobalContext());
return generateUrlPrefixFromInstanceID(key, modName) + "yang-ext:mount/";
}
- public ResourceList getResourceList(UriInfo uriInfo, Long id) {
- InstanceIdentifier iid = getInstanceId(id);
+ public ResourceList getResourceList(final UriInfo uriInfo, final Long id) {
+ YangInstanceIdentifier iid = getInstanceId(id);
if (iid == null) {
return null; // indicating not found.
}
return list;
}
- private InstanceIdentifier getInstanceId(Long id) {
- InstanceIdentifier instanceId;
+ private YangInstanceIdentifier getInstanceId(final Long id) {
+ YangInstanceIdentifier instanceId;
synchronized (lock) {
instanceId = longIdToInstanceId.get(id);
}
return instanceId;
}
- private SchemaContext getSchemaContext(InstanceIdentifier id) {
+ private SchemaContext getSchemaContext(final YangInstanceIdentifier id) {
if (id == null) {
return null;
return context;
}
- public ApiDeclaration getMountPointApi(UriInfo uriInfo, Long id, String module, String revision) {
- InstanceIdentifier iid = getInstanceId(id);
+ public ApiDeclaration getMountPointApi(final UriInfo uriInfo, final Long id, final String module, final String revision) {
+ YangInstanceIdentifier iid = getInstanceId(id);
SchemaContext context = getSchemaContext(iid);
String urlPrefix = getYangMountUrl(iid);
if (context == null) {
return super.getApiDeclaration(module, revision, uriInfo, context, urlPrefix);
}
- private ApiDeclaration generateDataStoreApiDoc(UriInfo uriInfo, String context) {
+ private ApiDeclaration generateDataStoreApiDoc(final UriInfo uriInfo, final String context) {
ApiDeclaration declaration = super.createApiDeclaration(createBasePathFromUriInfo(uriInfo));
List<Api> apis = new LinkedList<>();
}
- private Api createGetApi(String datastore, String note, String context) {
+ private Api createGetApi(final String datastore, final String note, final String context) {
Operation getConfig = new Operation();
getConfig.setMethod("GET");
getConfig.setNickname("GET " + datastore);
return api;
}
- public void setMountService(MountProvisionService mountService) {
+ public void setMountService(final MountProvisionService mountService) {
this.mountService = mountService;
}
@Override
- public void onMountPointCreated(InstanceIdentifier path) {
+ public void onMountPointCreated(final YangInstanceIdentifier path) {
synchronized (lock) {
Long idLong = idKey.incrementAndGet();
instanceIdToLongId.put(path, idLong);
}
@Override
- public void onMountPointRemoved(InstanceIdentifier path) {
+ public void onMountPointRemoved(final YangInstanceIdentifier path) {
synchronized (lock) {
Long id = instanceIdToLongId.remove(path);
longIdToInstanceId.remove(id);