Package com.ikanow.infinit.e.api.utils

Examples of com.ikanow.infinit.e.api.utils.PropertiesManager


 
    // Setup a list of feeds
    @SuppressWarnings("unchecked")
    List<BasicDBObject> docs = (List<BasicDBObject>) rp.getData();
   
    PropertiesManager props = new PropertiesManager();
   
    // Set the title of the feed
    feed.setTitle( "Infinit.e Knowledge Discovery RSS Feed" );
    feed.setDescription( "Infinit.e Search Results RSS Feed" );
    feed.setLanguage( "en-us" );
    feed.setPublishedDate( new Date( System.currentTimeMillis() ) );
    feed.setFeedType( feedType ); // set the type of your feed
    String urlRoot = props.getUrlRoot();
    if (null != urlRoot) {
      feed.setLink(urlRoot.replace("/api/", ""));
    }
    else { // feed.link needs to be specified, otherwise RSS feed will fail:
      feed.setLink("http://www.ikanow.com/#SET_YOUR_URL_ROOT");
View Full Code Here


  public static AliasManager getAliasManager() {

    synchronized (AliasManager.class) {
      if (_bFirstTime) {
        // Check if (beta) aliasing enabled
        PropertiesManager props = new PropertiesManager();
        if (props.getAliasingEnabled()) {
          if (null == _myself) {
            logger.debug("Initialized alias manager");
           
            return (_myself = new AliasManager());           
          }         
View Full Code Here

// 0] Top level processing
 
  public ResponsePojo doQuery(String userIdStr, AdvancedQueryPojo query, String communityIdStrList, StringBuffer errorString) throws UnknownHostException, MongoException, IOException, InstantiationException, IllegalAccessException {

    if (null == _properties) {
      _properties = new PropertiesManager();
      _aggregationAccuracy = _properties.getAggregationAccuracy();
      _dataModelProps = new com.ikanow.infinit.e.data_model.utils.PropertiesManager();
      _replicaSetDistributionRatio = 1 + _dataModelProps.getDocDbReadDistributionRatio();
     
      String[] queryExtensions = _properties.getQueryExtensions();
View Full Code Here

     ResponsePojo rp = new ResponsePojo();
     Date startTime = new Date()

     if ( !needCookie ) //wordpress calls go here
     {
       PropertiesManager properties = new PropertiesManager();
       boolean allowedToRegisterUpdate = RESTTools.mustComeFromAuthority(properties, ipAddress, cookie, admuser, admpass)

       // Assuming one of the above forms of authentication worked...
      
       if (allowedToRegisterUpdate )
View Full Code Here

        rp.setResponse(new ResponseObject("Logout", false, "Not logged in."));
      }
    }
    else if (this.mustComeFromAuthority)
    {      
      boolean bCanProceed = RESTTools.mustComeFromAuthority(new PropertiesManager(), ipAddress, cookie, admuser, admpass);

      if (bCanProceed)
      {      
        if (action.equals("forgot"))
        {  
View Full Code Here

 
  private void createSecurityPermissions() {     
     
    EmbeddedRestletApp.intializeInfiniteConfig(null, _config.getServletContext());
   
      PropertiesManager pm = new PropertiesManager();
     
      // Trusted hosts:
     
      String trustedHosts = pm.getSaasTrustedDns();
      if (null != trustedHosts) {
        _trustedDnsNames = trustedHosts.split("\\s*,\\s*");       
      }
     
      // Logging:
     
      _loggingEnabled = pm.getApiLoggingEnabled();
      if (_loggingEnabled) {
        String loggingRegex = pm.getApiLoggingRegex();
          if ((null != loggingRegex) && !loggingRegex.trim().isEmpty()) {
            if (loggingRegex.startsWith("*")) { // (log everything that matches the regex)
              _loggingErrorsOnly = false;
              loggingRegex = loggingRegex.substring(1);
            }
            else if (loggingRegex.startsWith("!")) { // (default -log errors only- just remove this char)
              loggingRegex = loggingRegex.substring(1);             
            }
            if (!loggingRegex.isEmpty()) {
              _loggingRegex = Pattern.compile(loggingRegex.trim(), Pattern.CASE_INSENSITIVE);
            }
          }
      }//(else only log failures)
      //TESTED
     
      // Security:
     
      String allow = pm.getRemoteAccessAllow();
      String deny = pm.getRemoteAccessDeny();
      if (((null == allow) || allow.trim().isEmpty()) && ((null == deny) || deny.trim().isEmpty())) {
          _bCreatedSecurityLayer = true;
        return; // no remote access security
      }
      if ((null != allow) && !allow.trim().isEmpty()) {
View Full Code Here

                DbManager.getSocial().getCommunityApprove().insert(cap.toDb());
               
                // Get to addresses for Owner and Moderators
                String toAddresses = getToAddressesFromCommunity(cp);
               
                PropertiesManager propManager = new PropertiesManager();
                String rootUrl = propManager.getUrlRoot();
               
                String subject = pp.getDisplayName() + " is trying to join infinit.e community: " + cp.getName();
                String body = pp.getDisplayName() + " is trying to join infinit.e community: " + cp.getName() + "<br/>Do you want to accept this request?" +
                "<br/><a href=\"" + rootUrl + "social/community/requestresponse/"+cap.get_id().toString() + "/true\">Accept</a> " +
                "<a href=\"" + rootUrl + "social/community/requestresponse/"+cap.get_id().toString() + "/false\">Deny</a>";
               
                SendMail mail = new SendMail(new PropertiesManager().getAdminEmailAddress(), toAddresses, subject, body);
               
                if (mail.send("text/html"))
                {
                  rp.setResponse(new ResponseObject("Join Community",true,"Joined community successfully, awaiting owner approval"));
                  rp.setData(new CommunityApprovalPojo(false));
View Full Code Here

                 
                  //send email out inviting user
                  CommunityApprovePojo cap = cp.createCommunityApprove(personIdStr,communityIdStr,"invite",userIdStr);
                  DbManager.getSocial().getCommunityApprove().insert(cap.toDb());
                 
                  PropertiesManager propManager = new PropertiesManager();
                  String rootUrl = propManager.getUrlRoot();
                 
                  if (null == rootUrl) {
                    rp.setResponse(new ResponseObject("Invite Community",false,"The system was unable to email the invite because an invite was required and root.url is not set up."));
                    return rp;
                  }
                 
                  String subject = "Invite to join infinit.e community: " + cp.getName();
                  String body = "You have been invited to join the community " + cp.getName() +
                    "<br/><a href=\"" + rootUrl + "social/community/requestresponse/"+cap.get_id().toString() + "/true\">Accept</a> " +
                    "<a href=\"" + rootUrl + "social/community/requestresponse/"+cap.get_id().toString() + "/false\">Deny</a>";
                 
                  SendMail mail = new SendMail(new PropertiesManager().getAdminEmailAddress(), pp.getEmail(), subject, body);
                 
                  if (mail.send("text/html"))
                  {
                    if (isSysAdmin) {
                      rp.setResponse(new ResponseObject("Invite Community",true,"Invited user to community successfully: " + cap.get_id().toString()));
View Full Code Here

 
        // Message Body
        String body = "<p>Your new password is: " + newpassword + "</p>";
 
        // Send
        new SendMail(new PropertiesManager().getAdminEmailAddress(), ap.getUsername(), subject, body).send("text/html")
 
        // (Remove new password from end of this message once mailing works, Currently attached just so can use)
        rp.setResponse(new ResponseObject("Reset Password",true,"Password reset successfully, new password has been emailed to user."));
      }//TESTED
      else
      { // Two stage process ... first "forgotten password" just sends email containing link to click on
       
        // To avoid people just hitting this button 1000 times, ensure only sent once per 5 minutes
        if ((now.getTime() - ap.getModified().getTime()) < 300000L) { // ie 300s ie 5mins
          rp.setResponse(new ResponseObject("Reset Password",true,"Password reset request ignored, try later."));
          return rp;
        }//TESTED
       
        // Update auth to ensure this isn't abused
        ap.setModified(now);
        DbManager.getSocial().getAuthentication().save(ap.toDb());
       
        //email new password
        // Subject Line
        String subject = "Request to reset password";
 
        PropertiesManager props = new PropertiesManager();
       
        // Message Body
        StringBuffer newLink = new StringBuffer(props.getUrlRoot()).append("auth/forgotpassword").
                              append("?username=").append(URLEncoder.encode(username, "UTF-8")).
                              append("&password=").append(URLEncoder.encode(ap.getPassword(), "UTF-8"));
        String body = "<p>Click on this link to reset password: " + newLink.toString() + "</p>";
 
        // Send
        new SendMail(props.getAdminEmailAddress(), ap.getUsername(), subject, body).send("text/html")
 
        // (Remove new password from end of this message once mailing works, Currently attached just so can use)
        rp.setResponse(new ResponseObject("Reset Password",true,"Email has been sent containing link to reset password."));
      }//TESTED
    }
View Full Code Here

   
    // Get Information for Person requesting the new source
    PersonPojo p = SocialUtils.getPerson(source.getOwnerId().toString());
   
    // Get the root URL to prepend to the approve/reject link below
    PropertiesManager propManager = new PropertiesManager();
    String rootUrl = propManager.getUrlRoot();
   
    // Subject Line
    String subject = "Approve/Reject New Source: " + source.getTitle();
   
    // Get array of community IDs and get corresponding CommunityPojo objects
    ArrayList<CommunityPojo> communities = SocialUtils.getCommunities(source.getCommunityIds());
   
    // Iterate over the communities and send an email to each set of owner/moderators requesting
    // that the approve or reject the source
    for (CommunityPojo c : communities)
    {
      // Email address or addresses to send to
      // Extract email addresses for owners and moderators from list of community members
      StringBuffer sendTo = new StringBuffer();
      Set<CommunityMemberPojo> members = c.getMembers();
      CommunityMemberPojo owner = null;
      for (CommunityMemberPojo member : members)
      {
        if (member.getUserType().equalsIgnoreCase("owner") || member.getUserType().equalsIgnoreCase("moderator"))
        {
          owner = member;
          if (sendTo.length() > 0) sendTo.append(";");
          sendTo.append(member.getEmail());
        }
      }
      if (0 == sendTo.length()) {
        throw new RuntimeException("community " + c.getName() + " / " + c.getId() + " has no owner/moderator");
      }
     
      //create a community request and post to db
      CommunityApprovePojo cap = new CommunityApprovePojo();
      cap.set_id(new ObjectId());
      cap.setCommunityId( c.getId().toString() );
      cap.setIssueDate(new Date());
      cap.setPersonId(owner.get_id().toString());
      cap.setRequesterId(p.get_id().toString());
      cap.setType("source");
      cap.setSourceId(source.getId().toString());
      DbManager.getSocial().getCommunityApprove().insert(cap.toDb());   
     
      // Message Body
      String body = "<p>" + p.getDisplayName() + " has requested that the following source be " +
        "added to the " + c.getName() + " community:</p>" +
        "<p>" +
        "Title: " + source.getTitle() + "<br/>" +
        "Description: " + source.getDescription() + "<br/>" +
        "URL (eg): " + source.getRepresentativeUrl() + "<br/>" +
        "</p>" +
        "<p>Please click on the Approve or Reject links below to complete the approval process: </p>" +
        "<li><a href=\"" + rootUrl + "social/community/requestresponse/" + cap.get_id().toString() + "/true\">Approve new Source</a></li>" +
        "<li><a href=\"" + rootUrl + "social/community/requestresponse/" + cap.get_id().toString() + "/false\">Reject new Source</a></li>";             
     
      // Send
      new SendMail(new PropertiesManager().getAdminEmailAddress(), sendTo.toString(), subject, body).send("text/html")
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.api.utils.PropertiesManager

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.