Package org.apache.lenya.workflow

Examples of org.apache.lenya.workflow.WorkflowManager


     * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
     */
    protected void initParameters() {
        super.initParameters();

        WorkflowManager resolver = null;
        try {
            Document doc = getSourceDocument();
            if (doc != null) {
                // read parameters from Dublin Core meta-data
                MetaData dc = doc.getMetaData(DublinCore.DC_NAMESPACE);
                setParameter(DublinCore.ELEMENT_TITLE, dc.getFirstValue(DublinCore.ELEMENT_TITLE));
                setParameter(DublinCore.ELEMENT_DESCRIPTION, dc
                        .getFirstValue(DublinCore.ELEMENT_DESCRIPTION));

                // read parameters from document attributes
                setParameter(LANGUAGES, doc.getLanguages());
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
                String lastModified = format
                        .format(new Date(getSourceDocument().getLastModified()));
                setParameter(LASTMODIFIED, lastModified);
                boolean visible = doc.getLink().getNode().isVisible();
                setParameter(VISIBLE_IN_NAVIGATION, Boolean.valueOf(visible));

                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
                        getSession(), getLogger(), doc);
                resolver = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
                if (resolver.hasWorkflow(workflowable)) {
                    Workflow workflow = resolver.getWorkflowSchema(workflowable);
                    String[] variableNames = workflow.getVariableNames();
                    Version latestVersion = workflowable.getLatestVersion();
                    Boolean isLive = null;
                    if (latestVersion != null) {
                        setParameter(STATE, latestVersion.getState());
View Full Code Here


     */
    public Object getAttribute(String name, Configuration modeConf, Map objectModel)
            throws ConfigurationException {

        Object value = null;
        WorkflowManager wfManager = null;

        try {
            PageEnvelope envelope = getEnvelope(objectModel, name);
            Document document = envelope.getDocument();
            if (document != null && document.exists()) {
                wfManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
                Session session = RepositoryUtil.getSession(this.manager,
                        ObjectModelHelper.getRequest(objectModel));
                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
                        session,
                        getLogger(),
                        document);
                if (wfManager.hasWorkflow(workflowable)) {

                    Version latestVersion = workflowable.getLatestVersion();

                    if (name.equals(STATE)) {
                        if (latestVersion == null) {
                            Workflow workflow = wfManager.getWorkflowSchema(workflowable);
                            value = workflow.getInitialState();
                        } else {
                            value = latestVersion.getState();
                        }
                    } else if (name.startsWith(VARIABLE_PREFIX)) {
                        String variableName = name.substring(VARIABLE_PREFIX.length());
                        Workflow workflow = wfManager.getWorkflowSchema(workflowable);
                        String[] variableNames = workflow.getVariableNames();
                        if (Arrays.asList(variableNames).contains(variableName)) {
                            if (latestVersion == null) {
                                value = Boolean.valueOf(workflow.getInitialValue(variableName));
                            } else {
View Full Code Here

     * @param event The name of the event.
     * @throws WorkflowException if the event could not be invoked in the current situation.
     */
    public static void invoke(ServiceManager manager, Session session, Logger logger,
            Document document, String event) throws WorkflowException {
        WorkflowManager wfManager = null;
        try {
            wfManager = (WorkflowManager) manager.lookup(WorkflowManager.ROLE);
            Workflowable workflowable = getWorkflowable(manager, session, logger, document);
            wfManager.invoke(workflowable, event);
        } catch (ServiceException e) {
            throw new WorkflowException(e);
        } finally {
            if (wfManager != null) {
                manager.release(wfManager);
View Full Code Here

     *            set to <code>false</code>, non-supporting documents are ignored.
     * @throws WorkflowException if the event could not be invoked in the current situation.
     */
    public static void invoke(ServiceManager manager, Session session, Logger logger,
            Document document, String event, boolean force) throws WorkflowException {
        WorkflowManager wfManager = null;
        try {
            wfManager = (WorkflowManager) manager.lookup(WorkflowManager.ROLE);
            Workflowable workflowable = getWorkflowable(manager, session, logger, document);
            wfManager.invoke(workflowable, event, force);
        } catch (ServiceException e) {
            throw new WorkflowException(e);
        } finally {
            if (wfManager != null) {
                manager.release(wfManager);
View Full Code Here

     * @throws WorkflowException if <code>force</code> is set to <code>true</code> and a
     *             document does not support the workflow event.
     */
    public static void invoke(ServiceManager manager, Session session, Logger logger,
            DocumentSet documentSet, String event, boolean force) throws WorkflowException {
        WorkflowManager wfManager = null;
        try {
            wfManager = (WorkflowManager) manager.lookup(WorkflowManager.ROLE);

            Document[] documents = documentSet.getDocuments();
            for (int i = 0; i < documents.length; i++) {
                Workflowable workflowable = new DocumentWorkflowable(manager,
                        session,
                        documents[i],
                        logger);
                wfManager.invoke(workflowable, event, force);
            }

        } catch (ServiceException e) {
            throw new WorkflowException(e);
        } finally {
View Full Code Here

     * @return A boolean value.
     * @throws WorkflowException
     */
    public static boolean canInvoke(ServiceManager manager, Session session, Logger logger,
            Document document, String event) throws WorkflowException {
        WorkflowManager wfManager = null;
        try {
            wfManager = (WorkflowManager) manager.lookup(WorkflowManager.ROLE);
            Workflowable workflowable = new DocumentWorkflowable(manager, session, document, logger);
            return wfManager.canInvoke(workflowable, event);
        } catch (ServiceException e) {
            throw new WorkflowException(e);
        } finally {
            if (wfManager != null) {
                manager.release(wfManager);
View Full Code Here

     * @return if an error occurs.
     * @throws WorkflowException
     */
    public static boolean canInvoke(ServiceManager manager, Session session, Logger logger,
            DocumentSet documents, String event) throws WorkflowException {
        WorkflowManager wfManager = null;
        try {
            wfManager = (WorkflowManager) manager.lookup(WorkflowManager.ROLE);

            boolean canInvoke = true;
            Document[] documentArray = documents.getDocuments();
            for (int i = 0; i < documentArray.length; i++) {
                Workflowable workflowable = new DocumentWorkflowable(manager,
                        session,
                        documentArray[i],
                        logger);
                canInvoke = canInvoke && wfManager.canInvoke(workflowable, event);
            }
            return canInvoke;

        } catch (ServiceException e) {
            throw new WorkflowException(e);
View Full Code Here

     * @return A boolean value.
     * @throws WorkflowException if an error occurs.
     */
    public static boolean hasWorkflow(ServiceManager manager, Session session, Logger logger,
            Document document) throws WorkflowException {
        WorkflowManager wfManager = null;
        try {
            wfManager = (WorkflowManager) manager.lookup(WorkflowManager.ROLE);
            Workflowable workflowable = new DocumentWorkflowable(manager, session, document, logger);
            return wfManager.hasWorkflow(workflowable);
        } catch (ServiceException e) {
            throw new WorkflowException(e);
        } finally {
            if (wfManager != null) {
                manager.release(wfManager);
View Full Code Here

     * @return A workflow schema.
     * @throws WorkflowException if an error occurs.
     */
    public static Workflow getWorkflowSchema(ServiceManager manager, Session session,
            Logger logger, Document document) throws WorkflowException {
        WorkflowManager wfManager = null;
        try {
            wfManager = (WorkflowManager) manager.lookup(WorkflowManager.ROLE);
            Workflowable workflowable = getWorkflowable(manager, session, logger, document);
            if (wfManager.hasWorkflow(workflowable)) {
                return wfManager.getWorkflowSchema(workflowable);
            } else {
                throw new WorkflowException("The document [" + document + "] has no workflow!");
            }
        } catch (ServiceException e) {
            throw new WorkflowException(e);
View Full Code Here

    public void setup(SourceResolver _resolver, Map _objectModel, String src, Parameters _parameters)
            throws ProcessingException, SAXException, IOException {

        super.setup(_resolver, _objectModel, src, _parameters);

        WorkflowManager workflowManager = null;

        try {
            Request request = ObjectModelHelper.getRequest(_objectModel);
            Session session = RepositoryUtil.getSession(this.manager, request);
            DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);

            String webappUrl = ServletHelper.getWebappURI(request);
            Document document = null;
            if (map.isDocument(webappUrl)) {
                document = map.getFromURL(webappUrl);
                ResourceType doctype = document.getResourceType();
                if (document.getPublication().getWorkflowSchema(doctype) != null) {
                    setHasWorkflow(true);
                    workflowManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
                } else {
                    setHasWorkflow(false);
                }
            } else {
                setHasWorkflow(false);
            }

            if (hasWorkflow()) {
                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
                        session,
                        getLogger(),
                        document);
                Workflow workflow = workflowManager.getWorkflowSchema(workflowable);
                String[] events = workflow.getEvents();
                for (int i = 0; i < events.length; i++) {
                    if (workflowManager.canInvoke(workflowable, events[i])) {
                        this.executableEvents.add(events[i]);
                    }
                }

            }
View Full Code Here

TOP

Related Classes of org.apache.lenya.workflow.WorkflowManager

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.