Package org.apache.isis.runtimes.dflt.remoting.common.exchange

Examples of org.apache.isis.runtimes.dflt.remoting.common.exchange.ExecuteServerActionResponse


        }

        final KnownObjectsRequest knownObjects = new KnownObjectsRequest();
        final Data[] parameterObjectData = parameterValues(parameterAdapters, knownObjects);
        final ReferenceData targetReference = targetAdapter == null ? null : encoder.encodeActionTarget(targetAdapter, knownObjects);
        ExecuteServerActionResponse response;
        try {
            final ExecuteServerActionRequest request = new ExecuteServerActionRequest(getAuthenticationSession(), ActionType.USER, objectAction.getIdentifier().toNameParmsIdentityString(), targetReference, parameterObjectData);
            response = serverFacade.executeServerAction(request);

            // must deal with transient-now-persistent objects first
            if (targetAdapter.isTransient()) {
                encoder.madePersistent(targetAdapter, response.getPersistedTarget());
            }

            final List<ObjectActionParameter> parameters2 = objectAction.getParameters();
            for (int i = 0; i < parameterAdapters.length; i++) {
                if (parameters2.get(i).getSpecification().isNotCollection()) {
                    encoder.madePersistent(parameterAdapters[i], response.getPersistedParameters()[i]);
                }
            }

            final Data returned = response.getReturn();
            final ObjectAdapter returnedObject = returned instanceof NullData ? null : encoder.decode(returned);

            final ObjectData[] updates = response.getUpdates();
            for (final ObjectData update : updates) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("update " + update.getOid());
                }
                encoder.decode(update);
            }

            final ReferenceData[] disposed = response.getDisposed();
            for (final ReferenceData element : disposed) {
                final Oid oid = element.getOid();
                if (LOG.isDebugEnabled()) {
                    LOG.debug("disposed " + oid);
                }
View Full Code Here


        system.shutdown();
    }

    @Test
    public void testExecuteOK() {
        final ExecuteServerActionResponse results = null;
        mockery.checking(new Expectations() {
            {
                one(mockEncoder).encodeServerActionResult(with(equalTo(adapter)), with(equalTo(new ObjectData[0])), with(equalTo(new ReferenceData[0])), with(nullValue(ObjectData.class)), with(equalTo(new ObjectData[0])), with(equalTo(new String[0])), with(equalTo(new String[0])));
                will(returnValue(results));

            }
        });

        IsisContext.getTransactionManager().startTransaction();
        final ExecuteServerActionRequest request = new ExecuteServerActionRequest(new TestProxySession(), ActionType.USER, "action()", targetData, parameterData);
        final ExecuteServerActionResponse result = server.executeServerAction(request);
        IsisContext.getTransactionManager().endTransaction();

        assertEquals(results, result);
    }
View Full Code Here

        assertEquals(results, result);
    }

    @Test
    public void testExecuteWhereObjectDeleted() {
        final ExecuteServerActionResponse results = null;

        mockery.checking(new Expectations() {
            {
                final ReferenceData deletedObjectIdentityData = new DummyReferenceData(adapter.getOid(), "", adapter.getVersion());
                one(mockEncoder).encodeIdentityData(adapter);
                will(returnValue(deletedObjectIdentityData));

                one(mockEncoder).encodeServerActionResult(with(equalTo(adapter)), with(equalTo(new ObjectData[0])), with(equalTo(new ReferenceData[] { deletedObjectIdentityData })), with(nullValue(ObjectData.class)), with(equalTo(new ObjectData[0])), with(equalTo(new String[0])),
                        with(equalTo(new String[0])));
                will(returnValue(null));
            }
        });

        IsisContext.getTransactionManager().startTransaction();

        IsisContext.getUpdateNotifier().addDisposedObject(adapter);
        final ExecuteServerActionRequest request = new ExecuteServerActionRequest(new TestProxySession(), ActionType.USER, "action()", targetData, parameterData);
        final ExecuteServerActionResponse result = server.executeServerAction(request);

        IsisContext.getTransactionManager().endTransaction();

        assertEquals(results, result);
    }
View Full Code Here

    }

    @Test
    public void testExecuteWhereObjectChanged() {

        final ExecuteServerActionResponse results = null;
        mockery.checking(new Expectations() {
            {
                final ObjectData changedObjectData = new DummyObjectData();
                one(mockEncoder).encodeForUpdate(adapter);
                will(returnValue(changedObjectData));

                one(mockEncoder).encodeServerActionResult(with(equalTo(adapter)), with(equalTo(new ObjectData[] { changedObjectData })), with(equalTo(new ReferenceData[0])), with(nullValue(ObjectData.class)), with(equalTo(new ObjectData[0])), with(equalTo(new String[0])),
                        with(equalTo(new String[0])));
                will(returnValue(null));
            }
        });

        IsisContext.getTransactionManager().startTransaction();

        IsisContext.getUpdateNotifier().addChangedObject(adapter);

        final ExecuteServerActionRequest request = new ExecuteServerActionRequest(new TestProxySession(), ActionType.USER, "action()", targetData, parameterData);
        final ExecuteServerActionResponse result = server.executeServerAction(request);

        IsisContext.getTransactionManager().endTransaction();

        assertEquals(results, result);
    }
