package com.perforce.workshop.tjuricek.initializer.model; import java.io.File; import java.util.ArrayList; import java.util.List; /** * Creates a new perforce client for later use. Many operations will probably * depend upon this client. * <p> * The clients are necessary, and extra clients can be made. However, if you * do not specify them, one will be created for each new user in the system * and then deleted at the end of the initialization run. */ public class PerforceClient { private boolean temporary; private String name; private String root; private String owner; private String host; private boolean hostEdit; private String description; private boolean descriptionEdit; private List<String[]> view; public PerforceClient() { this.temporary = false; this.hostEdit = false; this.descriptionEdit = false; this.view = new ArrayList<String[]>(); } /** * Applies most of our conventions and system configuration to create a * client for use only during this initialization process. * * @param user The perforce login, there should be a PerforceUser * definition. * @param rootDir The local file directory we use as the root * @return The new client; only metadata, the root does not exist yet */ public static PerforceClient createTemporaryClient(String user, File rootDir) { PerforceClient client = new PerforceClient(); client.setTemporary(true); client.setName("initializer-" + user); client.setOwner(user); client.setDescription("Client used for data initialization. Safe to " + "delete."); // These clients should only ever modify the depot client.view.add(new String[]{ "//depot/...", "//" + client.getName() + "/..."}); File clientRoot = new File(rootDir, client.getName()); client.setRoot(clientRoot.getAbsolutePath()); return client; } public boolean isTemporary() { return temporary; } public void setTemporary(boolean temporary) { this.temporary = temporary; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getRoot() { return root; } public void setRoot(String root) { this.root = root; } public File getRootFile() { return new File(root); } public String getOwner() { return owner; } public void setOwner(String owner) { this.owner = owner; } public String getHost() { return host; } public void setHost(String host) { this.hostEdit = !host.equals(this.host); this.host = host; } public boolean isHostEdit() { return hostEdit; } public boolean isDescriptionEdit() { return descriptionEdit; } public String getDescription() { return description; } public void setDescription(String description) { this.descriptionEdit = !description.equals(this.description); this.description = description; } public List<String[]> getView() { return view; } public void setView(List<String[]> view) { this.view = view; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PerforceClient that = (PerforceClient) o; if (descriptionEdit != that.descriptionEdit) return false; if (hostEdit != that.hostEdit) return false; if (temporary != that.temporary) return false; if (description != null ? !description.equals(that.description) : that.description != null) return false; if (host != null ? !host.equals(that.host) : that.host != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (owner != null ? !owner.equals(that.owner) : that.owner != null) return false; if (root != null ? !root.equals(that.root) : that.root != null) return false; if (view != null ? !view.equals(that.view) : that.view != null) return false; return true; } @Override public int hashCode() { int result = (temporary ? 1 : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (root != null ? root.hashCode() : 0); result = 31 * result + (owner != null ? owner.hashCode() : 0); result = 31 * result + (host != null ? host.hashCode() : 0); result = 31 * result + (hostEdit ? 1 : 0); result = 31 * result + (description != null ? description.hashCode() : 0); result = 31 * result + (descriptionEdit ? 1 : 0); result = 31 * result + (view != null ? view.hashCode() : 0); return result; } @Override public String toString() { return "PerforceClient{" + "temporary=" + temporary + ", name='" + name + '\'' + ", root='" + root + '\'' + ", owner='" + owner + '\'' + ", host='" + host + '\'' + ", hostEdit=" + hostEdit + ", description='" + description + '\'' + ", descriptionEdit=" + descriptionEdit + ", view=" + view + '}'; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 9165 | tjuricek |
Some documentation framework and a fatjar style distribution for the initializer to run outside of a gradle plugin. Upped the version to 0.1.2, but this may need some testing before it's really guaranteed to work in standalone mode |
||
//guest/tjuricek/initializer/src/main/java/com/perforce/workspace/tjuricek/initializer/model/PerforceClient.java | |||||
#1 | 9088 | tjuricek |
0.1.0 First version of the initializer. This currently requires setting up a local version of the p4java_ext project, since that project is awating approval into the main jcenter repository. |