コード例 #1
0
 /*
  * (non-Javadoc)
  * @see org.encuestame.core.service.SetupOperations#demoInstall()
  */
 @Override
 public void demoInstall() {
     try {
         this.csvParser.executeCSVDemoInstall(EnMePlaceHolderConfigurer
                 .getIntegerProperty("demo.votes.by.tppoll"),
                 EnMePlaceHolderConfigurer
                 .getIntegerProperty("demo.votes.by.poll"),
                 EnMePlaceHolderConfigurer
                 .getIntegerProperty("demo.votes.by.survey"));
     } catch (Exception e) {
         e.printStackTrace();
         log.fatal(e);
         RequestSessionMap.setErrorMessage(e.getMessage());
     }
 }
コード例 #2
0
 /*
  * (non-Javadoc)
  * @see org.encuestame.core.service.SetupOperations#validateInstall()
  */
 public void validateInstall() {
     log.debug("validateInstall ------------");
     final XMLConfigurationFileSupport config = EnMePlaceHolderConfigurer.getConfigurationManager();
     log.debug("validateInstall ------------"+config.getXmlConfiguration().getBasePath());
     config.getXmlConfiguration().addProperty("install.date", DateUtil.getCurrentFormatedDate());
     config.getXmlConfiguration().addProperty("install.uuid", RandomStringUtils.randomAlphanumeric(50));
     log.debug("validateInstall ------------");
 }
コード例 #3
0
 /**
  * Check status version.
  * @return the status.
  */
 public String checkStatus() {
     //TODO: replace by ENUMs
     log.debug("Check Version Status");
     String status = "install";
     final String currentVersion = EnMePlaceHolderConfigurer.getProperty("app.version");
     log.debug("Current Version : "+ currentVersion);
     final String installedVersion = EnMePlaceHolderConfigurer.getConfigurationManager().getInstalledVersion();
     log.debug("Installed Version : "+installedVersion);
     if (installedVersion != null) {
         float f1 = Float.valueOf(cleanVersion(currentVersion));
         log.debug("Current Version : "+f1);
         float f2 = Float.valueOf(cleanVersion(installedVersion));
         log.debug("Installed Version : "+f2);
         if (f2 < f1) {
             status = "upgrade";
         }
     }
     return status;
 }
コード例 #4
0
 /*
  * (non-Javadoc)
  * @see org.encuestame.core.service.SetupOperations#loadInstallParameters()
  */
 @Override
 public List<String> loadInstallParameters() {
     final List<String> parameters = new ArrayList<String>();
     parameters.add(this.createParameter("database", EnMePlaceHolderConfigurer.getProperty("datasource.database")));
     parameters.add(this.createParameter("jdbc-url", EnMePlaceHolderConfigurer.getProperty("datasource.urldb")));
     parameters.add(this.createParameter("jdbc-driver", EnMePlaceHolderConfigurer.getProperty("datasource.classname")));
     parameters.add(this.createParameter("username", EnMePlaceHolderConfigurer.getProperty("datasource.userbd")));
     parameters.add(this.createParameter("password", EnMePlaceHolderConfigurer.getProperty("datasource.pass")));
     parameters.add(this.createParameter("dialect", EnMePlaceHolderConfigurer.getProperty("datasource.dialect")));
     return parameters;
 }
