//Class to list all labels associated with a given file pattern.
import java.net.URISyntaxException;
import java.util.List;
import java.util.ArrayList;
import com.perforce.p4java.core.ILabel;
import com.perforce.p4java.core.ILabelSummary;
import com.perforce.p4java.exception.P4JavaException;
import com.perforce.p4java.exception.RequestException;
import com.perforce.p4java.server.IServer;
import com.perforce.p4java.core.file.*;
import com.perforce.p4java.impl.generic.core.file.FileSpec;
public class ListLabelsDemo extends P4JavaDemo
{
public static void main(String[] args) {
try {
IServer server = getServer(null);
//hard-coding username for now
server.setUserName("jen");
//Security0 just for this test.
// server.login(password);
List<IFileSpec> labeledFiles = server.getDepotFiles(
FileSpecBuilder.makeFileSpecList(new
String[]{"//depot/testfile"}), false);
if (labeledFiles != null) {
for (IFileSpec fileSpec : labeledFiles) {
if (fileSpec != null) {
if (fileSpec.getOpStatus() == FileSpecOpStatus.VALID) {
System.out.println(fileSpec.getDepotPathString());
} else {
System.err.println(fileSpec.getStatusMessage());
}
}
}
}
System.out.println("Labels on Perforce server at URI '"
+ serverUri + "':");
List<ILabelSummary> labelList = server.getLabels(null, 1, null, labeledFiles);
if (labelList != null) {
for (ILabelSummary labelSummary : labelList) {
System.out.println(labelSummary.getName());
}
}
} catch (RequestException rexc) {
System.err.println(rexc.getDisplayString());
rexc.printStackTrace();
} catch (Exception exc) {
System.err.println(exc.getLocalizedMessage());
exc.printStackTrace();
}
}
//End class
}
# |
Change |
User |
Description |
Committed |
|
#1
|
25911 |
Jen Bottom |
Adding correct version of build.xml |
|
|