Skip to content

Commit 52c86b8

Browse files
committed
2023.2 Patch 1 Code Drop
1 parent aea150e commit 52c86b8

27 files changed

+900
-83
lines changed

RELEASE.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,29 @@ Known Limitations
122122
<java-home>/lib/security/US_export_policy.jar
123123
124124
* P4Java would not support file operations on altsync enabled clients.
125-
125+
126+
127+
-------------------------------------------
128+
Updates in 2023.2 Patch 1 (2023.2/2581742) (2024/04/05)
129+
130+
#2578705 (Job #113772)
131+
Added support for "p4 renameclient" command.
132+
133+
#2578400 (Job #113890)
134+
Added support for "p4 opened -x" and "p4 opened -g" options.
135+
136+
#2551449, #2549979 (Job #118024)
137+
Added support for "p4 license -L" option.
138+
139+
#2577562 (Job #115953)
140+
Added support for "p4 sizes -c" option.
141+
142+
#2576245 (Job #115954)
143+
Added support for "p4 integrated -m" option.
144+
145+
#2558625 (Job #117352)
146+
Enhanced p4 print to return data in a byte buffer instead of creating a temp file.
147+
126148
-------------------------------------------
127149
Updates in 2023.2 (2023.2/2542382) (2024/01/16)
128150

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.perforce.p4java.core;
2+
3+
public interface IServerIPMACAddress extends IServerResource {
4+
5+
String getServerInterface();
6+
7+
String getMACAddress();
8+
9+
String getIPV4Address();
10+
11+
String getIPV6Address();
12+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.perforce.p4java.impl.generic.core;
2+
3+
import com.perforce.p4java.core.IServerIPMACAddress;
4+
import java.util.Map;
5+
6+
public class ServerIPMACAddress extends ServerResource implements IServerIPMACAddress {
7+
private String serverInterface;
8+
private String macAddress;
9+
private String ipv4Address;
10+
private String ipv6Address;
11+
12+
public ServerIPMACAddress() {}
13+
14+
public ServerIPMACAddress(Map<String, Object> map) {
15+
if(map.size() > 0 ) {
16+
this.serverInterface = String.valueOf(map.get("interface"));
17+
this.macAddress = String.valueOf(map.get("macAddress"));
18+
this.ipv4Address = String.valueOf(map.get("ipv4Address"));
19+
this.ipv6Address = String.valueOf(map.get("ipv6Address"));
20+
}
21+
}
22+
23+
public String getServerInterface() {
24+
return serverInterface;
25+
}
26+
27+
public String getMACAddress() { return macAddress; }
28+
29+
public String getIPV4Address() {
30+
return ipv4Address;
31+
}
32+
33+
public String getIPV6Address() {
34+
return ipv6Address;
35+
}
36+
}

src/main/java/com/perforce/p4java/impl/mapbased/rpc/CommandEnv.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public void setMap(Map<String, Object> map) {
176176

177177
private long syncTime = 0;
178178
private boolean nullSync = false;
179+
private boolean bufferOutput = false;
179180

180181
/**
181182
* The Perforce RPC connection in use for this command.
@@ -478,4 +479,12 @@ public boolean isNullSync() {
478479
public void setNullSync(boolean nullSync) {
479480
this.nullSync = nullSync;
480481
}
482+
483+
public boolean isBufferOutput() {
484+
return bufferOutput;
485+
}
486+
487+
public void setBufferOutput(boolean bufferOutput) {
488+
this.bufferOutput = bufferOutput;
489+
}
481490
}

src/main/java/com/perforce/p4java/impl/mapbased/rpc/NtsServerImpl.java

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.perforce.p4java.impl.mapbased.rpc.packet.RpcPacket;
2222
import com.perforce.p4java.impl.mapbased.rpc.packet.RpcPacketDispatcher;
2323
import com.perforce.p4java.impl.mapbased.rpc.stream.RpcStreamConnection;
24+
import com.perforce.p4java.impl.mapbased.rpc.sys.RpcByteBufferOutput;
2425
import com.perforce.p4java.impl.mapbased.rpc.sys.RpcOutputStream;
2526
import com.perforce.p4java.impl.mapbased.server.ServerAddressBuilder;
2627
import com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser;
@@ -36,6 +37,7 @@
3637
import java.io.IOException;
3738
import java.io.InputStream;
3839
import java.nio.BufferOverflowException;
40+
import java.nio.ByteBuffer;
3941
import java.nio.charset.UnsupportedCharsetException;
4042
import java.util.HashMap;
4143
import java.util.List;
@@ -405,6 +407,11 @@ public InputStream execStreamCmd(String cmdName, String[] cmdArgs) throws Connec
405407
return this.execStreamCmd(cmdName, cmdArgs, null, null, false);
406408
}
407409

410+
@Override
411+
public ByteBuffer execStreamCmdForBuffer(String cmdName, String[] cmdArgs) throws ConnectionException, RequestException, AccessException {
412+
return this.execStreamCmdForBuffer(cmdName, cmdArgs, null, null, false);
413+
}
414+
408415
/**
409416
* @see com.perforce.p4java.impl.mapbased.server.Server#execStreamCmd(java.lang.String, java.lang.String[], java.util.Map)
410417
*/
@@ -513,6 +520,93 @@ protected InputStream execStreamCmd(String cmdName, String[] cmdArgs, Map<String
513520
}
514521
}
515522

523+
/**
524+
* Note that this method does the access / request exception processing here rather
525+
* than passing things up the stack; we may introduce an extended version of this
526+
* method to take the map array as an output parameter in later releases.
527+
*
528+
* @param cmdName cmdName
529+
* @param cmdArgs cmdArgs
530+
* @param inMap inMap
531+
* @param inString inString
532+
* @param ignoreCallbacks ignoreCallbacks
533+
* @return byte buffer
534+
* @throws ConnectionException on error
535+
* @throws RequestException on error
536+
* @throws AccessException on error
537+
*/
538+
protected ByteBuffer execStreamCmdForBuffer(String cmdName, String[] cmdArgs, Map<String, Object> inMap, String inString, boolean ignoreCallbacks) throws ConnectionException, RequestException, AccessException {
539+
if (cmdName == null) {
540+
throw new NullPointerError("Null command name passed to execStreamCmd");
541+
}
542+
543+
if (!this.connected) {
544+
throw new ConnectionNotConnectedException("Not currently connected to a Perforce server");
545+
}
546+
547+
CommandEnv cmdEnv = null;
548+
549+
try {
550+
int cmdCallBackKey = this.nextCmdCallBackKey.incrementAndGet();
551+
long startTime = System.currentTimeMillis();
552+
if (inMap != null && ClientLineEnding.CONVERT_TEXT) {
553+
ClientLineEnding.convertMap(inMap);
554+
}
555+
ExternalEnv env = setupCmd(cmdName, cmdArgs, inMap, ignoreCallbacks, cmdCallBackKey, true);
556+
cmdEnv = new CommandEnv(this, new RpcCmdSpec(cmdName, cmdArgs, getAuthTicket(), inMap, inString, env), this.rpcConnection, this.protocolSpecs, this.serverProtocolMap, this.progressCallback, cmdCallBackKey, writeInPlace(cmdName), this.isNonCheckedSyncs());
557+
cmdEnv.setDontWriteTicket(isDontWriteTicket(cmdName.toLowerCase(Locale.ENGLISH), cmdArgs));
558+
cmdEnv.setFieldRule(getRpcPacketFieldRule(inMap, CmdSpec.getValidP4JCmdSpec(cmdName)));
559+
cmdEnv.setStreamCmd(true);
560+
cmdEnv.setBufferOutput(true);
561+
562+
List<Map<String, Object>> retMapList = dispatcher.dispatch(cmdEnv);
563+
564+
long endTime = System.currentTimeMillis();
565+
566+
if (!ignoreCallbacks && (this.commandCallback != null)) {
567+
this.processCmdCallbacks(cmdCallBackKey, endTime - startTime, retMapList);
568+
}
569+
570+
if ((retMapList != null) && (retMapList.size() != 0)) {
571+
for (Map<String, Object> map : retMapList) {
572+
ResultMapParser.handleErrorStr(map);
573+
ResultMapParser.handleWarningStr(map);
574+
}
575+
}
576+
577+
RpcByteBufferOutput outStream = (RpcByteBufferOutput) cmdEnv.getStateMap().get(RpcServer.RPC_BYTE_BUFFER_OUTPUT_KEY);
578+
579+
if (outStream != null) {
580+
return outStream.getByteBuffer();
581+
}
582+
583+
return null;
584+
585+
} catch (BufferOverflowException exc) {
586+
Log.error("RPC Buffer overflow: " + exc.getLocalizedMessage());
587+
Log.exception(exc);
588+
throw new P4JavaError("RPC Buffer overflow: " + exc.getLocalizedMessage(), exc);
589+
} catch (ConnectionNotConnectedException cnce) {
590+
this.connected = false;
591+
this.status = ServerStatus.ERROR;
592+
throw cnce;
593+
} finally {
594+
// Handle user cancelled command
595+
if (cmdEnv != null && cmdEnv.isUserCanceled()) {
596+
if (rpcConnection != null) {
597+
rpcConnection.disconnect(dispatcher);
598+
try {
599+
connect();
600+
} catch (ConfigException cfe) {
601+
this.connected = false;
602+
this.status = ServerStatus.ERROR;
603+
throw new ConnectionNotConnectedException(cfe);
604+
}
605+
}
606+
}
607+
}
608+
}
609+
516610
/**
517611
* Factors out the command setup that's common to stream and map commands.
518612
*

src/main/java/com/perforce/p4java/impl/mapbased/rpc/OneShotServerImpl.java

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.perforce.p4java.impl.mapbased.rpc.stream.RpcSocketPool;
2424
import com.perforce.p4java.impl.mapbased.rpc.stream.RpcSocketPool.ShutdownHandler;
2525
import com.perforce.p4java.impl.mapbased.rpc.stream.RpcStreamConnection;
26+
import com.perforce.p4java.impl.mapbased.rpc.sys.RpcByteBufferOutput;
2627
import com.perforce.p4java.impl.mapbased.rpc.sys.RpcOutputStream;
2728
import com.perforce.p4java.impl.mapbased.server.ServerAddressBuilder;
2829
import com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser;
@@ -39,6 +40,7 @@
3940
import java.io.InputStream;
4041
import java.net.Socket;
4142
import java.nio.BufferOverflowException;
43+
import java.nio.ByteBuffer;
4244
import java.util.HashMap;
4345
import java.util.List;
4446
import java.util.Locale;
@@ -386,6 +388,11 @@ public InputStream execStreamCmd(String cmdName, String[] cmdArgs) throws Connec
386388
return this.execStreamCmd(cmdName, cmdArgs, null, null, false);
387389
}
388390

391+
@Override
392+
public ByteBuffer execStreamCmdForBuffer(String cmdName, String[] cmdArgs) throws ConnectionException, RequestException, AccessException {
393+
return this.execStreamCmdForBuffer(cmdName, cmdArgs, null, null, false);
394+
}
395+
389396
/**
390397
* @see com.perforce.p4java.impl.mapbased.server.Server#execStreamCmd(String, String[], Map)
391398
*/
@@ -487,6 +494,86 @@ protected InputStream execStreamCmd(String cmdName, String[] cmdArgs, Map<String
487494
}
488495
}
489496

