删除JasperReports Server Repository的文件夹

时间:2013-03-25 10:09:25

标签: java spring jasper-reports jasperserver

我想删除 JasperReports Server 存储库的其中一个文件夹。

我正在使用 JR服务器repository.deleteFolder(string URI) API。但是在删除文件夹时我得到了“拒绝访问”,虽然我已经通过下面的 Admin 权限给了该文件夹。我也手动创建了一个securitycontext对象,因为这是我的应用程序部署时调用的代码

public void enableRoleAdministrator(ExecutionContext ctx, String userName,
        String folderName) {
    try {
        List ctxAttrib = ctx.getAttributes();
        if (ctxAttrib != null) {

            ctxAttrib.add(ObjectPermissionService.PRIVILEGED_OPERATION);
        } else {
            ctxAttrib = new ArrayList<String>();
            ctxAttrib.add(ObjectPermissionService.PRIVILEGED_OPERATION);

        }
        ctx.setAttributes(ctxAttrib);

        ObjectPermission userPermission = objectPermissionService
                .newObjectPermission(null);
        User user = profileAttributeService.getUserAuthorityService()
                .getUser(ctx, userName);
        userPermission.setURI("repo:/" + folderName);
        System.out.println("The URI is "+userPermission.getURI());
        userPermission.setPermissionRecipient(user);
        System.out.println("The userPermission is "+userPermission.getPermissionRecipient().toString());
        System.out.println("The user is "+user);
        userPermission.setPermissionMask(ADMINISTRATION);
        objectPermissionService.putObjectPermission(ctx, userPermission);
        System.out.println("Before calling delete Folder");
        repository.deleteFolder(ctx, folderName);

        System.out.println("After calling delete Folder");

    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception occurred" + ex.getMessage());
        System.out.println("Exception while deletingnnn forlder "+ex.getMessage());
        ex.printStackTrace();

    }
}

0 个答案:

没有答案