/**
* Class for customer repro.
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Date;
import java.util.List;
import com.perforce.p4java.client.IClient;
import com.perforce.p4java.core.ChangelistStatus;
import com.perforce.p4java.core.IChangelist;
import com.perforce.p4java.core.file.FileSpecBuilder;
import com.perforce.p4java.core.file.FileSpecOpStatus;
import com.perforce.p4java.core.file.IFileSpec;
import com.perforce.p4java.exception.P4JavaException;
import com.perforce.p4java.exception.RequestException;
import com.perforce.p4java.impl.generic.core.Changelist;
import com.perforce.p4java.impl.mapbased.server.Server;
import com.perforce.p4java.option.client.AddFilesOptions;
import com.perforce.p4java.server.IOptionsServer;
import com.perforce.p4java.core.file.IntegrationOptions;
import com.perforce.p4java.option.client.IntegrateFilesOptions;
import com.perforce.p4java.impl.generic.core.file.FileSpec;
import com.perforce.p4java.option.client.EditFilesOptions;
import com.perforce.p4java.option.client.ResolveFilesAutoOptions;
import com.perforce.p4java.server.ServerFactory;
import com.perforce.p4java.server.IServerInfo;
import com.perforce.p4java.core.ILabel;
import com.perforce.p4java.core.ILabelMapping;
import com.perforce.p4java.core.ViewMap;
import com.perforce.p4java.impl.generic.core.Label;
import com.perforce.p4java.impl.generic.core.Label.LabelMapping;
import java.io.FileWriter;
import java.io.PrintWriter;
public class LabelTest extends P4JavaDemo
{
//Set the variables we may need
/** Name of the label. */
private String name;
/** Owner of the label. */
private String owner;
/** Description of the label. */
private String description;
/** Revision specification for the label. */
private String revision;
/** Lock the label. */
private boolean locked = false;
private boolean autoReload = false;
/** New or updated label returned from the Perforce command. */
private ILabel retLabel;
/**
* Default constructor.
*/
public LabelTest()
{
super();
//Initialise instance variables
this.name = "testlabel";
this.owner = "Jen";
this.description = "Created for a test";
this.revision = "@1";
}
/**
* Sets the name.
*
* @param name
* the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the owner.
*
* @param owner
* the new owner
*/
public void setOwner(String owner) {
this.owner = owner;
}
/**
* Sets the description.
*
* @param description
* the new description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Sets the locked.
*
* @param locked
* the new locked
*/
public void setLocked(boolean locked) {
this.locked = locked;
}
/**
* Sets the revision.
*
* @param revision
* the new revision
*/
public void setRevision(String revision) {
this.revision = revision;
}
/**
* Gets the ret label.
*
* @return the ret label
*/
public ILabel getRetLabel() {
return retLabel;
}
public void createLabel()
{
try {
//Create a Server object
// IOptionsServer server = getOptionsServer(null, null);
IOptionsServer server = ServerFactory.getOptionsServer("p4java://localhost:1666", null);
server.setUserName(userName);
// server.setUserName("jen");
server.connect();
// server.login(password);
//Get p4 info
IServerInfo info = server.getServerInfo();
System.out.println(info);
//Create a client object
IClient client = server.getClient("javatest");
if (client != null)
{
server.setCurrentClient(client);
}
// Build the view map for the label.
// Only the left hand side of a mapping is used for labels.
ViewMap<ILabelMapping> viewMap = new ViewMap<ILabelMapping>();
//Hard-coding in some file paths for testing.
String[] viewPaths = {"//depot/dir1", "//depot/dir2"};
for (int i = 0; i < viewPaths.length; i++) {
ILabelMapping entry = new LabelMapping(i + 1, viewPaths[i]);
viewMap.addEntry((LabelMapping) entry);
}
Date lastAccess = null;
Date lastUpdate = null;
//Create the Label Object
ILabel label = new Label(name, owner, lastAccess, lastUpdate,
description, revision, locked, viewMap);
server.createLabel(label);
//End try
}
catch (RequestException rexc) {
System.err.println(rexc.getDisplayString());
rexc.printStackTrace();
} catch (P4JavaException jexc) {
System.err.println(jexc.getLocalizedMessage());
jexc.printStackTrace();
} catch (Exception exc) {
System.err.println(exc.getLocalizedMessage());
exc.printStackTrace();
}
//end main
}
}
# |
Change |
User |
Description |
Committed |
|
#1
|
25911 |
Jen Bottom |
Adding correct version of build.xml |
|
|