001package co.codewizards.cloudstore.core.repo.transport; 002 003import static co.codewizards.cloudstore.core.util.Util.*; 004 005import java.net.URL; 006import java.util.UUID; 007 008import co.codewizards.cloudstore.core.util.AssertUtil; 009 010public abstract class AbstractRepoTransportFactory implements RepoTransportFactory { 011 012 @Override 013 public int getPriority() { 014 return 0; 015 } 016 017 @Override 018 public RepoTransport createRepoTransport(URL remoteRoot, UUID clientRepositoryId) { 019 AssertUtil.assertNotNull(remoteRoot, "remoteRoot"); 020 // clientRepositoryId may be null! 021 RepoTransport repoTransport = _createRepoTransport(); 022 if (repoTransport == null) 023 throw new IllegalStateException(String.format("Implementation error in class %s: _createRepoTransport(...) returned null!", this.getClass().getName())); 024 025 repoTransport.setRepoTransportFactory(this); 026 repoTransport.setRemoteRoot(remoteRoot); 027 repoTransport.setClientRepositoryId(clientRepositoryId); 028 return repoTransport; 029 } 030 031 protected abstract RepoTransport _createRepoTransport(); 032}