Package com.adito.policyframework

Source Code of com.adito.policyframework.PolicyDataSource

package com.adito.policyframework;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.util.LabelValueBean;

import com.adito.input.MultiSelectDataSource;
import com.adito.security.SessionInfo;

/**
*/
public class PolicyDataSource implements MultiSelectDataSource {
  private static Log log = LogFactory.getLog(PolicyDataSource.class);

  public Collection<LabelValueBean> getValues(SessionInfo session) {
   
    ArrayList l = new ArrayList();
    try {
   
      Policy policy;
      for(Iterator it = PolicyDatabaseFactory.getInstance().getPolicies(session.getUser().getRealm()).iterator(); it.hasNext();) {
        policy = (Policy)it.next();
                l.add(new LabelValueBean(policy.getResourceName(), String.valueOf(policy.getResourceId())));
      }
    } catch(Exception ex) {
      log.error("Error obtaining policies for data source", ex);
    }
   
    return l;
  }

}
TOP

Related Classes of com.adito.policyframework.PolicyDataSource

TOP
Copyright © 2018 www.massapi.com. 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.