use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspacePermissionsRoleManagementBackingBean 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_MANAGEWORKSPACESETTINGS, workspaceEntity)) {
return NavigationRules.ACCESS_DENIED;
}
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceName = workspaceBackingBean.getWorkspaceName();
/**
* View data
*/
permissions = permissionController.listPermissionsByScope(PermissionScope.WORKSPACE);
Collections.sort(permissions, new Comparator<Permission>() {
@Override
public int compare(Permission o1, Permission o2) {
return o1.getName().compareTo(o2.getName());
}
});
roleEntities = new ArrayList<RoleEntity>();
List<SystemRoleEntity> systemRoleEntities = roleController.listSystemRoleEntities();
List<EnvironmentRoleEntity> environmentRoleEnties = roleController.listEnvironmentRoleEntities();
List<WorkspaceRoleEntity> workspaceRoleEntities = roleController.listWorkspaceRoleEntities();
Collections.sort(environmentRoleEnties, new Comparator<EnvironmentRoleEntity>() {
@Override
public int compare(EnvironmentRoleEntity o1, EnvironmentRoleEntity o2) {
return o1.getArchetype().compareTo(o2.getArchetype());
}
});
Collections.sort(workspaceRoleEntities, new Comparator<WorkspaceRoleEntity>() {
@Override
public int compare(WorkspaceRoleEntity o1, WorkspaceRoleEntity o2) {
return o1.getArchetype().compareTo(o2.getArchetype());
}
});
for (SystemRoleEntity systemRoleEntity : systemRoleEntities) {
roleEntities.add(systemRoleEntity);
}
for (EnvironmentRoleEntity environmentRoleEntity : environmentRoleEnties) {
roleEntities.add(environmentRoleEntity);
}
for (WorkspaceRoleEntity workspaceRoleEntity : workspaceRoleEntities) {
roleEntities.add(workspaceRoleEntity);
}
return null;
}
use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspaceUsersBackingBean 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;
}
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
if (!sessionController.hasWorkspacePermission(MuikkuPermissions.LIST_WORKSPACE_MEMBERS, workspaceEntity)) {
return NavigationRules.NOT_FOUND;
}
return null;
}
use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspaceHelpPageManagementBackingBean 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.MANAGE_WORKSPACE_HELP, workspaceEntity)) {
return NavigationRules.ACCESS_DENIED;
}
rootFolder = workspaceMaterialController.findWorkspaceRootFolderByWorkspaceEntity(workspaceEntity);
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceName = workspaceBackingBean.getWorkspaceName();
try {
WorkspaceMaterial helpPage = workspaceMaterialController.ensureWorkspaceHelpPageExists(workspaceEntity);
contentNodes = Arrays.asList(workspaceMaterialController.createContentNode(helpPage));
} catch (WorkspaceMaterialException e) {
logger.log(Level.SEVERE, "Error loading materials", e);
return NavigationRules.INTERNAL_ERROR;
}
materialsBaseUrl = String.format("/workspace/%s/materials", workspaceUrlName);
return null;
}
use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspaceJournalBackingBean 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.ACCESS_WORKSPACE_JOURNAL, workspaceEntity)) {
return NavigationRules.ACCESS_DENIED;
}
if (studentId != null && !sessionController.hasWorkspacePermission(MuikkuPermissions.LIST_ALL_JOURNAL_ENTRIES, workspaceEntity)) {
return NavigationRules.ACCESS_DENIED;
}
workspaceBackingBean.setWorkspaceUrlName(urlName);
workspaceEntityId = workspaceEntity.getId();
canListAllEntries = sessionController.hasWorkspacePermission(MuikkuPermissions.LIST_ALL_JOURNAL_ENTRIES, workspaceEntity);
return null;
}
use of org.ocpsoft.rewrite.annotation.RequestAction in project muikku by otavanopisto.
the class WorkspaceManagementBackingBean 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.MANAGE_WORKSPACE, workspaceEntity)) {
return NavigationRules.ACCESS_DENIED;
}
workspaceEntityId = workspaceEntity.getId();
workspaceBackingBean.setWorkspaceUrlName(urlName);
WorkspaceEntityFile customFrontImage = workspaceEntityFileController.findWorkspaceEntityFile(workspaceEntity, "workspace-frontpage-image-cropped");
hasCustomFrontPageImage = customFrontImage != null;
customFrontPageImageUrl = hasCustomFrontPageImage ? String.format("/rest/workspace/workspaces/%d/workspacefile/workspace-frontpage-image-cropped", workspaceEntity.getId()) : null;
return null;
}
Aggregations