[opencms-dev] OSWorkflow-OpenCMS for 6.0 beta 3 final release

Shi Yusen shiys at langhua.cn
Fri Oct 21 17:57:17 CEST 2005


Hi list,

The attachment is osworkflow-opencms source package. It's in LGPL license.
It's very different from the former one.

Installation Guide:
1. Import the osworkflow module into OpenCMS.

2. Add datasource jdbc/OsWorkflowDS in context element in context.xml, for
example:
   <Resource name="jdbc/OsWorkflowDS" auth="Container"
type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="root" password="111111"
driverClassName="com.mysql.jdbc.Driver"
 
url="jdbc:mysql://localhost:3309/osworkflow?autoReconnect=true"/>

3. Create database and tables. Please choose the right SQL scripts for your
database software.

4. Modify the source code of OpenCms:

4.1 Edit the /org/opencms/db/CmsDriverManager.java:
    public synchronized CmsPublishList getPublishList(
    ...
        } else if (directPublishResource.isFile()
            && I_CmsConstants.C_STATE_UNCHANGED !=
directPublishResource.getState()) {
            
            // when publishing a file directly this file is the only
candidate
            // if it is modified and unlocked
            
            if (getLock(dbc, directPublishResource).isNullLock()) {
                // added by Shi Yusen, shiys at langhua.cn
                // not publish the file if its workflow is still underway
            	boolean canPublish = true;
                CmsProperty workflowid = m_vfsDriver.readPropertyObject(dbc,
CmsWorkflowDialog.C_WORKFLOWID, dbc.currentProject(),
directPublishResource);
                if (!workflowid.isNullProperty()) {
                	String entryId = workflowid.getValue();
                	if (CmsStringUtil.isNotEmpty(entryId)) {
            			Workflow wf = new
BasicWorkflow(dbc.currentUser().getName());
            		    Configuration myconfig = new
DefaultConfiguration();
            		    wf.setConfiguration(myconfig);
        				long id = Long.parseLong(entryId);
        				int entryState =
wf.getEntryState(id);
        				if (entryState !=
WorkflowEntry.KILLED && entryState != WorkflowEntry.COMPLETED) {
        					canPublish = false;
        				}
                	}
                }
                if (canPublish)
                	publishList.addFile(directPublishResource);
            }
            
        }
    ....

    private List filterResources(CmsDbContext dbc, List folderList, List
resourceList) {

        List result = new ArrayList();

        // local folder list for adding new publishing subfolders
        // this solves the TestPublishIssues.testPublishScenarioD problem.
        List newFolderList = folderList==null?new ArrayList():new
ArrayList(folderList);

        for (int i = 0; i < resourceList.size(); i++) {
            CmsResource res = (CmsResource)resourceList.get(i);
            try {
                CmsLock lock = getLock(dbc, res);
                if (! lock.isNullLock()) {
                    // checks if there is a shared lock and if the resource
is deleted
                    // this solves the
TestPublishIssues.testPublishScenarioE problem.
                    if (lock.getType()==CmsLock.C_TYPE_SHARED_INHERITED ||
lock.getType()==CmsLock.C_TYPE_SHARED_EXCLUSIVE) { 
                        if (res.getState()!=I_CmsConstants.C_STATE_DELETED)
{
                            continue;
                        }
                    } else {
                        // don't add locked resources
                        continue;
                    }
                }

                if (!I_CmsConstants.C_ROOT.equals(res.getRootPath()) &&
!checkParentResource(dbc, newFolderList, res)) {
                    continue;
                }

                // added by Shi Yusen, shiys at langhua.cn
                // not publish the file if its workflow is still underway
                CmsProperty workflowid = m_vfsDriver.readPropertyObject(dbc,
CmsWorkflowDialog.C_WORKFLOWID, dbc.currentProject(), res);
                if (!workflowid.isNullProperty()) {
                	String entryId = workflowid.getValue();
                	if (CmsStringUtil.isNotEmpty(entryId)) {
            			Workflow wf = new
BasicWorkflow(dbc.currentUser().getName());
            		    Configuration myconfig = new
DefaultConfiguration();
            		    wf.setConfiguration(myconfig);
        				long id = Long.parseLong(entryId);
        				int entryState =
wf.getEntryState(id);
        				if (entryState !=
WorkflowEntry.KILLED && entryState != WorkflowEntry.COMPLETED) {
        					continue;
        				}
                	}
                }
                
                if (res.isFolder()) {
                    newFolderList.add(res);
                }
                
                result.add(res);

            } catch (Exception e) {
                // noop
            }
        }
        return result;
    }

4.2 Edit the /org/opencms/loader/mimetypes.properties, add the following
line:
jnlp=application/x-java-jnlp-file

5. Build a new opencms.jar and opencms-legacy.jar and deploy them in tomcat.

6. Add workflowpage in opencms-workplace.xml:
			<explorertype name="workflowpage"
key="fileicon.workflowpage" icon="workflowpage.gif">
				<newresource
uri="../../modules/cn.langhua.osworkflow/commons/newresource_workflowpage.js
p" order="110"/>
				<accesscontrol>
					<accessentry
