$ref: '#/components/schemas/RestInputCmHandle'
updatedCmHandles:
type: array
- example:
- cmHandle: my-cm-handle
- cmHandleProperties:
- add-my-property: add-property
- update-my-property: updated-property
- delete-my-property: '~'
- publicCmHandleProperties:
- add-my-property: add-property
- update-my-property: updated-property
- delete-my-property: '~'
items:
$ref: '#/components/schemas/RestInputCmHandle'
+ example:
+ cmHandle: my-cm-handle
+ cmHandleProperties:
+ add-my-property: add-property
+ update-my-property: updated-property
+ delete-my-property: '~'
+ publicCmHandleProperties:
+ add-my-property: add-property
+ update-my-property: updated-property
+ delete-my-property: '~'
removedCmHandles:
type: array
items:
type: string
- example: [my-cm-handle1, my-cm-handle2, my-cm-handle3]
+ example: [my-cm-handle1, my-cm-handle2, my-cm-handle3]
RestInputCmHandle:
required:
* Return module references for a cm handle.
*
* @param cmHandle the cm handle
- * @return module references for cm handle
+ * @return module references for cm handle. Namespace will be always blank because restConf does not include this.
*/
public ResponseEntity<List<ModuleReference>> getModuleReferencesByCmHandle(final String cmHandle) {
final List<ModuleReference> moduleReferences =
+++ /dev/null
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.cps.ncmp.api.models
-
-import org.onap.cps.spi.model.ExtendedModuleReference
-import spock.lang.Specification
-
-class moduleReferenceSpec extends Specification {
-
- def 'lombok data annotation correctly implements toString() and hashCode() methods'() {
- given: 'two moduleReference objects'
- def moduleReference1 = new ExtendedModuleReference('module1', "some namespace", '1')
- def moduleReference2 = new ExtendedModuleReference('module1', "some namespace", '1')
- when: 'lombok generated methods are called'
- then: 'the methods exist and behaviour is accurate'
- assert moduleReference1.toString() == moduleReference2.toString()
- assert moduleReference1.hashCode() == moduleReference2.hashCode()
- and: 'therefore equals works as expected'
- assert moduleReference1.equals(moduleReference2)
- }
-
-}
import com.fasterxml.jackson.databind.ObjectMapper
import org.hibernate.exception.ConstraintViolationException
-import org.mockito.InjectMocks
-import org.mockito.Mock
import org.onap.cps.spi.CpsAdminPersistenceService
import org.onap.cps.spi.CpsModulePersistenceService
import org.onap.cps.spi.entities.DataspaceEntity
-import org.onap.cps.spi.entities.YangResourceEntity
import org.onap.cps.spi.exceptions.DuplicatedYangResourceException
-import org.onap.cps.spi.model.ExtendedModuleReference
import org.onap.cps.spi.model.ModuleReference
import org.onap.cps.spi.repository.AnchorRepository
import org.onap.cps.spi.repository.DataspaceRepository
-import org.onap.cps.spi.repository.FragmentRepository
import org.onap.cps.spi.repository.SchemaSetRepository
import org.onap.cps.spi.repository.YangResourceRepository
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.dao.DataIntegrityViolationException
-import org.springframework.test.context.jdbc.Sql
import spock.lang.Shared
-import spock.lang.Specification
import java.sql.SQLException
import org.onap.cps.spi.exceptions.DataspaceNotFoundException
import org.onap.cps.spi.exceptions.SchemaSetNotFoundException
import org.onap.cps.spi.model.ModuleReference
-import org.onap.cps.spi.model.ExtendedModuleReference
import org.onap.cps.spi.repository.AnchorRepository
-import org.onap.cps.spi.repository.ModuleReferenceRepository
import org.onap.cps.spi.repository.SchemaSetRepository
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.jdbc.Sql
static final String NEW_RESOURCE_CHECKSUM = 'b13faef573ed1374139d02c40d8ce09c80ea1dc70e63e464c1ed61568d48d539'
static final String NEW_RESOURCE_MODULE_NAME = 'stores'
static final String NEW_RESOURCE_REVISION = '2020-09-15'
- static final ExtendedModuleReference newModuleReference = ExtendedModuleReference.builder().name(NEW_RESOURCE_MODULE_NAME)
+ static final ModuleReference newModuleReference = ModuleReference.builder().moduleName(NEW_RESOURCE_MODULE_NAME)
.revision(NEW_RESOURCE_REVISION).build()
def newYangResourcesNameToContentMap = [(NEW_RESOURCE_NAME):NEW_RESOURCE_CONTENT]
/**
* Identify previously unknown Yang Resource module references.
+ * The system will ignore the namespace of all module references.
*
* @param moduleReferencesToCheck the moduleReferencesToCheck
- * @returns collection of module references
+ * @returns collection of module references (namespace will be always blank)
*/
Collection<ModuleReference> identifyNewModuleReferences(
Collection<ModuleReference> moduleReferencesToCheck);
final var yangTextSchemaSourceSet = yangTextSchemaSourceSetCache
.get(dataspaceName, schemaSetName);
return SchemaSet.builder().name(schemaSetName).dataspaceName(dataspaceName)
- .extendedModuleReferences(yangTextSchemaSourceSet.getModuleReferences()).build();
+ .moduleReferences(yangTextSchemaSourceSet.getModuleReferences()).build();
}
@Override
/**
* Identify new module references from those returned by a node compared to what is in CPS already.
+ * The system will ignore the namespace of all module references.
*
* @param moduleReferencesToCheck the module references ot check
- * @returns Collection of {@link ModuleReference} of previously unknown module references
+ * @returns Collection of {@link ModuleReference} (namespace will be always blank)
+ *
*/
Collection<ModuleReference> identifyNewModuleReferences(
Collection<ModuleReference> moduleReferencesToCheck);
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2021 Nordix Foundation.
+ * Copyright (C) 2020-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
* ================================================================================
private String dataspace;
private String schemaSetName;
private String anchorName;
- private ExtendedModuleReference extendedModuleReference;
+ private ModuleReference moduleReference;
private String xpath;
private Map<String, Object> leaves = Collections.emptyMap();
private Collection<String> xpathsChildren;
+++ /dev/null
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * Modifications Copyright 2020-2021 Pantheon.tech
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.cps.spi.model;
-
-import java.io.Serializable;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class ExtendedModuleReference implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String name;
- private String namespace;
- private String revision;
-
-}
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static final long serialVersionUID = -1761408847591042599L;
private String moduleName;
private String revision;
+ @Builder.Default
+ private String namespace = "";
+
+ /**
+ * Constructor for module references without namespace (will remain blank).
+ *
+ * @param moduleName module names.
+ * @param revision revision of module.
+ */
+ public ModuleReference(final String moduleName, final String revision) {
+ this.moduleName = moduleName;
+ this.revision = revision;
+ this.namespace = "";
+ }
}
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Pantheon.tech
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
private static final long serialVersionUID = 1464791260718603291L;
private String name;
private String dataspaceName;
- private List<ExtendedModuleReference> extendedModuleReferences;
+ private List<ModuleReference> moduleReferences;
}
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Pantheon.tech
+ * Modifications Copyright (C) 2022 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
package org.onap.cps.yang;
import java.util.List;
-import org.checkerframework.checker.nullness.qual.NonNull;
-import org.onap.cps.spi.model.ExtendedModuleReference;
+import org.onap.cps.spi.model.ModuleReference;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
*
* @return list of ModuleRef
*/
- @NonNull
- List<ExtendedModuleReference> getModuleReferences();
+ List<ModuleReference> getModuleReferences();
/**
* Return SchemaContext for given YangSchema.
* @return SchemaContext
*/
- @NonNull
SchemaContext getSchemaContext();
}
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Pantheon.tech
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import lombok.NoArgsConstructor;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.spi.exceptions.ModelValidationException;
-import org.onap.cps.spi.model.ExtendedModuleReference;
+import org.onap.cps.spi.model.ModuleReference;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
}
@Override
- public List<ExtendedModuleReference> getModuleReferences() {
+ public List<ModuleReference> getModuleReferences() {
return schemaContext.getModules().stream()
.map(YangTextSchemaSourceSetImpl::toModuleReference)
.collect(Collectors.toList());
}
- private static ExtendedModuleReference toModuleReference(final Module module) {
- return ExtendedModuleReference.builder()
- .name(module.getName())
+ private static ModuleReference toModuleReference(final Module module) {
+ return ModuleReference.builder()
+ .moduleName(module.getName())
.namespace(module.getQNameModule().getNamespace().toString())
.revision(module.getRevision().map(Revision::toString).orElse(null))
.build();
import org.onap.cps.spi.exceptions.ModelValidationException
import org.onap.cps.spi.exceptions.SchemaSetInUseException
import org.onap.cps.spi.model.Anchor
-import org.onap.cps.spi.model.ExtendedModuleReference
import org.onap.cps.spi.model.ModuleReference
import org.onap.cps.yang.YangTextSchemaSourceSetBuilder
import spock.lang.Specification
def 'Create schema set from new modules and existing modules.'() {
given: 'a list of existing modules module reference'
- def moduleReferenceForExistingModule = new ExtendedModuleReference("test", "test.org", "2021-10-12")
+ def moduleReferenceForExistingModule = new ModuleReference("test", "2021-10-12","test.org")
def listOfExistingModulesModuleReference = [moduleReferenceForExistingModule]
when: 'create schema set from modules method is invoked'
objectUnderTest.createSchemaSetFromModules("someDataspaceName", "someSchemaSetName", [newModule: "newContent"], listOfExistingModulesModuleReference)
then: 'the correct schema set is returned'
result.getName().contains('someSchemaSet')
result.getDataspaceName().contains('someDataspace')
- result.getExtendedModuleReferences().contains(new ExtendedModuleReference('stores', 'org:onap:ccsdk:sample', '2020-09-15'))
+ result.getModuleReferences().contains(new ModuleReference('stores', '2020-09-15', 'org:onap:ccsdk:sample'))
}
def 'Delete schema-set when cascade is allowed.'() {
def 'Get all yang resources module references.'() {
given: 'an already present module reference'
- def moduleReferences = [new ExtendedModuleReference()]
+ def moduleReferences = [new ModuleReference('some module name','some revision name')]
mockCpsModulePersistenceService.getYangResourceModuleReferences('someDataspaceName') >> moduleReferences
expect: 'the list provided by persistence service is returned as result'
objectUnderTest.getYangResourceModuleReferences('someDataspaceName') == moduleReferences