package com.perforce.p4java; import java.net.URISyntaxException; import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.perforce.p4java.exception.ConfigException; import com.perforce.p4java.exception.ConnectionException; import com.perforce.p4java.exception.NoSuchObjectException; import com.perforce.p4java.exception.ResourceException; import com.perforce.p4java.impl.mapbased.rpc.RpcPropertyDefs; import com.perforce.p4java.server.IOptionsServer; import com.perforce.p4java.server.ServerFactory; public class RshConnection { private static Logger logger = LoggerFactory.getLogger(RshConnection.class); public static IOptionsServer getRshConnection(String p4root) { // Get a server connection String p4d = getP4D(); String rsh = "rsh:" + p4d + " -r " + p4root + " -i"; String p4javaUri = getP4JavaUri(rsh); return getIOptionsServer(p4javaUri); } private static IOptionsServer getIOptionsServer(String p4javaUri) { IOptionsServer newIServer = null; Properties props = System.getProperties(); // Identify ourselves in server log files. props.put(PropertyDefs.PROG_NAME_KEY, "jrsh"); props.put(PropertyDefs.PROG_VERSION_KEY, "1.0"); props.put(RpcPropertyDefs.RPC_SOCKET_POOL_SIZE_NICK, "1"); props.put(RpcPropertyDefs.RPC_RELAX_CMD_NAME_CHECKS_NICK, "true"); props.put(RpcPropertyDefs.RPC_SOCKET_SO_TIMEOUT_NICK, "0"); try { newIServer = ServerFactory.getOptionsServer(p4javaUri, props, null); } catch (ConnectionException | NoSuchObjectException | ConfigException | ResourceException | URISyntaxException e) { StringBuffer sb = new StringBuffer(); sb.append("Unable to get servert: "); sb.append(p4javaUri); logger.error(sb.toString()); } return newIServer; } private static String getP4D() { String p4dPath = "src/test/resources/"; String p4dVersion = "r15.1"; String os = System.getProperty("os.name").toLowerCase(); String p4d = p4dPath + p4dVersion + "/"; if (os.contains("win")) { p4d += "bin.ntx64/p4d.exe"; } if (os.contains("mac")) { p4d += "bin.darwin90x86_64/p4d"; } if (os.contains("nix") || os.contains("nux")) { p4d += "bin.linux26x86_64/p4d"; } return p4d; } private static String getP4JavaUri(String port) { if (port.startsWith("ssl:")) { String trim = port.substring(4, port.length()); return "p4javassl://" + trim; } if (port.startsWith("rsh:")) { String trim = port.substring(4, port.length()); return "p4jrsh://" + trim + " --java"; } return "p4java://" + port; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 15416 | Robert Cowham | Project now basically works with rsh. | ||
#1 | 15413 | Robert Cowham |
Populate -o //guest/paul_allen/dev/rsh/... //guest/robert_cowham/perforce/dev/java-test/.... |
||
//guest/paul_allen/dev/rsh/src/main/java/com/perforce/p4java/RshConnection.java | |||||
#2 | 14167 | Paul Allen | Tidy up. | ||
#1 | 14166 | Paul Allen | Initial Import of RSH p4java test |