Example usage for java.math BigInteger ONE

List of usage examples for java.math BigInteger ONE

Introduction

In this page you can find the example usage for java.math BigInteger ONE.

Prototype

BigInteger ONE

To view the source code for java.math BigInteger ONE.

Click Source Link

Document

The BigInteger constant one.

Usage

From source file:org.miloss.fgsms.common.UtilityTest.java

@Test
public void testARSSerialization() throws Exception {
    JAXBContext ctx = Utility.getARSSerializationContext();
    DatatypeFactory df = DatatypeFactory.newInstance();
    //   org.miloss.fgsms.services.interfaces.automatedreportingservice.AddOrUpdateScheduledReportRequestMsg req = new AddOrUpdateScheduledReportRequestMsg();
    // req.setClassification(new SecurityWrapper());
    GregorianCalendar gcal = new GregorianCalendar();
    ReportDefinition rd = new ReportDefinition();
    rd.getAdditionalReaders().add("test");
    rd.setEnabled(true);//from   ww w.j a  v a  2 s.com
    rd.setFriendlyName("test");
    rd.setJobId("test");
    //rd.setLastRanAt(df.newCalendar(gcal));
    rd.setOwner("test");
    rd.setSchedule(new ScheduleDefinition());
    WeeklySchedule ws = new WeeklySchedule();
    ws.getDayOfTheWeekIs().add(Daynames.SUNDAY);
    ws.setReoccurs(BigInteger.ONE);
    rd.getSchedule().getTriggers().add(ws);
    DailySchedule ds = new DailySchedule();
    ds.setReoccurs(BigInteger.ONE);
    ds.setStartingAt((gcal));

    rd.getSchedule().getTriggers().add(ds);
    MonthlySchedule ms = new MonthlySchedule();
    ms.getDayOfTheMonthIs().add(1);
    ms.getMonthNameIs().add(Monthnames.MAY);
    ds.setStartingAt((gcal));

    rd.getSchedule().getTriggers().add(ms);

    rd.setExportCSVDataRequestMsg(new ExportCSVDataRequestMsg());
    rd.getExportCSVDataRequestMsg().setClassification(new SecurityWrapper());
    rd.getExportCSVDataRequestMsg().setExportType(ExportRecordsEnum.MACHINE);
    rd.getExportCSVDataRequestMsg().setRange(new TimeRangeDiff());
    rd.getExportCSVDataRequestMsg().getURLs().add("test");
    rd.getExportCSVDataRequestMsg().getRange().setEnd(df.newDuration(1000));
    rd.getExportCSVDataRequestMsg().getRange().setStart(df.newDuration(1000));

    rd.setExportDataRequestMsg(new ExportDataRequestMsg());
    rd.getExportDataRequestMsg().setClassification(new SecurityWrapper());
    rd.getExportDataRequestMsg().getURLs().add("test");
    rd.getExportDataRequestMsg().setRange(new TimeRangeDiff());
    rd.getExportDataRequestMsg().getRange().setEnd(df.newDuration(1000));
    rd.getExportDataRequestMsg().getRange().setStart(df.newDuration(1000));
    rd.getExportDataRequestMsg().setReportTypes(new ArrayOfReportTypeContainer());
    ReportTypeContainer rtc = new ReportTypeContainer();
    rtc.setType("org.miloss.fgsms.services.rs.impl.reports.ws.MeanTimeBetweenFailureByService");
    rd.getExportDataRequestMsg().getReportTypes().getReportTypeContainer().add(rtc);
    rd.getNotifications().add(new SLAAction());
    //   req.getJobs().add(rd);
    Marshaller m = ctx.createMarshaller();
    StringWriter sw = new StringWriter();
    m.marshal(rd, sw);
    System.out.println(sw.toString());
    assertNotNull(sw.toString());
    Unmarshaller u = ctx.createUnmarshaller();
    Object unmarshal = u.unmarshal(new StringReader(sw.toString()));
    ReportDefinition rd2 = (ReportDefinition) unmarshal;
    assertNotNull(rd2);
    assertNotNull(rd2.getExportCSVDataRequestMsg());
    assertNotNull(rd2.getExportDataRequestMsg());
    assertFalse(rd2.getNotifications().isEmpty());
    assertNotNull(rd2.getSchedule());
    assertFalse(rd2.getSchedule().getTriggers().isEmpty());
}