497+
/**
498+
* Note that this method does the access / request exception processing here rather
499+
* than passing things up the stack; we may introduce an extended version of this
500+
* method to take the map array as an output parameter in later releases.
501+
*
502+
* @param cmdName cmdName
503+
* @param cmdArgs cmdArgs
504+
* @param inMap inMap
505+
* @param inString inString
506+
* @param ignoreCallbacks ignoreCallbacks
507+
* @return bytebuffer
508+
* @throws ConnectionException on error
509+
* @throws RequestException on error
510+
* @throws AccessException on error
511+
*/
512+
protected ByteBuffer execStreamCmdForBuffer(String cmdName, String[] cmdArgs, Map<String, Object> inMap, String inString, boolean ignoreCallbacks) throws ConnectionException, RequestException, AccessException {
513+
RpcPacketDispatcher dispatcher = null;
514+
RpcConnection rpcConnection = null;
515+
if (cmdName == null) {
516+
throw new NullPointerError("Null command name passed to execStreamCmdForBuffer");
517+
}
518+
519+
if (!this.connected) {
520+
throw new ConnectionNotConnectedException("Not currently connected to a Perforce server");
521+
}
522+
523+
try {
524+
int cmdCallBackKey = this.nextCmdCallBackKey.incrementAndGet();
525+
long startTime = System.currentTimeMillis();
526+
dispatcher = new RpcPacketDispatcher(props, this);
527+
rpcConnection = new RpcStreamConnection(serverHost, serverPort, props, this.serverStats, this.p4Charset, null, this.socketPool, this.secure, this.rsh);
528+
ProtocolCommand protocolSpecs = new ProtocolCommand();
529+
if (inMap != null && ClientLineEnding.CONVERT_TEXT) {
530+
ClientLineEnding.convertMap(inMap);
531+
}
532+
ExternalEnv env = setupCmd(dispatcher, rpcConnection, protocolSpecs, cmdName.toLowerCase(Locale.ENGLISH), cmdArgs, inMap, ignoreCallbacks, cmdCallBackKey, true);
533+
CommandEnv cmdEnv = new CommandEnv(this, new RpcCmdSpec(cmdName.toLowerCase(Locale.ENGLISH), cmdArgs, getAuthTicket(), inMap, inString, env), rpcConnection, protocolSpecs, this.serverProtocolMap, this.progressCallback, cmdCallBackKey, writeInPlace(cmdName), this.isNonCheckedSyncs());
534+
cmdEnv.setDontWriteTicket(isDontWriteTicket(cmdName.toLowerCase(Locale.ENGLISH), cmdArgs));
535+
cmdEnv.setFieldRule(getRpcPacketFieldRule(inMap, CmdSpec.getValidP4JCmdSpec(cmdName)));
536+
cmdEnv.setStreamCmd(true);
537+
cmdEnv.setBufferOutput(true);
538+
539+
List<Map<String, Object>> retMapList = dispatcher.dispatch(cmdEnv);
540+
541+
long endTime = System.currentTimeMillis();
542+
543+
if (!ignoreCallbacks && (this.commandCallback != null)) {
544+
this.processCmdCallbacks(cmdCallBackKey, endTime - startTime, retMapList);
545+
}
546+
547+
if ((retMapList != null) && (retMapList.size() != 0)) {
548+
for (Map<String, Object> map : retMapList) {
549+
ResultMapParser.handleErrorStr(map);
550+
ResultMapParser.handleWarningStr(map);
551+
}
552+
}
553+
554+
RpcByteBufferOutput outStream = (RpcByteBufferOutput) cmdEnv.getStateMap().get(RpcServer.RPC_BYTE_BUFFER_OUTPUT_KEY);
555+
556+
if (outStream != null) {
557+
return outStream.getByteBuffer();
558+
}
559+
560+
return null;
561+
562+
} catch (BufferOverflowException exc) {
563+
Log.error("RPC Byte Buffer overflow: " + exc.getLocalizedMessage());
564+
Log.exception(exc);
565+
throw new P4JavaError("RPC Byte Buffer overflow: " + exc.getLocalizedMessage());
566+
} catch (ConnectionNotConnectedException cnce) {
567+
this.connected = false;
568+
this.status = ServerStatus.ERROR;
569+
throw cnce;
570+
} finally {
571+
if (rpcConnection != null) {
572+
rpcConnection.disconnect(dispatcher);
573+
}
574+
}
575+
}
576+
490577
/**
491578
* Factors out the command setup that's common to stream and map commands.
492579
*

src/main/java/com/perforce/p4java/impl/mapbased/rpc/RpcServer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ public abstract class RpcServer extends Server {
222222
*/
223223
public static final String RPC_TMP_OUTFILE_STREAM_KEY = "";
224224

