Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Jury2013-02-28 16:16:22 -0500
committerRoberto E. Escobar2013-02-28 16:16:22 -0500
commit5508b58070bd2ed782e268b188fc1b63bb1a68a0 (patch)
treeb764d03f4b2a60a18d6a0f0074117d9d09f45457 /plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse
parent1d83c90b499743a92534f55fb88bca59ecad18e0 (diff)
downloadorg.eclipse.osee-5508b58070bd2ed782e268b188fc1b63bb1a68a0.tar.gz
org.eclipse.osee-5508b58070bd2ed782e268b188fc1b63bb1a68a0.tar.xz
org.eclipse.osee-5508b58070bd2ed782e268b188fc1b63bb1a68a0.zip
feature[ats_03ZG1]: Update OTE SVN connector for svnkit 1.7
Diffstat (limited to 'plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse')
-rw-r--r--plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/ScriptToProject.java74
-rw-r--r--plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnFileVersion.java5
-rw-r--r--plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnVersionProvider.java65
3 files changed, 116 insertions, 28 deletions
diff --git a/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/ScriptToProject.java b/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/ScriptToProject.java
new file mode 100644
index 0000000000..8fc58cb58d
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/ScriptToProject.java
@@ -0,0 +1,74 @@
+/*
+ * Created on Feb 27, 2013
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.version.svn;
+
+import java.io.File;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.team.svn.core.utility.SVNUtility;
+
+public class ScriptToProject {
+
+ private final Map<String, Set<String>> projectsScriptsMap = new HashMap<String, Set<String>>();
+ private final Map<String, File> scriptNameToScriptFileMap = new HashMap<String, File>();
+ private final IProject[] workspaceProjects;
+
+ public ScriptToProject(IProject[] workspaceProjects) {
+ this.workspaceProjects = workspaceProjects;
+ }
+
+ public void add(File scriptFile) {
+ String scriptName = scriptFile.getName();
+ IProject scriptProject = null;
+
+ for(IProject project:workspaceProjects){
+ String projectName = project.getName();
+ if(scriptFile.toString().contains(projectName)){
+ scriptProject = project;
+ }
+ }
+
+ URI scriptProjectLocationUri = scriptProject.getLocationURI();
+ File scriptProjectFile = new File(scriptProjectLocationUri);
+
+ if (isSvn(scriptProjectFile)) {
+ String scriptProjectLocation = scriptProjectFile.getAbsolutePath();
+ addScriptListValue(scriptProjectLocation, scriptName);
+ scriptNameToScriptFileMap.put(scriptName, scriptFile);
+ }
+ }
+
+ public Set<String> getProjectsSet() {
+ return projectsScriptsMap.keySet();
+ }
+
+ public void addScriptListValue(String key, String value) {
+ Set<String> values = projectsScriptsMap.get(key);
+ if (values == null) {
+ values = new HashSet<String>();
+ projectsScriptsMap.put(key, values);
+ }
+ values.add(value);
+ }
+
+ public File getScriptFileMatch(String project, String itemToMatch) {
+ Set<String> scriptsForProject = projectsScriptsMap.get(project);
+ if(scriptsForProject.contains(itemToMatch)){
+ return scriptNameToScriptFileMap.get(itemToMatch);
+ } else {
+ return null;
+ }
+ }
+
+ protected boolean isSvn(File file) {
+ File svn = new File(file, SVNUtility.getSVNFolderName());
+ return svn.exists();
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnFileVersion.java b/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnFileVersion.java
index 99d42d6070..81f3e75e7e 100644
--- a/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnFileVersion.java
+++ b/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnFileVersion.java
@@ -13,7 +13,6 @@ package org.eclipse.osee.ote.version.svn;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
-
import org.eclipse.osee.ote.version.FileVersion;
import org.eclipse.team.svn.core.connector.SVNEntryInfo;
@@ -29,8 +28,8 @@ public class SvnFileVersion implements FileVersion {
}
@Override
- public String getVersion() {
- return Long.toString(entry.revision);
+ public String getLastChangedRevision() {
+ return Long.toString(entry.lastChangedRevision);
}
@Override
diff --git a/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnVersionProvider.java b/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnVersionProvider.java
index e83231cdf0..1ba11c734c 100644
--- a/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnVersionProvider.java
+++ b/plugins/org.eclipse.osee.ote.version.svn/src/org/eclipse/osee/ote/version/svn/SvnVersionProvider.java
@@ -13,39 +13,54 @@ package org.eclipse.osee.ote.version.svn;
import java.io.File;
import java.util.List;
import java.util.Map;
-
+import java.util.logging.Level;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.ote.version.FileVersion;
import org.eclipse.osee.ote.version.FileVersionInformationProvider;
+import org.eclipse.team.svn.core.connector.ISVNConnector;
+import org.eclipse.team.svn.core.connector.ISVNConnector.Depth;
import org.eclipse.team.svn.core.connector.SVNEntryInfo;
+import org.eclipse.team.svn.core.connector.SVNEntryRevisionReference;
+import org.eclipse.team.svn.core.extension.CoreExtensionsManager;
+import org.eclipse.team.svn.core.operation.SVNNullProgressMonitor;
import org.eclipse.team.svn.core.utility.SVNUtility;
public class SvnVersionProvider implements FileVersionInformationProvider {
- @Override
- public FileVersion getFileVersion(File file) {
- if (isSvn(file)) {
- SVNEntryInfo entry = SVNUtility.getSVNInfo(file);
- if(entry != null){
- return new SvnFileVersion(entry);
- }
- }
- return null;
- }
-
- protected boolean isSvn(File file) {
- File svn = new File(file.getParentFile(), SVNUtility.getSVNFolderName());
- return svn.exists();
- }
+ protected boolean isSvn(File file) {
+ File svn = new File(file, SVNUtility.getSVNFolderName());
+ return svn.exists();
+ }
+
+ @Override
+ public void getFileVersions(List<File> scriptFiles, Map<File, FileVersion> versions) {
- @Override
- public void getFileVersions(List<File> files, Map<File, FileVersion> versions) {
- for(File file:files){
- FileVersion version = getFileVersion(file);
- if(version != null){
- versions.put(file, version);
- }
- }
- }
+ IProject[] workspaceProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ ScriptToProject collection = new ScriptToProject(workspaceProjects);
+
+ for(File scriptFile:scriptFiles){
+ collection.add(scriptFile);
+ }
+ ISVNConnector proxy = CoreExtensionsManager.instance().getSVNConnectorFactory().newInstance();
+ for (String projectName : collection.getProjectsSet()) {
+ try {
+ SVNEntryInfo []st = SVNUtility.info(proxy, new SVNEntryRevisionReference(projectName), Depth.INFINITY, new SVNNullProgressMonitor());
+ for (SVNEntryInfo entry : st) {
+ String svnEntryPath = entry.path;
+ String itemToMatch = svnEntryPath.substring(svnEntryPath.lastIndexOf("/") + 1);
+ File scriptFile = collection.getScriptFileMatch(projectName, itemToMatch);
+ if(scriptFile != null){
+ versions.put(scriptFile, new SvnFileVersion(entry));
+ }
+ }
+ }
+ catch (Exception ex) {
+ OseeLog.logf(getClass(), Level.SEVERE, "SVNConnectorException while retrieving script SVN info ", ex);
+ }
+ }
+ }
}

Back to the top