package com.perforce.polarion.repository.provider; import java.util.Properties; import com.perforce.p4java.PropertyDefs; import com.perforce.p4java.client.IClient; import com.perforce.p4java.exception.P4JavaException; import com.perforce.p4java.impl.mapbased.rpc.RpcPropertyDefs; import com.perforce.p4java.server.IOptionsServer; import com.perforce.p4java.server.ServerFactory; import com.polarion.platform.service.repository.RepositoryException; public class ConnectionFactory { public static IOptionsServer getConnection(P4RepositoryConfiguration config) { IOptionsServer iserver = null; Properties props = System.getProperties(); props.put(PropertyDefs.PROG_NAME_KEY, "P4-Polarion"); props.put(PropertyDefs.PROG_VERSION_KEY, "Undefined"); props.put(RpcPropertyDefs.RPC_SOCKET_SO_TIMEOUT_NICK, "0"); // build the p4java URI String serverUri; String p4port = config.getP4Port(); if (p4port.startsWith("ssl:")) { p4port = p4port.substring("ssl:".length()); serverUri = "p4javassl://" + p4port; } else { serverUri = "p4java://" + p4port; } try { // open a Perforce connection iserver = ServerFactory.getOptionsServer(serverUri, props); iserver.connect(); // set unicode if required String charset = config.getP4Charset(); if (charset != null && charset.length() > 0) { iserver.setCharsetName(charset); } // set user name iserver.setUserName(config.getP4User()); // authenticate with Perforce login(iserver, config); // Set active client workspace IClient iclient = iserver.getClient(config.getP4Client()); iserver.setCurrentClient(iclient); } catch (Exception e) { throw new RepositoryException(e); } return iserver; } private static void login(IOptionsServer iserver, P4RepositoryConfiguration config) throws P4JavaException { String status = iserver.getLoginStatus(); if (status.contains("not necessary")) { return; } String pass = config.getP4Password(); if (pass != null && pass.length() > 0) { if (config.isP4Ticket()) { // login if ticket is provided iserver.setAuthTicket(pass); } else { // login if password is provided iserver.login(pass); } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 16861 | Paul Allen |
Added job query code for scanner. Use Perforce counter to track last scan. JobSpec MUST include fields 'ModifiedBy' and 'ModifiedDate'. - updated p4java 15.2 |
||
#2 | 16844 | Paul Allen |
Reduce polling impact when looking for new changes. Faster responce on PersistenceListener. - Added logging for Perforce commands. |
||
#1 | 15897 | Matt Attaway | Pull changes after the rename in from Paul's dev branch so code will go back smoothly | ||
//guest/paul_allen/dev/p4-polarion/main/src/com/perforce/polarion/repository/provider/ConnectionFactory.java | |||||
#4 | 10073 | Paul Allen | Use boolean flag to indicate password or ticket in Perforce Connection dialog. | ||
#3 | 9999 | Paul Allen | Modified String isEmpty() check to use "length() > 0" to support Java 1.5 for build. | ||
#2 | 9998 | Paul Allen | Added Unicode server support and ExternalRepositoryCredentials annotation. | ||
#1 | 9756 | Paul Allen |
Changed Polarion name space to Perforce: com.perforce.polarion.repository.provider |
||
//guest/paul_allen/dev/p4-polarion/main/src/com/polarion/platform/repository/external/internal/p4/ConnectionFactory.java | |||||
#2 | 9746 | Paul Allen | Empty string detection when setting passwor or ticket. | ||
#1 | 9723 | Paul Allen | Initial import of P4 Polarion plugin code |