Package com.m4f.business.domain

Examples of com.m4f.business.domain.Inbox


  @RequestMapping(value="/sendInboxResponse", method=RequestMethod.POST)
  public @ResponseBody String sendInboxResponseEmail(
      @RequestParam(required=true) Long inboxId) {
    try {
      Locale locale = this.getAvailableLanguages().get(0);
      Inbox messageRes = inboxService.getInbox(inboxId, locale);
      Inbox messageReq = null;
      if(messageRes != null) {
        messageReq = inboxService.getInbox(messageRes.getRelatedId(), locale);
      }
      Properties props = new Properties();
      Session session = Session.getDefaultInstance(props, null);   
      try {
        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress(new StringBuffer("admin").append(EMAIL_DOMAIN_SUFFIX).toString(),
            this.getMessage("suggestion.problem.response.from")));
        msg.addRecipient(Message.RecipientType.TO,
                         new InternetAddress(messageReq.getFrom(), messageReq.getName()));
        msg.setSubject(this.getMessage("suggestion.problem.response.subject", messageReq.getId()));
        msg.setText(new StringBuffer(messageRes.getContent()).append("\n\n\n").append(this.getMessage("suggestion.problem.response.advice")).toString());
            Transport.send(msg);
      } catch (AddressException e) {
        LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
          } catch (MessagingException e) {
            LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
          }
         
      LOGGER.info("SENDING SEARCH RESULT TO EMAIL -> " + messageReq.getFrom());
    } catch(Exception e) {
      LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
      return "common.error";
    }
    return "task.launched";
View Full Code Here


    if(result.hasErrors()) {
      return "suggestion.inbox.form";
    }
    try {
      String remoteHost = request.getRemoteAddr() != null ? request.getRemoteAddr() : "";
      Inbox inbox = this.serviceLocator.getInboxService().createInbox();
      inbox.setType(form.getType());
      inbox.setRemoteHost(remoteHost);
      inbox.setUser(Inbox.USER.INTERNAL);
      inbox.setContent(form.getContent());
      inbox.setFrom(principal.getName());
      inbox.setName(principal.getName());
      inbox.setCreated(new Date());
      this.serviceLocator.getInboxService().save(inbox, locale);
    } catch(Exception e) {
      LOGGER.severe(StackTraceUtil.getStackTrace(e));
      return "common.error";
    }
View Full Code Here

  @Secured("ROLE_ADMIN")
  @RequestMapping(value="/delete/{inboxId}", method=RequestMethod.GET)
  public String delete(@PathVariable Long inboxId, Locale locale,
      @RequestHeader("referer") String referer, @RequestHeader("Host") String host) {
    try {
      Inbox inbox = this.serviceLocator.getInboxService().getInbox(inboxId, locale);
      this.serviceLocator.getInboxService().delete(inbox, locale);     
    } catch(Exception e) {
      LOGGER.severe(StackTraceUtil.getStackTrace(e));
      return "common.error";
    }
View Full Code Here

 
  @Secured("ROLE_ADMIN")
  @RequestMapping(value="/detail/{inboxId}", method=RequestMethod.GET)
  public String detail(@PathVariable Long inboxId, Model model, Locale locale) {
    try {
      Inbox inbox = this.serviceLocator.getInboxService().getInbox(inboxId, locale);
      inbox.setReaded(Boolean.TRUE);
      this.serviceLocator.getInboxService().save(inbox, locale);
      model.addAttribute("inbox", inbox);
    } catch(Exception e) {
      LOGGER.severe(StackTraceUtil.getStackTrace(e));
      return "common.error";
View Full Code Here

 
  @Secured("ROLE_ADMIN")
  @RequestMapping(value="/response/{inboxId}", method=RequestMethod.GET)
  public String responseToInboxMessage(Principal principal, @PathVariable Long inboxId, Model model, Locale locale) {
    try {
      Inbox inboxReq = this.serviceLocator.getInboxService().getInbox(inboxId, locale);
      InboxForm inbox = new InboxForm();
      inbox.setFrom(principal.getName());
      model.addAttribute("inboxReq", inboxReq);
      model.addAttribute("inbox", inbox);
    } catch(Exception e) {
View Full Code Here

  @RequestMapping(value="/response/{inboxId}", method=RequestMethod.POST)
  public String sendResponseToInboxMessage(@ModelAttribute("inbox") @Valid Inbox inboxRes, BindingResult result,
      @PathVariable Long inboxId, Model model, Locale locale, @RequestHeader("Host") String host) {
   
    try {
      Inbox inboxReq = this.serviceLocator.getInboxService().getInbox(inboxId, locale);
      if(inboxReq != null) {
        // Some hand setting.
        inboxRes.setRelatedId(inboxReq.getId());
        inboxRes.setFrom("admin@hirubila.m4f.es");
        inboxRes.setUser(USER.INTERNAL);
        inboxRes.setOrigin(ORIGIN.RESPONSE);
        // Save
        this.serviceLocator.getInboxService().save(inboxRes, locale);
View Full Code Here

      model.addAttribute("sent", false);
      return "search.results.error";
    }
    try {
      String host = request.getRemoteAddr() != null ? request.getRemoteAddr() : "";
      Inbox inbox = this.serviceLocator.getInboxService().createInbox();
      inbox.setType(Inbox.TYPE.PROBLEM);
      inbox.setRemoteHost(host);
      inbox.setUser(Inbox.USER.EXTERNAL);
      inbox.setContent(form.getContent());
      inbox.setFrom(form.getFrom());
      inbox.setName(form.getName());
      inbox.setCreated(new Date());
      this.serviceLocator.getInboxService().save(inbox, locale);
    } catch(Exception e) {
      LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
      return "common.error";
    }
View Full Code Here

  @ResponseStatus(HttpStatus.OK)
  public void sendInboxResponseEmail(
      @RequestParam(required=true) Long inboxId) {
    try {
      Locale locale = this.getAvailableLanguages().get(0);
      Inbox messageRes =
          this.serviceLocator.getInboxService().getInbox(inboxId, locale);
      Inbox messageReq = null;
      if(messageRes != null) {
        messageReq =
            this.serviceLocator.getInboxService().getInbox(messageRes.getRelatedId(), locale);
      }
      Properties props = new Properties();
      Session session = Session.getDefaultInstance(props, null);   
      try {
        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress(new StringBuffer("admin").append(EMAIL_DOMAIN_SUFFIX).toString(),
            this.getMessage("suggestion.problem.response.from")));
        msg.addRecipient(Message.RecipientType.TO,
                         new InternetAddress(messageReq.getFrom(), messageReq.getName()));
        msg.setSubject(this.getMessage("suggestion.problem.response.subject", messageReq.getId()));
        msg.setText(new StringBuffer(messageRes.getContent()).append("\n\n\n").append(
            this.getMessage("suggestion.problem.response.advice")).toString());
            Transport.send(msg);
      } catch (AddressException e) {
        LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
          } catch (MessagingException e) {
            LOGGER.log(Level.SEVERE, StackTraceUtil.getStackTrace(e));
          }
         
      LOGGER.info("SENDING SEARCH RESULT TO EMAIL -> " + messageReq.getFrom());
    } catch(Exception e) {
      LOGGER.severe(StackTraceUtil.getStackTrace(e));
    }
  }
View Full Code Here

TOP

Related Classes of com.m4f.business.domain.Inbox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.