use of org.geosdi.geoplatform.core.model.GPAuthServer in project geo-platform by geosdi.
the class GPServerDelegate method saveServer.
@Override
public ServerDTO saveServer(WSSaveServerRequest saveServerReq) throws IllegalParameterFault {
if (saveServerReq == null) {
throw new IllegalParameterFault("The WSSaveServerRequest must " + "not be null.");
}
Long id = saveServerReq.getId();
String serverUrl = saveServerReq.getServerUrl();
String organization = saveServerReq.getOrganization();
String aliasServerName = saveServerReq.getAliasServerName();
try {
URL serverURL = new URL(serverUrl);
} catch (MalformedURLException e) {
logger.error("MalformedURLException: " + e);
throw new IllegalParameterFault("Malformed URL");
}
GPOrganization org = organizationDao.findByName(organization);
if (org == null) {
throw new IllegalParameterFault("Server to save have an organization that does not exist");
}
GeoPlatformServer server;
if (id != null) {
// Existent server
server = serverDao.find(id);
} else {
// New server
if (this.isURLServerAlreadyExists(serverUrl)) {
throw new IllegalParameterFault("Duplicated Server URL");
}
server = new GeoPlatformServer();
server.setServerType(WMS);
}
server.setAliasName(aliasServerName);
server.setServerUrl(serverUrl);
server.setAuthServer(new GPAuthServer(saveServerReq.getUsername(), saveServerReq.getPassword()));
server.setProxy(saveServerReq.isProxy());
server.setOrganization(org);
serverDao.persist(server);
return new ServerDTO(server);
}
Aggregations