this.setInfoPath("/core/load");
}
@Override
protected String action() {
DataServerInfoPackage infoPackage = new DataServerInfoPackage();
DataServerInfoObject infoObject = new DataServerInfoObject();
if (this.getInfoObject() == null || this.getInfoObject().get("token") == null
|| this.getInfoObject().get("token").isEmpty()) {
infoPackage.setStatus(DataServerInfoStatusCode.ARGUMENT_ERROR);
infoPackage.setStatusMessage("You must have a token");
} else {
String adminHost = this.getInfoObject().get("token");
String extensionName = this.getInfoObject().get("extension");
if (this.extensionObject.isApiAuthTokenCorrect(adminHost)) {
if (extensionName != null && !extensionName.isEmpty()) {
try {
if (ExtensionManager.IsExtensionObjectExists(extensionName)) {
this.extensionObject.getExtensionManager().addExtensionByName(extensionName);
infoObject.putData("answer", "Extension will be loaded automatically soon: " + extensionName);
} else {
infoObject.putData("answer", "Extension is not exists: " + extensionName);
}
} catch (ExtensionManagerError e) {
infoObject.putData("answer", e.getMessage());
}
} else {
infoObject.putData("answer", "Can't add extension: empty string provided");
}
} else {
infoPackage.setStatus(DataServerInfoStatusCode.ARGUMENT_ERROR);
infoPackage.setStatusMessage(String.format("'%s' unknown token", adminHost));
}
}
infoPackage.setInfoObject(infoObject);
return infoPackage.toString();
}