225+
public static final String RPC_BYTE_BUFFER_OUTPUT_KEY = "";
226+
225227
/**
226228
* Use to key converter to use out of state map
227229
*/

src/main/java/com/perforce/p4java/impl/mapbased/rpc/func/RpcFunction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public class RpcFunction {
152152

153153
// ---------- UNSORTED
154154
new RpcFunctionMetadata(RpcFunctionSpec.USER_RENAMEUSER, RpcFunctionType.USER, "user-renameuser"),
155+
new RpcFunctionMetadata(RpcFunctionSpec.USER_RENAMECLIENT, RpcFunctionType.USER, "user-renameclient"),
155156
new RpcFunctionMetadata(RpcFunctionSpec.USER_SPECIFIED, RpcFunctionType.USER, "user-specified"),
156157
new RpcFunctionMetadata(RpcFunctionSpec.USER_LOGIN, RpcFunctionType.USER, "user-login"),
157158
new RpcFunctionMetadata(RpcFunctionSpec.USER_LOGIN2, RpcFunctionType.USER, "user-login2"),

src/main/java/com/perforce/p4java/impl/mapbased/rpc/func/RpcFunctionSpec.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public enum RpcFunctionSpec {
8080
USER_SIZES,
8181
USER_JOURNALWAIT,
8282
USER_RENAMEUSER,
83+
USER_RENAMECLIENT,
8384
USER_GRAPH,
8485
USER_REPOS,
8586
USER_TRANSMIT,

0 commit comments

Comments
 (0)