Search in sources :

Example 1 with CreatePrivateUrlCommand

use of edu.harvard.iq.dataverse.engine.command.impl.CreatePrivateUrlCommand in project dataverse by IQSS.

the class DatasetPage method createPrivateUrl.

public void createPrivateUrl() {
    try {
        PrivateUrl createdPrivateUrl = commandEngine.submit(new CreatePrivateUrlCommand(dvRequestService.getDataverseRequest(), dataset));
        privateUrl = createdPrivateUrl;
        JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.privateurl.infoMessageAuthor", Arrays.asList(getPrivateUrlLink(privateUrl))));
        privateUrlWasJustCreated = true;
    } catch (CommandException ex) {
        String msg = BundleUtil.getStringFromBundle("dataset.privateurl.noPermToCreate", PrivateUrlUtil.getRequiredPermissions(ex));
        logger.info("Unable to create a Private URL for dataset id " + dataset.getId() + ". Message to user: " + msg + " Exception: " + ex);
        JH.addErrorMessage(msg);
    }
}
Also used : CreatePrivateUrlCommand(edu.harvard.iq.dataverse.engine.command.impl.CreatePrivateUrlCommand) PrivateUrl(edu.harvard.iq.dataverse.privateurl.PrivateUrl) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) IllegalCommandException(edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException)

Example 2 with CreatePrivateUrlCommand

use of edu.harvard.iq.dataverse.engine.command.impl.CreatePrivateUrlCommand in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetRequiredPermissions.

@Test
public void testGetRequiredPermissions() {
    CreatePrivateUrlCommand createPrivateUrlCommand = new CreatePrivateUrlCommand(null, null);
    CommandException ex = new CommandException(null, createPrivateUrlCommand);
    List<String> strings = PrivateUrlUtil.getRequiredPermissions(ex);
    assertEquals(Arrays.asList("ManageDatasetPermissions"), strings);
}
Also used : CreatePrivateUrlCommand(edu.harvard.iq.dataverse.engine.command.impl.CreatePrivateUrlCommand) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) Test(org.junit.Test)

Aggregations

CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)2 CreatePrivateUrlCommand (edu.harvard.iq.dataverse.engine.command.impl.CreatePrivateUrlCommand)2 IllegalCommandException (edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException)1 PrivateUrl (edu.harvard.iq.dataverse.privateurl.PrivateUrl)1 Test (org.junit.Test)1