From source file:com.spotify.reaper.unit.service.SegmentRunnerTest.java

@Test
public void failureTest() throws InterruptedException, ReaperException, ExecutionException {
    final IStorage storage = new MemoryStorage();
    RepairUnit cf = storage//w ww.j  a v  a  2  s  .  c  o m
            .addRepairUnit(new RepairUnit.Builder("reaper", "reaper", Sets.newHashSet("reaper")));
    RepairRun run = storage.addRepairRun(
            new RepairRun.Builder("reaper", cf.getId(), DateTime.now(), 0.5, 1, RepairParallelism.PARALLEL));
    storage.addRepairSegments(Collections.singleton(
            new RepairSegment.Builder(run.getId(), new RingRange(BigInteger.ONE, BigInteger.ZERO), cf.getId())),
            run.getId());
    final long segmentId = storage.getNextFreeSegment(run.getId()).get().getId();

    final ExecutorService executor = Executors.newSingleThreadExecutor();
    final MutableObject<Future<?>> future = new MutableObject<>();

    AppContext context = new AppContext();
    context.storage = storage;
    context.jmxConnectionFactory = new JmxConnectionFactory() {
        @Override
        public JmxProxy connect(final Optional<RepairStatusHandler> handler, String host) {
            JmxProxy jmx = mock(JmxProxy.class);
            when(jmx.getClusterName()).thenReturn("reaper");
            when(jmx.isConnectionAlive()).thenReturn(true);
            when(jmx.tokenRangeToEndpoint(anyString(), any(RingRange.class)))
                    .thenReturn(Lists.newArrayList(""));
            when(jmx.triggerRepair(any(BigInteger.class), any(BigInteger.class), anyString(),
                    Matchers.<RepairParallelism>any(), Sets.newHashSet(anyString())))
                            .then(new Answer<Integer>() {
                                @Override
                                public Integer answer(InvocationOnMock invocation) {
                                    assertEquals(RepairSegment.State.NOT_STARTED,
                                            storage.getRepairSegment(segmentId).get().getState());
                                    future.setValue(executor.submit(new Runnable() {
                                        @Override
                                        public void run() {
                                            handler.get().handle(1, ActiveRepairService.Status.STARTED,
                                                    "Repair command 1 has started");
                                            assertEquals(RepairSegment.State.RUNNING,
                                                    storage.getRepairSegment(segmentId).get().getState());
                                            handler.get().handle(1, ActiveRepairService.Status.SESSION_FAILED,
                                                    "Repair command 1 has failed");
                                            assertEquals(RepairSegment.State.NOT_STARTED,
                                                    storage.getRepairSegment(segmentId).get().getState());
                                            handler.get().handle(1, ActiveRepairService.Status.FINISHED,
                                                    "Repair command 1 has finished");
                                            assertEquals(RepairSegment.State.NOT_STARTED,
                                                    storage.getRepairSegment(segmentId).get().getState());
                                        }
                                    }));

                                    return 1;
                                }
                            });

            return jmx;
        }
    };
    RepairRunner rr = mock(RepairRunner.class);
    RepairUnit ru = mock(RepairUnit.class);
    SegmentRunner sr = new SegmentRunner(context, segmentId, Collections.singleton(""), 1000, 0.5,
            RepairParallelism.PARALLEL, "reaper", ru, rr);
    sr.run();

    future.getValue().get();
    executor.shutdown();

    assertEquals(RepairSegment.State.NOT_STARTED, storage.getRepairSegment(segmentId).get().getState());
    assertEquals(1, storage.getRepairSegment(segmentId).get().getFailCount());
}

From source file:jp.co.ntts.vhut.util.Ipv4ConversionUtil.java

/**
 * IP(HEX)????.//  w  ww.j av a  2s  .  c  o m
 * ????int????????????.
 * @param startIpaddr (HEX/)
 * @param endIpaddr (HEX/)
 * @return IP(HEX)??
 */
