use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.
the class GPLayerDelegate method saveDragAndDropLayerAndTreeModifications.
@Override
public Boolean saveDragAndDropLayerAndTreeModifications(WSDDLayerAndTreeModificationsRequest ddLayerReq) throws ResourceNotFoundFault, IllegalParameterFault {
if (ddLayerReq == null) {
throw new IllegalParameterFault("The WSDDLayerAndTreeModificationsRequest must not be null.");
}
Long layerMovedID = ddLayerReq.getLayerMovedID();
Long newParentID = ddLayerReq.getNewParentID();
int newPosition = ddLayerReq.getNewPosition();
GPWebServiceMapData descendantsMapData = ddLayerReq.getDescendantsMapData();
GPLayer layerMoved = this.getLayerDetail(layerMovedID);
if (newParentID == null) {
throw new IllegalParameterFault("New folder parent NOT declared");
}
GPFolder folderParent = folderDao.find(newParentID);
if (folderParent == null) {
throw new ResourceNotFoundFault("The new parent does not exists", newParentID);
}
// TODO assert
EntityCorrectness.checkFolderLog(folderParent);
layerMoved.setFolder(folderParent);
int startFirstRange = 0, endFirstRange = 0;
if (layerMoved.getPosition() < newPosition) {
// Drag & Drop to top
startFirstRange = newPosition;
endFirstRange = layerMoved.getPosition() + 1;
} else if (layerMoved.getPosition() > newPosition) {
// Drag & Drop to bottom
startFirstRange = layerMoved.getPosition() - 1;
endFirstRange = newPosition;
}
int shiftValue = 1;
List<GPFolder> matchingFoldersFirstRange = folderDao.findByPositionAndProjectID(layerMoved.getProject().getId(), startFirstRange, endFirstRange);
List<GPLayer> matchingLayersFirstRange = layerDao.findByPositionAndProjectID(layerMoved.getProject().getId(), startFirstRange, endFirstRange);
if (layerMoved.getPosition() < newPosition) {
// Drag & Drop to top
this.executeFoldersModifications(matchingFoldersFirstRange, -shiftValue);
this.executeLayersModifications(matchingLayersFirstRange, -shiftValue);
} else if (layerMoved.getPosition() > newPosition) {
// Drag & Drop to bottom
this.executeFoldersModifications(matchingFoldersFirstRange, shiftValue);
this.executeLayersModifications(matchingLayersFirstRange, shiftValue);
}
folderDao.update(matchingFoldersFirstRange);
layerDao.update(matchingLayersFirstRange);
layerMoved.setPosition(newPosition);
layerDao.update(layerMoved);
folderDao.updateAncestorsDescendants(descendantsMapData.getDescendantsMap());
return TRUE;
}
use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.
the class WSAccountTest method testInsertDuplicateUserWRTEmail.
@Test
public void testInsertDuplicateUserWRTEmail() {
GPUser user = super.createUser("duplicate-email", organizationTest, USER);
user.setEmailAddress(super.userTest.getEmailAddress());
try {
gpWSClient.insertAccount(new InsertAccountRequest(user, FALSE));
fail("User already exist wrt email");
} catch (IllegalParameterFault ex) {
if (!ex.getMessage().toLowerCase().contains("email")) {
// Must be fail for other reasons
fail("Not fail for User already exist wrt email, but for: " + ex.getMessage());
}
}
}
use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.
the class CSWEntityCorrectness method checkCSWServer.
// ==========================================================================
// === Server
// ==========================================================================
public static void checkCSWServer(GeoPlatformServer server) throws IllegalParameterFault {
if (server.getServerType() != GPCapabilityType.CSW) {
throw new IllegalParameterFault("Server is not a CSW server.");
}
String url = server.getServerUrl();
if (url == null) {
throw new IllegalParameterFault("Server URL must not be null.");
}
if (!url.startsWith("http://") && !url.startsWith("https://")) {
throw new IllegalParameterFault("URL must be start with \"http://\" or \"https://\".");
}
GPOrganization organization = server.getOrganization();
if (organization == null) {
throw new IllegalParameterFault("Server Organization must not be null.");
}
}
use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.
the class GPFolderDelegate method saveFolderProperties.
@Override
public Long saveFolderProperties(Long folderID, String name, boolean checked, boolean expanded) throws ResourceNotFoundFault, IllegalParameterFault {
GPFolder folder = folderDao.find(folderID);
if (folder == null) {
throw new ResourceNotFoundFault("Folder not found", folderID);
}
// TODO assert
EntityCorrectness.checkFolderLog(folder);
if (name == null || name.trim().length() == 0) {
throw new IllegalParameterFault("Folder \"name\" cannot be null or empty");
}
folder.setName(name);
folder.setChecked(checked);
folder.setExpanded(expanded);
folderDao.update(folder);
return folder.getId();
}
use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.
the class GPFolderDelegate method insertFolder.
// <editor-fold defaultstate="collapsed" desc="Folder">
// =========================================================================
// === Folder
// =========================================================================
@Override
public Long insertFolder(InsertFolderRequest insertFolderRequest) throws ResourceNotFoundFault, IllegalParameterFault {
Long projectID = insertFolderRequest.getProjectID();
GPFolder folder = insertFolderRequest.getFolder();
if (projectID == null) {
throw new IllegalParameterFault("The projectID must not be null.");
}
if (folder == null) {
throw new IllegalParameterFault("The GPFolder passed in Request must " + "not be null.");
}
GPProject project = projectDao.find(projectID);
if (project == null) {
throw new ResourceNotFoundFault("Project not found", projectID);
}
// TODO assert
EntityCorrectness.checkProjectLog(project);
folder.setProject(project);
// TODO assert
EntityCorrectness.checkFolder(folder);
folderDao.persist(folder);
return folder.getId();
}
Aggregations