fixed a NPE and a serialization problem
This commit is contained in:
parent
7a7d2f08ac
commit
3ae2207d38
|
@ -49,6 +49,7 @@ import eu.dnetlib.openaire.exporter.model.context.ConceptSummary;
|
||||||
public class CommunityService {
|
public class CommunityService {
|
||||||
|
|
||||||
// TODO: Verificare Tickets: #8835, #8854, #6483, #3259, #3494
|
// TODO: Verificare Tickets: #8835, #8854, #6483, #3259, #3494
|
||||||
|
// L'IMPORT DI ALCUNI PROGETTI FALLISCE perche' non hanno openaireID
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DbCommunityRepository dbCommunityRepository;
|
private DbCommunityRepository dbCommunityRepository;
|
||||||
|
|
|
@ -6,7 +6,11 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
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.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.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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.community.model.DbOrganization;
|
||||||
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
|
||||||
import eu.dnetlib.openaire.exporter.model.context.Context;
|
import eu.dnetlib.openaire.exporter.model.context.Context;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|
||||||
@RestController
|
@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 class CommunityImporterController {
|
||||||
|
|
||||||
public final static Set<String> communityBlackList = Sets.newHashSet("fet-fp7", "fet-h2020");
|
public final static Set<String> communityBlackList = Sets.newHashSet("fet-fp7", "fet-h2020");
|
||||||
|
@ -29,20 +39,27 @@ public class CommunityImporterController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISClient isClient;
|
private ISClient isClient;
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(CommunityImporterController.class);
|
||||||
|
|
||||||
@GetMapping("/community_importer/communities")
|
@GetMapping("/community_importer/communities")
|
||||||
public List<String> importProfiles() throws CommunityException {
|
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()
|
final List<String> list = contextMap.keySet()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(id -> !communityBlackList.contains(id))
|
.filter(id -> !communityBlackList.contains(id))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
list.forEach(id -> {
|
list.forEach(id -> {
|
||||||
importer.importCommunity(contextMap.get(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")
|
@GetMapping("/community_importer/propagationOrgs")
|
||||||
|
|
|
@ -136,8 +136,12 @@ public class CommunityImporterService {
|
||||||
final List<CommunityContentprovider> datasources =
|
final List<CommunityContentprovider> datasources =
|
||||||
getCommunityInfo(context, CONTENTPROVIDERS_ID_SUFFIX, c -> asCommunityDataprovider(context.getId(), c));
|
getCommunityInfo(context, CONTENTPROVIDERS_ID_SUFFIX, c -> asCommunityDataprovider(context.getId(), c));
|
||||||
|
|
||||||
|
// TODO: REMOVE THIS FILTER ?
|
||||||
final List<CommunityProject> projects =
|
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 =
|
final List<CommunityOrganization> orgs =
|
||||||
getCommunityInfo(context, ORGANIZATION_ID_SUFFIX, c -> asCommunityOrganization(context.getId(), c));
|
getCommunityInfo(context, ORGANIZATION_ID_SUFFIX, c -> asCommunityOrganization(context.getId(), c));
|
||||||
|
|
|
@ -216,7 +216,7 @@ public class CommunityMappingUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] toStringArray(final List<String> list) {
|
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package eu.dnetlib.openaire.exporter.model.context;
|
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;
|
private String name;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue