Permalink
Browse files

Reverted Asset version mapping.

Added 409 CONFLICT exception to let the client know it should update the asset from the server before updating it.
  • Loading branch information...
Miggets7 committed Nov 19, 2018
1 parent 2e93449 commit 1ab0d7d0ea45923585e6d4f7cb6e7f23d28c81cc
@@ -37,6 +37,7 @@
import org.openremote.model.value.ValueException;
import org.openremote.model.value.Values;
import javax.persistence.OptimisticLockException;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.HttpHeaders;
import java.io.IOException;
@@ -344,6 +345,8 @@ public void update(RequestParams requestParams, String assetId, Asset asset) {
} catch (IllegalStateException ex) {
throw new WebApplicationException(ex, BAD_REQUEST);
} catch (OptimisticLockException opEx) {
throw new WebApplicationException("Refresh the asset from the server and try to update the changes again", opEx, CONFLICT);
}
}
@@ -702,11 +702,7 @@ public static Asset map(Asset assetToMap, Asset asset,
String overrideType,
Boolean overrideAccessPublicRead,
ObjectValue overrideAttributes) {
if (asset.getVersion() < assetToMap.getVersion()) {
asset.setVersion(assetToMap.getVersion());
}
asset.setVersion(assetToMap.getVersion());
asset.setName(overrideName != null ? overrideName : assetToMap.getName());
if (overrideType != null) {
asset.setType(overrideType);

1 comment on commit 1ab0d7d

@Miggets7

This comment has been minimized.

Collaborator

Miggets7 commented on 1ab0d7d Nov 19, 2018

Please sign in to comment.