Package com.esri.gpt.framework.jsf

Examples of com.esri.gpt.framework.jsf.MessageBroker


* @param context the context associated with the active request
* @throws Exception if an exception occurs
*/
private void executeRecoverPassword(ActionEvent event, RequestContext context)
  throws Exception {
  MessageBroker msgBroker = extractMessageBroker();
  try {
   
    // initialize parameters, recover the password
    String sUsername = getRecoverPasswordCriteria().getUsername();
    String sEmail = getRecoverPasswordCriteria().getEmailAddress();
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    User user = idAdapter.recoverPassword(getRecoverPasswordCriteria());
    if (user != null) {
     
      // get the new password
      UsernamePasswordCredentials upCred;
      upCred = user.getCredentials().getUsernamePasswordCredentials();
      String sPassword = upCred.getPassword();
     
      // send mail with the new password
      String[] args = new String[2];
      args[0] = sUsername;
      args[1] = sPassword;
      String sSubject = msgBroker.retrieveMessage("identity.forgotPassword.email.subject");
      String sBody = msgBroker.retrieveMessage("identity.forgotPassword.email.body",args);
      ApplicationConfiguration appConfig = context.getApplicationConfiguration();
      MailRequest mailReq = appConfig.getMailConfiguration().newOutboundRequest();
      mailReq.setToAddress(sEmail);
      mailReq.setSubject(sSubject);
      mailReq.setBody(sBody);
      mailReq.send();
     
      // add the success message, set the navigation outcome
      msgBroker.addSuccessMessage("identity.forgotPassword.success");
      setNavigationOutcome(ResourceKeys.NAVIGATIONOUTCOME_HOME_DIRECT);
    } else {
     
      // add the error message
      msgBroker.addErrorMessage("identity.forgotPassword.err.denied");
    }
  } finally {
  }
}
View Full Code Here


     */
    public MessageBroker getMsgBroker() {
      if (msgBroker!=null) {
        return msgBroker;
      } else {
        MessageBroker mb = new MessageBroker();
        mb.setBundleBaseName(MessageBroker.DEFAULT_BUNDLE_BASE_NAME);
        return mb;
      }
    }
View Full Code Here

