Author: tchemit Date: 2008-05-13 14:14:01 +0000 (Tue, 13 May 2008) New Revision: 649 Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSConnexion.java trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSFactory.java trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java Log: refactor config + introduction factory de config Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSConnexion.java =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSConnexion.java 2008-05-13 14:11:42 UTC (rev 648) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSConnexion.java 2008-05-13 14:14:01 UTC (rev 649) @@ -61,7 +61,7 @@ * @return the mode of this connexion * @throws IllegalStateException if {@link #init(VCSConnexionConfig)} was not invoked before. */ - VCSConnexionMode getMode() throws IllegalStateException; + VCSConnexionMode getConnexionMode() throws IllegalStateException; /** * @return the config of the connexion Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSFactory.java =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-05-13 14:11:42 UTC (rev 648) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSFactory.java 2008-05-13 14:14:01 UTC (rev 649) @@ -80,7 +80,7 @@ VCSFactory factory = getInstance(); // obtain matching provider - VCSProvider<?, ?> provider = factory.getProvider(config.getType().toUpperCase()); + VCSProvider<?, ?> provider = factory.getProvider(config.getRootConfig().getType().toUpperCase()); // delegate instanciation of connexion to provider VCSConnexion connexion = provider.newConnection(config); Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-05-13 14:11:42 UTC (rev 648) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/AbstractVCSConnexion.java 2008-05-13 14:14:01 UTC (rev 649) @@ -43,8 +43,11 @@ static protected final Log log = LogFactory.getLog(AbstractVCSConnexion.class); protected File localRoot; + protected URI remoteRoot; + protected VCSConnectionState state; + protected VCSConnexionConfig config; protected H handler; @@ -65,19 +68,22 @@ public File getWorkingCopy() throws IllegalStateException { checkInit(); if (localRoot == null) { - localRoot = getConfig().getLocalDatabasePath(); + localRoot = getConfig().getWorkingCopyFile(); } return localRoot; } public URI getRemoteURI() throws IllegalStateException { checkInit(); + if (remoteRoot == null) { + remoteRoot = getURIResolver().resolv(config); + } return remoteRoot; } - public VCSConnexionMode getMode() throws IllegalStateException { + public VCSConnexionMode getConnexionMode() throws IllegalStateException { checkInit(); - return getConfig().getMode(); + return getConfig().getConnexionMode(); } public VCSConnexionConfig getConfig() throws IllegalStateException { @@ -108,7 +114,7 @@ } public boolean hasWriteAccess() { - return !getConfig().isUseSshConnexion() && getMode() != VCSConnexionMode.ANONYMOUS; + return getConnexionMode() != VCSConnexionMode.ANONYMOUS; } public void addVCSHandlerEventListener(VCSConnexionEventListener l) { Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java 2008-05-13 14:11:42 UTC (rev 648) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/AbstractVCSHandler.java 2008-05-13 14:14:01 UTC (rev 649) @@ -107,9 +107,9 @@ } public void deleteWorkingCopy() { - if (connexion.getConfig().getLocalDatabasePath().exists()) { - FileUtil.deleteRecursively(connexion.getConfig().getLocalDatabasePath()); - connexion.getConfig().getLocalDatabasePath().delete(); + if (connexion.getConfig().getWorkingCopyFile().exists()) { + FileUtil.deleteRecursively(connexion.getConfig().getWorkingCopyFile()); + connexion.getConfig().getWorkingCopyFile().delete(); } } @@ -192,7 +192,7 @@ public boolean isFileInWorkingCopy(File file, boolean underVCS) { if (file == null) throw new RuntimeException(AbstractVCSHandler.class.getName() + "#isFileInWorkingCopy can not be invoked with some null parameter but was. [" + file + "," + this + "]"); - String rootPath = connexion.getConfig().getLocalDatabasePath().getAbsolutePath(); + String rootPath = connexion.getConfig().getWorkingCopyFile().getAbsolutePath(); String localPath = file.getAbsolutePath(); if (localPath.startsWith(rootPath) && !underVCS) { return true; @@ -211,13 +211,13 @@ public void assertFileInWC(File file) { if (!isFileInWorkingCopy(file, false)) - throw new VCSRuntimeException("the file [" + file + "] is not in the working copy [" + connexion.getConfig().getLocalDatabasePath() + "]"); + throw new VCSRuntimeException("the file [" + file + "] is not in the working copy [" + connexion.getConfig().getWorkingCopyFile() + "]"); } public String getRemoteRelativePath(File f) { if (!isFileInWorkingCopy(f, false)) return null; //System.out.println("file on vcs working copy : "+f); - String rootPath = connexion.getConfig().getLocalDatabasePath().getAbsolutePath(); + String rootPath = connexion.getConfig().getWorkingCopyFile().getAbsolutePath(); String localPath = f.getAbsolutePath(); if (!localPath.startsWith(rootPath)) return null; localPath = localPath.substring(rootPath.length() + 1); @@ -226,7 +226,7 @@ public String getLocalRelativePath(String remoteRelativePath) { String localPath = convertToLocalName(remoteRelativePath); - final File file = new File(connexion.getConfig().getLocalDatabasePath(), localPath); + final File file = new File(connexion.getConfig().getWorkingCopyFile(), localPath); if (!isFileInWorkingCopy(file, false)) return null; return localPath; } Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java 2008-05-13 14:11:42 UTC (rev 648) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/VCSConnexionConfigImpl.java 2008-05-13 14:14:01 UTC (rev 649) @@ -15,13 +15,17 @@ package org.codelutin.vcs.util; import org.codelutin.vcs.VCSConnexionConfig; +import org.codelutin.vcs.type.VCSConnexionMode; import org.codelutin.vcs.type.VCSTypeRepo; -import org.codelutin.vcs.type.VCSConnexionMode; import java.io.File; -/** @author chemit */ -public class VCSConnexionConfigImpl implements VCSConnexionConfig { +/** + * POJO implementation of {@link VCSConnexionConfig} + * + * @author chemit + */ +public class VCSConnexionConfigImpl { protected String type; protected boolean useSshConnexion; @@ -65,8 +69,8 @@ } public String getPassphrase() { - if (passPhrase==null) { - passPhrase=""; + if (passPhrase == null) { + passPhrase = ""; } return passPhrase; } @@ -136,6 +140,6 @@ } public void setConnexionMode(VCSConnexionMode mode) { - this.mode=mode; + this.mode = mode; } }