public static Set<String> getIpAddressSetBetween(String startIpaddr, String endIpaddr) {
    BigInteger startBI = new BigInteger(addrTobyte(startIpaddr));
    BigInteger endBI = new BigInteger(addrTobyte(endIpaddr));
    int length = (int) Math.min(endBI.subtract(startBI).longValue(), Integer.MAX_VALUE);

    Set<String> resultSet = new HashSet<String>();

    BigInteger currentBI = startBI;

    for (int i = 0; i <= length; i++) {
        resultSet.add(byteToAddr(currentBI.toByteArray()));
        currentBI = currentBI.add(BigInteger.ONE);
    }

    return resultSet;
}

From source file:com.github.jrrdev.mantisbtsync.core.services.JdbcIssuesServiceTest.java

/**
 * Test method for {@link com.github.jrrdev.mantisbtsync.core.services.JdbcIssuesService#insertCustomFieldIfNotExists(biz.futureware.mantis.rpc.soap.client.ObjectRef, java.math.BigInteger)}.
 *///from   www. ja  va2 s . co  m
@Test
public void testInsertCustomFieldIfNotExistsItemNull() {
    final Operation op = sequenceOf(
            insertInto("mantis_project_table").columns("id", "name").values(1, "project_1").build(),

            insertInto("mantis_enum_custom_field_types").columns("id", "name").values(1, "type_1").build());

    lauchOperation(op);

    dao.insertCustomFieldIfNotExists(null, BigInteger.ONE);
}

From source file:com.clustercontrol.repository.util.RepositoryUtil.java

/**
 * ???IP????/*from  w  ww .j  a v  a 2s  .c  om*/
 * @param strFrom 
 * @param strTo 
 * @param version IP??(4 or 6)
 * @return
 * @throws HinemosUnknown
 * @throws UnknownHostException
 */
public static List<String> getIpList(String strFrom, String strTo, int version)
        throws HinemosUnknown, UnknownHostException {
    List<String> list = new ArrayList<String>();
    if (version == 4) {
        int from = ipV4ToInt(strFrom);
        int to = ipV4ToInt(strTo);
        if (from > to) {
            throw new HinemosUnknown(
                    MessageConstant.MESSAGE_PLEASE_SET_CORRECT_RANGE_OF_IP_ADDRESSES.getMessage());
        }
        for (int i = from; i <= to; i++) {
            list.add(intToIpV4(i));
        }
    } else {
        BigInteger from = byteToBigIntV6(InetAddress.getByName(strFrom).getAddress());
        BigInteger to = byteToBigIntV6(InetAddress.getByName(strTo).getAddress());

        if (from.compareTo(to) > 0) {
            throw new HinemosUnknown(
                    MessageConstant.MESSAGE_PLEASE_SET_CORRECT_RANGE_OF_IP_ADDRESSES.getMessage());
        } else if (from.compareTo(to) == 0) {
            list.add(bigIntToIpV6(from));
        } else {
            int i = 0;
            while (true) {
                list.add(bigIntToIpV6(from));
                from = from.add(BigInteger.ONE);
                i++;
                if (i > 256 || from.compareTo(to) >= 0) {
                    break;
                }
            }
        }
    }
    return list;
}

From source file:com.github.jrrdev.mantisbtsync.core.services.JdbcIssuesServiceTest.java

/**
 * Test method for {@link com.github.jrrdev.mantisbtsync.core.services.JdbcIssuesService#insertCustomFieldIfNotExists(biz.futureware.mantis.rpc.soap.client.ObjectRef, java.math.BigInteger)}.
 *//*  w w  w  . ja v a2  s . c  om*/
@Test
public void testInsertCustomFieldIfNotExistsProjectNull() {
    final Operation op = insertInto("mantis_enum_custom_field_types").columns("id", "name").values(1, "type_1")
            .build();

    lauchOperation(op);

    final ObjectRef item = new ObjectRef(BigInteger.ONE, "item");
    dao.insertCustomFieldIfNotExists(item, null);

    final List<ObjectRef> list = getJdbcTemplate().query(
            "SELECT cf.id, cf.name" + " FROM mantis_custom_field_table cf",
            new BeanPropertyRowMapper<ObjectRef>(ObjectRef.class));

    assertEquals(1, list.size());
    assertEquals(item, list.get(0));
}

