Skip to content

Commit

Permalink
fix(core): Ensure lastModified and lastModifiedBy is set on item (#530)
Browse files Browse the repository at this point in the history
Currently we're relying on the underlying `StorageService` implementations
to set and track lastModified and lastModifiedBy.

Pulling it up to the `StorageServiceSupport` ensures consistent behavior
across all current and future `StorageService` implementations.
  • Loading branch information
ajordens authored May 21, 2019
1 parent 053cfa4 commit 9f1ad52
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ public T findById(String id) throws NotFoundException {
}

public void update(String id, T item) {
item.setLastModifiedBy(AuthenticatedRequest.getSpinnakerUser().orElse("anonymous"));
item.setLastModified(System.currentTimeMillis());
service.storeObject(objectType, buildObjectKey(id), item);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.front50.exception.NotFoundException;
import com.netflix.spinnaker.front50.retry.GcsSafeRetry;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import groovy.lang.Closure;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
Expand Down Expand Up @@ -390,8 +389,6 @@ public Object doCall() throws Exception {

@Override
public <T extends Timestamped> void storeObject(ObjectType objectType, String objectKey, T obj) {
obj.setLastModifiedBy(AuthenticatedRequest.getSpinnakerUser().orElse("anonymous"));

byte[] bytes;
String path = keyToPath(objectKey, objectType.group);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.netflix.spinnaker.front50.exception.NotFoundException;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.Duration;
Expand Down Expand Up @@ -165,7 +164,6 @@ public <T extends Timestamped> void storeObject(ObjectType objectType, String ob
throw new ReadOnlyModeException();
}
try {
item.setLastModifiedBy(AuthenticatedRequest.getSpinnakerUser().orElse("anonymous"));
byte[] bytes = objectMapper.writeValueAsBytes(item);

ObjectMetadata objectMetadata = new ObjectMetadata();
Expand Down

0 comments on commit 9f1ad52

Please sign in to comment.