@RetryTransaction @Transactional("permazenGuiTransactionManager") private boolean canUpgrade(ObjId id) { final JObject jobj = JTransaction.getCurrent().get(id); return jobj.exists() && jobj.getSchemaVersion() != this.jdb.getActualVersion(); }
@RetryTransaction @Transactional("permazenGuiTransactionManager") private JObject doCopyForEdit(ObjId id) { // Find object final JTransaction jtx = JTransaction.getCurrent(); final JObject jobj = jtx.get(id); if (!jobj.exists()) return null; // Copy out object and its dependencies return this.objectChooser.getJObjectContainer().copyWithRelated(jobj, jtx.getSnapshotTransaction(), new CopyState()); }
/** * Copy the given {@link JObject} into the destination transaction. * * <p> * The implementation in {@link ChangeCopier} copies {@code jobj} and objects reachable via the configured copy cascade, * unless {@code jobj} does not exist, in which case it is not copied (but the * {@linkplain JTransaction#get(ObjId) corresponding} {@link JObject} is still returned). * Subclasses may override as needed. * * @param jobj original object * @return copied object in {@link #dest} * @throws IllegalArgumentException if {@code jobj} is null */ @SuppressWarnings("unchecked") protected JObject copy(JObject jobj) { Preconditions.checkArgument(jobj != null, "null jobj"); final ObjId id = jobj.getObjId(); if (jobj.exists()) { final JTransaction jtx = jobj.getTransaction(); jtx.copyTo(this.dest, this.copyState, jtx.cascadeFindAll(id, this.cascadeName, this.recursionLimit)); } return dest.get(this.copyState.getDestinationId(id)); } }
@Override @RetryTransaction @org.springframework.transaction.annotation.Transactional("permazenGuiTransactionManager") protected boolean execute() { final ObjId id = this.objectChooser.getObjId(); if (id == null) return true; final JObject jobj = JTransaction.getCurrent().get(id); if (!jobj.exists()) { Notification.show("Object " + id + " no longer exists", null, Notification.Type.WARNING_MESSAGE); return false; } try { ReferenceFieldField.this.setValue(jobj.copyTo(ReferenceFieldField.this.dest, new CopyState())); } catch (Exception e) { Notification.show("Error: " + e, null, Notification.Type.ERROR_MESSAGE); } return true; } }
@Override protected JObject readInternal(Class<? extends JObject> type, HttpInputMessage input) throws IOException { // Decode the snapshot transaction final SnapshotJTransaction jtx = SnapshotJTransactionHttpMessageConverter.readSnapshotTransaction( this.jdb, input, this.validationGroups); // Get the root object's ID final MediaType mediaType = input.getHeaders().getContentType(); if (mediaType == null) { throw new HttpMessageNotReadableException("required parameter `" + ROOT_OBJECT_ID_PARAMETER_NAME + "' missing; no `Content-Type' header found"); } final String objId = mediaType.getParameter(ROOT_OBJECT_ID_PARAMETER_NAME); if (objId == null) { throw new HttpMessageNotReadableException("required parameter `" + ROOT_OBJECT_ID_PARAMETER_NAME + "' missing from Content-Type `" + mediaType + "'"); } final ObjId id; try { id = new ObjId(objId); } catch (IllegalArgumentException e) { throw new HttpMessageNotReadableException("invalid `" + ROOT_OBJECT_ID_PARAMETER_NAME + "' parameter value `" + objId + "' in Content-Type `" + mediaType + "'"); } // Find the root object final JObject jobj = jtx.get(id); if (!jobj.exists()) throw new HttpMessageNotReadableException("no object with object ID " + id + " found in object graph"); // Done return jobj; }
if (!this.create && !target.exists()) { Notification.show("Object " + id + " no longer exists", null, Notification.Type.WARNING_MESSAGE); return true;