Package org.nxplanner.tags

Examples of org.nxplanner.tags.DomainContext


        return loadedObject;
    }

    private void checkAuthorization(Object object, String permission)
            throws RepositoryException {
        DomainContext context = new DomainContext();
        try {
            context.populate(object);
            int objectIdentifier = ((Integer)PropertyUtils.getProperty(object, "id")).intValue();
            if (!SystemAuthorizer.get().hasPermission(context.getProjectId(),
                    SecurityHelper.getRemoteUserId(ThreadServletRequest.get()), object, permission)) {
                throw new AuthorizationException("not authorized for object "+permission+": "+
                        objectClass+" "+objectIdentifier);
            }
        } catch (RuntimeException e) {
View Full Code Here


    // Support Functions
    //

    private int getProjectId(Class containerClass, int containerId) throws Exception {
        Object object = ThreadSession.get().load(containerClass, new Integer(containerId));
        DomainContext context = new DomainContext();
        context.populate(object);
        return context.getProjectId();
    }
View Full Code Here

        context.populate(object);
        return context.getProjectId();
    }

    private int getProjectId(Object object) throws Exception {
        DomainContext context = new DomainContext();
        context.populate(object);
        return context.getProjectId();
    }
View Full Code Here

            }
        });
    }

    public void setUpDomainContext() {
        DomainContext context = new DomainContext();
        context.setProjectId(10);
        context.save(request);
    }
View Full Code Here

        }
    }

    protected DomainContext setDomainContext(HttpServletRequest request, Object object)
            throws Exception {
        DomainContext domainContext = DomainContext.get(request);
        if (domainContext != null) {
            return domainContext;
        }
        domainContext = new DomainContext();
        domainContext.populate(object);
        String projectIdParam = request.getParameter("projectId");
        if (domainContext.getProjectId() == 0 && StringUtils.isNotEmpty(projectIdParam) && !projectIdParam.equals("0")) {
            ObjectRepository objectRepository = getRepository(Project.class);
            Project project = (Project)objectRepository.load(Integer.parseInt((request.getParameter("projectId"))));
            domainContext.populate(project);
        }
        domainContext.save(request);
        return domainContext;
    }
View Full Code Here

        Project project = newProject();
        Iteration iteration = newIteration(project);
        UserStory story = newUserStory(iteration);
        Task task = newTask(story);
        commitCloseAndOpenSession();
        DomainContext context = new DomainContext();
        context.populate(task);
        assertEquals(project.getId(), context.getProjectId());
        assertEquals(project.getName(), context.getProjectName());
        assertEquals(iteration.getId(), context.getIterationId());
        assertEquals(iteration.getName(), context.getIterationName());
        assertEquals(story.getId(), context.getStoryId());
        assertEquals(story.getName(), context.getStoryName());
        assertSame(task, context.getTargetObject());
    }
View Full Code Here

    public void testPopulateStory() throws Exception {
        Project project = newProject();
        Iteration iteration = newIteration(project);
        UserStory story = newUserStory(iteration);
        commitCloseAndOpenSession();
        DomainContext context = new DomainContext();
        context.populate(story);
        assertEquals(project.getId(), context.getProjectId());
        assertEquals(project.getName(), context.getProjectName());
        assertEquals(iteration.getId(), context.getIterationId());
        assertEquals(iteration.getName(), context.getIterationName());
        assertEquals(story.getId(), context.getStoryId());
        assertEquals(story.getName(), context.getStoryName());
        assertSame(story, context.getTargetObject());
    }
View Full Code Here

TOP

Related Classes of org.nxplanner.tags.DomainContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.