Skip to content

Commit

Permalink
2023.2 Patch 1 Code Drop
Browse files Browse the repository at this point in the history
  • Loading branch information
skumar7322 committed Apr 15, 2024
1 parent aea150e commit 52c86b8
Show file tree
Hide file tree
Showing 27 changed files with 900 additions and 83 deletions.
24 changes: 23 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,29 @@ Known Limitations
<java-home>/lib/security/US_export_policy.jar
* P4Java would not support file operations on altsync enabled clients.



-------------------------------------------
Updates in 2023.2 Patch 1 (2023.2/2581742) (2024/04/05)

#2578705 (Job #113772)
Added support for "p4 renameclient" command.

#2578400 (Job #113890)
Added support for "p4 opened -x" and "p4 opened -g" options.

#2551449, #2549979 (Job #118024)
Added support for "p4 license -L" option.

#2577562 (Job #115953)
Added support for "p4 sizes -c" option.

#2576245 (Job #115954)
Added support for "p4 integrated -m" option.

#2558625 (Job #117352)
Enhanced p4 print to return data in a byte buffer instead of creating a temp file.

-------------------------------------------
Updates in 2023.2 (2023.2/2542382) (2024/01/16)

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/perforce/p4java/core/IServerIPMACAddress.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.perforce.p4java.core;

