// only send when there is something to send
HttpClient client = HttpClientFactory.getHttpClientInstance();
client.getParams().setParameter("http.useragent", "OLAT Registration Agent ; " + VERSION);
String url = REGISTRATION_SERVER+persitedProperties.getStringPropertyValue(CONF_KEY_IDENTIFYER, false)+"/";
logInfo("URL:"+url, null);
PutMethod method = new PutMethod(url);
if(registrationKey != null){
//updating
method.setRequestHeader("Authorization",registrationKey);
logInfo("Authorization: "+registrationKey,null);
}else{
logInfo("Authorization: NONE",null);
}
method.setRequestHeader("Content-Type", "application/xml; charset=utf-8");
try {
method.setRequestEntity(new StringRequestEntity(registrationData, "application/xml", "UTF8"));
client.executeMethod(method);
int status = method.getStatusCode();
if (status == HttpStatus.SC_NOT_MODIFIED || status == HttpStatus.SC_OK) {
logInfo("Successfully registered OLAT installation on olat.org server, thank you for your support!", null);
registrationKey = method.getResponseBodyAsString();
persitedProperties.setStringProperty(CONF_SECRETKEY, registrationKey, false);
persitedProperties.savePropertiesAndFireChangedEvent();
} else if (method.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
logError("File could be created not on registration server::" + method.getStatusLine().toString(), null);
} else if(method.getStatusCode() == HttpStatus.SC_NO_CONTENT){
logInfo(method.getResponseBodyAsString(), method.getStatusText());
}
else {
logError("Unexpected HTTP Status::" + method.getStatusLine().toString() + " during registration call", null);
}
} catch (Exception e) {
logError("Unexpected exception during registration call", e);
}
} else {