コード例 #5
0
 /**
  * Public Tweet Poll (OAuth method).
  *
  * @param tweetText tweet text
  * @return status of tweet
  * @throws EnMeExpcetion exception
  */
 public TweetPublishedMetadata publicTweetPoll(
     final String tweetText, final SocialAccount socialAccount, final Set<HashTag> hashtags)
     throws EnMeExpcetion {
   TweetPublishedMetadata published = new TweetPublishedMetadata();
   log.debug("publicTweetPoll:{ " + tweetText);
   if (socialAccount.getAccounType().equals(SocialProvider.TWITTER)) {
     log.debug("Publish on TWITTER");
     final TwitterAPIOperations twitterAPIOperations =
         new TwitterAPITemplate(
             EnMePlaceHolderConfigurer.getProperty("twitter.oauth.consumerSecret"),
             EnMePlaceHolderConfigurer.getProperty("twitter.oauth.consumerKey"),
             socialAccount);
     try {
       published = twitterAPIOperations.updateStatus(tweetText);
     } catch (Exception e) {
       log.error(e);
       e.printStackTrace();
     }
   } else if (socialAccount.getAccounType().equals(SocialProvider.IDENTICA)) {
     log.debug("Publish on IDENTICA");
     final IdenticaAPIOperations identicaAPIOperations =
         new IdenticaAPITemplate(
             EnMePlaceHolderConfigurer.getProperty("identica.consumer.key"),
             EnMePlaceHolderConfigurer.getProperty("identica.consumer.secret"),
             socialAccount.getAccessToken(),
             socialAccount.getSecretToken());
     try {
       log.debug("Publish on Identica............>");
       published = identicaAPIOperations.updateStatus(tweetText);
       log.debug("Publish on Identica...... " + published);
     } catch (Exception e) {
       published.setDatePublished(Calendar.getInstance().getTime());
       log.error(e);
       e.printStackTrace();
     }
   } else if (socialAccount.getAccounType().equals(SocialProvider.PLURK)) {
     log.debug("Publish on PLURK");
     final PlurkAPIOperations tumblrAPIOperations =
         new PlurkAPITemplate(
             EnMePlaceHolderConfigurer.getProperty("plurk.consumer.key"),
             EnMePlaceHolderConfigurer.getProperty("plurk.consumer.secret"),
             socialAccount.getAccessToken(),
             socialAccount.getSecretToken());
     try {
       log.debug("Publish on Identica............>");
       published = tumblrAPIOperations.updateStatus(tweetText);
       log.debug("Publish on Identica...... " + published);
     } catch (Exception e) {
       published.setDatePublished(Calendar.getInstance().getTime());
       log.error(e);
       e.printStackTrace();
     }
   } else if (socialAccount.getAccounType().equals(SocialProvider.TUMBLR)) {
     log.debug("Publish on TUMBLR");
     final TumblrAPIOperations tumblrAPIOperations =
         new TumblrAPITemplate(
             EnMePlaceHolderConfigurer.getProperty("tumblr.consumer.key"),
             EnMePlaceHolderConfigurer.getProperty("tumblr.consumer.secret"),
             socialAccount.getAccessToken(),
             socialAccount.getSecretToken());
     try {
       log.debug("Publish on TUMBLR............>");
       published = tumblrAPIOperations.updateStatus(tweetText, socialAccount, hashtags);
       log.debug("Publish on TUMBLR...... " + published);
     } catch (Exception e) {
       published.setDatePublished(Calendar.getInstance().getTime());
       log.error(e);
       e.printStackTrace();
     }
   } else if (socialAccount.getAccounType().equals(SocialProvider.FACEBOOK)) {
     log.debug("Publish on FACEBOOK");
     FacebookAPIOperations facebookAPIOperations =
         new FacebookAPITemplate(socialAccount.getAccessToken());
     try {
       log.debug("Publish on FACEBOOK............>");
       published = facebookAPIOperations.updateStatus(tweetText);
       log.debug("Publish on FACEBOOK...... " + published);
       published.setDatePublished(Calendar.getInstance().getTime());
     } catch (HttpClientErrorException e) {
       log.error("-----------------------FACEBOOK EXPIRED TOKEN----------------------- 1");
       log.error(e.getStatusCode());
       log.error(e.getResponseBodyAsString());
       log.error(e.getStatusText());
       published.setDatePublished(Calendar.getInstance().getTime());
       // refresh token point.
       // offline_access scope permission is enabled by default . In this case
       // https://developers.facebook.com/docs/authentication/permissions/
       log.error("-----------------------FACEBOOK EXPIRED TOKEN----------------------- 2");
       e.printStackTrace();
     } catch (Exception e) {
       published.setDatePublished(Calendar.getInstance().getTime());
       log.error(e);
       e.printStackTrace();
     }
   } else if (socialAccount.getAccounType().equals(SocialProvider.LINKEDIN)) {
     log.debug("Publish on LinkedIn");
     LinkedInAPIOperations linkedInAPIOperations =
         new LinkedInAPITemplate(
             EnMePlaceHolderConfigurer.getProperty("linkedIn.oauth.api.key"),
             EnMePlaceHolderConfigurer.getProperty("linkedIn.oauth.api.secret"),
             socialAccount.getAccessToken(),
             socialAccount.getSecretToken());
     try {
       log.debug("Publish on LinkedIn 1............>");
       published = linkedInAPIOperations.updateStatus(tweetText);
       published.setTextTweeted(tweetText);
       published.setDatePublished(Calendar.getInstance().getTime());
       published.setTweetId(RandomStringUtils.randomAscii(15));
       log.debug("Publish on LinkedIn 2...... " + published);
     } catch (Exception e) {
       published.setDatePublished(Calendar.getInstance().getTime());
       log.error(e);
       e.printStackTrace();
     }
   } else if (socialAccount.getAccounType().equals(SocialProvider.GOOGLE_BUZZ)) {
     BuzzAPIOperations buzzInAPIOperations = new GoogleBuzzAPITemplate(socialAccount);
     try {
       log.debug("Publish on LinkedIn............>");
       published = buzzInAPIOperations.updateStatus(tweetText);
       published.setTextTweeted(tweetText);
       published.setDatePublished(Calendar.getInstance().getTime());
       published.setTweetId(RandomStringUtils.randomAscii(15));
       log.debug("Publish on LinkedIn...... " + published);
     } catch (Exception e) {
       published.setDatePublished(Calendar.getInstance().getTime());
       log.error(e);
       e.printStackTrace();
     }
   }
   if (published != null) {
     log.debug("publicTweetPoll:s " + published.toString());
   }
   return published;
 }
コード例 #6
0
 /**
  *
  * @return
  */
 @Deprecated
 private String getTypeDatabase() {
     final String typeDatabase = EnMePlaceHolderConfigurer
             .getConfigurationManager().getProperty("database.type");
     return typeDatabase;
 }