Skip to content

Commit 4775ba7

Browse files
authored
Merge branch 'main' into 8792-qa-affiliations-and-professional-activities-in-the-summary-page-should-be-sorted-like-in-the-public-page
2 parents 64d073b + 90071ed commit 4775ba7

5 files changed

Lines changed: 69 additions & 60 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## v2.38.5 - 2023-08-18
2+
3+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.4...v2.38.5)
4+
5+
- [#6873](https://github.com/ORCID/ORCID-Source/pull/6873): send-deactivate-account.json should be a POST action, since we are as…
6+
7+
## v2.38.4 - 2023-08-17
8+
9+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.3...v2.38.4)
10+
11+
- [#6871](https://github.com/ORCID/ORCID-Source/pull/6871): Fixed the s3 auth , code formatting
12+
113
## v2.38.3 - 2023-08-16
214

315
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.2...v2.38.3)

orcid-core/src/main/java/org/orcid/core/manager/impl/OrgManagerImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.orcid.core.manager.OrgManager;
1010
import org.orcid.core.manager.SourceManager;
1111
import org.orcid.core.manager.read_only.ClientDetailsManagerReadOnly;
12+
import org.orcid.core.utils.OrcidStringUtils;
1213
import org.orcid.jaxb.model.common_v2.OrganizationHolder;
1314
import org.orcid.jaxb.model.message.Iso3166Country;
1415
import org.orcid.jaxb.model.message.Organization;
@@ -20,7 +21,6 @@
2021
import org.orcid.persistence.jpa.entities.OrgEntity;
2122
import org.orcid.persistence.jpa.entities.ProfileEntity;
2223
import org.orcid.persistence.jpa.entities.SourceEntity;
23-
import org.orcid.core.utils.OrcidStringUtils;
2424

2525
import au.com.bytecode.opencsv.CSVWriter;
2626

