Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Deployment and Operations
Backup Service
Commits
c0f522e3
Commit
c0f522e3
authored
Oct 30, 2020
by
Riabokon Stanislav(EPAM)[GCP]
Browse files
Fixed sonar comments.
parent
44768c98
Changes
8
Hide whitespace changes
Inline
Side-by-side
backup-core/src/main/java/org/opengroup/osdu/backup/api/BackupApi.java
View file @
c0f522e3
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* 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.
*/
package
org.opengroup.osdu.backup.api
;
import
java.util.EnumMap
;
...
...
@@ -35,35 +51,35 @@ public class BackupApi {
public
ResponseEntity
<
BackupSchedule
>
submitBackupSchedule
(
@RequestBody
BackupSchedule
backupSchedule
)
{
BackupSchedule
savedBackupSchedule
=
backupService
.
submitBackupSchedule
(
backupSchedule
);
return
new
ResponseEntity
<
BackupSchedule
>(
savedBackupSchedule
,
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>(
savedBackupSchedule
,
HttpStatus
.
CREATED
);
}
@PutMapping
(
"/schedule"
)
public
ResponseEntity
<
BackupSchedule
>
updateBackupSchedule
(
@RequestBody
BackupSchedule
backupSchedule
)
{
BackupSchedule
savedBackupSchedule
=
backupService
.
updateBackupSchedule
(
backupSchedule
);
return
new
ResponseEntity
<
BackupSchedule
>(
savedBackupSchedule
,
HttpStatus
.
ACCEPTED
);
return
new
ResponseEntity
<>(
savedBackupSchedule
,
HttpStatus
.
ACCEPTED
);
}
@GetMapping
(
"/schedule"
)
public
ResponseEntity
<
BackupSchedule
>
getScheduleById
(
@RequestParam
String
id
)
{
return
new
ResponseEntity
<
BackupSchedule
>(
backupService
.
getBackupSchedule
(
id
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
backupService
.
getBackupSchedule
(
id
),
HttpStatus
.
OK
);
}
@PostMapping
(
"/backup_import"
)
public
ResponseEntity
<
BackupStamp
>
submitImport
(
@RequestBody
BackupImportRequest
backupId
)
{
BackupStamp
stamp
=
backupService
.
submitBackupImportRequest
(
backupId
);
return
new
ResponseEntity
<
BackupStamp
>(
stamp
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
stamp
,
HttpStatus
.
OK
);
}
@GetMapping
(
"/list_schedules"
)
public
ResponseEntity
<
List
<
BackupSchedule
>>
listSchedules
()
{
return
new
ResponseEntity
<
List
<
BackupSchedule
>
>(
backupService
.
listSchedules
(),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
backupService
.
listSchedules
(),
HttpStatus
.
OK
);
}
@GetMapping
(
"/list_backups"
)
public
ResponseEntity
<
EnumMap
<
Asset
,
List
<
BackupStamp
>>>
listBackups
()
{
return
new
ResponseEntity
<
EnumMap
<
Asset
,
List
<
BackupStamp
>>
>(
backupService
.
listBackups
(),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
backupService
.
listBackups
(),
HttpStatus
.
OK
);
}
}
backup-core/src/main/java/org/opengroup/osdu/backup/api/HealthCheckApi.java
View file @
c0f522e3
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* 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.
*/
package
org.opengroup.osdu.backup.api
;
import
javax.annotation.security.PermitAll
;
...
...
@@ -14,12 +30,12 @@ public class HealthCheckApi {
@PermitAll
@GetMapping
(
"/liveness_check"
)
public
ResponseEntity
<
String
>
livenessCheck
()
{
return
new
ResponseEntity
<
String
>(
"Backup service is alive"
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
"Backup service is alive"
,
HttpStatus
.
OK
);
}
@PermitAll
@GetMapping
(
"/readiness_check"
)
public
ResponseEntity
<
String
>
readinessCheck
()
{
return
new
ResponseEntity
<
String
>(
"Backup service is ready"
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
"Backup service is ready"
,
HttpStatus
.
OK
);
}
}
backup-core/src/main/java/org/opengroup/osdu/backup/config/AssetServiceLocatorException.java
View file @
c0f522e3
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* 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.
*/
package
org.opengroup.osdu.backup.config
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
...
...
@@ -5,8 +21,6 @@ import org.springframework.http.HttpStatus;
public
class
AssetServiceLocatorException
extends
Exception
{
private
AppException
appException
;
public
AssetServiceLocatorException
(
String
reason
)
{
throw
new
AppException
(
HttpStatus
.
BAD_REQUEST
.
value
(),
reason
,
"No service for such asset type"
);
}
...
...
backup-core/src/main/java/org/opengroup/osdu/backup/di/EntitlementsClientFactory.java
View file @
c0f522e3
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -13,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.opengroup.osdu.backup.di
;
import
lombok.RequiredArgsConstructor
;
...
...
backup-core/src/main/java/org/opengroup/osdu/backup/exception/AppExceptionHandler.java
View file @
c0f522e3
...
...
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.opengroup.osdu.backup.exception
;
import
java.util.Objects
;
...
...
@@ -46,6 +45,6 @@ public class AppExceptionHandler {
log
.
warn
(
exceptionMsg
,
e
.
getOriginalException
());
}
return
new
ResponseEntity
<
Object
>(
e
.
getError
(),
HttpStatus
.
resolve
(
e
.
getError
().
getCode
()));
return
new
ResponseEntity
<>(
e
.
getError
(),
HttpStatus
.
resolve
(
e
.
getError
().
getCode
()));
}
}
backup-core/src/main/java/org/opengroup/osdu/backup/model/BackupRole.java
View file @
c0f522e3
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* 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.
*/
package
org.opengroup.osdu.backup.model
;
public
class
BackupRole
{
public
static
final
String
BACKUP
=
"backup.service"
;
private
BackupRole
()
{
}
}
backup-core/src/main/java/org/opengroup/osdu/backup/swagger/HomeController.java
View file @
c0f522e3
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -22,7 +23,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
public
class
HomeController
{
@RequestMapping
(
value
=
"/swagger"
)
public
String
swagger
()
{
System
.
out
.
println
(
"swagger-ui.html"
);
return
"redirect:swagger-ui.html"
;
}
}
provider/backup-gcp/src/main/java/org/opengroup/osdu/backup/provider/gcp/config/GCPConfiguration.java
View file @
c0f522e3
/*
* Copyright 2020 Google LLC
* Copyright 2020 EPAM Systems, Inc
*
* 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.
*/
package
org.opengroup.osdu.backup.provider.gcp.config
;
import
com.google.api.client.googleapis.javanet.GoogleNetHttpTransport
;
...
...
@@ -31,7 +47,7 @@ public class GCPConfiguration {
@Bean
public
Datastore
googleDatastore
()
{
JsonFactory
JSON_FACTORY
=
new
JacksonFactory
();
JsonFactory
jsonFactory
=
new
JacksonFactory
();
try
{
GoogleCredentials
credential
=
GoogleCredentials
.
getApplicationDefault
();
...
...
@@ -44,7 +60,7 @@ public class GCPConfiguration {
credential
.
refreshAccessToken
();
return
new
Datastore
(
GoogleNetHttpTransport
.
newTrustedTransport
(),
JSON_FACTORY
,
return
new
Datastore
(
GoogleNetHttpTransport
.
newTrustedTransport
(),
jsonFactory
,
new
HttpCredentialsAdapter
(
credential
));
}
catch
(
GeneralSecurityException
|
IOException
e
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment