Search in sources :

Example 1 with RemoteTransaction

use of org.structr.net.data.RemoteTransaction in project structr by structr.

the class PeerToPeerService method setProperty.

public void setProperty(final String uuid, final String key, final Object value) throws FrameworkException {
    logger.info("Attempting to modify shared node with UUID {}: {} = {} in Structr", new Object[] { uuid, key, value });
    final RepositoryObject sharedObject = repository.getObject(uuid);
    if (sharedObject != null) {
        try (final RemoteTransaction tx = peer.beginTx(sharedObject)) {
            tx.setProperty(sharedObject, key, value);
            tx.commit();
        } catch (Exception ex) {
            System.out.println("timeout");
            throw new FrameworkException(500, ex.getMessage());
        }
    } else {
        System.out.println("No such object " + uuid);
    }
}
Also used : RemoteTransaction(org.structr.net.data.RemoteTransaction) RepositoryObject(org.structr.net.repository.RepositoryObject) FrameworkException(org.structr.common.error.FrameworkException) FrameworkException(org.structr.common.error.FrameworkException) IOException(java.io.IOException)

Example 2 with RemoteTransaction

use of org.structr.net.data.RemoteTransaction in project structr by structr.

the class Peer method set.

public void set(final String objectId, final String key, final Object value) {
    final RepositoryObject sharedObject = repository.getObject(objectId);
    if (sharedObject != null) {
        try (final RemoteTransaction tx = beginTx(sharedObject)) {
            tx.setProperty(sharedObject, key, value);
            tx.commit();
        } catch (Exception tex) {
            System.out.println("Failed");
        }
    } else {
        System.out.println("No such object " + objectId);
    }
}
Also used : RemoteTransaction(org.structr.net.data.RemoteTransaction) RepositoryObject(org.structr.net.repository.RepositoryObject) DefaultRepositoryObject(org.structr.net.repository.DefaultRepositoryObject) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) IOException(java.io.IOException) TimeoutException(org.structr.net.data.TimeoutException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 3 with RemoteTransaction

use of org.structr.net.data.RemoteTransaction in project structr by structr.

the class Peer method beginTx.

public RemoteTransaction beginTx(final RepositoryObject sharedObject) throws TimeoutException {
    final RemoteTransaction tx = new RemoteTransaction(this);
    tx.begin(sharedObject);
    return tx;
}
Also used : RemoteTransaction(org.structr.net.data.RemoteTransaction)

Aggregations

RemoteTransaction (org.structr.net.data.RemoteTransaction)3 IOException (java.io.IOException)2 RepositoryObject (org.structr.net.repository.RepositoryObject)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 FrameworkException (org.structr.common.error.FrameworkException)1 TimeoutException (org.structr.net.data.TimeoutException)1 DefaultRepositoryObject (org.structr.net.repository.DefaultRepositoryObject)1