com.ibm.workplace.wcm.api
Interface WcmProjectService

All Known Implementing Classes:
ProjectService

public interface WcmProjectService

WcmProjectService enables access to the WCM API through Portal services.

Here is an example of how to retrieve the WcmProjectService:

 try
 {
    // Construct and inital Context
    InitialContext ctx = new InitialContext();

    // Retrieve WcmProjectService using JNDI name
    WcmProjectService service = (WcmProjectService) ctx.lookup("portal:service/wcm/WcmProjectService");
 }
 catch (NamingException ne)
 {
    System.out.print("Naming Exception: " + ne);
 }
 

Since:
8.5

Field Summary
static java.lang.String JNDI_NAME
          JNDI name of this service
 
Method Summary
 Document addItemToProject(Workspace workspace, Project project, WorkflowedDocument workflowedDocument)
          Add a Document into the given Project.
 void cancelDeletion(Workspace workspace, Project project, Document document)
          Clear deletion marking from a Document on a Project
 Project createProject(Workspace workspace)
          Create a new Project object.
 Project createProject(Workspace workspace, DocumentId projectTemplateDocumentId)
          Create a Project using the specified ProjectTemplate.
 ProjectTemplate createProjectTemplate(Workspace workspace)
          Creates a new ProjectTemplate.
 ProjectTemplate createProjectTemplate(Workspace workspace, Project project)
          Creates a new ProjectTemplate taking the basic settings and properties of the supplied Project.
 void deleteProject(Workspace workspace, Project project)
          Delete Project object from WCM repository.
 ResultIterator<Project> findProjectsByName(Workspace workspace, java.lang.String name)
          Obtain existing Project(s) from WCM repository by their name.
 ResultIterator<Project> findProjectsByState(Workspace workspace, ProjectStateSelectors.State projectState)
          Obtain a Project from WCM repository with its project state.
 ResultIterator<Project> findProjectsByTitle(Workspace workspace, java.lang.String title)
          Obtain existing Project(s) from WCM repository by their title.
 Project getProjectById(Workspace workspace, DocumentId projectDocumentId)
          Obtain a Project from WCM repository by its DocumentId
 void markItemForDeletion(Workspace workspace, Project project, Document document)
          Set a Document into deleted state.
 LocalizedMessageContainer markItemForDeletion(Workspace workspace, Project project, Document document, boolean checkExternalReferences)
          Set a Document into deleted state.
 void removeItemFromProject(Workspace workspace, Project project, Document document)
          Remove a Document from Project
 void saveProject(Workspace workspace, Project project)
          Add or update a Project in the WCM repository.
 

Field Detail

JNDI_NAME

static final java.lang.String JNDI_NAME
JNDI name of this service

See Also:
Constant Field Values
Method Detail

createProjectTemplate

ProjectTemplate createProjectTemplate(Workspace workspace)
                                      throws com.ibm.workplace.wcm.api.exceptions.DocumentCreationException,
                                             com.ibm.workplace.wcm.api.exceptions.AuthorizationException
Creates a new ProjectTemplate.

A typical usage of this method is as follows:

 Workspace workspace = WCM_API.getRepository().getWorkspace(username, password);
 InitialContext ctx = new InitialContext();
 Workspace workspace = (WcmProjectService) ctx.lookup("portal:service/wcm/WcmProjectService");
 ProjectTemplate projectTemplate = projectService.createProjectTemplate(workspace);
 projectTemplate.setName(name);
 ProjectPrototype prototype = projectTemplate.getPrototype();
 prototype.setPublishOptions(PublishOptions.MANUAL);
 prototype.setApprovalMode(ApprovalMode.REQUIRE_ALL_APPROVALS);
 prototype.setCommentMode(CommentMode.ENABLED);
 prototype.setWorkflowActionsForState(State.REVIEW, actionIds);
 prototype.setWorkflowActionsForState(State.REJECTED, actionIds);
 workspace.save(projectTemplate);
 

Parameters:
workspace - workspace
Returns:
the new ProjectTemplate object.
Throws:
com.ibm.workplace.wcm.api.exceptions.DocumentCreationException - if the object cannot be created.
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the user does not have minimum Editor access.
Since:
8.0

createProjectTemplate

ProjectTemplate createProjectTemplate(Workspace workspace,
                                      Project project)
                                      throws com.ibm.workplace.wcm.api.exceptions.DocumentCreationException,
                                             com.ibm.workplace.wcm.api.exceptions.AuthorizationException
