// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/dto/InstancePair.java
// public class InstancePair {
// 
// 	private String sourceInstance;
// 	private String copyInstance;
// 
// 	public InstancePair(String sourceInstance, String copyInstance) {
// 		this.sourceInstance = sourceInstance;
// 		this.copyInstance = copyInstance;
// 	}
// 
// 	public String getSource() {
// 		return sourceInstance;
// 	}
// 
// 	public String getCopy() {
// 		return copyInstance;
// 	}
// 
// 	@Override
// 	public boolean equals(Object lhs) {
// 		return lhs instanceof InstancePair && this.hashCode() == lhs.hashCode();
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		return sourceInstance.hashCode() + copyInstance.hashCode();
// 	}
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/model/BrokerAction.java
// @Entity
// public class BrokerAction {
// 
// 	@Id
// 	private String id;
// 
// 	private String actor;
// 
// 	private BrokerActionState state;
// 
// 	private String action;
// 
// 	public BrokerAction() {
// 	}
// 
// 	public BrokerAction(String id, BrokerActionState state, String action) {
// 		this.setId(id);
// 		this.actor = id;
// 		this.state = state;
// 		this.action = action;
// 	}
// 
// 	public String getActor() {
// 		return actor;
// 	}
// 
// 	public void setActor(String actor) {
// 		this.actor = actor;
// 	}
// 
// 	public BrokerActionState getState() {
// 		return state;
// 	}
// 
// 	public void setState(BrokerActionState state) {
// 		this.state = state;
// 	}
// 
// 	public String getAction() {
// 		return action;
// 	}
// 
// 	public void setAction(String action) {
// 		this.action = action;
// 	}
// 
// 	public String getId() {
// 		return id;
// 	}
// 
// 	private void setId(String id) {
// 		this.id = id;
// 	}
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/model/BrokerActionState.java
// public enum BrokerActionState {
// 	FAILED, COMPLETE, IN_PROGRESS
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/provider/CopyProvider.java
// public interface CopyProvider {
// 
// 	/**
// 	 * Create a copy of the source instance. The implementer should inject that
// 	 * through an environment variable or other means. Upon the copy will be
// 	 * launched and accessible to clients.
// 	 * 
// 	 * @param instanceId
// 	 *            to create a copy of
// 	 * @return the id of the new copy.
// 	 * @throws ServiceBrokerException
// 	 *             on error
// 	 */
// 	String createCopy(String instanceId)
// 			throws ServiceBrokerException;
// 
// 	/**
// 	 * Remove a copy from the iaas. The expectation is that all artifacts
// 	 * associated with the copy (snapshots, ami's etc) are cleaned up
// 	 * 
// 	 * @param instance
// 	 *            to delete
// 	 * @throws ServiceBrokerException
// 	 *             on error
// 	 */
// 	void deleteCopy(final String instance)
// 			throws ServiceBrokerException;
// 
// 	/**
// 	 * Return the creds hash associated with service brokers. Should contain a
// 	 * URI, username, password or whatever makes sense for your service. Will be
// 	 * injected into your app.
// 	 */
// 	Map<String, Object> getCreds(final String instance)
// 			throws ServiceBrokerException;
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/repo/BrokerActionRepository.java
// @RepositoryRestResource(collectionResourceRel = "actions", path = "actions")
// public interface BrokerActionRepository extends
// 		PagingAndSortingRepository<BrokerAction, String> {
// 
// 	List<BrokerAction> findByState(@Param("state") BrokerActionState state);
// }


import static org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerActionState.COMPLETE;
import static org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerActionState.FAILED;
import static org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerActionState.IN_PROGRESS;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.log4j.Logger;
import org.cloudfoundry.community.servicebroker.datalifecycle.dto.InstancePair;
import org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerAction;
import org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerActionState;
import org.cloudfoundry.community.servicebroker.datalifecycle.provider.CopyProvider;
import org.cloudfoundry.community.servicebroker.datalifecycle.repo.BrokerActionRepository;
import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException;
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException;
import org.cloudfoundry.community.servicebroker.model.CreateServiceInstanceBindingRequest;
import org.cloudfoundry.community.servicebroker.model.DeleteServiceInstanceBindingRequest;
import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding;
import org.cloudfoundry.community.servicebroker.service.ServiceInstanceBindingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
package org.cloudfoundry.community.servicebroker.datalifecycle.service;




