Skip to content

Commit

Permalink
NXP-29764: avoid 500 error when updating/deleting distribution that d…
Browse files Browse the repository at this point in the history
…oes not exist anymore
  • Loading branch information
atchertchian committed Oct 14, 2020
1 parent 3759338 commit 0af1c3a
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -75,6 +75,7 @@
import org.nuxeo.ecm.core.api.Blob;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.DocumentNotFoundException;
import org.nuxeo.ecm.core.api.IdRef;
import org.nuxeo.ecm.core.api.IterableQueryResult;
import org.nuxeo.ecm.core.api.NuxeoException;
Expand Down Expand Up @@ -555,11 +556,11 @@ public Object uploadDistribTmpValid() {

protected DistributionSnapshot getPersistedDistrib(String distribId, String distribDocId) {
if (StringUtils.isNotBlank(distribDocId)) {
DocumentModel doc = ctx.getCoreSession().getDocument(new IdRef(distribDocId));
if (doc == null) {
try {
return ctx.getCoreSession().getDocument(new IdRef(distribDocId)).getAdapter(DistributionSnapshot.class);
} catch (DocumentNotFoundException e) {
return null;
}
return doc.getAdapter(DistributionSnapshot.class);
}
List<DistributionSnapshot> snapshots = getSnapshotManager().getPersistentSnapshots(ctx.getCoreSession(),
distribId, false);
Expand Down

0 comments on commit 0af1c3a

Please sign in to comment.