Creates a new ProjectTemplate taking the basic settings and properties of the supplied Project. The publish settings, approval and action properties of the Project will be copied over to the new ProjectTemplate.

Parameters:
workspace - workspace
project - The project to base the new template off.
Returns:
the new ProjectTemplate object.
Throws:
com.ibm.workplace.wcm.api.exceptions.DocumentCreationException - if the object cannot be created.
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the user does not have minimum Editor access.
Since:
8.5

createProject

Project createProject(Workspace workspace)
                      throws com.ibm.workplace.wcm.api.exceptions.AuthorizationException,
                             com.ibm.workplace.wcm.api.exceptions.DocumentCreationException
Create a new Project object. The default project template attributes will be used.

Parameters:
workspace - workspace
Returns:
Created Project
Throws:
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have permission
com.ibm.workplace.wcm.api.exceptions.DocumentCreationException - if the item could not be created
Since:
7.0

createProject

Project createProject(Workspace workspace,
                      DocumentId projectTemplateDocumentId)
                      throws com.ibm.workplace.wcm.api.exceptions.DocumentCreationException,
                             com.ibm.workplace.wcm.api.exceptions.AuthorizationException
Create a Project using the specified ProjectTemplate. The created Project will inherit all attributes defined on the ProjectPrototype of the given ProjectTemplate.

Parameters:
workspace - workspace
projectTemplateDocumentId - the document id of a ProjectTemplate.
Returns:
a Project instance created from the given ProjectTemplate.
Throws:
java.lang.IllegalArgumentException - if the given id is null or is not a ProjectTemplate
com.ibm.workplace.wcm.api.exceptions.DocumentCreationException - if the project can not be created or the specified ProjectTemplatedoes not exist.
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have sufficient access.
Since:
8.0

saveProject

void saveProject(Workspace workspace,
                 Project project)
                 throws com.ibm.workplace.wcm.api.exceptions.AuthorizationException,
                        com.ibm.workplace.wcm.api.exceptions.DuplicateChildException,
                        com.ibm.workplace.wcm.api.exceptions.DocumentSaveException,
                        com.ibm.workplace.wcm.api.exceptions.ProjectException
Add or update a Project in the WCM repository.

Parameters:
workspace - workspace
project - Project object to save
Throws:
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have permission
com.ibm.workplace.wcm.api.exceptions.DuplicateChildException - if another item with the same name already exists
com.ibm.workplace.wcm.api.exceptions.DocumentSaveException - if an error occurs while saving the item
com.ibm.workplace.wcm.api.exceptions.ProjectException - if an internal error occurs
Since:
7.0

deleteProject

void deleteProject(Workspace workspace,
                   Project project)
                   throws com.ibm.workplace.wcm.api.exceptions.AuthorizationException,
                          com.ibm.workplace.wcm.api.exceptions.DocumentNotFoundException,
                          com.ibm.workplace.wcm.api.exceptions.DocumentDeleteException,
                          com.ibm.workplace.wcm.api.exceptions.DocumentDeleteReferentialIntegrityException,
                          com.ibm.workplace.wcm.api.exceptions.ProjectException
Delete Project object from WCM repository.

Parameters:
workspace - workspace
project - Project to delete
Throws:
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have permission
com.ibm.workplace.wcm.api.exceptions.DocumentNotFoundException - if the item could not be found
com.ibm.workplace.wcm.api.exceptions.DocumentDeleteException - if the item could not be deleted
com.ibm.workplace.wcm.api.exceptions.DocumentDeleteReferentialIntegrityException - if the item cannot be deleted because another item refers to it
com.ibm.workplace.wcm.api.exceptions.ProjectException - if an internal error occurs
Since:
7.0

addItemToProject

Document addItemToProject(Workspace workspace,
                          Project project,
                          WorkflowedDocument workflowedDocument)
                          throws com.ibm.workplace.wcm.api.exceptions.AuthorizationException,
                                 com.ibm.workplace.wcm.api.exceptions.IllegalDocumentTypeException,
                                 com.ibm.workplace.wcm.api.exceptions.DocumentIsLockedException,
                                 com.ibm.workplace.wcm.api.exceptions.MaximumProjectItemsReachedException,
                                 com.ibm.workplace.wcm.api.exceptions.ProjectException
Add a Document into the given Project.

