@SpringBootApplication\r
public class Application {\r
\r
- public static void main(String[] args) {\r
+ public static void main(final String[] args) {\r
SpringApplication.run(Application.class, args);\r
}\r
}
\ No newline at end of file
* @return a ResponseEntity with the anchor name.
*/
@Override
- public final ResponseEntity<String> createAnchor(@Valid Anchor anchor, String dataspaceName) {
+ public final ResponseEntity<String> createAnchor(@Valid final Anchor anchor, final String dataspaceName) {
final AnchorDetails anchorDetails = modelMapper.map(anchor, AnchorDetails.class);
anchorDetails.setDataspace(dataspaceName);
final String anchorName = cpService.createAnchor(anchorDetails);
}
@Override
- public ResponseEntity<Object> createModules(@Valid MultipartFile multipartFile, String dataspaceName) {
+ public ResponseEntity<Object> createModules(@Valid final MultipartFile multipartFile, final String dataspaceName) {
final File fileToParse = saveToFile(multipartFile);
final SchemaContext schemaContext = cpService.parseAndValidateModel(fileToParse);
cpService.storeSchemaContext(schemaContext, dataspaceName);
}
@Override
- public ResponseEntity<Object> createNode(@Valid MultipartFile multipartFile, String dataspaceName) {
+ public ResponseEntity<Object> createNode(@Valid final MultipartFile multipartFile, final String dataspaceName) {
return null;
}
@Override
- public ResponseEntity<Object> deleteAnchor(String dataspaceName, String anchorName) {
+ public ResponseEntity<Object> deleteAnchor(final String dataspaceName, final String anchorName) {
return null;
}
@Override
- public ResponseEntity<Object> deleteDataspace(String dataspaceName) {
+ public ResponseEntity<Object> deleteDataspace(final String dataspaceName) {
return null;
}
@Override
- public ResponseEntity<Object> getAnchor(String dataspaceName, String anchorName) {
+ public ResponseEntity<Object> getAnchor(final String dataspaceName, final String anchorName) {
return null;
}
@Override
- public ResponseEntity<Object> getAnchors(String dataspaceName) {
+ public ResponseEntity<Object> getAnchors(final String dataspaceName) {
return null;
}
@Override
- public ResponseEntity<Object> getModule(String dataspaceName, @Valid String namespaceName, @Valid String revision) {
+ public ResponseEntity<Object> getModule(final String dataspaceName, @Valid final String namespaceName,
+ @Valid final String revision) {
return null;
}
@Override
- public ResponseEntity<Object> getNode(String dataspaceName) {
+ public ResponseEntity<Object> getNode(final String dataspaceName) {
return null;
}
@Override
- public ResponseEntity<Object> getNodeByDataspaceAndAnchor(String dataspaceName, String anchorName) {
+ public ResponseEntity<Object> getNodeByDataspaceAndAnchor(final String dataspaceName, final String anchorName) {
return null;
}
* @return a ResponseEntity.
*/
@PostMapping("/upload-yang-json-data-file")
- public final ResponseEntity<String> uploadYangJsonDataFile(
- @RequestParam("file") MultipartFile uploadedFile) {
+ public final ResponseEntity<String> uploadYangJsonDataFile(@RequestParam("file") final MultipartFile uploadedFile) {
validateJsonStructure(uploadedFile);
final int persistenceObjectId = cpService.storeJsonStructure(getJsonString(uploadedFile));
- return new ResponseEntity<String>(
+ return new ResponseEntity<>(
"Object stored in CPS with identity: " + persistenceObjectId, HttpStatus.OK);
-
}
/**
* @return response with response code 500.
*/
@ExceptionHandler
- public ResponseEntity<Object> handleInternalErrorException(Exception exception) {
+ public ResponseEntity<Object> handleInternalErrorException(final Exception exception) {
return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception);
}
@ExceptionHandler({CpsException.class})
- public ResponseEntity<Object> handleCpsException(CpsException exception) {
+ public ResponseEntity<Object> handleCpsException(final CpsException exception) {
return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception.getMessage(), extractDetails(exception));
}
@ExceptionHandler({CpsValidationException.class})
- public ResponseEntity<Object> handleCpsValidationException(CpsException exception) {
+ public ResponseEntity<Object> handleCpsValidationException(final CpsException exception) {
return buildErrorResponse(HttpStatus.BAD_REQUEST, exception.getMessage(), extractDetails(exception));
}
@ExceptionHandler({CpsNotFoundException.class})
- public ResponseEntity<Object> handleCpsNotFoundException(CpsException exception) {
+ public ResponseEntity<Object> handleCpsNotFoundException(final CpsException exception) {
return buildErrorResponse(HttpStatus.NOT_FOUND, exception.getMessage(), extractDetails(exception));
}
- private static ResponseEntity<Object> buildErrorResponse(HttpStatus status, Exception exception) {
+ private static ResponseEntity<Object> buildErrorResponse(final HttpStatus status, final Exception exception) {
return buildErrorResponse(status, exception.getMessage(), ExceptionUtils.getStackTrace(exception));
}
- private static ResponseEntity<Object> buildErrorResponse(HttpStatus status, String message, String details) {
- ErrorMessage errorMessage = new ErrorMessage();
+ private static ResponseEntity<Object> buildErrorResponse(final HttpStatus status, final String message,
+ final String details) {
+ final ErrorMessage errorMessage = new ErrorMessage();
errorMessage.setStatus(status.toString());
errorMessage.setMessage(message);
errorMessage.setDetails(details);
return new ResponseEntity<>(errorMessage, status);
}
- private static String extractDetails(CpsException exception) {
+ private static String extractDetails(final CpsException exception) {
return exception.getCause() == null
? exception.getDetails()
: ExceptionUtils.getStackTrace(exception.getCause());
*
* @param name the Dataspace name.
*/
- public Dataspace(String name) {
+ public Dataspace(final String name) {
this.name = name;
}
}
\ No newline at end of file
@Column
private String jsonStructure;
- public JsonDataEntity(String jsonStructure) {
+ public JsonDataEntity(final String jsonStructure) {
this.jsonStructure = jsonStructure;
}
}
import lombok.NoArgsConstructor;
import lombok.Setter;
-
/**
* Entity to store a yang module.
*/
/**
* Initialize a module entity.
*
- * @param namespace the module namespace.
+ * @param namespace the module namespace.
* @param moduleContent the module content.
- * @param revision the revision number of the module.
- * @param dataspace the dataspace related to the module.
+ * @param revision the revision number of the module.
+ * @param dataspace the dataspace related to the module.
*/
- public Module(String namespace, String moduleContent, String revision, Dataspace dataspace) {
+ public Module(final String namespace, final String moduleContent, final String revision,
+ final Dataspace dataspace) {
this.namespace = namespace;
this.moduleContent = moduleContent;
this.revision = revision;
package org.onap.cps.spi.repository;
-
import java.util.Optional;
import javax.validation.constraints.NotNull;
import org.onap.cps.exceptions.CpsNotFoundException;
}
@Override
- public void deleteJsonById(int jsonObjectId) {
+ public void deleteJsonById(final int jsonObjectId) {
dataPersistenceService.deleteJsonById(jsonObjectId);
}
}
@Override
- public String createAnchor(AnchorDetails anchorDetails) {
+ public String createAnchor(final AnchorDetails anchorDetails) {
return fragmentPersistenceService.createAnchor(anchorDetails);
}
}
\ No newline at end of file
* @param qnames array of qualified names that points the schema node for this fragment
* @param xpath the xpath for this fragment
*/
- private Fragment(final Fragment parentFragment, final Module module, final QName[] qnames, String xpath) {
+ private Fragment(final Fragment parentFragment, final Module module, final QName[] qnames, final String xpath) {
this.parentFragment = parentFragment;
this.module = module;
this.qnames = qnames;
*
* @param cause the cause of the exception
*/
- public CpsException(Throwable cause) {
+ public CpsException(final Throwable cause) {
super(cause.getMessage(), cause);
}
* @param message the error message
* @param cause the cause of the exception
*/
- public CpsException(String message, Throwable cause) {
+ public CpsException(final String message, final Throwable cause) {
super(message, cause);
}
* @param message the error message
* @param details the error details
*/
- public CpsException(String message, String details) {
+ public CpsException(final String message, final String details) {
super(message);
this.details = details;
}
*
* @param cause the cause of the exception
*/
- public CpsNotFoundException(Throwable cause) {
+ public CpsNotFoundException(final Throwable cause) {
super(cause.getMessage(), cause);
}
* @param message the error message
* @param cause the cause of the exception
*/
- public CpsNotFoundException(String message, Throwable cause) {
+ public CpsNotFoundException(final String message, final Throwable cause) {
super(message, cause);
}
* @param message the error message
* @param details the error details
*/
- public CpsNotFoundException(String message, String details) {
+ public CpsNotFoundException(final String message, final String details) {
super(message, details);
}
}
*
* @param cause the cause of the exception
*/
- public CpsValidationException(Throwable cause) {
+ public CpsValidationException(final Throwable cause) {
super(cause.getMessage(), cause);
}
* @param message the error message
* @param cause the cause of the exception
*/
- public CpsValidationException(String message, Throwable cause) {
+ public CpsValidationException(final String message, final Throwable cause) {
super(message, cause);
}
* @param message the error message
* @param details the error details
*/
- public CpsValidationException(String message, String details) {
+ public CpsValidationException(final String message, final String details) {
super(message, details);
}
}
* @throws IOException when there is an IO issue
*/
public static String getResourceFileContent(final String filename) throws IOException {
- File file = new File(ClassLoader.getSystemClassLoader().getResource(filename).getFile());
+ final File file = new File(ClassLoader.getSystemClassLoader().getResource(filename).getFile());
return new String(Files.readAllBytes(file.toPath()));
}
}