package test; import com.perforce.p4java.client.IClient; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.exception.P4JavaException; import com.perforce.p4java.option.UsageOptions; import com.perforce.p4java.server.IOptionsServer; import com.perforce.p4java.server.ServerFactory; import com.perforce.p4java.server.callback.ILogCallback; import java.util.Properties; /** * * * Do Stuff * * @author jbrown */ public class ConnectFactory { String uri; String clientName; String userName; String fileSpec; public static boolean LOGGING; public static IOptionsServer getServer(String uri, String userName, String password, String clientName) throws Exception { IOptionsServer server = null; UsageOptions uOpts = new UsageOptions(null); uOpts.setProgramName("SyncTest"); Properties props = new Properties(); props.putAll(System.getProperties()); // Logging? if (Boolean.parseBoolean(props.getProperty("log", "false"))) { com.perforce.p4java.Log.setLogCallback(new LogCallBack()); LOGGING = true; } else { LOGGING = false; } System.out.println("Connecting to " + uri); server = ServerFactory.getOptionsServer(uri, props, uOpts); server.setUserName(userName); server.connect(); if (password != null && password.length() > 0) { server.login(password); System.out.println("Login successful for user '" + server.getUserName() + "'."); } if (clientName != null) { IClient client = server.getClient(clientName); if (client == null) { throw new P4JavaException("Client " + clientName + " not found."); } server.setCurrentClient(client); } return server; } /** * Prints contents of List<IFileSpec> * * @param msg Title for list output * @param specs */ public static void dumpSpecs(String msg, java.util.List<IFileSpec> specs) { System.out.println("\n" + msg + " - (size=" + specs.size() + ")"); for (IFileSpec spec : specs) { System.out.println(" depot: " + spec.getDepotPath()); System.out.println(" client: " + spec.getClientPathString()); System.out.println(" status: " + spec.getStatusMessage()); System.out.println(" opstatus: " + spec.getOpStatus()); System.out.println(" action: " + spec.getAction()); System.out.println(" change : " + spec.getChangelistId()); System.out.println(" workRev : " + spec.getWorkRev()); System.out.println(""); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 28709 | Joel Brown |
Allow setting character encoding (charset) with syncs with the Java System Property -Dcharset=<value> |
||
#2 | 26536 | Joel Brown | Add additional logging | ||
#1 | 25636 | Joel Brown | Simple P4Java methods to sync and reconcile. |