If a new and unsaved Item is passed to this method then the add to Project will only committed after a Workspace.save() is called on the Item.

Parameters:
workspace - workspace
project - Project to which the Document is added.
workflowedDocument - WorkflowedDocument to add to Project
Returns:
Document actually added into the Project
Throws:
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have permission
com.ibm.workplace.wcm.api.exceptions.IllegalDocumentTypeException - if the document of this type cannot be added to a project
com.ibm.workplace.wcm.api.exceptions.DocumentIsLockedException - the item is locked by another user and cannot be added to a project by this user
com.ibm.workplace.wcm.api.exceptions.MaximumProjectItemsReachedException - if no more items can be added to the project
com.ibm.workplace.wcm.api.exceptions.ProjectException - if an internal error has occurred
FirstStageContainsPublishActionException - if the workflowed document has a workflow with the first stage having a published action
java.lang.IllegalArgumentException - if the specified WorkflowedDocument or Project is null
Since:
7.0

removeItemFromProject

void removeItemFromProject(Workspace workspace,
                           Project project,
                           Document document)
                           throws com.ibm.workplace.wcm.api.exceptions.AuthorizationException,
                                  com.ibm.workplace.wcm.api.exceptions.DocumentIsLockedException,
                                  com.ibm.workplace.wcm.api.exceptions.ProjectException
Remove a Document from Project

Parameters:
workspace - workspace
project - Project from which the Document is removed.
document - Document to be removed from Project.
Throws:
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have permission
com.ibm.workplace.wcm.api.exceptions.DocumentIsLockedException - the item is locked by another user and cannot be removed from a project by this user
com.ibm.workplace.wcm.api.exceptions.ProjectException - if an internal error has occurred
java.lang.IllegalArgumentException - if the specified Document or Project is null
Since:
7.0

markItemForDeletion

void markItemForDeletion(Workspace workspace,
                         Project project,
                         Document document)
                         throws com.ibm.workplace.wcm.api.exceptions.AuthorizationException,
                                com.ibm.workplace.wcm.api.exceptions.DocumentNotFoundException,
                                com.ibm.workplace.wcm.api.exceptions.DocumentRetrievalException,
                                com.ibm.workplace.wcm.api.exceptions.DocumentDeleteException,
                                com.ibm.workplace.wcm.api.exceptions.DocumentDeleteReferentialIntegrityException,
                                com.ibm.workplace.wcm.api.exceptions.ProjectException
Set a Document into deleted state.
The item may fail to be marked for deletion if it fails the to meet the following requirements:
  • Project Type: The item cannot be a project
  • Draft Item: the item should be a draft
  • In Project: the item should belong to a project
  • Pending item: the item cannot be pending published
  • Multiple Draft: the published item should have only one draft
  • References to the Mark for Deletion item in the project: all these references should be marked for deletion as well
  • References to the Published Item of the draft (if it has one): make sure these references do not exist
  • Hierarchical Items: if the item is hierarchical then it should not have children
Also note that even if the item is marked for deletion it may still fail to delete successfully with project publish if new references are introduced to the publish item.

Parameters:
workspace - workspace
project - Project in which a item resides in.
document - Document to be marked as deleted.
Throws:
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have permission
com.ibm.workplace.wcm.api.exceptions.DocumentNotFoundException - if the item could not be found
com.ibm.workplace.wcm.api.exceptions.DocumentRetrievalException - if an error occurs while locating the item
com.ibm.workplace.wcm.api.exceptions.DocumentDeleteException - if the item could not be deleted
com.ibm.workplace.wcm.api.exceptions.DocumentDeleteReferentialIntegrityException - if the item cannot be deleted because another item refers to it
com.ibm.workplace.wcm.api.exceptions.ProjectException - if an internal error occurs
Since:
7.0

markItemForDeletion

LocalizedMessageContainer markItemForDeletion(Workspace workspace,
                                              Project project,
                                              Document document,
                                              boolean checkExternalReferences)
                                              throws com.ibm.workplace.wcm.api.exceptions.AuthorizationException,
                                                     com.ibm.workplace.wcm.api.exceptions.DocumentNotFoundException,
                                                     com.ibm.workplace.wcm.api.exceptions.DocumentRetrievalException,
                                                     com.ibm.workplace.wcm.api.exceptions.DocumentDeleteException,
                                                     com.ibm.workplace.wcm.api.exceptions.DocumentDeleteReferentialIntegrityException,
                                                     com.ibm.workplace.wcm.api.exceptions.ProjectException
