Appendix > Installing the Remote API > To work with the workspace
To work with the workspace
With an open connection, you can create new Windchill Requirements Connector projects, add already existing ones to the workspace, or browse the workspace to see all workspace projects. See the example below:
IRemoteClient remoteClient ...;

// To access the workspace and find the projects and files
IRemoteWorkspace workspace = remoteClient.getWorkspace();
for(IRemoteProject project : workspace.getProjects()) {
for(IRemoteResource resource : project.getChildren()) {
if(resource.getType() == ResourceType.File) {
IRemoteFile file = (IRemoteFile)resource;
System.out.print("File: ");
System.out.println(file.getName());
} else if(resource.getType() == ResourceType.Folder) {
IRemoteFolder folder = (IRemoteFolder)resource;
System.out.print("Folder: ");
System.out.println(folder.getName());
// You can access the children of the folder with
the getChildren method
IRemoteResource[] children = folder.getChildren();
}
}
}

// To create a new project with local replication
IOperationResult result = remoteClient.createProjectWithLocalReplication("C:/foo/bar/NewProject", "NewProject");
// "C:/foo/bar/NewProject" is a path a the server
if(!result.getSuccessful()) {
// Creation of project failed, print the error messages
for(IOperationMessage message : result.getMessages()) {
System.err.print(message.getSeverity().name());
System.err.print(" ");
System.err.print(message.getMessage());
System.err.print(" at ");
System.err.println(message.getLocation());
}
} else {
// you will find the project with the name "NewProject" in the workspace
}

// To create a new project with global replication
// "C:/path/to/GlobalDatabaseSettings" is the path to the global
// replication database settings
// The path must be found in the global database preferences:
// remoteClient.getGlobalReplicationPreferences()
IOperationResult result = remoteClient.createProjectWithGlobalReplication
("C:/path/to/GlobalDatabaseSettings", "C:/foo/bar/NewProject", "NewProject");

// To Import an existing project into the workspace
remoteClient.importProject("C:/foo/bar/OldProject");
Was this helpful?