zava
Elite Observer

Get Page's current state in Server Task's Script called from Javaclient

Jump to solution

Hi,

I try to get the current state from my page in a Tasks Script, I use

    PageStoreRoot store = (PageStoreRoot) us.getStore(Store.Type.PAGESTORE, false);

    IDProvider page = store.getStoreElement(uuid, Page.UID_TYPE);

page is NULL, with true (release state) I get my Page in release state.

the script is called remotely from Javaclient or Eclipse.

Any idea how can I get the current state, with version 5.0 it works, since 5.2 doesnt work anymore.

task call method

  public static Boolean callSchedule(StoreElement se, String state, UserService us) {

    ScheduleEntry entry = us.getConnection().getService(AdminService.class).getScheduleStorage().getScheduleEntry(us.getProject(), "(IT) Workflow");

    List<ScheduleTask> tasks = entry.getTasks();

    ScriptTask task = null;

    for ( ScheduleTask scriptTask : tasks ) {

      if ( scriptTask.getName().equals("Workflow") ) {

        try {

          task = (ScriptTask) scriptTask;

          task.setParameter("state", state);

          task.setParameter("uuid", se.getName());

          ScheduleEntryControl control = entry.execute();

          control.awaitTermination();

        } catch ( Exception e ) {

          Loggi.E(e.getMessage());

        }

      }

    }

    return true;

  }

Task Script

UserService us = connection.getProjectById(context.getProject().getId()).getUserService();

us.clearCache();

task = context.getTask();

String state =  (String) task.getParameters().get(0).getValue();

String uuid = (String) task.getParameters().get(1).getValue();

WorkflowActions.storeArticleInfo(us,state,uuid);

Store Article method

    PageStoreRoot store = (PageStoreRoot) us.getStore(Store.Type.PAGESTORE, false);

    IDProvider se = store.getStoreElement(uuid, Page.UID_TYPE);

    ........

    se.setLock(true, false);

error... lock is not supported for release store elements

0 Kudos
1 Solution

Accepted Solutions
zava
Elite Observer

Solution get Elements current state on TaskScript with  DelegatingScheduleContext

StoreElementAgent sea = ((StoreElementAgent) context.requestSpecialist(StoreElementAgent.TYPE));

PageStoreRoot store = (PageStoreRoot)  sea.loadStoreElement("root", IDProvider.UidType.PAGESTORE, false);

ele = store.getStoreElement( eleID );

View solution in original post

0 Kudos
1 Reply
zava
Elite Observer

Solution get Elements current state on TaskScript with  DelegatingScheduleContext

StoreElementAgent sea = ((StoreElementAgent) context.requestSpecialist(StoreElementAgent.TYPE));

PageStoreRoot store = (PageStoreRoot)  sea.loadStoreElement("root", IDProvider.UidType.PAGESTORE, false);

ele = store.getStoreElement( eleID );

0 Kudos