Set a Document into deleted state.
The item may fail to be marked for deletion if it fails the to meet the following requirements:
  • Project Type: The item cannot be a project
  • Draft Item: the item should be a draft
  • In Project: the item should belong to a project
  • Pending item: the item cannot be pending published
  • Multiple Draft: the published item should have only one draft
  • References to the Mark for Deletion item in the project: all these references should be marked for deletion as well
  • References to the Published Item of the draft (if it has one): make sure these references do not exist
  • Hierarchical Items: if the item is hierarchical then it should not have children
Also note that even if the item is marked for deletion it may still fail to delete successfully with project publish if new references are introduced to the publish item.

Parameters:
workspace - workspace
project - Project in which a item resides in.
document - Document to be marked as deleted.
checkExternalReferences - indicates whether to check for invalid references external to the project
Returns:
a localized message container that contains warning messages as a result of the project external check references parameter
Throws:
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have permission
com.ibm.workplace.wcm.api.exceptions.DocumentNotFoundException - if the item could not be found
com.ibm.workplace.wcm.api.exceptions.DocumentRetrievalException - if an error occurs while locating the item
com.ibm.workplace.wcm.api.exceptions.DocumentDeleteException - if the item could not be deleted
com.ibm.workplace.wcm.api.exceptions.DocumentDeleteReferentialIntegrityException - if the item cannot be deleted because another item refers to it
com.ibm.workplace.wcm.api.exceptions.ProjectException - if an internal error occurs
Since:
8.5

cancelDeletion

void cancelDeletion(Workspace workspace,
                    Project project,
                    Document document)
                    throws com.ibm.workplace.wcm.api.exceptions.AuthorizationException,
                           com.ibm.workplace.wcm.api.exceptions.ProjectException
Clear deletion marking from a Document on a Project

Parameters:
workspace - workspace
project - Project in which a item resides in.
document - Document to be cancelled from deletion marking.
Throws:
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have permission
com.ibm.workplace.wcm.api.exceptions.ProjectException - if an internal error has occurred
Since:
7.0

findProjectsByName

ResultIterator<Project> findProjectsByName(Workspace workspace,
                                           java.lang.String name)
                                           throws com.ibm.workplace.wcm.api.exceptions.QueryServiceException
Obtain existing Project(s) from WCM repository by their name.

Parameters:
workspace - workspace
name - Project name to be retrieved.
Returns:
Obtained Project object(s) with the given name
Throws:
com.ibm.workplace.wcm.api.exceptions.QueryServiceException - if an error occurs doing the query
Since:
7.0

findProjectsByTitle

ResultIterator<Project> findProjectsByTitle(Workspace workspace,
                                            java.lang.String title)
                                            throws com.ibm.workplace.wcm.api.exceptions.QueryServiceException
Obtain existing Project(s) from WCM repository by their title.

Parameters:
workspace - workspace
title - Project title to be retrieved.
Returns:
Obtained Project object(s) with the given title
Throws:
com.ibm.workplace.wcm.api.exceptions.QueryServiceException - if an error occurs doing the query
Since:
7.0

getProjectById

Project getProjectById(Workspace workspace,
                       DocumentId projectDocumentId)
                       throws com.ibm.workplace.wcm.api.exceptions.AuthorizationException,
                              com.ibm.workplace.wcm.api.exceptions.DocumentRetrievalException
Obtain a Project from WCM repository by its DocumentId

Parameters:
workspace - workspace
projectDocumentId - Id of Project to be retrieved.
Returns:
Obtained Project object
Throws:
com.ibm.workplace.wcm.api.exceptions.AuthorizationException - if the current user does not have permission
com.ibm.workplace.wcm.api.exceptions.DocumentRetrievalException - if an error occurs while locating the item
Since:
7.0

findProjectsByState

ResultIterator<Project> findProjectsByState(Workspace workspace,
                                            ProjectStateSelectors.State projectState)
                                            throws com.ibm.workplace.wcm.api.exceptions.QueryServiceException
Obtain a Project from WCM repository with its project state.

Parameters:
workspace - workspace
projectState - project state defined by ProjectStateSelectors.State
Returns:
Retrieved projects
Throws:
com.ibm.workplace.wcm.api.exceptions.QueryServiceException - if an error occurs doing the query
Since:
7.0