use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspaceMaterialUploadBackingBean method init.
@RequestAction
public String init() {
String urlName = getWorkspaceUrlName();
if (StringUtils.isBlank(urlName)) {
return "/error/not-found.jsf";
}
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByUrlName(urlName);
if (workspaceEntity == null) {
return "/error/not-found.jsf";
}
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceName = workspaceBackingBean.getWorkspaceName();
return null;
}
use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspaceMaterialsBackingBean method init.
@RequestAction
public String init() {
String urlName = getWorkspaceUrlName();
if (StringUtils.isBlank(urlName)) {
return NavigationRules.NOT_FOUND;
}
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByUrlName(urlName);
if (workspaceEntity == null) {
return NavigationRules.NOT_FOUND;
}
if (!workspaceEntity.getPublished()) {
if (!sessionController.hasWorkspacePermission(MuikkuPermissions.ACCESS_UNPUBLISHED_WORKSPACE, workspaceEntity)) {
return NavigationRules.NOT_FOUND;
}
}
if (workspaceEntity.getAccess() != WorkspaceAccess.ANYONE) {
if (!sessionController.hasWorkspacePermission(MuikkuPermissions.ACCESS_WORKSPACE_MATERIALS, workspaceEntity)) {
if (!sessionController.isLoggedIn()) {
return navigationController.requireLogin();
} else {
return NavigationRules.ACCESS_DENIED;
}
}
}
rootFolder = workspaceMaterialController.findWorkspaceRootFolderByWorkspaceEntity(workspaceEntity);
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceName = workspaceBackingBean.getWorkspaceName();
workspaceNameExtension = workspaceBackingBean.getWorkspaceNameExtension();
try {
contentNodes = workspaceMaterialController.listWorkspaceMaterialsAsContentNodes(workspaceEntity, false);
} catch (WorkspaceMaterialException e) {
logger.log(Level.SEVERE, "Error loading materials", e);
return NavigationRules.INTERNAL_ERROR;
}
materialsBaseUrl = String.format("/workspace/%s/materials", workspaceUrlName);
maySignUp = resolveMaySignUp();
canSignUp = sessionController.hasWorkspacePermission(MuikkuPermissions.WORKSPACE_SIGNUP, workspaceEntity);
workspaceVisitController.visit(workspaceEntity);
return null;
}
use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspaceMaterialsReadingBackingBean method init.
@RequestAction
public String init() {
String urlName = getWorkspaceUrlName();
if (StringUtils.isBlank(urlName)) {
return NavigationRules.NOT_FOUND;
}
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByUrlName(urlName);
if (workspaceEntity == null) {
return NavigationRules.NOT_FOUND;
}
if (!workspaceEntity.getPublished()) {
if (!sessionController.hasWorkspacePermission(MuikkuPermissions.ACCESS_UNPUBLISHED_WORKSPACE, workspaceEntity)) {
return NavigationRules.NOT_FOUND;
}
}
if (workspaceEntity.getAccess() != WorkspaceAccess.ANYONE) {
if (!sessionController.hasWorkspacePermission(MuikkuPermissions.ACCESS_WORKSPACE_MATERIALS, workspaceEntity)) {
if (!sessionController.isLoggedIn()) {
return navigationController.requireLogin();
} else {
return NavigationRules.ACCESS_DENIED;
}
}
}
rootFolder = workspaceMaterialController.findWorkspaceRootFolderByWorkspaceEntity(workspaceEntity);
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceName = workspaceBackingBean.getWorkspaceName();
materialsBaseUrl = String.format("/workspace/%s/materials", workspaceUrlName);
try {
contentNodes = workspaceMaterialController.listWorkspaceMaterialsAsContentNodes(workspaceEntity, false);
} catch (WorkspaceMaterialException e) {
logger.log(Level.SEVERE, "Error loading materials", e);
return NavigationRules.INTERNAL_ERROR;
}
return null;
}
use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspacePermissionsManagementBackingBean method init.
@RequestAction
public String init() {
String urlName = getWorkspaceUrlName();
if (StringUtils.isBlank(urlName)) {
return NavigationRules.NOT_FOUND;
}
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByUrlName(urlName);
if (workspaceEntity == null) {
return NavigationRules.NOT_FOUND;
}
if (!sessionController.hasWorkspacePermission(MuikkuPermissions.WORKSPACE_MANAGE_PERMISSIONS, workspaceEntity)) {
return NavigationRules.NOT_FOUND;
}
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceName = workspaceBackingBean.getWorkspaceName();
userGroupBeans = new ArrayList<WorkspacePermissionsManagementBackingBean.UserGroupBean>();
permissions = new ArrayList<Permission>();
// TODO: atm we only support the sign up permission
Permission permission = permissionController.findByName(MuikkuPermissions.WORKSPACE_SIGNUP);
permissions.add(permission);
List<UserGroupEntity> userGroupEntities;
String permissionGroupIds = pluginSettingsController.getPluginSetting("workspace", "permission-group-ids");
if (permissionGroupIds == null) {
userGroupEntities = userGroupEntityController.listUserGroupEntities();
} else {
userGroupEntities = new ArrayList<UserGroupEntity>();
String[] idArray = permissionGroupIds.split(",");
for (int i = 0; i < idArray.length; i++) {
Long groupId = NumberUtils.createLong(idArray[i]);
if (groupId != null) {
UserGroupEntity userGroupEntity = userGroupEntityController.findUserGroupEntityById(groupId);
if (userGroupEntity == null) {
logger.warning(String.format("Missing group %d in plugin setting workspace.permission-group-ids", groupId));
} else {
userGroupEntities.add(userGroupEntity);
}
} else {
logger.warning(String.format("Malformatted plugin setting workspace.permission-group-ids %s", permissionGroupIds));
}
}
}
for (UserGroupEntity userGroupEntity : userGroupEntities) {
UserGroup userGroup = userGroupController.findUserGroup(userGroupEntity);
userGroupBeans.add(new UserGroupBean(userGroupEntity.getId(), userGroup.getName()));
}
Collections.sort(userGroupBeans, new Comparator<UserGroupBean>() {
@Override
public int compare(UserGroupBean o1, UserGroupBean o2) {
return o1.getName().compareTo(o2.getName());
}
});
return null;
}
use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspaceDiscussionsBackingBean method init.
@RequestAction
public String init() {
String urlName = getWorkspaceUrlName();
if (StringUtils.isBlank(urlName)) {
return NavigationRules.NOT_FOUND;
}
WorkspaceEntity workspaceEntity = workspaceController.findWorkspaceEntityByUrlName(urlName);
if (workspaceEntity == null) {
return NavigationRules.NOT_FOUND;
}
if (!sessionController.hasWorkspacePermission(ForumResourcePermissionCollection.FORUM_ACCESSWORKSPACEFORUMS, workspaceEntity)) {
return NavigationRules.ACCESS_DENIED;
}
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceName = workspaceBackingBean.getWorkspaceName();
lockStickyPermission = sessionController.hasWorkspacePermission(ForumResourcePermissionCollection.FORUM_LOCK_OR_STICKIFY_WORKSPACE_MESSAGES, workspaceEntity);
showFullNamePermission = sessionController.hasEnvironmentPermission(ForumResourcePermissionCollection.FORUM_SHOW_FULL_NAMES);
Map<Long, AreaPermission> areaPermissions = new HashMap<>();
for (WorkspaceForumArea forumArea : forumController.listWorkspaceForumAreas(workspaceEntity)) {
AreaPermission areaPermission = new AreaPermission(sessionController.hasWorkspacePermission(ForumResourcePermissionCollection.FORUM_EDIT_WORKSPACE_MESSAGES, workspaceEntity), sessionController.hasWorkspacePermission(ForumResourcePermissionCollection.FORUM_DELETE_WORKSPACE_MESSAGES, workspaceEntity));
areaPermissions.put(forumArea.getId(), areaPermission);
}
canCreateArea = sessionController.hasWorkspacePermission(ForumResourcePermissionCollection.FORUM_CREATEWORKSPACEFORUM, workspaceEntity);
canUpdateArea = sessionController.hasWorkspacePermission(ForumResourcePermissionCollection.FORUM_UPDATEWORKSPACEFORUM, workspaceEntity);
canDeleteArea = sessionController.hasWorkspacePermission(ForumResourcePermissionCollection.FORUM_DELETEWORKSPACEFORUM, workspaceEntity);
try {
this.areaPermissions = new ObjectMapper().writeValueAsString(areaPermissions);
} catch (JsonProcessingException e) {
return NavigationRules.INTERNAL_ERROR;
}
return null;
}
Aggregations