Project

General

Profile

« Previous | Next » 

Revision 51764

Retry in case of known NullPointerException on the catalogue

View differences:

modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/catalogue/CatalogueRegistrator.java
52 52

  
53 53

  
54 54

  
55
	public String register(final Resource resource, final Resource type, final String group) throws IOException, ParthenosPublisherException, URISyntaxException {
55
	public String register(final Resource resource, final Resource type, final String group)
56
			throws IOException, ParthenosPublisherException, URISyntaxException, InterruptedException {
56 57
		String resURI = resource.getURI();
57 58
		log.debug(String.format("Catalogue --> Processing resource : %s with type: %s", resURI, type.getLocalName()));
58 59
		//For the catalogue: Must be purely lowercase alphanumeric (ascii) characters and these symbols: -_
......
86 87
			}
87 88
			String uuid = catalogueAPIClient.doRegister(json, resCatName);
88 89
			if(StringUtils.isBlank(uuid)){
89
				log.warn(String.format("%s could not be registered", resURI));
90
				log.warn(String.format("%s could not be registered, sleeping 1sec and then try again", resURI));
91
				Thread.sleep(1000);
92
				uuid = catalogueAPIClient.doRegister(json, resCatName);
93
				if(StringUtils.isBlank(uuid)) {
94
					log.warn(String.format("%s could not be registered even the second time, giving up", resURI));
95
					return null;
96
				}
90 97
			}
91
			else {
92
				log.debug(String.format("%s registered on the catalogue with uuid: %s", resURI, uuid));
93
			}
98
			log.debug(String.format("%s registered on the catalogue with uuid: %s", resURI, uuid));
94 99
			return uuid;
95 100
		}
96

  
97 101
	}
98 102

  
99 103
	protected boolean purge(final String resCatName) throws URISyntaxException, IOException {

Also available in: Unified diff