com.pureinfo.srm.config.workflow.function.HonorGuarder.java Source code

Java tutorial

Introduction

Here is the source code for com.pureinfo.srm.config.workflow.function.HonorGuarder.java

Source

/**
 * PureInfo Quake
 * @(#)HonorGuarder.java   1.0 Nov 14, 2005
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

package com.pureinfo.srm.config.workflow.function;

import org.apache.commons.lang.StringUtils;

import com.pureinfo.ark.auth.model.IUser;
import com.pureinfo.ark.content.model.ArkContent;
import com.pureinfo.ark.interaction.view.ViewGuarderImplBase;
import com.pureinfo.force.exception.PureException;
import com.pureinfo.srm.auth.model.SRMUser;
import com.pureinfo.srm.config.workflow.WorkflowHelper;
import com.pureinfo.srm.config.workflow.model.WfProcess;

/**
 * <P>
 * Created on Nov 14, 2005 4:44:06 PM <BR>
 * Last modified on Nov 14, 2005
 * </P>
 * 
 * @author Freeman.Hu
 * @version 1.0, Nov 14, 2005
 * @since Quake 1.0
 */
public class HonorGuarder extends ViewGuarderImplBase {

    /**
     * @see com.pureinfo.ark.interaction.view.ViewGuarderImplBase#checkPass(com.pureinfo.ark.content.model.ArkContent,
     *      com.pureinfo.ark.auth.model.IUser, java.lang.Object[])
     */
    protected boolean checkPass(ArkContent _content, IUser _user, Object[] _args) throws PureException {
        if (_args.length != 1)
            throw new PureException(PureException.INVALID_REQUEST, "args must have two arguments!");
        if ("null".equals(_args[0])) {
            WfProcess process = WorkflowHelper.getHonorProcess();
            return process != null ? true : false;
        }
        String[] acts = StringUtils.split((String) _args[0], "|");
        for (int i = 0; i < acts.length; i++) {
            if (WorkflowHelper.checkHonorRole(acts[i], ((SRMUser) _user).getRolesList()))
                return true;
        }
        return false;
    }

}