View Full Code Here

        assertEquals(results, result);
    }

    @Test
    public void testExecuteWhereMessagesAndWarningGenerated() {
        final ExecuteServerActionResponse results = null;
        mockery.checking(new Expectations() {
            {
                one(mockEncoder).encodeServerActionResult(with(equalTo(adapter)), with(equalTo(new ObjectData[0])), with(equalTo(new ReferenceData[0])), with(nullValue(ObjectData.class)), with(equalTo(new ObjectData[0])), with(equalTo(new String[] { "message 1", "message 2" })),
                        with(equalTo(new String[] { "warning 1", "warning 2" })));
                will(returnValue(null));
            }
        });

        IsisContext.getTransactionManager().startTransaction();

        IsisContext.getMessageBroker().addMessage("message 1");
        IsisContext.getMessageBroker().addMessage("message 2");

        IsisContext.getMessageBroker().addWarning("warning 1");
        IsisContext.getMessageBroker().addWarning("warning 2");

        final ExecuteServerActionRequest request = new ExecuteServerActionRequest(new TestProxySession(), ActionType.USER, "action()", targetData, parameterData);
        final ExecuteServerActionResponse result = server.executeServerAction(request);

        IsisContext.getTransactionManager().endTransaction();

        assertEquals(results, result);
    }
View Full Code Here

        // actionPeer.getTarget();
        // expectLastCall().andStubReturn(ObjectAction.REMOTE);

        final ExecuteServerActionRequest request = new ExecuteServerActionRequest(IsisContext.getAuthenticationSession(), ActionType.USER, identifierString, targetData, parameterData);
        mockDistribution.executeServerAction(request);
        final ExecuteServerActionResponse result = new ExecuteServerActionResponse(new DummyNullValue("type"), new ObjectData[0], new ReferenceData[0], null, new ObjectData[2], new String[0], new String[0]);
        expectLastCall().andReturn(result);

        mockEncoder.madePersistent(target, null);
        expectLastCall();
View Full Code Here

        IsisContext.getPersistenceSession().makePersistent(target);

        final ExecuteServerActionRequest request = new ExecuteServerActionRequest(IsisContext.getAuthenticationSession(), ActionType.USER, identifierString, targetData, parameterData);
        mockDistribution.executeServerAction(request);
        final ExecuteServerActionResponse result = new ExecuteServerActionResponse(new DummyNullValue("type"), new ObjectData[0], new ReferenceData[0], null, new ObjectData[2], new String[0], new String[0]);
        expectLastCall().andReturn(result);

        replay(mockObjectActionPeer, mockEncoder, mockDistribution);
        proxy.invoke(target, parameters);
        verify(mockObjectActionPeer, mockEncoder, mockDistribution);
View Full Code Here

        final ObjectAdapter object = system.createPersistentTestObject();

        final ExecuteServerActionRequest request = new ExecuteServerActionRequest(IsisContext.getAuthenticationSession(), ActionType.USER, identifierString, targetData, parameterData);
        mockDistribution.executeServerAction(request);
        final ReferenceData[] disposedReferenceData = new ReferenceData[] { new DummyReferenceData(object.getOid(), object.getSpecification().getFullIdentifier(), null) };
        final ExecuteServerActionResponse result = new ExecuteServerActionResponse(new DummyNullValue("type"), new ObjectData[0], disposedReferenceData, null, new ObjectData[2], new String[0], new String[0]);
        expectLastCall().andReturn(result);

        replay(mockObjectActionPeer, mockEncoder, mockDistribution);
        proxy.invoke(target, parameters);
        verify(mockObjectActionPeer, mockEncoder, mockDistribution);
View Full Code Here

            resultData = encodeCompletePersistentGraph(result);
        } else {
            throw new UnknownTypeException(result);
        }

        return new ExecuteServerActionResponse(resultData, updatesData, disposedData, persistedTargetData,
            persistedParametersData, messages, warnings);
    }
View Full Code Here

        final String actionIdentifier = request.getActionIdentifier();
        final ReferenceData target = request.getTarget();
        final Data[] parameters = request.getParameters();

        log("execute action " + actionIdentifier + "/" + actionType + indentedNewLine() + "target: " + dump(target) + indentedNewLine() + "parameters: " + dump(parameters));
        ExecuteServerActionResponse result;
        try {
            result = decorated.executeServerAction(request);
            log("  <-- returns: " + dump(result.getReturn()));
            log("  <-- persisted target: " + dump(result.getPersistedTarget()));
            log("  <-- persisted parameters: " + dump(result.getPersistedParameters()));
            log("  <-- updates: " + dump(result.getUpdates()));
            log("  <-- disposed: " + dump(result.getDisposed()));
        } catch (final RuntimeException e) {
            log("  <-- exception: " + e.getClass().getName() + " " + e.getMessage());
            throw e;
        }
        return result;
View Full Code Here

TOP

Related Classes of org.apache.isis.runtimes.dflt.remoting.common.exchange.ExecuteServerActionResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.