## com.imcode.imcms.api
Class DocumentService

    java.lang.Object
      com.imcode.imcms.api.DocumentService

    public class DocumentService

extends java.lang.Object

Constructor Summary
`DocumentService(ContentManagementSystem contentManagementSystem)`

Method Summary
`CategoryType` `createNewCategoryType(java.lang.String name, int maxChoices)`
`FileDocument` `createNewFileDocument(Document parent)`
`TextDocument` `createNewTextDocument(Document parent)`
`UrlDocument` `createNewUrlDocument(Document parent)`
`void` `deleteDocument(Document document)`
`Category[]` `getAllCategoriesOfType(CategoryType categoryType)`
`CategoryType[]` `getAllCategoryTypes()`
`Category` `getCategory(CategoryType categoryType, java.lang.String categoryName)`
`Category` `getCategory(int categoryId)`
`CategoryType` `getCategoryType(int categoryTypeId)`
`CategoryType` `getCategoryType(java.lang.String categoryTypeName)`
`Document` `getDocument(int documentId)` Used to get a document of any type.
`Document` `getDocument(java.lang.String documentIdString)` Used to get a document of any type.
`java.util.List` `getDocuments(SearchQuery query)`
`Section` `getSection(int sectionId)`
`Section` `getSection(java.lang.String name)`
`TextDocument` `getTextDocument(int documentId)`
`TextDocument` `getTextDocument(java.lang.String documentIdString)`
`UrlDocument` `getUrlDocument(int documentId)`
`UrlDocument` `getUrlDocument(java.lang.String documentIdString)`
`org.w3c.dom.Document` `getXmlDomForDocument(Document document)`
`SearchQuery` `parseLuceneSearchQuery(java.lang.String query)`
`void` `saveCategory(Category category)`
`void` `saveChanges(Document document)` Saves the changes to a modified document.
`Document[]` `search(SearchQuery query)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DocumentService

    public DocumentService(ContentManagementSystem contentManagementSystem)

Method Detail

### getDocument

    public Document getDocument(java.lang.String documentIdString)
                         throws NoPermissionException

  Used to get a document of any type. If you need a specific document, i.e. a TextDocument, use @see getTextDocument instead.

  Parameters:
    `documentIdString` - The unique id or name of the document requested, can be either the int value also known as "meta_id" or the document name also known as "alias".
  Returns:
    The document The type is usually a subclass to document, if there exist one.
  Throws:
    `NoPermissionException` - If the current user dosen't have the rights to read this document.

### getDocument

    public Document getDocument(int documentId)
                         throws NoPermissionException

  Used to get a document of any type. If you need a specific document, i.e. a TextDocument, use @see getTextDocument instead.

  Parameters:
    `documentId` - The id number of the document requested, also sometimes known as "meta_id"
  Returns:
    The document The type is usually a subclass to document, if there exist one.
  Throws:
    `NoPermissionException` - If the current user dosen't have the rights to read this document.

### getTextDocument

    public TextDocument getTextDocument(java.lang.String documentIdString)
                                 throws NoPermissionException

  Parameters:
    `documentIdString` - The unique id or name of the document requested, can be either the int value alsp known as "meta_id" or the document name also known as "alias".
  Returns:
    The document
  Throws:
    `NoPermissionException` - If the current user dosen't have the rights to read this document.

### getTextDocument

    public TextDocument getTextDocument(int documentId)
                                 throws NoPermissionException

  Parameters:
    `documentId` - The id number of the document requested, also known as "meta_id"
  Returns:
    The document
  Throws:
    `NoPermissionException` - If the current user dosen't have the rights to read this document.

### getUrlDocument

    public UrlDocument getUrlDocument(java.lang.String documentIdString)
                               throws NoPermissionException

  Parameters:
    `documentIdString` - The unique id or name of the document requested, can be either the int value also known as "meta_id" or the document name also known as "alias".
  Returns:
    The document
  Throws:
    `NoPermissionException` - If the current user dosen't have the rights to read this document.

### getUrlDocument

    public UrlDocument getUrlDocument(int documentId)
                               throws NoPermissionException

  Parameters:
    `documentId` - The id number of the document requested, also known as "meta_id"
  Returns:
    The document
  Throws:
    `NoPermissionException` - If the current user dosen't have the rights to read this document.

### createNewTextDocument

    public TextDocument createNewTextDocument(Document parent)
                                       throws NoPermissionException

  Throws:
    `NoPermissionException`

### createNewUrlDocument

    public UrlDocument createNewUrlDocument(Document parent)
                                     throws NoPermissionException

  Throws:
    `NoPermissionException`

### createNewFileDocument

    public FileDocument createNewFileDocument(Document parent)
                                       throws NoPermissionException

  Throws:
    `NoPermissionException`

### saveChanges

    public void saveChanges(Document document)
                     throws NoPermissionException,
                            SaveException

  Saves the changes to a modified document. Note that this method is synchronized.

  Throws:
    `NoPermissionException`
    `SaveException`

### getCategory

    public Category getCategory(CategoryType categoryType,
                                java.lang.String categoryName)

### getCategory

    public Category getCategory(int categoryId)

### getCategoryType

    public CategoryType getCategoryType(int categoryTypeId)

### getCategoryType

    public CategoryType getCategoryType(java.lang.String categoryTypeName)

### getAllCategoriesOfType

    public Category[] getAllCategoriesOfType(CategoryType categoryType)

### getAllCategoryTypes

    public CategoryType[] getAllCategoryTypes()

### createNewCategoryType

    public CategoryType createNewCategoryType(java.lang.String name,
                                              int maxChoices)
                                       throws NoPermissionException,
                                              CategoryTypeAlreadyExistsException

  Parameters:
    `name` -
    `maxChoices` -
  Returns:
    The newly craeated category type.
  Throws:
    `NoPermissionException`
    `CategoryTypeAlreadyExistsException`

### getSection

    public Section getSection(int sectionId)

### getSection

    public Section getSection(java.lang.String name)

  Since:
    2.0

### getDocuments

    public java.util.List getDocuments(SearchQuery query)
                                throws SearchException

  Throws:
    `SearchException`

### search

    public Document[] search(SearchQuery query)
                      throws SearchException

  Throws:
    `SearchException`

### parseLuceneSearchQuery

    public SearchQuery parseLuceneSearchQuery(java.lang.String query)
                                       throws BadQueryException

  Throws:
    `BadQueryException`

### getXmlDomForDocument

    public org.w3c.dom.Document getXmlDomForDocument(Document document)

### saveCategory

    public void saveCategory(Category category)
                      throws NoPermissionException,
                             CategoryAlreadyExistsException

  Throws:
    `NoPermissionException`
    `CategoryAlreadyExistsException`

### deleteDocument

    public void deleteDocument(Document document)
                        throws NoPermissionException

  Throws:
    `NoPermissionException`