public interface IServerIPMACAddress extends IServerResource {

String getServerInterface();

String getMACAddress();

String getIPV4Address();

String getIPV6Address();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.perforce.p4java.impl.generic.core;

import com.perforce.p4java.core.IServerIPMACAddress;
import java.util.Map;

public class ServerIPMACAddress extends ServerResource implements IServerIPMACAddress {
private String serverInterface;
private String macAddress;
private String ipv4Address;
private String ipv6Address;

public ServerIPMACAddress() {}

public ServerIPMACAddress(Map<String, Object> map) {
if(map.size() > 0 ) {
this.serverInterface = String.valueOf(map.get("interface"));
this.macAddress = String.valueOf(map.get("macAddress"));
this.ipv4Address = String.valueOf(map.get("ipv4Address"));
this.ipv6Address = String.valueOf(map.get("ipv6Address"));
}
}

public String getServerInterface() {
return serverInterface;
}

public String getMACAddress() { return macAddress; }

public String getIPV4Address() {
return ipv4Address;
}

public String getIPV6Address() {
return ipv6Address;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public void setMap(Map<String, Object> map) {

private long syncTime = 0;
private boolean nullSync = false;
private boolean bufferOutput = false;

/**
* The Perforce RPC connection in use for this command.
Expand Down Expand Up @@ -478,4 +479,12 @@ public boolean isNullSync() {
public void setNullSync(boolean nullSync) {
this.nullSync = nullSync;
}

public boolean isBufferOutput() {
return bufferOutput;
}

public void setBufferOutput(boolean bufferOutput) {
this.bufferOutput = bufferOutput;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.perforce.p4java.impl.mapbased.rpc.packet.RpcPacket;
import com.perforce.p4java.impl.mapbased.rpc.packet.RpcPacketDispatcher;
import com.perforce.p4java.impl.mapbased.rpc.stream.RpcStreamConnection;
import com.perforce.p4java.impl.mapbased.rpc.sys.RpcByteBufferOutput;
import com.perforce.p4java.impl.mapbased.rpc.sys.RpcOutputStream;
import com.perforce.p4java.impl.mapbased.server.ServerAddressBuilder;
import com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser;
Expand All @@ -36,6 +37,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.nio.charset.UnsupportedCharsetException;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -405,6 +407,11 @@ public InputStream execStreamCmd(String cmdName, String[] cmdArgs) throws Connec
return this.execStreamCmd(cmdName, cmdArgs, null, null, false);
}

@Override
public ByteBuffer execStreamCmdForBuffer(String cmdName, String[] cmdArgs) throws ConnectionException, RequestException, AccessException {
return this.execStreamCmdForBuffer(cmdName, cmdArgs, null, null, false);
}

/**
* @see com.perforce.p4java.impl.mapbased.server.Server#execStreamCmd(java.lang.String, java.lang.String[], java.util.Map)
*/
Expand Down Expand Up @@ -513,6 +520,93 @@ protected InputStream execStreamCmd(String cmdName, String[] cmdArgs, Map<String
}
}

/**
* Note that this method does the access / request exception processing here rather
* than passing things up the stack; we may introduce an extended version of this
* method to take the map array as an output parameter in later releases.
*
* @param cmdName cmdName
* @param cmdArgs cmdArgs
* @param inMap inMap
* @param inString inString
* @param ignoreCallbacks ignoreCallbacks
* @return byte buffer
* @throws ConnectionException on error
* @throws RequestException on error
* @throws AccessException on error
*/
protected ByteBuffer execStreamCmdForBuffer(String cmdName, String[] cmdArgs, Map<String, Object> inMap, String inString, boolean ignoreCallbacks) throws ConnectionException, RequestException, AccessException {
if (cmdName == null) {
throw new NullPointerError("Null command name passed to execStreamCmd");
}

if (!this.connected) {
throw new ConnectionNotConnectedException("Not currently connected to a Perforce server");
}

CommandEnv cmdEnv = null;

try {
int cmdCallBackKey = this.nextCmdCallBackKey.incrementAndGet();
long startTime = System.currentTimeMillis();
if (inMap != null && ClientLineEnding.CONVERT_TEXT) {
ClientLineEnding.convertMap(inMap);
}
ExternalEnv env = setupCmd(cmdName, cmdArgs, inMap, ignoreCallbacks, cmdCallBackKey, true);
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());
cmdEnv.setDontWriteTicket(isDontWriteTicket(cmdName.toLowerCase(Locale.ENGLISH), cmdArgs));
cmdEnv.setFieldRule(getRpcPacketFieldRule(inMap, CmdSpec.getValidP4JCmdSpec(cmdName)));
cmdEnv.setStreamCmd(true);
cmdEnv.setBufferOutput(true);

List<Map<String, Object>> retMapList = dispatcher.dispatch(cmdEnv);

long endTime = System.currentTimeMillis();

if (!ignoreCallbacks && (this.commandCallback != null)) {
this.processCmdCallbacks(cmdCallBackKey, endTime - startTime, retMapList);
}

if ((retMapList != null) && (retMapList.size() != 0)) {
for (Map<String, Object> map : retMapList) {
ResultMapParser.handleErrorStr(map);
ResultMapParser.handleWarningStr(map);
}
}

RpcByteBufferOutput outStream = (RpcByteBufferOutput) cmdEnv.getStateMap().get(RpcServer.RPC_BYTE_BUFFER_OUTPUT_KEY);

if (outStream != null) {
return outStream.getByteBuffer();
}

return null;

} catch (BufferOverflowException exc) {
Log.error("RPC Buffer overflow: " + exc.getLocalizedMessage());
Log.exception(exc);
throw new P4JavaError("RPC Buffer overflow: " + exc.getLocalizedMessage(), exc);
} catch (ConnectionNotConnectedException cnce) {
this.connected = false;
this.status = ServerStatus.ERROR;
throw cnce;
} finally {
// Handle user cancelled command
if (cmdEnv != null && cmdEnv.isUserCanceled()) {
if (rpcConnection != null) {
rpcConnection.disconnect(dispatcher);
try {
connect();
} catch (ConfigException cfe) {
this.connected = false;
this.status = ServerStatus.ERROR;
throw new ConnectionNotConnectedException(cfe);
}
}
}
}
}

/**
* Factors out the command setup that's common to stream and map commands.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.perforce.p4java.impl.mapbased.rpc.stream.RpcSocketPool;
import com.perforce.p4java.impl.mapbased.rpc.stream.RpcSocketPool.ShutdownHandler;
import com.perforce.p4java.impl.mapbased.rpc.stream.RpcStreamConnection;
import com.perforce.p4java.impl.mapbased.rpc.sys.RpcByteBufferOutput;
import com.perforce.p4java.impl.mapbased.rpc.sys.RpcOutputStream;
import com.perforce.p4java.impl.mapbased.server.ServerAddressBuilder;
import com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser;
Expand All @@ -39,6 +40,7 @@
import java.io.InputStream;
import java.net.Socket;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -386,6 +388,11 @@ public InputStream execStreamCmd(String cmdName, String[] cmdArgs) throws Connec
return this.execStreamCmd(cmdName, cmdArgs, null, null, false);
}

@Override
public ByteBuffer execStreamCmdForBuffer(String cmdName, String[] cmdArgs) throws ConnectionException, RequestException, AccessException {
return this.execStreamCmdForBuffer(cmdName, cmdArgs, null, null, false);
}

/**
* @see com.perforce.p4java.impl.mapbased.server.Server#execStreamCmd(String, String[], Map)
*/
Expand Down Expand Up @@ -487,6 +494,86 @@ protected InputStream execStreamCmd(String cmdName, String[] cmdArgs, Map<String
}
}

/**
* Note that this method does the access / request exception processing here rather
* than passing things up the stack; we may introduce an extended version of this
* method to take the map array as an output parameter in later releases.
*
* @param cmdName cmdName
* @param cmdArgs cmdArgs
* @param inMap inMap
* @param inString inString
* @param ignoreCallbacks ignoreCallbacks
* @return bytebuffer
* @throws ConnectionException on error
* @throws RequestException on error
* @throws AccessException on error
*/
protected ByteBuffer execStreamCmdForBuffer(String cmdName, String[] cmdArgs, Map<String, Object> inMap, String inString, boolean ignoreCallbacks) throws ConnectionException, RequestException, AccessException {
RpcPacketDispatcher dispatcher = null;
RpcConnection rpcConnection = null;
if (cmdName == null) {
throw new NullPointerError("Null command name passed to execStreamCmdForBuffer");
}

if (!this.connected) {
throw new ConnectionNotConnectedException("Not currently connected to a Perforce server");
}

try {
int cmdCallBackKey = this.nextCmdCallBackKey.incrementAndGet();
long startTime = System.currentTimeMillis();
dispatcher = new RpcPacketDispatcher(props, this);
rpcConnection = new RpcStreamConnection(serverHost, serverPort, props, this.serverStats, this.p4Charset, null, this.socketPool, this.secure, this.rsh);
ProtocolCommand protocolSpecs = new ProtocolCommand();
if (inMap != null && ClientLineEnding.CONVERT_TEXT) {
ClientLineEnding.convertMap(inMap);
}
ExternalEnv env = setupCmd(dispatcher, rpcConnection, protocolSpecs, cmdName.toLowerCase(Locale.ENGLISH), cmdArgs, inMap, ignoreCallbacks, cmdCallBackKey, true);
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());
cmdEnv.setDontWriteTicket(isDontWriteTicket(cmdName.toLowerCase(Locale.ENGLISH), cmdArgs));
cmdEnv.setFieldRule(getRpcPacketFieldRule(inMap, CmdSpec.getValidP4JCmdSpec(cmdName)));
cmdEnv.setStreamCmd(true);
cmdEnv.setBufferOutput(true);

List<Map<String, Object>> retMapList = dispatcher.dispatch(cmdEnv);

long endTime = System.currentTimeMillis();

if (!ignoreCallbacks && (this.commandCallback != null)) {
this.processCmdCallbacks(cmdCallBackKey, endTime - startTime, retMapList);
}

if ((retMapList != null) && (retMapList.size() != 0)) {
for (Map<String, Object> map : retMapList) {
ResultMapParser.handleErrorStr(map);
ResultMapParser.handleWarningStr(map);
}
}

RpcByteBufferOutput outStream = (RpcByteBufferOutput) cmdEnv.getStateMap().get(RpcServer.RPC_BYTE_BUFFER_OUTPUT_KEY);

if (outStream != null) {
return outStream.getByteBuffer();
}

return null;

} catch (BufferOverflowException exc) {
Log.error("RPC Byte Buffer overflow: " + exc.getLocalizedMessage());
Log.exception(exc);
throw new P4JavaError("RPC Byte Buffer overflow: " + exc.getLocalizedMessage());
} catch (ConnectionNotConnectedException cnce) {
this.connected = false;
this.status = ServerStatus.ERROR;
throw cnce;
} finally {
if (rpcConnection != null) {
rpcConnection.disconnect(dispatcher);
}
}
}

