/* * Recupère la question et ses réponses selon le profil de l'utilisateur courant, ainsi que ses * destinataires met la question en session */ public Question getQuestion(long questionId) throws QuestionReplyException { Question question = getQuestionManager().getQuestion(questionId); setCurrentQuestion(question); question.writeRecipients(getQuestionManager().getQuestionRecipients(questionId)); question.writeReplies(getRepliesForQuestion(questionId)); return question; }
/* * Enregistre une FAQ */ public long saveNewFAQ() throws QuestionReplyException { newQuestion.setStatus(2); // close newQuestion.setReplyNumber(1); newQuestion.setPublicReplyNumber(1); newQuestion.setPrivateReplyNumber(0); newReply.setPublicReply(1); newReply.setPrivateReply(0); WAPrimaryKey pk = newReply.getPK(); pk.setComponentName(getComponentId()); newReply.setPK(pk); return getQuestionManager().createQuestionReply(newQuestion, newReply); }
/** * @param question the current question-reply question * @param users list of users to notify * @throws QuestionReplyException */ private void notifyTemplateQuestion(Question question, UserDetail[] users) throws QuestionReplyException { try { UserDetail user = getUserDetail(getUserId()); String senderName = user.getFirstName() + " " + user.getLastName(); String subject = getString("questionReply.notification") + getComponentLabel(); // String message = senderName + intro + " \n" + content + "\n \n"; // Get default resource bundle String resource = "com.silverpeas.questionReply.multilang.questionReplyBundle"; ResourceLocator message = new ResourceLocator(resource, I18NHelper.defaultLanguage); // Initialize templates Map<String, SilverpeasTemplate> templates = new HashMap<String, SilverpeasTemplate>(); NotificationMetaData notifMetaData = new NotificationMetaData(NotificationParameters.NORMAL, subject, templates, "question"); List<String> languages = DisplayI18NHelper.getLanguages(); for (String language : languages) { // initialize new resource locator message = new ResourceLocator(resource, language); // Create a new silverpeas template SilverpeasTemplate template = getNewTemplate(); template.setAttribute("UserDetail", user); template.setAttribute("userName", senderName); template.setAttribute("QuestionDetail", question); template.setAttribute("questionTitle", question.getTitle()); template.setAttribute("questionContent", question.getContent()); template.setAttribute("url", question._getPermalink()); templates.put(language, template); notifMetaData.addLanguage( language, message.getString("questionReply.notification", "") + getComponentLabel(), ""); } notifMetaData.setSender(getUserId()); notifMetaData.addUserRecipients(users); // notifMetaData.setLink(question._getURL()); notifMetaData.setSource(getSpaceLabel() + " - " + getComponentLabel()); getNotificationSender().notifyUser(notifMetaData); } catch (Exception e) { throw new QuestionReplyException( "QuestionReplySessionController.notify()", SilverpeasException.ERROR, "questionReply.EX_NOTIFICATION_MANAGER_FAILED", "", e); } }
/* * initialise les destinataires de la question à créer */ public void setNewQuestionRecipients(Collection<String> userIds) { Collection<Recipient> recipients = new ArrayList<Recipient>(); if (userIds != null) { Iterator<String> it = userIds.iterator(); while (it.hasNext()) { String userId = it.next(); Recipient recipient = new Recipient(userId); recipients.add(recipient); } } newQuestion.writeRecipients(recipients); }
public synchronized void deleteCategory(String categoryId) throws QuestionReplyException { try { // pour cette catégorie, rechercher les questions et mettre "" dans la // catégorie Collection<Question> questions = getQuestionsByCategory(categoryId); for (Question question : questions) { question.setCategoryId(""); getQuestionManager().updateQuestion(question); } // suppression de la catégorie NodePK nodePk = new NodePK(categoryId, getComponentId()); getNodeBm().removeNode(nodePk); } catch (Exception e) { throw new QuestionReplyException( "QuestionReplySessioncontroller.deleteCategory()", SilverpeasRuntimeException.ERROR, "QuestionReply.MSG_CATEGORY_NOT_EXIST", e); } }
/** * @param question * @throws QuestionReplyException */ private void notifyQuestion(Question question) throws QuestionReplyException { Collection<Recipient> recipients = question.readRecipients(); UserDetail[] users = new UserDetail[recipients.size()]; Iterator<Recipient> it = recipients.iterator(); int i = 0; while (it.hasNext()) { Recipient recipient = it.next(); users[i] = getUserDetail(recipient.getUserId()); i++; } notifyTemplateQuestion(question, users); }
public String getCurrentQuestionContentId() { String contentId = null; if (currentQuestion != null) { try { ContentManager contentManager = new ContentManager(); contentId = "" + contentManager.getSilverContentId( currentQuestion.getPK().getId(), currentQuestion.getInstanceId()); } catch (ContentManagerException ignored) { SilverTrace.error( "questionReply", "QuestionReplySessionController", "questionReply.EX_UNKNOWN_CONTENT_MANAGER", ignored); contentId = null; } } return contentId; }
public void setNewQuestionContent(String title, String content, String categoryId) { newQuestion.setTitle(title); newQuestion.setContent(content); newQuestion.setCategoryId(categoryId); }
/* * initialise le contenu de la question à créer */ public void setNewQuestionContent(String title, String content) { newQuestion.setTitle(title); newQuestion.setContent(content); }