From source file:com.netflix.imfutility.cpl._2013.Cpl2013ContextBuilderStrategy.java

private void processResourceRepeat(TrackFileResourceType trackFileResource, long repeat) {
    // 1. init resource context
    ResourceUUID resourceId = ResourceUUID.create(trackFileResource.getId(), repeat);
    ResourceKey resourceKey = ResourceKey.create(currentSegmentUuid, currentSequenceUuid, currentSequenceType);
    contextProvider.getResourceContext().initResource(resourceKey, resourceId);

    // 2. Init essence parameter in Edit Units (as defined in CPL)
    // Check that we have a corresponding track file in assetmap
    // asset map already contains full absolute paths
    UUID trackId = UUID.create(trackFileResource.getTrackFileId());
    String assetPath = assetMap.getAsset(trackId);
    if (assetPath == null) {
        throw new ConversionException(
                String.format("Resource track file '%s' isn't present in assetmap.xml", trackId));
    }//from  w  ww.  j a  va2 s  .  c  om
    assetMap.markAssetReferenced(trackId);
    contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId,
            ResourceContextParameters.ESSENCE, assetPath);

    // 3. init edit rate parameter
    BigFraction editRate = ((trackFileResource.getEditRate() != null)
            && !trackFileResource.getEditRate().isEmpty())
                    ? ConversionHelper.parseEditRate(trackFileResource.getEditRate())
                    : compositionEditRate;
    contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId,
            ResourceContextParameters.EDIT_RATE, ConversionHelper.toEditRate(editRate));

    // 4. Init startTime parameter
    BigInteger startTimeEditUnit = trackFileResource.getEntryPoint() != null ? trackFileResource.getEntryPoint()
            : BigInteger.valueOf(0);
    contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId,
            ResourceContextParameters.START_TIME_EDIT_UNIT, startTimeEditUnit.toString());

    // 5. init duration parameter
    BigInteger durationEditUnit;
    if (trackFileResource.getSourceDuration() != null) {
        durationEditUnit = trackFileResource.getSourceDuration();
    } else {
        durationEditUnit = trackFileResource.getIntrinsicDuration().subtract(startTimeEditUnit);
    }
    contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId,
            ResourceContextParameters.DURATION_EDIT_UNIT, durationEditUnit.toString());

    // 6. init endTime parameter
    BigInteger endTimeEditUnit = startTimeEditUnit.add(durationEditUnit);
    contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId,
            ResourceContextParameters.END_TIME_EDIT_UNIT, endTimeEditUnit.toString());

    // 7. init total repeat count parameter
    BigInteger repeatCount = trackFileResource.getRepeatCount() != null ? trackFileResource.getRepeatCount()
            : BigInteger.ONE;
    contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId,
            ResourceContextParameters.REPEAT_COUNT, repeatCount.toString());

    // 8. init trackFile ID
    contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId,
            ResourceContextParameters.TRACK_FILE_ID, trackId.getUuid());

    // 9. init essence descriptor ID
    String essenceDescId = trackFileResource.getSourceEncoding();
    contextProvider.getResourceContext().addResourceParameter(resourceKey, resourceId,
            ResourceContextParameters.ESSENCE_DESC_ID, essenceDescId);
}

From source file:org.geppetto.model.neuroml.services.NeuroMLModelInterpreterService.java

/**
 * @param n//from   www . ja  va2s  .  c om
 * @param parentEntity
 * @param url
 * @param aspect
 * @param neuroml
 * @throws MalformedURLException
 * @throws JAXBException
 * @throws ModelInterpreterException
 * @throws ContentError 
 */
