use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class ManageGroupsPage method deleteGroup.
public void deleteGroup() {
if (selectedGroup != null) {
explicitGroups.remove(selectedGroup);
try {
engineService.submit(new DeleteExplicitGroupCommand(dvRequestService.getDataverseRequest(), selectedGroup));
JsfHelper.addFlashMessage("The group has been deleted.");
} catch (CommandException ex) {
String failMessage = "The explicit group cannot be deleted.";
JH.addMessage(FacesMessage.SEVERITY_FATAL, failMessage);
}
} else {
logger.info("Selected group is null");
}
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class RolePermissionFragment method assignRole.
private void assignRole(RoleAssignee ra, DataverseRole r) {
try {
String privateUrlToken = null;
commandEngine.submit(new AssignRoleCommand(ra, r, dvObject, dvRequestService.getDataverseRequest(), privateUrlToken));
JH.addMessage(FacesMessage.SEVERITY_INFO, "Role " + r.getName() + " assigned to " + ra.getDisplayInfo().getTitle() + " on " + StringEscapeUtils.escapeHtml(dvObject.getDisplayName()));
} catch (CommandException ex) {
JH.addMessage(FacesMessage.SEVERITY_ERROR, "Can't assign role: " + ex.getMessage());
}
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class RolePermissionFragment method revokeRole.
public void revokeRole(Long roleAssignmentId) {
try {
commandEngine.submit(new RevokeRoleCommand(em.find(RoleAssignment.class, roleAssignmentId), dvRequestService.getDataverseRequest()));
JH.addMessage(FacesMessage.SEVERITY_INFO, "Role assignment revoked successfully");
} catch (PermissionException ex) {
JH.addMessage(FacesMessage.SEVERITY_ERROR, "Cannot revoke role assignment - you're missing permission", ex.getRequiredPermissions().toString());
logger.log(Level.SEVERE, "Error revoking role assignment: " + ex.getMessage(), ex);
} catch (CommandException ex) {
JH.addMessage(FacesMessage.SEVERITY_ERROR, "Cannot revoke role assignment: " + ex.getMessage());
logger.log(Level.SEVERE, "Error revoking role assignment: " + ex.getMessage(), ex);
}
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class HarvestingClientsPage method saveClient.
// this saves an existing client that the user has edited:
public void saveClient(ActionEvent ae) {
HarvestingClient harvestingClient = getSelectedClient();
if (harvestingClient == null) {
// TODO:
// tell the user somehow that the client cannot be saved, and advise
// them to save the settings they have entered.
// as of now - we will show an error message, but only after the
// edit form has been closed.
}
// nickname is not editable for existing clients:
// harvestingClient.setName(newNickname);
harvestingClient.setHarvestingUrl(newHarvestingUrl);
harvestingClient.setHarvestingSet(newOaiSet);
harvestingClient.setMetadataPrefix(newMetadataFormat);
harvestingClient.setHarvestStyle(newHarvestingStyle);
if (isNewHarvestingScheduled()) {
harvestingClient.setScheduled(true);
if (isNewHarvestingScheduledWeekly()) {
harvestingClient.setSchedulePeriod(HarvestingClient.SCHEDULE_PERIOD_WEEKLY);
if (getWeekDayNumber() == null) {
// create a "week day is required..." error message, etc.
// but we may be better off not even giving them an opportunity
// to leave the field blank - ?
}
harvestingClient.setScheduleDayOfWeek(getWeekDayNumber());
} else {
harvestingClient.setSchedulePeriod(HarvestingClient.SCHEDULE_PERIOD_DAILY);
}
if (getHourOfDay() == null) {
// see the comment above, about the day of week. same here.
}
harvestingClient.setScheduleHourOfDay(getHourOfDay());
} else {
harvestingClient.setScheduled(false);
}
try {
harvestingClient = engineService.submit(new UpdateHarvestingClientCommand(dvRequestService.getDataverseRequest(), harvestingClient));
configuredHarvestingClients = harvestingClientService.getAllHarvestingClients();
if (!harvestingClient.isScheduled()) {
dataverseTimerService.removeHarvestTimer(harvestingClient);
}
JsfHelper.addSuccessMessage("Succesfully updated harvesting client " + harvestingClient.getName());
} catch (CommandException ex) {
logger.log(Level.WARNING, "Failed to save harvesting client", ex);
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Failed to save harvesting client", ex.getMessage());
} catch (Exception ex) {
JH.addMessage(FacesMessage.SEVERITY_FATAL, "Failed to save harvesting client (reason unknown).");
logger.log(Level.SEVERE, "Failed to save harvesting client (reason unknown)." + ex.getMessage(), ex);
}
setPageMode(PageMode.VIEW);
}
use of edu.harvard.iq.dataverse.engine.command.exception.CommandException in project dataverse by IQSS.
the class HarvestingClientsPage method createClient.
public void createClient(ActionEvent ae) {
// will be set as type OAI by default
HarvestingClient newHarvestingClient = new HarvestingClient();
newHarvestingClient.setName(newNickname);
if (getSelectedDestinationDataverse() == null) {
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Failed to create a new Harvesting Client configuration: no destination dataverse selected.");
}
newHarvestingClient.setDataverse(getSelectedDestinationDataverse());
if (getSelectedDestinationDataverse().getHarvestingClientConfigs() == null) {
getSelectedDestinationDataverse().setHarvestingClientConfigs(new ArrayList<>());
}
getSelectedDestinationDataverse().getHarvestingClientConfigs().add(newHarvestingClient);
newHarvestingClient.setHarvestingUrl(newHarvestingUrl);
if (!StringUtils.isEmpty(newOaiSet)) {
newHarvestingClient.setHarvestingSet(newOaiSet);
}
newHarvestingClient.setMetadataPrefix(newMetadataFormat);
newHarvestingClient.setHarvestStyle(newHarvestingStyle);
if (isNewHarvestingScheduled()) {
newHarvestingClient.setScheduled(true);
if (isNewHarvestingScheduledWeekly()) {
newHarvestingClient.setSchedulePeriod(HarvestingClient.SCHEDULE_PERIOD_WEEKLY);
if (getWeekDayNumber() == null) {
// create a "week day is required..." error message, etc.
// but we may be better off not even giving them an opportunity
// to leave the field blank - ?
}
newHarvestingClient.setScheduleDayOfWeek(getWeekDayNumber());
} else {
newHarvestingClient.setSchedulePeriod(HarvestingClient.SCHEDULE_PERIOD_DAILY);
}
if (getHourOfDay() == null) {
// see the comment above, about the day of week. same here.
}
newHarvestingClient.setScheduleHourOfDay(getHourOfDay());
}
// make default archive url (used to generate links pointing back to the
// archival sources, when harvested datasets are displayed in search results),
// from the harvesting url:
newHarvestingClient.setArchiveUrl(makeDefaultArchiveUrl());
// set default description - they can customize it as they see fit:
newHarvestingClient.setArchiveDescription(JH.localize("harvestclients.viewEditDialog.archiveDescription.default.generic"));
try {
newHarvestingClient = engineService.submit(new CreateHarvestingClientCommand(dvRequestService.getDataverseRequest(), newHarvestingClient));
configuredHarvestingClients = harvestingClientService.getAllHarvestingClients();
// NO, we no longer create timers here. It is the job of the Mother Timer!
// dataverseTimerService.createHarvestTimer(newHarvestingClient);
String successMessage = JH.localize("harvestclients.newClientDialog.success");
successMessage = successMessage.replace("{0}", newHarvestingClient.getName());
JsfHelper.addSuccessMessage(successMessage);
}/* TODO: (?) add a dedicated "NameAlreadyExists" exception for the
create client command?
catch ( CreateHarvestingClientCommand.NicknameAlreadyExistsException naee ) {
FacesContext.getCurrentInstance().addMessage(newHarvestingClient.getName(),
new FacesMessage( FacesMessage.SEVERITY_ERROR, naee.getMessage(), null));
}*/
catch (CommandException ex) {
logger.log(Level.WARNING, "Harvesting client creation command failed", ex);
JsfHelper.JH.addMessage(FacesMessage.SEVERITY_ERROR, "Harvesting Client creation command failed.", ex.getMessage());
} catch (Exception ex) {
JH.addMessage(FacesMessage.SEVERITY_FATAL, "Harvesting client creation failed (reason unknown).");
logger.log(Level.SEVERE, "Harvesting client creation failed (reason unknown)." + ex.getMessage(), ex);
}
setPageMode(PageMode.VIEW);
}
Aggregations