/**
* Factors out the command setup that's common to stream and map commands.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ public abstract class RpcServer extends Server {
*/
public static final String RPC_TMP_OUTFILE_STREAM_KEY = "";

public static final String RPC_BYTE_BUFFER_OUTPUT_KEY = "";

/**
* Use to key converter to use out of state map
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public class RpcFunction {

// ---------- UNSORTED
new RpcFunctionMetadata(RpcFunctionSpec.USER_RENAMEUSER, RpcFunctionType.USER, "user-renameuser"),
new RpcFunctionMetadata(RpcFunctionSpec.USER_RENAMECLIENT, RpcFunctionType.USER, "user-renameclient"),
new RpcFunctionMetadata(RpcFunctionSpec.USER_SPECIFIED, RpcFunctionType.USER, "user-specified"),
new RpcFunctionMetadata(RpcFunctionSpec.USER_LOGIN, RpcFunctionType.USER, "user-login"),
new RpcFunctionMetadata(RpcFunctionSpec.USER_LOGIN2, RpcFunctionType.USER, "user-login2"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public enum RpcFunctionSpec {
USER_SIZES,
USER_JOURNALWAIT,
USER_RENAMEUSER,
USER_RENAMECLIENT,
USER_GRAPH,
USER_REPOS,
USER_TRANSMIT,
Expand Down
Loading

0 comments on commit 52c86b8

Please sign in to comment.