SecurityRule.java :  » Content-Management-System » harmonise » org » openharmonise » him » actions » rules » Java Open Source

Java Open Source » Content Management System » harmonise 
harmonise » org » openharmonise » him » actions » rules » SecurityRule.java
/*
 * The contents of this file are subject to the 
 * Mozilla Public License Version 1.1 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
 * See the License for the specific language governing rights and 
 * limitations under the License.
 *
 * The Initial Developer of the Original Code is Simulacra Media Ltd.
 * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
 *
 * All Rights Reserved.
 *
 * Contributor(s):
 */
package org.openharmonise.him.actions.rules;

import org.openharmonise.vfs.*;

/**
 * Rule that will return true if the currently selected virtual file
 * allows the method that was specified for this rule.
 * 
 * @author Matthew Large
 * @version $Revision: 1.1 $
 *
 */
public class SecurityRule implements EnableRule {

  boolean m_bComparator = true;

  /**
   * Method name to check.
   */
  String m_sMethod = null;
  
  /**
   * Constructs a new security rule.
   * 
   * @param sMethod Method name to check
   */
  public SecurityRule(String sMethod) {
    super();
    this.m_sMethod = sMethod;
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.actions.rules.EnableRule#isEnabled(com.simulacramedia.vfs.VirtualFile)
   */
  public boolean isEnabled(VirtualFile vfFile) {
    boolean bEnabled = false;
    
    if(vfFile!=null && vfFile.getAllowedMethods().contains(this.m_sMethod)) {
      bEnabled = true;
    }

    return this.m_bComparator==bEnabled;
  }

  /* (non-Javadoc)
   * @see com.simulacramedia.contentmanager.actions.rules.EnableRule#setResultComparator(boolean)
   */
  public void setResultComparator(boolean bComparator) {
    this.m_bComparator = bComparator;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.