-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove existing passphrase implementation + Minor refactor
- Loading branch information
Showing
1 changed file
with
16 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
import java.util.Map; | ||
|
||
/** | ||
* Object to add a database connection to a PCTRun task | ||
* Represent a database connection in PCT tasks | ||
* | ||
* @author <a href="mailto:[email protected]">Gilles QUERRET </a> | ||
*/ | ||
|
@@ -49,8 +49,7 @@ public class PCTConnection extends DataType { | |
private File paramFile = null; | ||
private Boolean singleUser = null; | ||
private Boolean readOnly = null; | ||
private String passphrase = null; | ||
private Map<String, PCTAlias> aliases = null; | ||
private Map<String, PCTAlias> aliases = new HashMap<>(); | ||
private List<PCTRunOption> options = null; | ||
|
||
/** | ||
|
@@ -174,13 +173,6 @@ public void setReadOnly(boolean readOnly) { | |
this.readOnly = readOnly; | ||
} | ||
|
||
/** | ||
* If true, append -Passphrase to connection string | ||
*/ | ||
public void setPassphrase(String passphrase) { | ||
this.passphrase = passphrase; | ||
} | ||
|
||
/** | ||
* If true, opens the database in single-user mode | ||
* | ||
|
@@ -198,7 +190,7 @@ public void addOption(PCTRunOption option) { | |
} | ||
|
||
/** | ||
* Adds an alias to the current DB connection. | ||
* Add an alias to the current DB connection. | ||
* | ||
* The previous method's name (addPCTAlias) was changed when I switched from Vector to HashMap | ||
* as a container for PCTAlias. When using addPCTAlias, you enter the method with a newly | ||
|
@@ -212,10 +204,6 @@ public void addConfiguredPCTAlias(PCTAlias alias) { | |
} | ||
|
||
public void addConfiguredAlias(PCTAlias alias) { | ||
if (this.aliases == null) { | ||
aliases = new HashMap<>(); | ||
} | ||
|
||
if (aliases.put(alias.getName(), alias) != null) | ||
throw new BuildException(MessageFormat.format( | ||
Messages.getString("PCTConnection.0"), alias.getName())); //$NON-NLS-1$ | ||
|
@@ -226,7 +214,7 @@ protected PCTConnection getRef() { | |
} | ||
|
||
/** | ||
* Checks if aliases defined | ||
* Check if aliases defined | ||
* | ||
* @return True if aliases defined for this database connection | ||
*/ | ||
|
@@ -236,7 +224,7 @@ public boolean hasAliases() { | |
} | ||
|
||
/** | ||
* Checks if an alias is defined | ||
* Check if an alias is defined | ||
* | ||
* @param aliasName String | ||
* @return True if alias defined for this database connection | ||
|
@@ -247,7 +235,7 @@ public boolean hasNamedAlias(String aliasName) { | |
} | ||
|
||
/** | ||
* Returns an ordered list of connection parameters | ||
* Return a list of connection parameters | ||
* | ||
* @return List of String | ||
* @throws BuildException Something went wrong (dbName or paramFile not defined) | ||
|
@@ -298,7 +286,6 @@ public List<String> getConnectParametersList() { | |
list.remove("-1"); | ||
} | ||
} | ||
|
||
|
||
if (cacheFile != null) { | ||
list.add("-cache"); //$NON-NLS-1$ | ||
|
@@ -320,21 +307,14 @@ public List<String> getConnectParametersList() { | |
list.add(hostName); | ||
} | ||
|
||
if (readOnly != null ) { | ||
if (readOnly != null) { | ||
if (readOnly) { | ||
list.add("-RO"); | ||
} | ||
else | ||
{ | ||
} else { | ||
list.remove("-RO"); | ||
} | ||
} | ||
|
||
if (passphrase != null) { | ||
list.add("-KeyStorePassPhrase"); | ||
list.add(passphrase); | ||
} | ||
|
||
if ((userName != null) && (userName.trim().length() > 0)) { | ||
list.add("-U"); //$NON-NLS-1$ | ||
list.add(userName); | ||
|
@@ -359,7 +339,7 @@ public List<String> getConnectParametersList() { | |
|
||
} | ||
/** | ||
* Returns a string which could be used by a CONNECT statement or directly in a _progres or | ||
* Return a string which could be used by a CONNECT statement or directly in a _progres or | ||
* prowin32 command line | ||
* | ||
* @return Connection string | ||
|
@@ -375,9 +355,9 @@ public String createConnectString() { | |
} | ||
|
||
/** | ||
* Returns a string which could be used to connect a database from a background worker Pipe | ||
* separated list, first entry is connection string, followed by aliases. Aliases are comma | ||
* separated list, first entry is alias name, second is 1 if NO-ERROR, 0 w/o no-error | ||
* Return a string which could be used to connect a database from a background worker. Pipe | ||
* separated list, first entry is connection string, followed by aliases. Aliases are | ||
* comma-separated lists, first entry is alias name, second is 1 if NO-ERROR, 0 w/o no-error | ||
* | ||
* @return Connection string | ||
*/ | ||
|
@@ -406,16 +386,14 @@ public void createArguments(ExecTask task) { | |
} | ||
|
||
/** | ||
* Returns defined aliases for a database connection | ||
* Return defined aliases for a database connection | ||
* | ||
* @return Collection | ||
*/ | ||
public Collection<PCTAlias> getAliases() { | ||
Map<String, PCTAlias> map = new HashMap<>(); | ||
if (aliases != null) { | ||
for (String str : aliases.keySet()) { | ||
map.put(str, aliases.get(str)); | ||
} | ||
for (Map.Entry<String, PCTAlias> entry : aliases.entrySet()) { | ||
map.put(entry.getKey(), entry.getValue()); | ||
} | ||
if (isReference()) { | ||
for (PCTAlias alias : getRef().getAliases()) { | ||
|
@@ -427,7 +405,7 @@ public Collection<PCTAlias> getAliases() { | |
} | ||
|
||
/** | ||
* Returns database name | ||
* Return database name | ||
* | ||
* @return String | ||
*/ | ||
|