Hello,
As we cannot create a project from project template using Webservices (see https://knowledge.opentext.com/knowledge/cs.dll?func=ll&objId=22340284&objAction=viewincontainer), I am investigating another option.
The idea is to create an empty project and to copy the content from an existing project used as a template.
However, the copyNode function gives an odd results. All folders copied from the source project are displayed as sub-project in the target folder. See printscreen below.
Did I miss something? Is there a know issue?
Thanks for your feedback.
JP

/**
* Create an IT Project from the IT Project template
* @param projectTemplateID ID of the project template to copy
* @param coordinatorID ID of the user to be added as coordinator of the project
* @param targetfolderID ID of the target folder
* @param newProjectName Name of the new project
* @return ID of the newly created project
* @throws Exception
*/
public static int runCreateITProject(int targetfolderID, int projectTemplateID, int coordinatorID, String newProjectName) throws Exception {
String wsRootURL = rb.getString("wsRootURL");
String wsUserName = rb.getString("wsUserName");
String wsPassword = rb.getString("wsPassword");
String wsTimeout = rb.getString("wsTimeout");
try{
OpentextUtils.wsTimeout = Integer.parseInt(wsTimeout);
// Authentication service
String wsAuthWSDLURL = wsRootURL + "Authentication?wsdl";
// DocumentManagement service
String wsDocWSDLURL = wsRootURL + "DocumentManagement?wsdl";
// ContentService
String wsContentWSDLURL = wsRootURL + "ContentService?wsdl";
// MemberService
String wsMemberWSDLURL = wsRootURL + "MemberService?wsdl";
// CollaborationService
String wsCollaborationWSDLURL = wsRootURL + "Collaboration?wsdl";
// Authentication token
String authToken = OpentextUtils.getAuthenticationToken(new URL(wsAuthWSDLURL), wsUserName, wsPassword);
// Document management Service
DocumentManagement dm = OpentextUtils.getDMService(new URL(wsDocWSDLURL), authToken);
// Content Service
ContentService cs = OpentextUtils.getContentService(new URL(wsContentWSDLURL), authToken);
//
Collaboration col = OpentextUtils.getCollaborationService(new URL(wsCollaborationWSDLURL), authToken);
// Get ContentService binder
WSBindingProvider csBindingProvider = (WSBindingProvider) cs;
// As we cannot copy a project, we are going to create a new one from the template and after copy all its content
ProjectInfo projetInfo = col.getProject(projectTemplateID);
projetInfo.setParentID(targetfolderID);
projetInfo.setID(0);
projetInfo.setCreatedBy(null);
projetInfo.setName(newProjectName);
Node nodeNewProject = col.createProject(projetInfo);
CopyOptions options= new CopyOptions();
options.setAttrSourceType(AttributeSourceType.DESTINATION);
options.setAddVersion(true);
options.setCopyCurrent(true);
options.setCurrentUserAsOwner(true);
options.setKeepReservedState(false);
options.setKeepVersionLocks(true);
GetNodesInContainerOptions containerOptions = new GetNodesInContainerOptions();
containerOptions.setMaxDepth(1); // We only copy the first level of sub folders
containerOptions.setMaxResults(1000);
List<Node> listFolders = dm.getNodesInContainer(projectTemplateID, containerOptions);
for (Iterator<Node> iterator = listFolders.iterator(); iterator.hasNext();) {
Node node = (Node) iterator.next();
dm.copyNode(node.getID(), nodeNewProject.getID(), node.getName(), options);
}
System.out.println("Project created: " + nodeNewProject.getID());
return nodeNewProject.getID();
} catch (Throwable e) {
log.error("Internal Error", e);
e.printStackTrace();
}
return 0;
}