private void addNetworkSubEntities(Network n, EntityNode parentEntity, URL url, AspectNode aspect,
        ModelWrapper model) throws ModelInterpreterException {
    if (n.getPopulation().size() == 1 && parentEntity.getId().equals(n.getPopulation().get(0).getComponent())
            && n.getPopulation().get(0).getSize().equals(BigInteger.ONE)) {
        // there's only one cell whose name is the same as the geppetto entity, don't create any subentities
        neuroMLAccessUtility.getComponent(n.getPopulation().get(0).getComponent(), model, Resources.CELL);
        mapCellIdToEntity(parentEntity.getId(), parentEntity, aspect);
        return;
    }
    for (Population p : n.getPopulation()) {
        //BaseCell cell = getCell(p, url, model);
        BaseCell cell = (BaseCell) neuroMLAccessUtility.getComponent(p.getComponent(), model, Resources.CELL);
        if (p.getType() != null && p.getType().equals(PopulationTypes.POPULATION_LIST)) {
            int i = 0;
            for (Instance instance : p.getInstance()) {
                String id = VariablePathSerializer.getArrayName(p.getId(), i);
                EntityNode e = getEntityNodefromCell(cell, id, aspect);

                if (instance.getLocation() != null) {
                    e.setPosition(getPoint(instance.getLocation()));
                }
                e.setId(id);
                parentEntity.addChild(e);
                i++;
            }

        } else {
            int size = p.getSize().intValue();

            for (int i = 0; i < size; i++) {
                // FIXME the position of the population within the network needs to be specified in neuroml
                String id = VariablePathSerializer.getArrayName(cell.getId(), i);
                EntityNode e = getEntityNodefromCell(cell, id, aspect);
                e.setId(id);
                parentEntity.addChild(e);
            }
        }
    }

}

From source file:com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardConsumerTest.java

/**
 * Test method for {@link ShardConsumer#consumeShard()}
 *//*ww  w  .j ava2s  .c o m*/
@Test
public final void testConsumeShard() throws Exception {
    int numRecs = 10;
    BigInteger startSeqNum = BigInteger.ONE;
    String streamShardId = "kinesis-0-0";
    String testConcurrencyToken = "testToken";
    File file = KinesisLocalFileDataCreator.generateTempDataFile(1, "kinesis-0-", numRecs, startSeqNum,
            "unitTestSCT001");

    IKinesisProxy fileBasedProxy = new KinesisLocalFileProxy(file.getAbsolutePath());

    final int maxRecords = 2;
    final int idleTimeMS = 0; // keep unit tests fast
    ICheckpoint checkpoint = new InMemoryCheckpointImpl(startSeqNum.toString());
    checkpoint.setCheckpoint(streamShardId, ExtendedSequenceNumber.TRIM_HORIZON, testConcurrencyToken);
    when(leaseManager.getLease(anyString())).thenReturn(null);

    TestStreamlet processor = new TestStreamlet();

    StreamConfig streamConfig = new StreamConfig(fileBasedProxy, maxRecords, idleTimeMS,
            callProcessRecordsForEmptyRecordList, skipCheckpointValidationValue, INITIAL_POSITION_LATEST);

    ShardInfo shardInfo = new ShardInfo(streamShardId, testConcurrencyToken, null, null);
    ShardConsumer consumer = new ShardConsumer(shardInfo, streamConfig, checkpoint, processor, leaseManager,
            parentShardPollIntervalMillis, cleanupLeasesOfCompletedShards, executorService, metricsFactory,
            taskBackoffTimeMillis,
            KinesisClientLibConfiguration.DEFAULT_SKIP_SHARD_SYNC_AT_STARTUP_IF_LEASES_EXIST);

    assertThat(consumer.getCurrentState(),
            is(equalTo(ConsumerStates.ShardConsumerState.WAITING_ON_PARENT_SHARDS)));
    consumer.consumeShard(); // check on parent shards
    Thread.sleep(50L);
    consumer.consumeShard(); // start initialization
    assertThat(consumer.getCurrentState(), is(equalTo(ConsumerStates.ShardConsumerState.INITIALIZING)));
    consumer.consumeShard(); // initialize
    processor.getInitializeLatch().await(5, TimeUnit.SECONDS);

    // We expect to process all records in numRecs calls
    for (int i = 0; i < numRecs;) {
        boolean newTaskSubmitted = consumer.consumeShard();
        if (newTaskSubmitted) {
            LOG.debug("New processing task was submitted, call # " + i);
            assertThat(consumer.getCurrentState(), is(equalTo(ConsumerStates.ShardConsumerState.PROCESSING)));
            // CHECKSTYLE:IGNORE ModifiedControlVariable FOR NEXT 1 LINES
            i += maxRecords;
        }
        Thread.sleep(50L);
    }

    assertThat(processor.getShutdownReason(), nullValue());
    consumer.notifyShutdownRequested(shutdownNotification);
    consumer.consumeShard();
    assertThat(processor.getNotifyShutdownLatch().await(1, TimeUnit.SECONDS), is(true));
    Thread.sleep(50);
    assertThat(consumer.getShutdownReason(), equalTo(ShutdownReason.REQUESTED));
    assertThat(consumer.getCurrentState(), equalTo(ConsumerStates.ShardConsumerState.SHUTDOWN_REQUESTED));
    verify(shutdownNotification).shutdownNotificationComplete();
    assertThat(processor.isShutdownNotificationCalled(), equalTo(true));
    consumer.consumeShard();
    Thread.sleep(50);
    assertThat(consumer.getCurrentState(), equalTo(ConsumerStates.ShardConsumerState.SHUTDOWN_REQUESTED));

    consumer.beginShutdown();
    Thread.sleep(50L);
    assertThat(consumer.getShutdownReason(), equalTo(ShutdownReason.ZOMBIE));
    assertThat(consumer.getCurrentState(), is(equalTo(ConsumerStates.ShardConsumerState.SHUTTING_DOWN)));
    consumer.beginShutdown();
    consumer.consumeShard();
    verify(shutdownNotification, atLeastOnce()).shutdownComplete();
    assertThat(consumer.getCurrentState(), is(equalTo(ConsumerStates.ShardConsumerState.SHUTDOWN_COMPLETE)));
    assertThat(processor.getShutdownReason(), is(equalTo(ShutdownReason.ZOMBIE)));

    executorService.shutdown();
    executorService.awaitTermination(60, TimeUnit.SECONDS);

    String iterator = fileBasedProxy.getIterator(streamShardId, ShardIteratorType.TRIM_HORIZON.toString());
    List<Record> expectedRecords = toUserRecords(fileBasedProxy.get(iterator, numRecs).getRecords());
    verifyConsumedRecords(expectedRecords, processor.getProcessedRecords());
    file.delete();
}

