/******************************************************************************
 * CrudLogicImpl.java - created by Sakai App Builder -AZ
 * 
 * Copyright (c) 2007 Sakai Project/Sakai Foundation
 * Licensed under the Educational Community License version 1.0
 * 
 * A copy of the Educational Community License has been included in this 
 * distribution and is available at: http://www.opensource.org/licenses/ecl1.php
 * 
 *****************************************************************************/

package org.sakaiproject.wontovlab.logic.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sakaiproject.wontovlab.dao.AccessControlDao;
import org.sakaiproject.wontovlab.logic.AccessControlLogic;
import org.sakaiproject.wontovlab.logic.ExternalLogic;
import org.sakaiproject.wontovlab.logic.UtilLogic;
import org.sakaiproject.wontovlab.model.AccessControl;



/**
 * This is the implementation of the business logic interface
 * @author Sakai App Builder -AZ
 */
public class AccessControlLogicImpl implements AccessControlLogic 
{

	public AccessControlLogicImpl() {
	}
	
	
	private static Log log = LogFactory.getLog(AccessControlLogicImpl.class);

	private AccessControlDao dao;
	public void setDao(AccessControlDao dao) {
		this.dao = dao;
	}

	private ExternalLogic externalLogic;
	public void setExternalLogic(ExternalLogic externalLogic) {
		this.externalLogic = externalLogic;
	}
	
	private UtilLogic utilLogic;
	public void setUtilLogic(UtilLogic utilLogic) {
		this.utilLogic = utilLogic;
	}

	/**
	 * Place any code that should run when this class is initialized by spring here
	 */
	public void init() {
		log.debug("init");
	}


    public void saveAccessControl(AccessControl accessControl)
    {
		log.debug("In saveExperiment with Experiment:" + accessControl.getOwnerId());
		// set the owner and site to current if they are not set
		if (accessControl.getOwnerId() == null) {
			accessControl.setOwnerId(externalLogic.getCurrentUserId() );
		}

		dao.saveAccessControl(accessControl);
		log.info("Saving Experiment: " + accessControl.getOwnerId());
		
    	
   	
    }
    
    
	


}