public UIComponent makeInputComponent(UiContext context,
                                      Section section,
                                      Parameter parameter) {
 
  // initialize the panel
  MessageBroker msgBroker = context.extractMessageBroker();
  HtmlPanelGroup panel = new HtmlPanelGroup();
  String sIdPfx = getFacesId();
  panel.setId(sIdPfx);
 
  // build a map of values
  HashMap<String,String> valuesMap = new HashMap<String,String>();
  for (ContentValue value: parameter.getContent().getMultipleValues()) {
    valuesMap.put(value.getValue(),"");
  }
 
  // add a checkbox for each code
  Codes codes = parameter.getContent().getCodes();
  for (Code code: codes.values()) {
   
    // make the checkbox
    String sKey = code.getKey();
    String sFKey = sKey.replace('.','_');
    sFKey = sKey.replace(':','_');
    String sId  = sIdPfx+"-"+sFKey;
    HtmlSelectBooleanCheckbox checkBox = new HtmlSelectBooleanCheckbox();
    checkBox.setId(sId);
    checkBox.setDisabled(!getEditable());
    checkBox.setSelected(valuesMap.containsKey(sKey));
    checkBox.setOnchange(getOnChange());
    checkBox.setOnclick(getOnClick());
    panel.getChildren().add(checkBox);
   
    // make the label
    String sLabel = sKey;
    String sResKey = code.getResourceKey();
    if (sResKey.length() > 0) {
      sLabel = msgBroker.retrieveMessage(sResKey);
    }
    HtmlOutputLabel outLabel = new HtmlOutputLabel();
    // even label has to have unique id (for GlassFish)
    outLabel.setId(sId+"label");
    outLabel.setFor(sId);
View Full Code Here

* @param context the context associated with the active request
* @throws Exception if an exception occurs
*/
private void executeRegisterUser(ActionEvent event, RequestContext context)
  throws Exception {
  MessageBroker msgBroker = extractMessageBroker();
  try {
   
    // register the user,
    // add the success message, set navigation outcome to the home page
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    idAdapter.registerUser(getNewUser());
    msgBroker.addSuccessMessage("catalog.identity.userRegistration.success");
    setNavigationOutcome(ResourceKeys.NAVIGATIONOUTCOME_HOME_DIRECT);
  
    // attempt to login if not single sign-on mode
    boolean bSingleSignOn = false;
    if (!bSingleSignOn) {
     
      // authenticate the user, add the successful login message
      User user = extractRequestContext().getUser();
      user.reset();
      user.setCredentials(getNewUser().getCredentials());
      idAdapter.authenticate(user);
      String[] args = new String[1];
      args[0] = user.getName();
      extractMessageBroker().addSuccessMessage("identity.login.success",args);
    } else {

      // navigate to login page if single sign-on mode
      setNavigationOutcome("catalog.identity.login");
    }
   
  } catch (UsernamePolicyException e) {
    msgBroker.addErrorMessage("identity.profile.err.username");
  } catch (PasswordPolicyException e) {
    msgBroker.addErrorMessage("identity.profile.err.password");
  } catch (PasswordConfirmationException e) {
    msgBroker.addErrorMessage("identity.profile.err.confirm");
  } catch (EmailPolicyException e) {
    msgBroker.addErrorMessage("identity.profile.err.email");
  } catch (javax.naming.NameAlreadyBoundException e) {
    msgBroker.addErrorMessage("identity.profile.err.userExists");
  }
}
View Full Code Here

* @param context the context associated with the active request
* @throws Exception if an exception occurs
*/
private void executeSendFeedback(ActionEvent event, RequestContext context)
  throws Exception {
  MessageBroker msgBroker = extractMessageBroker();
  ApplicationConfiguration appConfig = context.getApplicationConfiguration();
  FeedbackMessage msg = getFeedbackMessage();
 
  // validate parameters
  boolean bOk = true;
  String sName = msg.getFromName();
  String sEmail = msg.getFromAddress();
  String sBody = msg.getBody();
  String sSender = sEmail;
  if (!Val.chkEmail(sEmail)) {
    bOk = false;
    msgBroker.addErrorMessage("identity.feedback.err.email");
  } else if (sBody.length() == 0) {
    bOk = false;
    msgBroker.addErrorMessage("identity.feedback.err.body");
  } else if (sName.length() > 0) {
    sSender = sName;
  }
 
  // send mail if ok
  if (bOk) {
   
    // try to filter out mischievous content
    sSender = sSender.replaceAll("<", "&lt;");
    sBody = sBody.replaceAll("<", "&lt;");
   
    // build the message subject and body
    String[] args = new String[3];
    args[0] = sSender;
    args[1] = sBody;
    args[2] = RequestContext.resolveBaseContextPath((HttpServletRequest) context.getServletRequest());
    String sSubject = msgBroker.retrieveMessage("identity.feedback.email.subject");
    sBody = msgBroker.retrieveMessage("identity.feedback.email.body",args);
   
    // send the message to the site
    MailRequest mailReq = appConfig.getMailConfiguration().newInboundRequest();
    mailReq.setFromAddress(sEmail);
    mailReq.setSubject(sSubject);
    mailReq.setBody(sBody);
    mailReq.send();
   
    // send a copy of the message to the user
    MailRequest mailReqCopy = appConfig.getMailConfiguration().newOutboundRequest();
    mailReqCopy.setToAddress(sEmail);
    mailReqCopy.setSubject(sSubject);
    mailReqCopy.setBody(sBody);
    mailReqCopy.send();     
   
    // add the success message, set the navigation outcome
    msgBroker.addSuccessMessage("identity.feedback.success");
    setNavigationOutcome(ResourceKeys.NAVIGATIONOUTCOME_HOME_DIRECT);
  }
}
View Full Code Here

   
  SavedSearchCriterias savedSearchCriterias =
    saveRpstry.getSavedList(context.getUser());
  if(savedSearchCriterias.size() >=
    SearchConfig.getConfiguredInstance().getMaxSavedSearches()) {
    MessageBroker messageBroker =
      new FacesContextBroker(request,response).extractMessageBroker();
    String message =
      messageBroker.getMessage("catalog.search.error.maxSavedSearchesReached")
        .getSummary();
    writeSavedSearches(request, response, context, message);
    return;
  }
 
  String body = IOUtils.toString(request.getInputStream(), "UTF-8");
  Map<String, String> paramMap = urlToParamMap(body);
 
  String name = "";
  String criteria = "";
  name = paramMap.get("name");
  if("".equals(Val.chkStr(name))) {
    MessageBroker messageBroker =
      new FacesContextBroker(request,response).extractMessageBroker();
    String message =
      messageBroker.getMessage("catalog.search.savedSearches.noSaveName")
        .getSummary();
    writeSavedSearches(request, response, context, message);
    return;
  }
  criteria = Val.chkStr(paramMap.get("criteria"));
View Full Code Here

* @param context the context associated with the active request
* @throws Exception if an exception occurs
*/
private void executeUpdateProfile(ActionEvent event, RequestContext context)
  throws Exception {
  MessageBroker msgBroker = extractMessageBroker();
  try {
   
    // make a temp user to process the update in case of failure
    User user = extractRequestContext().getUser();
    User userUpdate = new User();
    userUpdate.setKey(user.getKey());
    userUpdate.setLocalID(user.getLocalID());
    userUpdate.setDistinguishedName(user.getDistinguishedName());
    userUpdate.setProfile(getActiveUserAttributes());
   
    // execute the update,
    // update the in memory profile for the active user
    // set the success message and navigation outcome
    IdentityAdapter idAdapter = context.newIdentityAdapter();
    idAdapter.updateUserProfile(userUpdate);
    user.setProfile(userUpdate.getProfile());
    msgBroker.addSuccessMessage("catalog.identity.myProfile.success");
    setNavigationOutcome(ResourceKeys.NAVIGATIONOUTCOME_HOME_DIRECT);
   
  } catch (EmailPolicyException e) {
    msgBroker.addErrorMessage("identity.profile.err.email");
  } catch (javax.naming.NameAlreadyBoundException e) {
    msgBroker.addErrorMessage("identity.profile.err.userExists");
  }
}
View Full Code Here

    String criteria = savedCriteria.getCriteria();
    try {
      InputStream inputStream = new ByteArrayInputStream(criteria.getBytes());
      Document doc = XMLUtils.newDocument(new InputSource(inputStream));
      SearchCriteria searchCriteria = new SearchCriteria(doc);
      MessageBroker messageBroker =
        new FacesContextBroker(request,response).extractMessageBroker();
      RestUrlBuilder builder = RestUrlBuilder.newBuilder(context,request,
          messageBroker);
      String id = SearchEngineLocal.ID;
      for(ISearchFilter filter : searchCriteria.getMiscelleniousFilters()) {
View Full Code Here

   this.verbose = true;
  
   ApplicationContext appCtx = ApplicationContext.getInstance();

   // create harvester engine
   MessageBroker messageBroker = new MessageBroker();
   messageBroker.setBundleBaseName(MessageBroker.DEFAULT_BUNDLE_BASE_NAME);
   Harvester harvester = new Harvester(messageBroker, appCtx.getConfiguration().getHarvesterConfiguration());
   appCtx.setHarvestingEngine(harvester);
  
   CfgConfigFileProcessor processor = new CfgConfigFileProcessor();
   processor.processConfigFile(new File(url.getPath()),this,true);
View Full Code Here

TOP

Related Classes of com.esri.gpt.framework.jsf.MessageBroker

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.