principal="GROUP.Administrators" permissions="+r+v+w+c"/>
					<accessentry
principal="GROUP.Projectmanagers" permissions="+r+v+w+c"/>
					<accessentry principal="GROUP.Users"
permissions="+r+v+w+c"/>
				</accesscontrol>
				<editoptions>
					<defaultproperties enabled="true"
shownavigation="true">
						<property name="Title"/>
						<property name="Keywords"/>
						<property
name="Description"/>
					</defaultproperties>
					<contextmenu>
						<entry
key="explorer.context.lock" uri="commons/lock.jsp" rules="d d aaaa dddd
dddd" order="10"/>
						<entry
key="explorer.context.overridelock" uri="commons/lockchange.jsp" rules="d d
dddd dddd aaaa" order="20"/>
						<entry
key="explorer.context.unlock" uri="commons/unlock.jsp" rules="d d dddd aaaa
dddd" order="30"/>
						<separator order="40"/>
						<entry
key="explorer.context.copytoproject" uri="commons/copytoproject.jsp"
rules="d a dddd dddd dddd" order="50"/>
						<entry
key="explorer.context.publish" uri="commons/publishresource.jsp" rules="d d
iaaa iaaa dddd" order="60"/>
						<separator order="70"/>
						<entry
key="explorer.context.pageedit" uri="editors/editor.jsp" target="_top"
rules="d d iiii aaai dddd" order="80"/>
						<entry
key="explorer.context.editsource" uri="editors/editor.jsp?editormode=edit"
target="_top" rules="d d iiii aaai dddd" order="90"/>
						<separator order="100"/>
						<entry
key="explorer.context.copy" uri="commons/copy.jsp" rules="d d aaai aaai
dddd" order="150"/>
						<entry
key="explorer.context.move" uri="commons/move.jsp" rules="d d iiii aaai
dddd" order="170"/>
						<entry
key="explorer.context.delete" uri="commons/delete.jsp" rules="d d iiii aaai
dddd" order="180"/>
						<entry
key="explorer.context.touch" uri="commons/touch.jsp" rules="d d iiii aaai
dddd" order="190"/>
						<entry
key="explorer.context.undochanges" uri="commons/undochanges.jsp" rules="d d
iiid iaid dddd" order="200"/>
						<entry
key="explorer.context.undelete" uri="commons/undelete.jsp" rules="d d ddda
ddda dddd" order="210"/>
						<separator order="240"/>
						<entry
key="explorer.context.showsiblings"
uri="views/explorer/explorer_files.jsp?showlinks=true" rules="a a aaaa aaaa
aaaa" order="250"/>
						<separator order="260"/>
						<entry
key="explorer.context.access" uri="commons/chacc.jsp" rules="a a iiii aaai
dddd" order="300"/>
						<entry
key="explorer.context.secure" uri="commons/secure.jsp" rules="d d iiii aaai
dddd" order="302"/>
						<entry
key="explorer.context.type" uri="commons/chtype.jsp" rules="d d iiii aaai
dddd" order="305"/>
						<entry
key="explorer.context.chnav" uri="commons/chnav.jsp" rules="d d iiii aaai
dddd" order="310"/>
						<separator order="330"/>
						<entry
key="explorer.context.editcontrolfile"
uri="editors/editor.jsp?editastext=true" target="_top" rules="d d iiii aaai
dddd" order="335"/>
						<separator order="340"/>
						<entry
key="explorer.context.history" uri="commons/history.jsp" rules="d d iiii
aaai dddd" order="350"/>
						<entry
key="explorer.context.property"
uri="../modules/cn.langhua.osworkflow/commons/property.jsp" rules="a a aaai
aaai aaai" order="360"/>
						<separator order="400"/> 
						<entry
key="explorer.context.workflow"
uri="../modules/cn.langhua.osworkflow/commons/workflow.jsp" rules="d d iiii
aaai dddd" order="420"/>
					</contextmenu>
				</editoptions>
			</explorertype>

7. Add resourceloader in opencms-vfs.xml:
				<loader
class="cn.langhua.loader.CmsWorkflowPageLoader" />

8. Add resourcetype in opencms-vfs.xml:
				<type
class="cn.langhua.file.types.CmsResourceTypeWorkflowPage"
name="workflowpage" id="43"/>

9. Restart tomcat.


Test:
Click
/system/modules/cn.langhua.osworkflow/osworkflow-2.7.0-example/default.jsp.
You may
run the example successfully. If not, check the installation steps above.


Usage:
1. Create your workflow definition file and store it in
/system/modules/cn.langhua.osworkflow/classes/.

2. Add your workflow to
/system/modules/cn.langhua.osworkflow/classes/workflows.xml.

3. Publish the files and restart tomcat.

4. Create a workflowpage with your workflow.

5. Start workflow from context menu.

6. Continue the workflow in administration view.

-- End --

Have a nice weekend,

Shi Yusen/Beijing Langhua Ltd.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: osworkflow-opencms-src-0.2.zip
Type: application/octet-stream
Size: 127773 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20051021/0ae21a4e/attachment.obj>


More information about the opencms-dev mailing list