Beispiel #1
0
 /* (non-Javadoc)
  * @see org.apache.lenya.cms.usecase.DocumentUsecase#doCheckPreconditions()
  */
 protected void doCheckPreconditions() throws Exception {
   super.doCheckPreconditions();
   RMIProvider rmiProvider = null;
   try {
     rmiProvider = (RMIProvider) this.manager.lookup(RMIProvider.ROLE);
     this.newsletterManager =
         (NewsletterManager) rmiProvider.getRMIObject(NEWSLETTER_MANAGER_NAME);
     Iterator it = this.newsletterManager.getRepositoryNames().iterator();
     ArrayList repositoryNames = new ArrayList();
     while (it.hasNext()) {
       repositoryNames.add(it.next());
     }
     this.setParameter(REPOSITORIES_PARAM_NAME, repositoryNames.toArray());
   } catch (RMIException e) {
     this.addErrorMessage(e.getMessage());
   } catch (RemoteException e) {
     String msg = "Error occured while accessing a remote object: " + NEWSLETTER_MANAGER_NAME;
     getLogger().error(msg, e);
     this.addErrorMessage(msg);
   } finally {
     if (rmiProvider != null) {
       this.manager.release(rmiProvider);
     }
   }
   this.setParameter(STEP_PARAM_NAME, "init");
 }
Beispiel #2
0
 /* (non-Javadoc)
  * @see org.apache.lenya.cms.usecase.AbstractUsecase#advance()
  */
 public void advance() throws UsecaseException {
   super.advance();
   String repository = this.getParameterAsString(REPOSITORY_PARAM_NAME);
   RMIProvider rmiProvider = null;
   try {
     rmiProvider = (RMIProvider) this.manager.lookup(RMIProvider.ROLE);
     this.newsletterManager =
         (NewsletterManager) rmiProvider.getRMIObject(NEWSLETTER_MANAGER_NAME);
     if (!this.newsletterManager.setRepository(repository)) {
       this.addErrorMessage("No repository found with name: " + repository);
     }
     Integer userCount = new Integer(this.newsletterManager.countUsers());
     this.setParameter(USER_COUNT_PARAM_NAME, userCount);
   } catch (RMIException e) {
     this.addErrorMessage(e.getMessage());
   } catch (RemoteException e) {
     String msg = "Error occured while accessing a remote object: " + NEWSLETTER_MANAGER_NAME;
     getLogger().error(msg, e);
     this.addErrorMessage(msg);
   } catch (ServiceException e) {
     throw new UsecaseException(e);
   } finally {
     if (rmiProvider != null) {
       this.manager.release(rmiProvider);
     }
   }
   this.setParameter(STEP_PARAM_NAME, "confirm");
 }
Beispiel #3
0
 /* (non-Javadoc)
  * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
  */
 protected void doExecute() throws Exception {
   super.doExecute();
   String repository = this.getParameterAsString(REPOSITORY_PARAM_NAME);
   String subject = this.getParameterAsString(SUBJECT_PARAM_NAME, "Newsletter");
   RMIProvider rmiProvider = null;
   SourceResolver resolver = null;
   try {
     rmiProvider = (RMIProvider) this.manager.lookup(RMIProvider.ROLE);
     resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
     this.newsletterManager =
         (NewsletterManager) rmiProvider.getRMIObject(NEWSLETTER_MANAGER_NAME);
     if (!this.newsletterManager.setRepository(repository)) {
       this.addInfoMessage("No repository found with name: " + repository);
       return;
     }
     ResourceType resourceType = this.getSourceDocument().getResourceType();
     String formatURI = resourceType.getFormatURI(this.formatName);
     String body = getURIContentsAsString(resolver, formatURI);
     this.newsletterManager.sendMailToRepositoryUsers(
         this.senderEmailAddress, this.senderName, subject, body);
   } catch (RMIException e) {
     this.addErrorMessage(e.getMessage());
   } catch (RemoteException e) {
     String msg = "Error occured while accessing a remote object: " + NEWSLETTER_MANAGER_NAME;
     getLogger().error(msg, e);
     this.addErrorMessage(msg);
     throw new RemoteException(msg, e);
   } catch (ServiceException e) {
     throw new UsecaseException(e);
   } finally {
     if (rmiProvider != null) {
       this.manager.release(rmiProvider);
     }
     if (resolver != null) {
       this.manager.release(resolver);
     }
   }
 }