Package jeeves.server

Examples of jeeves.server.UserSession


  public Element exec(Element params, ServiceContext context) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    DataManager dataMan = gc.getBean(DataManager.class);
    AccessManager am = gc.getBean(AccessManager.class);
    UserSession us = context.getUserSession();

    context.info("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(us);

    Set<Integer> ids = new HashSet<Integer>();
View Full Code Here


      this.userName = this.context.getUserSession().getUsername();
      this.userProfile = this.context.getUserSession().getProfile();
    }
   
    private void login() {
        UserSession session = new UserSession();
        session.loginAs(new User().setUsername(this.userName).setId(this.userId).setProfile(this.userProfile));
        this.context.setUserSession(session);
    }
View Full Code Here

                        final ServiceContext serviceContext = createServiceContext();
                        loginAsAdmin(serviceContext);

                        final String metadataCategory = metadataCategoryRepository.findAll().get(0).getName();
                        final Element sampleMetadataXml = getSampleMetadataXml();
                        final UserSession userSession = serviceContext.getUserSession();
                        final int userIdAsInt = userSession.getUserIdAsInt();
                        final DataManager dm = DataManagerWorksWithoutTransactionIntegrationTest.this.dataManager;
                        String schema = dm.autodetectSchema(sampleMetadataXml);
                        final String mdId = dm.insertMetadata(serviceContext, schema, sampleMetadataXml,
                                "uuid" + _inc.incrementAndGet(), userIdAsInt, "2", "source",
                                MetadataType.METADATA.codeString, null, metadataCategory, new ISODate().getDateAndTime(),
View Full Code Here

    @Test
    public void testDeleteMetadata() throws Exception {
        int count = (int) _metadataRepository.count();
        final ServiceContext serviceContext = createServiceContext();
        loginAsAdmin(serviceContext);
        final UserSession userSession = serviceContext.getUserSession();
        final String mdId = _dataManager.insertMetadata(serviceContext, "iso19139", new Element("MD_Metadata"), "uuid",
                userSession.getUserIdAsInt(),
                "" + ReservedGroup.all.getId(), "sourceid", "n", "doctype", null, new ISODate().getDateAndTime(), new ISODate().getDateAndTime(),
                false, false);

        assertEquals(count + 1, _metadataRepository.count());
View Full Code Here

    @Test
    public void testBuildPrivilegesMetadataInfo() throws Exception {
        final ServiceContext serviceContext = createServiceContext();
        loginAsAdmin(serviceContext);
        final UserSession userSession = serviceContext.getUserSession();
        final Element sampleMetadataXml = getSampleMetadataXml();
        String schema = _dataManager.autodetectSchema(sampleMetadataXml);

        final String mdId1 = _dataManager.insertMetadata(serviceContext, schema, new Element(sampleMetadataXml.getName(),
                        sampleMetadataXml.getNamespace()), "uuid",
                userSession.getUserIdAsInt(),
                "" + ReservedGroup.all.getId(), "sourceid", "n", "doctype", null, new ISODate().getDateAndTime(), new ISODate().getDateAndTime(),
                false, false);


        Element info = new Element("info", Geonet.Namespaces.GEONET);
View Full Code Here

        return new File(cl.getResource(testClassName + ".class").getFile());
    }

    public User loginAsAdmin(ServiceContext context) {
        final User admin = _userRepo.findAllByProfile(Profile.Administrator).get(0);
        UserSession userSession = new UserSession();
        userSession.loginAs(admin);
        context.setUserSession(userSession);
        return admin;
    }
View Full Code Here

                    public void run() throws Exception {
                        final ServiceContext serviceContext = createServiceContext();
                        loginAsAdmin(serviceContext);

                        final Element sampleMetadataXml = getSampleMetadataXml();
                        final UserSession userSession = serviceContext.getUserSession();
                        final int userIdAsInt = userSession.getUserIdAsInt();
                        final String mdId = _dataManager.insertMetadata(serviceContext, "iso19139", sampleMetadataXml,
                                "uuid" + _inc.incrementAndGet(), userIdAsInt, "2", "source",
                                MetadataType.METADATA.codeString, null, "maps", new ISODate().getDateAndTime(),
                                new ISODate().getDateAndTime(), false, false);
                        Element newMd = new Element("MD_Metadata", GMD).addContent(new Element("fileIdentifier",
View Full Code Here

      HttpServletResponse response, Authentication authentication) {
    HttpSession httpSession = request.getSession(false);
    if(httpSession != null) {
      Object tmp = httpSession.getAttribute(JeevesServlet.USER_SESSION_ATTRIBUTE_KEY);
      if (tmp instanceof UserSession) {
        UserSession userSession = (UserSession) tmp;
        userSession.clear();
      }
    }

  }
View Full Code Here

//    }
    HttpSession httpSession = req.getSession();
        if (Log.isDebugEnabled(Log.REQUEST)) {
            Log.debug(Log.REQUEST, "Session id is " + httpSession.getId());
        }
    UserSession session     = (UserSession) httpSession.getAttribute(USER_SESSION_ATTRIBUTE_KEY);

    //------------------------------------------------------------------------
    //--- create a new session if doesn't exist

    if (session == null) {
      //--- create session

      session = new UserSession();

      httpSession.setAttribute(USER_SESSION_ATTRIBUTE_KEY, session);
      session.setsHttpSession(httpSession);

            if (Log.isDebugEnabled(Log.REQUEST)) {
                Log.debug(Log.REQUEST, "Session created for client : " + ip);
            }
    }
View Full Code Here

            uuid = UUID.randomUUID().toString();

        // -----------------------------------------------------------------------
        // --- insert metadata into the system

        UserSession us = context.getUserSession();

        if (us.getUserId() == null)
            throw new NoApplicableCodeEx("User not authenticated.");

        Profile profile = us.getProfile();

        // Only editors and above are allowed to insert metadata
        if (profile != Profile.Editor && profile != Profile.Reviewer
            && profile != Profile.UserAdmin && profile != Profile.Administrator)
            throw new NoApplicableCodeEx("User not allowed to insert metadata.");

        int userId = us.getUserIdAsInt();

        AccessManager am = gc.getBean(AccessManager.class);

        // Set default group: user first group
        Set<Integer> userGroups = am.getVisibleGroups(userId);
View Full Code Here

TOP

Related Classes of jeeves.server.UserSession

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.