@Service
public class LCServiceInstanceBindingService implements
		ServiceInstanceBindingService {

	private CopyProvider provider;

	private Logger logger = Logger
			.getLogger(LCServiceInstanceBindingService.class);

	private LCServiceInstanceBindingManager bindings;

	private LCServiceInstanceService instanceService;

// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/dto/InstancePair.java
// public class InstancePair {
// 
// 	private String sourceInstance;
// 	private String copyInstance;
// 
// 	public InstancePair(String sourceInstance, String copyInstance) {
// 		this.sourceInstance = sourceInstance;
// 		this.copyInstance = copyInstance;
// 	}
// 
// 	public String getSource() {
// 		return sourceInstance;
// 	}
// 
// 	public String getCopy() {
// 		return copyInstance;
// 	}
// 
// 	@Override
// 	public boolean equals(Object lhs) {
// 		return lhs instanceof InstancePair && this.hashCode() == lhs.hashCode();
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		return sourceInstance.hashCode() + copyInstance.hashCode();
// 	}
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/model/BrokerAction.java
// @Entity
// public class BrokerAction {
// 
// 	@Id
// 	private String id;
// 
// 	private String actor;
// 
// 	private BrokerActionState state;
// 
// 	private String action;
// 
// 	public BrokerAction() {
// 	}
// 
// 	public BrokerAction(String id, BrokerActionState state, String action) {
// 		this.setId(id);
// 		this.actor = id;
// 		this.state = state;
// 		this.action = action;
// 	}
// 
// 	public String getActor() {
// 		return actor;
// 	}
// 
// 	public void setActor(String actor) {
// 		this.actor = actor;
// 	}
// 
// 	public BrokerActionState getState() {
// 		return state;
// 	}
// 
// 	public void setState(BrokerActionState state) {
// 		this.state = state;
// 	}
// 
// 	public String getAction() {
// 		return action;
// 	}
// 
// 	public void setAction(String action) {
// 		this.action = action;
// 	}
// 
// 	public String getId() {
// 		return id;
// 	}
// 
// 	private void setId(String id) {
// 		this.id = id;
// 	}
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/model/BrokerActionState.java
// public enum BrokerActionState {
// 	FAILED, COMPLETE, IN_PROGRESS
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/provider/CopyProvider.java
// public interface CopyProvider {
// 
// 	/**
// 	 * Create a copy of the source instance. The implementer should inject that
// 	 * through an environment variable or other means. Upon the copy will be
// 	 * launched and accessible to clients.
// 	 * 
// 	 * @param instanceId
// 	 *            to create a copy of
// 	 * @return the id of the new copy.
// 	 * @throws ServiceBrokerException
// 	 *             on error
// 	 */
// 	String createCopy(String instanceId)
// 			throws ServiceBrokerException;
// 
// 	/**
// 	 * Remove a copy from the iaas. The expectation is that all artifacts
// 	 * associated with the copy (snapshots, ami's etc) are cleaned up
// 	 * 
// 	 * @param instance
// 	 *            to delete
// 	 * @throws ServiceBrokerException
// 	 *             on error
// 	 */
// 	void deleteCopy(final String instance)
// 			throws ServiceBrokerException;
// 
// 	/**
// 	 * Return the creds hash associated with service brokers. Should contain a
// 	 * URI, username, password or whatever makes sense for your service. Will be
// 	 * injected into your app.
// 	 */
// 	Map<String, Object> getCreds(final String instance)
// 			throws ServiceBrokerException;
// }
// 
// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/repo/BrokerActionRepository.java
// @RepositoryRestResource(collectionResourceRel = "actions", path = "actions")
// public interface BrokerActionRepository extends
// 		PagingAndSortingRepository<BrokerAction, String> {
// 
// 	List<BrokerAction> findByState(@Param("state") BrokerActionState state);
// }


// Path: src/main/java/org/cloudfoundry/community/servicebroker/datalifecycle/service/LCServiceInstanceBindingService.java
import static org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerActionState.COMPLETE;
import static org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerActionState.FAILED;
import static org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerActionState.IN_PROGRESS;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.log4j.Logger;
import org.cloudfoundry.community.servicebroker.datalifecycle.dto.InstancePair;
import org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerAction;
import org.cloudfoundry.community.servicebroker.datalifecycle.model.BrokerActionState;
import org.cloudfoundry.community.servicebroker.datalifecycle.provider.CopyProvider;
import org.cloudfoundry.community.servicebroker.datalifecycle.repo.BrokerActionRepository;
import org.cloudfoundry.community.servicebroker.exception.ServiceBrokerException;
import org.cloudfoundry.community.servicebroker.exception.ServiceInstanceBindingExistsException;
import org.cloudfoundry.community.servicebroker.model.CreateServiceInstanceBindingRequest;
import org.cloudfoundry.community.servicebroker.model.DeleteServiceInstanceBindingRequest;
import org.cloudfoundry.community.servicebroker.model.ServiceInstanceBinding;
import org.cloudfoundry.community.servicebroker.service.ServiceInstanceBindingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

package org.cloudfoundry.community.servicebroker.datalifecycle.service;




@Service
public class LCServiceInstanceBindingService implements
		ServiceInstanceBindingService {

	private CopyProvider provider;

	private Logger logger = Logger
			.getLogger(LCServiceInstanceBindingService.class);

	private LCServiceInstanceBindingManager bindings;

	private LCServiceInstanceService instanceService;

	private BrokerActionRepository brokerRepo;