package com.perforce.workshop.tjuricek.p4java_ext; import com.perforce.p4java.exception.P4JavaException; import com.perforce.p4java.server.IOptionsServer; import java.util.Map; /** * Wraps calls to "p4 depot". These probably need to be run by an admin only * for the purposes of initializing a new Commons instance, though we do not * restrict that ourselves. You'll receive a P4JavaCommonsException if you attempt to * do something you do not have access for. */ public interface P4Depot extends P4Connection, P4Errors { static P4Depot create(P4Connection conn) { return new DefaultP4Depot(conn); } /** * Calls "p4 depot -o", which is basically what you want to do as a first * step when creating or updating a depot. * * @param name The depot name (does not need to exist) * @return The wrapped Map from java. */ default DepotSpec load(String name) { try { String[] opts = {"-o", name}; IOptionsServer server = getOptionsServer(); Map<String, Object>[] results = server.execMapCmd("depot", opts, null); checkError(results); if (results.length != 1) { throw new IllegalStateException("results.length != 1"); } return new DepotSpec(results[0]); } catch (P4JavaException e) { throw new P4Exception(e); } } /** * Calls "p4 depot -i" using the map contained by the depotSpec. * * @param depotSpec The spec map to use. Should probably be obtained by * load(), not created directly */ default void save(DepotSpec depotSpec) { try { String[] opts = {"-i"}; IOptionsServer server = getOptionsServer(); Map<String, Object>[] results = server.execMapCmd("depot", opts, depotSpec.getDepotMap()); checkError(results); } catch (P4JavaException e) { throw new P4Exception(e); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 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. |
||
//guest/tjuricek/p4java_ext/src/main/java/com/perforce/p4java_ext/P4Depot.java | |||||
#1 | 9085 | tjuricek | First import of the project, before package refactoring. |