001: /*
002: * Copyright 2004 Outerthought bvba and Schaubroeck nv
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.outerj.daisy.repository.commonimpl.comment;
017:
018: import org.outerj.daisy.repository.comment.CommentManager;
019: import org.outerj.daisy.repository.comment.Comment;
020: import org.outerj.daisy.repository.comment.Comments;
021: import org.outerj.daisy.repository.comment.CommentVisibility;
022: import org.outerj.daisy.repository.RepositoryException;
023: import org.outerj.daisy.repository.VariantKey;
024: import org.outerj.daisy.repository.variant.Branch;
025: import org.outerj.daisy.repository.variant.Language;
026: import org.outerj.daisy.repository.commonimpl.AuthenticatedUser;
027: import org.outerj.daisy.repository.commonimpl.CommonRepository;
028: import org.outerj.daisy.repository.commonimpl.DocId;
029:
030: public class CommentManagerImpl implements CommentManager {
031: private final CommonRepository repository;
032: private final CommonCommentManager commonCommentManager;
033: private final AuthenticatedUser user;
034:
035: public CommentManagerImpl(CommonRepository repository,
036: AuthenticatedUser user) {
037: this .repository = repository;
038: this .commonCommentManager = repository.getCommentManager();
039: this .user = user;
040: }
041:
042: public Comment addComment(String documentId, long branchId,
043: long languageId, CommentVisibility visibility,
044: String commentText) throws RepositoryException {
045: DocId docId = DocId.parseDocIdThrowNotFound(documentId,
046: repository);
047: return commonCommentManager.addComment(docId, branchId,
048: languageId, visibility, commentText, user);
049: }
050:
051: public Comment addComment(String documentId,
052: CommentVisibility visibility, String commentText)
053: throws RepositoryException {
054: return addComment(documentId, Branch.MAIN_BRANCH_ID,
055: Language.DEFAULT_LANGUAGE_ID, visibility, commentText);
056: }
057:
058: public void deleteComment(String documentId, long branchId,
059: long languageId, long commentId) throws RepositoryException {
060: DocId docId = DocId.parseDocIdThrowNotFound(documentId,
061: repository);
062: commonCommentManager.deleteComment(docId, branchId, languageId,
063: commentId, user);
064: }
065:
066: public void deleteComment(String documentId, long commentId)
067: throws RepositoryException {
068: deleteComment(documentId, Branch.MAIN_BRANCH_ID,
069: Language.DEFAULT_LANGUAGE_ID, commentId);
070: }
071:
072: public void deleteComment(Comment comment)
073: throws RepositoryException {
074: deleteComment(comment.getOwnerDocumentId(), comment
075: .getOwnerBranchId(), comment.getOwnerLanguageId(),
076: comment.getId());
077: }
078:
079: public Comments getComments(String documentId, long branchId,
080: long languageId) throws RepositoryException {
081: DocId docId = DocId.parseDocIdThrowNotFound(documentId,
082: repository);
083: return commonCommentManager.getComments(docId, branchId,
084: languageId, user);
085: }
086:
087: public Comments getComments(VariantKey variantKey)
088: throws RepositoryException {
089: return getComments(variantKey.getDocumentId(), variantKey
090: .getBranchId(), variantKey.getLanguageId());
091: }
092:
093: public Comments getComments(String documentId)
094: throws RepositoryException {
095: return getComments(documentId, Branch.MAIN_BRANCH_ID,
096: Language.DEFAULT_LANGUAGE_ID);
097: }
098:
099: public Comments getComments(CommentVisibility visibility)
100: throws RepositoryException {
101: return commonCommentManager.getComments(visibility, user);
102: }
103:
104: public Comments getComments() throws RepositoryException {
105: return commonCommentManager.getComments(user);
106: }
107: }
|