Fixing social post creation
This commit is contained in:
parent
78b1bb6639
commit
9b1190f359
|
@ -8,10 +8,13 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.gcube.gcat.configuration.CatalogueConfigurationFactory;
|
||||
import org.gcube.gcat.persistence.ckan.CKANUserCache;
|
||||
import org.gcube.gcat.utils.Constants;
|
||||
import org.gcube.portal.databook.shared.Post;
|
||||
import org.gcube.social_networking.social_networking_client_library.PostClient;
|
||||
import org.gcube.social_networking.socialnetworking.model.beans.PostInputBean;
|
||||
|
@ -126,7 +129,7 @@ public class SocialPost extends Thread {
|
|||
}
|
||||
|
||||
public void sendSocialPost(boolean notifyUsers) {
|
||||
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
try {
|
||||
String fullName = CKANUserCache.getCurrrentCKANUser().getNameSurname();
|
||||
|
||||
|
@ -148,6 +151,9 @@ public class SocialPost extends Thread {
|
|||
|
||||
logger.debug("The social post that is going to be written is\n{}", message);
|
||||
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
secretManager.startSession(secret);
|
||||
|
||||
logger.trace("The user is going to send the social post is {}", SecretManagerProvider.instance.get().getUser().getUsername());
|
||||
|
||||
logger.trace("SecurityTokenProvider : {}", SecurityTokenProvider.instance.get());
|
||||
|
@ -160,9 +166,10 @@ public class SocialPost extends Thread {
|
|||
Post post = postClient.writeApplicationPost(postInputBean);
|
||||
logger.trace("Sent post {}", post);
|
||||
|
||||
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to send Social Post", e);
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue