SystemRegistrationWorker implements Enregister { protected boolean doTheWork(String registrationData, String url, String version) { String registrationKey = propertyService.getStringProperty(PropertyLocator.SYSTEM_REG_SECRET_KEY); boolean regStatus = false; if (StringHelper.containsNonWhitespace(registrationData)) { final HttpClient client = HttpClientFactory.getHttpClientInstance(); client.getParams().setParameter("http.useragent", "OLAT Registration Agent ; " + version); log.info("URL:" + url, null); final PutMethod method = new PutMethod(url); if (registrationKey != null) { method.setRequestHeader("Authorization", registrationKey); if (log.isDebugEnabled()) { log.debug("Authorization: " + registrationKey, null); } else { log.debug("Authorization: EXISTS", null); } } else { log.info("Authorization: NONE", null); } method.setRequestHeader("Content-Type", "application/xml; charset=utf-8"); try { method.setRequestEntity(new StringRequestEntity(registrationData, "application/xml", "UTF8")); client.executeMethod(method); final int status = method.getStatusCode(); if (status == HttpStatus.SC_NOT_MODIFIED || status == HttpStatus.SC_OK) { log.info("Successfully registered OLAT installation on olat.org server, thank you for your support!", null); registrationKey = method.getResponseBodyAsString(); propertyService.setProperty(PropertyLocator.SYSTEM_REG_SECRET_KEY, registrationKey); regStatus = true; } else if (method.getStatusCode() == HttpStatus.SC_NOT_FOUND) { log.error("File could be created not on registration server::" + method.getStatusLine().toString(), null); regStatus = false; } else if (method.getStatusCode() == HttpStatus.SC_NO_CONTENT) { log.info(method.getResponseBodyAsString() + method.getStatusText()); regStatus = false; } else { log.error("Unexpected HTTP Status::" + method.getStatusLine().toString() + " during registration call", null); regStatus = false; } } catch (final Exception e) { log.error("Unexpected exception during registration call", e); regStatus = false; } } else { log.warn( "****************************************************************************************************************************************************************************", null); log.warn( "* This OLAT installation is not registered. Please, help us with your statistical data and register your installation under Adminisration - Systemregistration. THANK YOU! *", null); log.warn( "****************************************************************************************************************************************************************************", null); } return regStatus; } protected  SystemRegistrationWorker(); @Override @Async void register(String registrationData, String url, String version);  }
@Test @Ignore public void testRegistraion() { boolean result = sysReg.doTheWork(registrationData, SystemRegistrationManager.REGISTRATION_SERVER, "1.0"); assertTrue(result); }