@@ -157,10 +157,10 @@ public OrgEntity getOrgEntity(OrganizationHolder holder) {
157157

158158
OrgEntity orgEntity = new OrgEntity();
159159
org.orcid.jaxb.model.common_v2.Organization organization = holder.getOrganization();
160-
orgEntity.setName(organization.getName());
160+
orgEntity.setName(organization.getName().trim());
161161
org.orcid.jaxb.model.common_v2.OrganizationAddress address = organization.getAddress();
162-
orgEntity.setCity(address.getCity());
163-
orgEntity.setRegion(address.getRegion() != null ? address.getRegion() : "");
162+
orgEntity.setCity(address.getCity().trim());
163+
orgEntity.setRegion(address.getRegion() != null ? address.getRegion().trim() : "");
164164
orgEntity.setCountry(address.getCountry().value());
165165
if (organization.getDisambiguatedOrganization() != null && organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier() != null) {
166166
OrgDisambiguatedEntity disambiguatedOrg = orgDisambiguatedDao.findBySourceIdAndSourceType(

orcid-core/src/main/java/org/orcid/core/manager/v3/impl/OrgManagerImpl.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ public OrgEntity getOrgEntity(OrganizationHolder holder) {
154154

155155
private OrgEntity getOrgEntity(org.orcid.jaxb.model.v3.release.common.Organization organization) {
156156
OrgEntity orgEntity = new OrgEntity();
157-
orgEntity.setName(organization.getName());
157+
orgEntity.setName(organization.getName().trim());
158158
org.orcid.jaxb.model.v3.release.common.OrganizationAddress address = organization.getAddress();
159-
orgEntity.setCity(address.getCity());
160-
orgEntity.setRegion(address.getRegion() != null ? address.getRegion() : "");
159+
orgEntity.setCity(address.getCity().trim());
160+
orgEntity.setRegion(address.getRegion() != null ? address.getRegion().trim() : "");
161161
orgEntity.setCountry(address.getCountry().name());
162162

163163
if (organization.getDisambiguatedOrganization() != null && organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier() != null) {
@@ -275,6 +275,4 @@ private void updatePeerReviewOrgReferences(OrgEntity orgToReference, Long previo
275275
peerReviewDao.merge(p);
276276
});
277277
}
278-
279-
280278
}

orcid-scheduler-web/src/main/java/org/orcid/scheduler/autospam/cli/AutoLockSpamRecords.java

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
public class AutoLockSpamRecords {
5353

5454
private static final Logger LOG = LoggerFactory.getLogger(AutoLockSpamRecords.class);
55-
55+
5656
@Resource
5757
private SlackManager slackManager;
5858

@@ -61,48 +61,49 @@ public class AutoLockSpamRecords {
6161

6262
@Value("${org.orcid.core.orgs.load.slackUser}")
6363
private String slackUser;
64-
64+
6565
@Value("${org.orcid.message-listener.s3.accessKey}")
6666
private String S3_ACCESS_KEY;
67-
67+
6868
@Value("${org.orcid.message-listener.s3.secretKey}")
6969
private String S3_SECRET_KEY;
70-
70+
7171
@Value("${org.orcid.scheduler.aws.bucket:auto-spam-folder}")
7272
private String SPAM_BUCKET;
73-
73+
7474
@Value("${org.orcid.scheduler.aws.file:orcidspam.csv}")
7575
private String ORCID_S3_SPAM_FILE;
76-
76+
7777
@Value("${org.orcid.scheduler.autospam.enabled:false}")
7878
private boolean AUTOSPAM_ENABLED;
79-
79+
8080
@Value("${org.orcid.scheduler.autospam.file:orcidspam.csv}")
8181
private String ORCID_SPAM_FILE;
82-
82+
8383
@Value("${org.orcid.scheduler.autospam.daily.batch:20000}")
8484
private int DAILY_BATCH_SIZE;
85-
85+
8686
@Resource(name = "notificationManagerV3")
8787
private NotificationManager notificationManager;
88-
89-
@Resource(name="orcidOauth2TokenDetailDao")
88+
89+
@Resource(name = "orcidOauth2TokenDetailDao")
9090
private OrcidOauth2TokenDetailDao orcidOauthDao;
9191

9292
private static int ONE_DAY = 86400000;
9393

94+
@Resource(name = "profileEntityManagerV3")
9495
private ProfileEntityManager profileEntityManager;
95-
96+
9697
@Resource
9798
private ProfileEntityCacheManager profileEntityCacheManager;
98-
99-
@Resource
99+
100+
@Resource
100101
private AutospamEmailSender autospamEmailSender;
101-
102+
102103
@Resource
103104
private AffiliationsManager affiliationsManager;
104105

105-
//for running spam manually
106+
// for running spam manually
106107
public static void main(String[] args) {
107108
AutoLockSpamRecords autolockSpamRecords = new AutoLockSpamRecords();
108109
try {
@@ -125,16 +126,17 @@ private void autolockRecords(List<String> toLock) {
125126
for (String orcidId : toLock) {
126127
try {
127128
LOG.info("Processing orcidId: " + orcidId);
128-
if(OrcidStringUtils.isValidOrcid(orcidId)) {
129+
if (OrcidStringUtils.isValidOrcid(orcidId)) {
129130
ProfileEntity profileEntity = profileEntityManager.findByOrcid(orcidId);
130-
//only lock account was not reviewed and not already locked and not have an auth token
131-
132-
if(!profileEntity.isReviewed() && profileEntity.isAccountNonLocked() && !orcidOauthDao.hasToken(orcidId)) {
131+
// only lock account was not reviewed and not already locked
132+
// and not have an auth token
133+
134+
if (profileEntity != null && !profileEntity.isReviewed() && profileEntity.isAccountNonLocked() && !orcidOauthDao.hasToken(orcidId)) {
133135
List<Affiliation> affiliations = affiliationsManager.getAffiliations(orcidId);
134-
//Lock only if doesn't have any affiliations
135-
if(affiliations == null || affiliations.size() < 1) {
136+
// Lock only if doesn't have any affiliations
137+
if (affiliations == null || affiliations.size() < 1) {
136138
boolean wasLocked = profileEntityManager.lockProfile(orcidId, LockReason.SPAM_AUTO.getLabel(), "ML Detected", "");
137-
if(wasLocked) {
139+
if (wasLocked) {
138140
autospamEmailSender.sendOrcidLockedEmail(orcidId);
139141
accountsLocked++;
140142
}
@@ -144,45 +146,46 @@ private void autolockRecords(List<String> toLock) {
144146
}
145147
} catch (Exception e) {
146148
LOG.error("Exception when locking spam record " + orcidId, e);
147-
slackManager.sendAlert("Exception when locking spam record " + orcidId + ". LastOrcid processed is: " + lastOrcidProcessed , slackChannel, slackUser);
149+
slackManager.sendAlert("Exception when locking spam record " + orcidId + ". LastOrcid processed is: " + lastOrcidProcessed, slackChannel, slackUser);
148150
LOG.info("LastOrcid processed is: " + lastOrcidProcessed);
149151
e.printStackTrace();
150152
}
151153
}
152-
System.out.println("Spam locking for the batch processed on the day: " + System.currentTimeMillis() + " lastOrcid processed is: " + lastOrcidProcessed + " acccounts locked in DB: " + accountsLocked);
153-
LOG.info("Spam locking for the batch processed on the day: " + System.currentTimeMillis() + " lastOrcid processed is: " + lastOrcidProcessed + " acccounts locked in DB: " + accountsLocked);
154-
slackManager.sendAlert("Spam locking for the batch processed on the day ended. LastOrcid processed is: " + lastOrcidProcessed + " acccounts locked in DB: " + accountsLocked, slackChannel, slackUser);
155-
}
156-
157-
154+
System.out.println("Spam locking for the batch processed on the day: " + System.currentTimeMillis() + " lastOrcid processed is: " + lastOrcidProcessed
155+
+ " acccounts locked in DB: " + accountsLocked);
156+
LOG.info("Spam locking for the batch processed on the day: " + System.currentTimeMillis() + " lastOrcid processed is: " + lastOrcidProcessed
157+
+ " acccounts locked in DB: " + accountsLocked);
158+
slackManager.sendAlert(
159+
"Spam locking for the batch processed on the day ended. LastOrcid processed is: " + lastOrcidProcessed + " acccounts locked in DB: " + accountsLocked,
160+
slackChannel, slackUser);
161+
}
162+
158163
public void scheduledProcess() throws InterruptedException, IOException {
159-
if(AUTOSPAM_ENABLED) {
164+
if (AUTOSPAM_ENABLED) {
160165
process(true);
161-
}
166+
}
162167
}
163168

164-
165169
public void process(boolean fromS3) throws InterruptedException, IOException {
166170
List<String> allIDs = getAllSpamIDs(fromS3);
167171
System.out.println("Found " + allIDs.size() + " profiles for autolocking. Starting the autolocking process");
168172
slackManager.sendAlert("Found " + allIDs.size() + " profiles for autolocking.", slackChannel, slackUser);
169173
LOG.info("Found {} profiles for autolocking", allIDs.size());
170-
174+
171175
List<String> toLock = getNextIdSubset(allIDs);
172176
while (toLock != null && !toLock.isEmpty()) {
173177
autolockRecords(toLock);
174178
LOG.info("Locked {} profiles, {} remaining to lock", new Object[] { toLock.size(), allIDs.size() });
175179
LOG.info("Profiles autolocked");
176180
Thread.sleep(ONE_DAY);
177-
if(allIDs.size() - toLock.size() <=0) {
181+
if (allIDs.size() - toLock.size() <= 0) {
178182
break;
179-
}
180-
else {
183+
} else {
181184
toLock = getNextIdSubset(allIDs);
182185
}
183-
}
186+
}
184187
}
185-
188+
186189
@SuppressWarnings("resource")
187190
private void init() {
188191
ApplicationContext context = new ClassPathXmlApplicationContext("orcid-scheduler-context.xml");
@@ -205,17 +208,14 @@ private List<String> getNextIdSubset(List<String> ids) {
205208

206209
private ArrayList<String> getAllSpamIDs(boolean fromS3) throws IOException {
207210
Reader reader;
208-
if(fromS3) {
209-
BasicAWSCredentials creds = new BasicAWSCredentials(S3_SECRET_KEY, S3_ACCESS_KEY);
210-
AmazonS3 s3 = AmazonS3Client.builder()
211-
.withRegion(Regions.US_EAST_2)
212-
.withCredentials(new AWSStaticCredentialsProvider(creds))
213-
.build();
214-
211+
if (fromS3) {
212+
BasicAWSCredentials creds = new BasicAWSCredentials(S3_ACCESS_KEY, S3_SECRET_KEY);
213+
AmazonS3 s3 = AmazonS3Client.builder().withRegion(Regions.US_EAST_2).withCredentials(new AWSStaticCredentialsProvider(creds)).build();
214+
215215
S3Object response = s3.getObject(new GetObjectRequest(SPAM_BUCKET, ORCID_S3_SPAM_FILE));
216216
byte[] byteArray = IOUtils.toByteArray(response.getObjectContent());
217217
reader = new InputStreamReader(new ByteArrayInputStream(byteArray));
218-
218+
219219
} else {
220220
reader = new FileReader(ORCID_SPAM_FILE);
221221
}
@@ -232,10 +232,9 @@ private ArrayList<String> getAllSpamIDs(boolean fromS3) throws IOException {
232232
return spamList;
233233
}
234234

235-
236235
private static void bootstrapTogglz(OrcidTogglzConfiguration togglzConfig) {
237236
FeatureManager featureManager = new FeatureManagerBuilder().togglzConfig(togglzConfig).build();
238-
ContextClassLoaderFeatureManagerProvider.bind(featureManager);
239-
}
237+
ContextClassLoaderFeatureManagerProvider.bind(featureManager);
238+
}
240239

241240
}

orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht
515515
return new Errors();
516516
}
517517

518-
@RequestMapping(value = "/send-deactivate-account.json", method = RequestMethod.GET)
518+
@RequestMapping(value = "/send-deactivate-account.json", method = RequestMethod.POST)
519519
public @ResponseBody String startDeactivateOrcidAccount(HttpServletRequest request) {
520520
String currentUserOrcid = getCurrentUserOrcid();
521521
recordEmailSender.sendOrcidDeactivateEmail(currentUserOrcid);

0 commit comments

Comments
 (0)