use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class MapService method saveBaseLayer.
// @Override
// public String layerAuthenticate(String userName, String password, String url) throws GeoPlatformException {
// HTTPUtils hTTPUtils = new HTTPUtils(userName, password);
// String responce = null;
// try {
// logger.info("Layer: " + url);
// responce = hTTPUtils.get("http://localhost:8989/geoserver");
// logger.info("Auth Responce: " + responce);
// } catch (MalformedURLException mfe) {
// System.out.println("Url tazzo: " + mfe);
// }
// return responce;
// }
@Override
public void saveBaseLayer(String baseLayer, HttpServletRequest httpServletRequest) throws GeoPlatformException {
GPAccount account;
Long projectID;
try {
account = this.sessionUtility.getLoggedAccount(httpServletRequest);
projectID = this.sessionUtility.getDefaultProject(httpServletRequest);
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
}
try {
GPAccountProject accountProject = this.geoPlatformServiceClient.getAccountProjectByAccountAndProjectIDs(account.getId(), projectID);
accountProject.setBaseLayer(baseLayer);
this.geoPlatformServiceClient.updateAccountProject(accountProject);
} catch (ResourceNotFoundFault rnff) {
logger.error("Error on MapService: " + rnff);
throw new GeoPlatformException(rnff);
} catch (IllegalParameterFault ipf) {
logger.error("Error on MapService: " + ipf);
throw new GeoPlatformException(ipf);
}
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPViewportDelegate method replaceViewportList.
@Override
public void replaceViewportList(ManageViewportRequest request) throws ResourceNotFoundFault, IllegalParameterFault {
if (request == null) {
throw new IllegalParameterFault("The ManageViewportRequest must " + "not be null.");
}
Long accountProjectID = request.getAccountProjectID();
ArrayList<GPViewport> viewportList = request.getViewportList();
GPAccountProject accountProject = this.accountProjectDao.find(accountProjectID);
if (accountProject == null) {
throw new ResourceNotFoundFault("AccountProject not found", accountProjectID);
}
List<GPViewport> oldViewportList = this.viewportDao.findByAccountProjectID(accountProjectID);
for (GPViewport viewport : oldViewportList) {
this.viewportDao.removeById(viewport.getId());
}
if (viewportList != null) {
for (GPViewport viewport : viewportList) {
this.insertViewport(accountProjectID, viewport);
}
}
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPViewportDelegate method insertViewport.
private Long insertViewport(Long accountProjectID, GPViewport viewport) throws ResourceNotFoundFault, IllegalParameterFault {
GPAccountProject accountProject = this.accountProjectDao.find(accountProjectID);
if (accountProject == null) {
throw new ResourceNotFoundFault("AccountProject not found", accountProjectID);
}
viewport.setAccountProject(accountProject);
EntityCorrectness.checkViewport(viewport);
viewportDao.persist(viewport);
return viewport.getId();
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class GPTrackingServiceImpl method sendSharedProjectNotification.
/**
* @see GPTrackingService#sendSharedProjectNotification(java.lang.Long,
* org.geosdi.geoplatform.services.XMPPSubjectServerEnum, java.lang.String,
* org.geosdi.geoplatform.responce.collection.XmppAttributesMap)
*/
@Override
public void sendSharedProjectNotification(Long projectID, XMPPSubjectEnum subject, String text, XmppAttributesMap attributesMap) throws ResourceNotFoundFault {
GPProject project = projectDao.find(projectID);
if (project == null) {
throw new ResourceNotFoundFault("Project not found", projectID);
}
// TODO assert
EntityCorrectness.checkProjectLog(project);
if (!project.isShared()) {
// TODO assert
throw new EntityCorrectnessException("The Project must be shared.");
}
List<GPAccountProject> accounts = accountProjectDao.findNotOwnersByProjectID(projectID);
// TODO assert
EntityCorrectness.checkAccountProjectListLog(accounts);
Roster roster = this.connection.getRoster();
Message message = this.createUnknowMessage(subject, text, attributesMap);
for (GPAccountProject accountProject : accounts) {
GPAccount account = accountProject.getAccount();
// TODO assert
EntityCorrectness.checkAccountLog(account);
// If user have this project as default
if (accountProject.isDefaultProject()) {
// Username for User
String naturalID = account.getNaturalID();
String recipient = this.createXmppUri(naturalID);
logger.trace("\n\n*** Recipient XMPP uri: {} ***", recipient);
// If user is online send the message
Presence presence = roster.getPresence(recipient);
if (presence.isAvailable()) {
logger.info("\n*** Send Message to online user \"{}\" ***", naturalID);
message.setTo(recipient);
connection.sendPacket(message);
}
}
}
}
use of org.geosdi.geoplatform.core.model.GPAccountProject in project geo-platform by geosdi.
the class MapService method replaceViewportList.
@Override
public void replaceViewportList(List<GPClientViewport> viewportList, HttpServletRequest httpServletRequest) throws GeoPlatformException {
GPAccount account;
Long projectID;
try {
account = this.sessionUtility.getLoggedAccount(httpServletRequest);
projectID = this.sessionUtility.getDefaultProject(httpServletRequest);
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
}
try {
GPAccountProject accountProject = this.geoPlatformServiceClient.getAccountProjectByAccountAndProjectIDs(account.getId(), projectID);
this.geoPlatformServiceClient.replaceViewportList(new ManageViewportRequest(accountProject.getId(), convertClientViewportToDTO(viewportList)));
} catch (ResourceNotFoundFault | IllegalParameterFault rnff) {
logger.error("Error on MapService: " + rnff);
throw new GeoPlatformException(rnff);
}
}
Aggregations