package com.perforce.p4java_ext; import com.fasterxml.jackson.databind.ObjectMapper; import com.perforce.p4java.exception.P4JavaException; import com.perforce.p4java.server.IOptionsServer; import java.util.Map; /** * Interface to the "p4 submit" command */ public interface P4Submit extends P4ClientConnection, P4Errors { static P4Submit create(P4ClientConnection conn) { return new DefaultP4Submit(conn); } /** * Performs "p4 submit -c [id]" * * @param changeId The pending changelist ID, should be on the current client. * @return The final (actual) submitted changelist ID */ default String submit(String changeId) { try { String[] opts = new String[]{"-c", changeId}; IOptionsServer optionsServer = getOptionsServer(); Map<String, Object>[] results = optionsServer.execMapCmd("submit", opts, null); checkError(results); if (results.length > 0) { String changeStr = (String) results[0].get("change"); changeStr = changeStr.replaceAll("[^\\d]", ""); return changeStr; } else { String mapStr = ""; try { ObjectMapper mapper = new ObjectMapper(); mapStr = mapper.writeValueAsString(results); } catch (Exception ex) { ex.printStackTrace(); } throw new IllegalStateException("No changeId returned from submit -c " + changeId + ": " + mapStr); } } catch (P4JavaException ex) { throw new P4Exception(ex); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 9086 | tjuricek |
0.1.0 Initial release of p4java_ext Mostly just contains enough of the P4 API to build the test data initializer. About 4 commands have minimal testing, so it works. Kind of. |
||
#1 | 9085 | tjuricek | First import of the project, before package refactoring. |