fixed a NPE and a serialization problem

This commit is contained in:
Michele Artini 2023-06-30 10:05:38 +02:00
parent 7a7d2f08ac
commit 3ae2207d38
5 changed files with 38 additions and 12 deletions

View File

@ -49,6 +49,7 @@ import eu.dnetlib.openaire.exporter.model.context.ConceptSummary;
public class CommunityService {
// TODO: Verificare Tickets: #8835, #8854, #6483, #3259, #3494
// L'IMPORT DI ALCUNI PROGETTI FALLISCE perche' non hanno openaireID
@Autowired
private DbCommunityRepository dbCommunityRepository;

View File

@ -6,7 +6,11 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@ -17,8 +21,14 @@ import eu.dnetlib.openaire.common.ISClient;
import eu.dnetlib.openaire.community.model.DbOrganization;
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
import eu.dnetlib.openaire.exporter.model.context.Context;
import io.swagger.v3.oas.annotations.tags.Tag;
@RestController
@CrossOrigin(origins = {
"*"
})
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
@Tag(name = "OpenAIRE Communities: Migration API", description = "OpenAIRE Communities: Migration API")
public class CommunityImporterController {
public final static Set<String> communityBlackList = Sets.newHashSet("fet-fp7", "fet-h2020");
@ -29,20 +39,27 @@ public class CommunityImporterController {
@Autowired
private ISClient isClient;
private static final Log log = LogFactory.getLog(CommunityImporterController.class);
@GetMapping("/community_importer/communities")
public List<String> importProfiles() throws CommunityException {
final Map<String, Context> contextMap = getContextMap();
try {
final Map<String, Context> contextMap = getContextMap();
final List<String> list = contextMap.keySet()
.stream()
.filter(id -> !communityBlackList.contains(id))
.collect(Collectors.toList());
final List<String> list = contextMap.keySet()
.stream()
.filter(id -> !communityBlackList.contains(id))
.collect(Collectors.toList());
list.forEach(id -> {
importer.importCommunity(contextMap.get(id));
});
list.forEach(id -> {
importer.importCommunity(contextMap.get(id));
});
return list;
return list;
} catch (final Throwable e) {
log.error("Error importing communities", e);
throw new CommunityException(e.getMessage());
}
}
@GetMapping("/community_importer/propagationOrgs")

View File

@ -136,8 +136,12 @@ public class CommunityImporterService {
final List<CommunityContentprovider> datasources =
getCommunityInfo(context, CONTENTPROVIDERS_ID_SUFFIX, c -> asCommunityDataprovider(context.getId(), c));
// TODO: REMOVE THIS FILTER ?
final List<CommunityProject> projects =
getCommunityInfo(context, PROJECTS_ID_SUFFIX, c -> asCommunityProject(context.getId(), c));
getCommunityInfo(context, PROJECTS_ID_SUFFIX, c -> asCommunityProject(context.getId(), c))
.stream()
.filter(p -> p.getOpenaireId() != null)
.collect(Collectors.toList());
final List<CommunityOrganization> orgs =
getCommunityInfo(context, ORGANIZATION_ID_SUFFIX, c -> asCommunityOrganization(context.getId(), c));

View File

@ -216,7 +216,7 @@ public class CommunityMappingUtils {
}
private static String[] toStringArray(final List<String> list) {
return list.toArray(new String[list.size()]);
return list != null ? list.toArray(new String[list.size()]) : new String[0];
}
}

View File

@ -1,6 +1,10 @@
package eu.dnetlib.openaire.exporter.model.context;
public class Param {
import java.io.Serializable;
public class Param implements Serializable {
private static final long serialVersionUID = -1534376651378828800L;
private String name;