From source file:org.nordapp.web.servlet.SessionCallServlet.java

/**
 * @param req The request//  w ww. java  2s  .  com
 * @param resp The response
 * @param data The data
 * @throws IOException 
 */
private void process(SessionControl ctrl, HttpServletRequest req, HttpServletResponse resp,
        Map<String, Object> data) throws IOException {

    //
    // Session service
    //
    String cert = null;

    //The '0' session of the mandator
    Session mSession = SessionServiceImpl.getSession(context, cert, ctrl.getMandatorID(), "0");
    Integer baseIndex = ((Integer) mSession.getValue(Session.ENGINE_BASE_INDEX)).intValue();
    //String sessionId = session.getId();

    String[] elem = RequestPath.getPath(req, ctrl.getPathStartIndex());
    if (elem.length == 0)
        throw new MalformedURLException("The URL needs the form '" + req.getServletPath()
                + (ctrl.getPathStartIndex() == 0 ? "" : "mandator-id/session-id") + "/function-id' but was '"
                + req.getRequestURI() + "'");

    BigInteger engineId = ctrl.decodeCert();
    String functionId = elem[0];

    StringBuffer buffer = new StringBuffer();
    List<String> states = new ArrayList<String>();
    ResponseHandler rsHdl = new ResponseHandler(context, ctrl);

    EngineBaseService engineBaseService = null;
    Engine engine = null;
    BigInteger anonId = null;
    boolean anonymous = false;
    try {
        //
        // Gets the engine base service
        //
        engineBaseService = EngineBaseServiceImpl.getService(context, ctrl.getMandatorID(),
                String.valueOf(baseIndex));
        if (engineBaseService == null)
            throw new IOException(
                    "The mandator base service is not available (maybe down or a version conflict).");

        //
        // Run the step
        //
        Mandator mandator = MandatorServiceImpl.getMandator(context, ctrl.getMandatorID());
        if (mandator == null)
            throw new IOException("The mandator service is not available (maybe down or a version conflict).");

        //
        // getEngine() creates one, if there is no engine.
        //

        Map<String, Object> params = new HashMap<String, Object>();
        params.put(EngineBaseService.IS_AVAILABLE, Boolean.TRUE);
        params.put(EngineBaseService.IS_LOGIN, Boolean.TRUE);
        engine = engineBaseService.queryEngine(engineId, params);

        if (engine == null) {

            String key = ctrl.getGroupID() + "." + ctrl.getArtifactID() + ".anonymous-support";
            if (Boolean.valueOf(mandator.getProperty(key)).booleanValue()) {
                key = ctrl.getGroupID() + "." + ctrl.getArtifactID() + ".anonymous-session";
                String val = mandator.getProperty(key);
                anonId = val == null ? BigInteger.ONE : new BigInteger(val);

                //
                // TODO cache this to avoid the initialization each call
                //

                //setup the bundles
                engineBaseService.setupStore(anonId);
                //uses the login-flag to signal the init state
                engine = engineBaseService.getEngine(anonId);
                //cleanup the old state
                if (!engine.hasNext()) {
                    engine.reinit();
                }

                anonymous = true;
            } else
                throw new IllegalAccessException("There is no login to this session (needs login).");

            //engineBaseService.dropEngine(engineId);
        }

        //
        // Set the parameter to the user-session
        //
        if (!anonymous) {
            mSession = SessionServiceImpl.getSession(context, cert, ctrl.getMandatorID(),
                    ctrl.decodeCert().toString());

            if (mSession != null && data != null && data.size() > 0) {
                for (String key : data.keySet()) {
                    Object value = data.get(key);

                    logger.trace("Set data to session mandatorId:{}, sessionId:{}, key:{}, value:{}",
                            ctrl.getMandatorID(), ctrl.getCertID(), key, value);
                    mSession.setValue(key, value);
                } //for
            } //fi
        }

        try {
            engine.setLocalValue(Mandator.MANDATORID, ctrl.getMandatorID());
            engine.setLocalValue("anonymous", new Boolean(anonymous));
            engine.setLocalValue("sessionId", ctrl.decodeCert().toString());
            engine.setLocalValue("nativeSessionId", ctrl.decodeCert());
            engine.setLocalValue("immediate.result", null);
            engine.setLocalValue("immediate.fields", data == null ? null : Collections.unmodifiableMap(data));
            engine.setLocalValue("immediate.states", states);

            engine.call(functionId);
        } catch (Exception e) {
            e.printStackTrace();
        }

        Object val = engine.getLocalValue("immediate.result");
        if (val != null) {
            logger.trace("immediate.results:{}", val);
            //Gson gson = new Gson();
            buffer.append(String.valueOf(val));
        }

    } catch (Exception e) {
        logger.error("Error running the step.", e);
    } finally {

        if (anonymous) {

            //
            // TODO cache this to avoid the initialization each call
            //

            engine.exit();
            try {
                engineBaseService.dropEngine(anonId);
            } catch (Exception e) {
                logger.error("Error running the step.", e);
            }
        } //fi
    }

    //
    //
    //
    byte[] bytes = buffer.toString().getBytes();

    //
    // Set RESTful states to HTTP links
    //

    LinkHeader lhdr = new LinkHeaderImpl();
    if (ctrl.isStateful()) {
        StateUtil.setDefault(lhdr, req);

        lhdr.setLink_mandator(ctrl.getMandatorID());
        lhdr.setLink_uuid(ctrl.getCertID());

        for (String state : states) {
            if (state == null)
                continue;
            int k = state.trim().lastIndexOf(' ');
            if (k < 1 || k == (state.length() - 1))
                continue;
            lhdr.add(state.substring(0, k), state.substring(k + 1));
        }
        //StateUtil.setState(context, ctrl, lhdr, "init.state");
        logger.debug(lhdr.toString());
    }
    rsHdl.setLinkHeader(resp, lhdr.toString());

    //
    // Send the resource
    //
    rsHdl.avoidCaching(resp);
    rsHdl.sendData(bytes, resp);

}