/** * Try to establish an actual RPC connection to the target Perforce server. * Most of the actual setup work is done in the RpcConnection and * RpcPacketDispatcher constructors, but associated gubbins such as auto * login, etc., are done in the superclass. */ @Override public void connect() throws ConnectionException, AccessException, RequestException, ConfigException { connectionStart = System.currentTimeMillis(); super.connect(); }
/** * @see com.perforce.p4java.client.IClient#integrateFiles(com.perforce.p4java.core.file.IFileSpec, com.perforce.p4java.core.file.IFileSpec, java.lang.String, com.perforce.p4java.option.client.IntegrateFilesOptions) */ @Override public List<IFileSpec> integrateFiles(IFileSpec fromFile, IFileSpec toFile, String branchSpec, IntegrateFilesOptions opts) throws P4JavaException { // Set the server's current client to this client IClient currentClient = this.serverImpl.getCurrentClient(); this.serverImpl.setCurrentClient(this); List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList( CmdSpec.INTEG, Parameters.processParameters( opts, fromFile, toFile, branchSpec, this.serverImpl), null); // Set the server's current client back to the previous one this.serverImpl.setCurrentClient(currentClient); return getIntegrationFilesFromReturn(resultMaps); }
@Override public void setUserName(String userName) { this.userName = userName; setAuthTicket(getAuthTicket(userName)); }
private List<IFileSpec> haveList(List<IFileSpec> fileSpecs, String[] filter) throws ConnectionException, AccessException { List<IFileSpec> haveList = new ArrayList<IFileSpec>(); if ((this.serverImpl.getCurrentClient() == null) || !this.serverImpl.getCurrentClient().getName().equalsIgnoreCase(this.getName())) { return haveList; } List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList( CmdSpec.HAVE, Server.getPreferredPathArray(filter, fileSpecs), null); if (resultMaps != null) { for (Map<String, Object> result : resultMaps) { haveList.add(handleFileReturn(result, serverImpl)); } } return haveList; }
List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList(CmdSpec.CHANGE, new String[]{"-i"}, InputMapper.map(newChangelist)); int id = IChangelist.UNKNOWN; for (Map<String, Object> map : resultMaps) { if (!this.serverImpl.handleErrorStr(map)) { if (map.containsKey("change")) { String infoStr = this.serverImpl.getInfoStr(map); return this.serverImpl.getChangelist(id);
/** * @see com.perforce.p4java.client.IClient#lockFiles(java.util.List, com.perforce.p4java.option.client.LockFilesOptions) */ @Override public List<IFileSpec> lockFiles(List<IFileSpec> fileSpecs, LockFilesOptions opts) throws P4JavaException { List<IFileSpec> lockedList = new ArrayList<IFileSpec>(); List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList( CmdSpec.LOCK, Parameters.processParameters(opts, fileSpecs, serverImpl), null); if (resultMaps != null) { for (Map<String, Object> result : resultMaps) { lockedList.add(handleFileReturn(result, serverImpl)); } } return lockedList; }
int serverVersion = getServerVersion(); throwConnectionExceptionIfConditionFails(serverVersion != UNKNOWN_SERVER_VERSION, "Unable to determine Perforce server version for connection; " login(password); client = getClient(clientName); setCharsetName(p4Charset);
File tmpDir = new File(serverImpl.getProperties().getProperty( PropertyDefs.P4JAVA_TMP_DIR_KEY, System.getProperty("java.io.tmpdir"))); if (this.serverImpl.getServerVersionNumber() >= MINIMUM_ACTION_RESOLVE_SERVER_VERSION) { if (startFromRev != -1 || endFromRev != -1) { args.add("-Ac"); List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList(CmdSpec.RESOLVE, args.toArray(new String[0]), resolveMap);
/** * @see com.perforce.p4java.client.IClient#sync(java.util.List, com.perforce.p4java.option.client.SyncOptions, com.perforce.p4java.server.callback.IStreamingCallback, int) */ @Override public void sync(List<IFileSpec> fileSpecs, SyncOptions syncOpts, IStreamingCallback callback, int key) throws P4JavaException { if ((this.serverImpl.getCurrentClient() == null) || !this.serverImpl.getCurrentClient().getName().equalsIgnoreCase(this.getName())) { throw new RequestException( "Attempted to sync a client that is not the server's current client"); } this.serverImpl.execStreamingMapCommand(CmdSpec.SYNC.toString(), Parameters.processParameters( syncOpts, fileSpecs, this.server), null, callback, key); }
/** * @see com.perforce.p4java.client.IClient#sync(java.util.List, com.perforce.p4java.option.client.SyncOptions) */ @Override public List<IFileSpec> sync(List<IFileSpec> fileSpecs, SyncOptions syncOpts) throws P4JavaException { List<IFileSpec> specList = new ArrayList<IFileSpec>(); if ((this.serverImpl.getCurrentClient() == null) || !this.serverImpl.getCurrentClient().getName().equalsIgnoreCase(this.getName())) { throw new RequestException( "Attempted to sync a client that is not the server's current client"); } List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList(CmdSpec.SYNC, Parameters.processParameters( syncOpts, fileSpecs, this.server), null); if (resultMaps != null) { for (Map<String, Object> map : resultMaps) { specList.add(handleFileReturn(map, serverImpl)); } } return specList; }
when(base.getChangelists(eq(null), any())).thenReturn(Arrays.asList( when(base.getChangelist(eq(2), any())).thenReturn(secondCl); when(base.getExtendedFiles( argThat(t -> t.size() == 1 && t.get(0) .getOriginalPathString().equals("//" + root.getClientConfig().getClientname() + "/...")),
@Override public String getAuthTicket() { return getAuthTicket(userName); }
/** * Try to cleanly disconnect from the Perforce server at the other end of * the current connection (with the emphasis on "cleanly"). This should * theoretically include sending a release2 message, but we don't always get * the chance to do that. */ @Override public void disconnect() throws ConnectionException, AccessException { super.disconnect(); if (connectionStart != 0) { Log.stats("RPC connection connected for %s msec elapsed time", (System.currentTimeMillis() - connectionStart)); } serverStats.logStats(); // Clear up all counts for this RPC server authCounter.clearCount(); }
/** * @see com.perforce.p4java.client.IClient#openedFiles(java.util.List, com.perforce.p4java.option.server.OpenedFilesOptions) */ @Override public List<IFileSpec> openedFiles(List<IFileSpec> fileSpecs, OpenedFilesOptions opts) throws P4JavaException { if (opts == null) { return this.serverImpl.getOpenedFiles(fileSpecs, new OpenedFilesOptions().setClientName(this.name)); } else { // Need to clone (not quite literally) the opts so we don't change the original: if (opts.getOptions() != null) { List<String> optsStrings = opts.getOptions(); return this.serverImpl.getOpenedFiles(fileSpecs, new OpenedFilesOptions( optsStrings.toArray(new String[optsStrings.size()]) )); } else { return this.serverImpl.getOpenedFiles(fileSpecs, opts.setAllClients(false).setClientName(this.getName())); } } }
List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList(CmdSpec.CHANGE, new String[]{"-i"}, InputMapper.map(newChangelist)); int id = IChangelist.UNKNOWN; for (Map<String, Object> map : resultMaps) { if (!this.serverImpl.handleErrorStr(map)) { if (map.containsKey("change")) { String infoStr = this.serverImpl.getInfoStr(map); return this.serverImpl.getChangelist(id);
/** * @see com.perforce.p4java.client.IClient#resolvedFiles(java.util.List, com.perforce.p4java.option.client.ResolvedFilesOptions) */ @Override public List<IFileSpec> resolvedFiles(List<IFileSpec> fileSpecs, ResolvedFilesOptions opts) throws P4JavaException { List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList( CmdSpec.RESOLVED, Parameters.processParameters(opts, fileSpecs, serverImpl), null); return getIntegrationFilesFromReturn(resultMaps); }
private List<IFileSpec> haveList(List<IFileSpec> fileSpecs, String[] filter) throws ConnectionException, AccessException { List<IFileSpec> haveList = new ArrayList<IFileSpec>(); if ((this.serverImpl.getCurrentClient() == null) || !this.serverImpl.getCurrentClient().getName().equalsIgnoreCase(this.getName())) { return haveList; } List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList( CmdSpec.HAVE, Server.getPreferredPathArray(filter, fileSpecs), null); if (resultMaps != null) { for (Map<String, Object> result : resultMaps) { haveList.add(handleFileReturn(result, serverImpl)); } } return haveList; }
int serverVersion = getServerVersion(); throwConnectionExceptionIfConditionFails(serverVersion != UNKNOWN_SERVER_VERSION, "Unable to determine Perforce server version for connection; " login(password); client = getClient(clientName); setCharsetName(p4Charset);
File tmpDir = new File(serverImpl.getProperties().getProperty( PropertyDefs.P4JAVA_TMP_DIR_KEY, System.getProperty("java.io.tmpdir"))); if (this.serverImpl.getServerVersionNumber() >= MINIMUM_ACTION_RESOLVE_SERVER_VERSION) { if (startFromRev != -1 || endFromRev != -1) { args.add("-Ac"); List<Map<String, Object>> resultMaps = this.serverImpl.execMapCmdList(CmdSpec.RESOLVE, args.toArray(new String[0]), resolveMap);
/** * @see com.perforce.p4java.client.IClient#sync(java.util.List, com.perforce.p4java.option.client.SyncOptions, com.perforce.p4java.server.callback.IStreamingCallback, int) */ @Override public void sync(List<IFileSpec> fileSpecs, SyncOptions syncOpts, IStreamingCallback callback, int key) throws P4JavaException { if ((this.serverImpl.getCurrentClient() == null) || !this.serverImpl.getCurrentClient().getName().equalsIgnoreCase(this.getName())) { throw new RequestException( "Attempted to sync a client that is not the server's current client"); } this.serverImpl.execStreamingMapCommand(CmdSpec.SYNC.toString(), Parameters.processParameters( syncOpts, fileSpecs, this.server), null, callback, key); }