Fixing Code to send messages via social
This commit is contained in:
parent
9bb4c11602
commit
e291485133
|
@ -1,4 +1,4 @@
|
||||||
package org.gcube.gcat.moderation.thread;
|
package org.gcube.gcat.moderation.thread.social;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -6,6 +6,7 @@ import java.util.Set;
|
||||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||||
import org.gcube.gcat.api.moderation.CMItemStatus;
|
import org.gcube.gcat.api.moderation.CMItemStatus;
|
||||||
import org.gcube.gcat.api.moderation.Moderated;
|
import org.gcube.gcat.api.moderation.Moderated;
|
||||||
|
import org.gcube.gcat.moderation.thread.ModerationThread;
|
||||||
import org.gcube.gcat.social.Message;
|
import org.gcube.gcat.social.Message;
|
||||||
import org.gcube.gcat.social.SocialUsers;
|
import org.gcube.gcat.social.SocialUsers;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -14,9 +15,9 @@ import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public class MessageModerationThread extends ModerationThread {
|
public class SocialMessageModerationThread extends ModerationThread {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MessageModerationThread.class);
|
private static final Logger logger = LoggerFactory.getLogger(SocialMessageModerationThread.class);
|
||||||
|
|
||||||
protected String getSubject(CMItemStatus cmItemStatus) {
|
protected String getSubject(CMItemStatus cmItemStatus) {
|
||||||
StringWriter stringWriter = new StringWriter();
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
@ -42,8 +43,6 @@ public class MessageModerationThread extends ModerationThread {
|
||||||
@Override
|
@Override
|
||||||
protected void postMessage(CMItemStatus cmItemStatus, String message) throws Exception {
|
protected void postMessage(CMItemStatus cmItemStatus, String message) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -28,7 +28,8 @@ public class Constants {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
InputStream input = Constants.class.getClassLoader().getResourceAsStream(CLIENT_SECRET_FILENAME);
|
InputStream input = Constants.class.getClassLoader().getResourceAsStream(CLIENT_SECRET_FILENAME);
|
||||||
properties.load(input);
|
properties.load(input);
|
||||||
String root = context.substring(0, context.indexOf('/', 1));
|
int index = context.indexOf('/', 1);
|
||||||
|
String root = context.substring(0, index == -1 ? context.length() : index);
|
||||||
clientSecret = properties.getProperty(root);
|
clientSecret = properties.getProperty(root);
|
||||||
}
|
}
|
||||||
return clientSecret;
|
return clientSecret;
|
||||||
|
|
|
@ -37,14 +37,14 @@ public class ContextTest {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//DEFAULT_TEST_SCOPE_NAME = "/pred4s/preprod/preVRE";
|
// DEFAULT_TEST_SCOPE_NAME = "/pred4s/preprod/preVRE";
|
||||||
// DEFAULT_TEST_SCOPE_NAME = "/gcube/devsec/devVRE";
|
// DEFAULT_TEST_SCOPE_NAME = "/gcube/devsec/devVRE";
|
||||||
|
|
||||||
ROOT = "/gcube";
|
ROOT = "/gcube";
|
||||||
// VO = ROOT + "/devsec";
|
VO = ROOT + "/devsec";
|
||||||
// VRE = VO + "/devVRE";
|
VRE = VO + "/devVRE";
|
||||||
VO = ROOT + "/devNext";
|
// VO = ROOT + "/devNext";
|
||||||
VRE = VO + "/NextNext";
|
// VRE = VO + "/NextNext";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
package org.gcube.gcat.utils;
|
package org.gcube.gcat.utils;
|
||||||
|
|
||||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||||
|
import org.gcube.common.authorization.utils.secret.Secret;
|
||||||
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||||
|
import org.gcube.common.keycloak.model.TokenResponse;
|
||||||
import org.gcube.gcat.ContextTest;
|
import org.gcube.gcat.ContextTest;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*/
|
||||||
public class ConstantsTest extends ContextTest {
|
public class ConstantsTest extends ContextTest {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ConstantsTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(ConstantsTest.class);
|
||||||
|
@ -17,12 +22,17 @@ public class ConstantsTest extends ContextTest {
|
||||||
Constants.getCatalogueSecret().getToken());
|
Constants.getCatalogueSecret().getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void decrypt() throws Exception {
|
public void decrypt() throws Exception {
|
||||||
StringEncrypter stringEncrypter = StringEncrypter.getEncrypter();
|
StringEncrypter stringEncrypter = StringEncrypter.getEncrypter();
|
||||||
String decrypted = stringEncrypter.decrypt("w0KVc+78b2yUQsndDh/cXyyRquuwyILTygmoF0Y5Dls=");
|
String decrypted = stringEncrypter.decrypt("w0KVc+78b2yUQsndDh/cXyyRquuwyILTygmoF0Y5Dls=");
|
||||||
logger.debug("{}", decrypted);
|
logger.debug("{}", decrypted);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getToken() throws Exception {
|
||||||
|
Secret secret = Constants.getCatalogueSecret();
|
||||||
|
logger.debug(secret.getToken());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue