Skip to content

Commit

Permalink
Add some logs, remove others. (#4746)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbirk authored Sep 10, 2024
1 parent 68d0028 commit 05e6254
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import jakarta.annotation.PostConstruct;
import jakarta.transaction.Transactional;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -558,18 +557,18 @@ public ResponseEntity<Project> copyProject(@PathVariable("id") final UUID id) {
final ProjectExport export = cloneService.exportProject(id);
export.getProject().setName("Copy of " + export.getProject().getName());
log.info("Cloning...");
Project cloneProject = cloneService.importProject(userId, userName, export);
final Project cloneProject = cloneService.importProject(userId, userName, export);
log.info("Cloned...");
return cloneProject;
});
clonedProject = project.get();
} catch (ExecutionException e) {
} catch (final ExecutionException e) {
log.error("Execution Exception exporting project", e);
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, messages.get("postgres.service-unavailable"));
} catch (CancellationException e) {
} catch (final CancellationException e) {
log.error("Cancelled exporting project", e);
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, messages.get("generic.io-error.write"));
} catch (InterruptedException e) {
} catch (final InterruptedException e) {
log.error("Interrupted exporting project", e);
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, messages.get("postgres.service-unavailable"));
} catch (final Exception e) {
Expand Down Expand Up @@ -694,19 +693,23 @@ public ResponseEntity<Project> importProject(@RequestPart("file") final Multipar

Project project;
try {
log.info("Importing project");
project = cloneService.importProject(userId, userName, projectExport);
log.info("Project imported");
} catch (final Exception e) {
log.error("Error importing project", e);
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, messages.get("postgres.service-unavailable"));
}

try {
log.info("Setting project permissions");
final RebacProject rebacProject = new RebacProject(project.getId(), reBACService);
final RebacGroup rebacAskemAdminGroup = new RebacGroup(ReBACService.ASKEM_ADMIN_GROUP_ID, reBACService);
final RebacUser rebacUser = new RebacUser(userId, reBACService);

rebacUser.createCreatorRelationship(rebacProject);
rebacAskemAdminGroup.createWriterRelationship(rebacProject);
log.info("Project permissions set");
} catch (final Exception e) {
log.error("Error setting user's permissions for project", e);
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, messages.get("rebac.service-unavailable"));
Expand All @@ -718,6 +721,7 @@ public ResponseEntity<Project> importProject(@RequestPart("file") final Multipar
);
}

log.info("Returning project");
return ResponseEntity.status(HttpStatus.CREATED).body(project);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public Optional<ModelDescription> getDescription(final UUID id, final Schema.Per
@Override
@Observed(name = "function_profile")
protected String getAssetIndex() {
log.info("MODEL INDEX: {}", elasticConfig.getModelIndex());
return elasticConfig.getModelIndex();
}

Expand All @@ -124,7 +123,6 @@ protected String getAssetPath() {

@Override
public String getAssetAlias() {
log.info("MODEL ALIAS: {}", elasticConfig.getModelAlias());
return elasticConfig.getModelAlias();
}

Expand Down Expand Up @@ -169,7 +167,7 @@ public Model createAsset(final Model asset, final UUID projectId, final Schema.P
}
}
// Force proper annotation metadata
ModelMetadata metadata = asset.getMetadata();
final ModelMetadata metadata = asset.getMetadata();
if (metadata.getAnnotations() == null) {
metadata.setAnnotations(new Annotations());
asset.setMetadata(metadata);
Expand Down Expand Up @@ -221,7 +219,7 @@ public Optional<Model> updateAsset(
}
}
// Force proper annotation metadata
ModelMetadata metadata = asset.getMetadata();
final ModelMetadata metadata = asset.getMetadata();
if (metadata.getAnnotations() == null) {
metadata.setAnnotations(new Annotations());
asset.setMetadata(metadata);
Expand Down

0 comments on commit 05e6254

Please sign in to comment.