Fixing Code to send messages via social

This commit is contained in:
Luca Frosini 2022-03-28 16:03:34 +02:00
parent 9bb4c11602
commit e291485133
4 changed files with 23 additions and 13 deletions

View File

@ -1,4 +1,4 @@
package org.gcube.gcat.moderation.thread;
package org.gcube.gcat.moderation.thread.social;
import java.io.StringWriter;
import java.util.Set;
@ -6,6 +6,7 @@ import java.util.Set;
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.gcat.api.moderation.CMItemStatus;
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.SocialUsers;
import org.slf4j.Logger;
@ -14,9 +15,9 @@ import org.slf4j.LoggerFactory;
/**
* @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) {
StringWriter stringWriter = new StringWriter();
@ -42,8 +43,6 @@ public class MessageModerationThread extends ModerationThread {
@Override
protected void postMessage(CMItemStatus cmItemStatus, String message) throws Exception {
}
@Override

View File

@ -28,7 +28,8 @@ public class Constants {
Properties properties = new Properties();
InputStream input = Constants.class.getClassLoader().getResourceAsStream(CLIENT_SECRET_FILENAME);
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);
}
return clientSecret;

View File

@ -37,14 +37,14 @@ public class ContextTest {
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";
ROOT = "/gcube";
// VO = ROOT + "/devsec";
// VRE = VO + "/devVRE";
VO = ROOT + "/devNext";
VRE = VO + "/NextNext";
VO = ROOT + "/devsec";
VRE = VO + "/devVRE";
// VO = ROOT + "/devNext";
// VRE = VO + "/NextNext";
}

View File

@ -1,12 +1,17 @@
package org.gcube.gcat.utils;
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.keycloak.model.TokenResponse;
import org.gcube.gcat.ContextTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class ConstantsTest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(ConstantsTest.class);
@ -17,12 +22,17 @@ public class ConstantsTest extends ContextTest {
Constants.getCatalogueSecret().getToken());
}
@Test
public void decrypt() throws Exception {
StringEncrypter stringEncrypter = StringEncrypter.getEncrypter();
String decrypted = stringEncrypter.decrypt("w0KVc+78b2yUQsndDh/cXyyRquuwyILTygmoF0Y5Dls=");
logger.debug("{}", decrypted);
}
@Test
public void getToken() throws Exception {
Secret secret = Constants.getCatalogueSecret();
logger.debug(secret.getToken());
}
}