Package jeeves.server

Examples of jeeves.server.UserSession


                                               final boolean validate, final boolean ufo, final boolean index, final String lang,
                                               final String changeDate, final boolean updateDateStamp) throws Exception {
        Element metadataXml = md;

        // when invoked from harvesters, session is null?
        UserSession session = context.getUserSession();
        if(session != null) {
            session.removeProperty(Geonet.Session.VALIDATION_REPORT + metadataId);
        }
        String schema = getMetadataSchema(metadataId);
        if(ufo) {
            String parentUuid = null;
            Integer intId = Integer.valueOf(metadataId);
View Full Code Here


        MassiveReplaceReport report = new MassiveReplaceReport(process);

        GeonetContext gc = (GeonetContext) context
                .getHandlerContext(Geonet.CONTEXT_NAME);
        DataManager dataMan = gc.getBean(DataManager.class);
        UserSession session = context.getUserSession();

        // Clear previous report
        session.removeProperty("BATCH_PROCESSING_REPORT");

        // Apply the process to the selection
        Set<Integer> metadata = new HashSet<Integer>();

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

        synchronized (sm.getSelection("metadata")) {
            report.setTotalRecords(sm.getSelection("metadata").size());
            MassiveXslMetadataReindexer m = new MassiveXslMetadataReindexer(dataMan,
                    sm.getSelection("metadata").iterator(),
                    process, params,
                    context, metadata, report);
            m.process();
        }

        // Add the report to the session
        session.setProperty("BATCH_PROCESSING_REPORT", report);


        if (fullResponse) {
            return new Element(Jeeves.Elem.RESPONSE)
                .addContent(
View Full Code Here

    }
   
    String groupOwner= Util.getParam(params, Params.GROUP);
   
    // TODO : Check user can create a metadata in that group
    UserSession user = context.getUserSession();
    if (user.getProfile() != Profile.Administrator) {
            final Specifications<UserGroup> spec = where(UserGroupSpecs.hasProfile(Profile.Editor))
                    .and(UserGroupSpecs.hasUserId(user.getUserIdAsInt()))
                    .and(UserGroupSpecs.hasGroupId(Integer.valueOf(groupOwner)));

            final List<UserGroup> userGroups = context.getBean(UserGroupRepository.class).findAll(spec);

      if (userGroups.size() == 0) {
View Full Code Here

        Lib.resource.checkEditPrivilege(context, id);

        // get info to log the upload

        UserSession session = context.getUserSession();
        String username = session.getUsername();
        if (username == null)
            username = "unknown (this shouldn't happen?)";

        String fname = file.getName();
        String fsize = Long.toString(file.getSize());
View Full Code Here

  public Element exec(Element params, ServiceContext context) throws Exception {

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);

    DataManager dm = gc.getBean(DataManager.class);
    UserSession us = context.getUserSession();


    context.info("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(us);
View Full Code Here

        Lib.resource.checkEditPrivilege(context, id);

        // get info to log the upload

        UserSession session = context.getUserSession();
        String username = session.getUsername();
        if (username == null)
            username = "unknown (this shouldn't happen?)";


        final Metadata metadata = context.getBean(MetadataRepository.class).findOne(id);
View Full Code Here

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

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

    Set<Integer> metadata = new HashSet<Integer>();
    Set<String> notFound = new HashSet<String>();
    Set<Integer> notOwner = new HashSet<Integer>();

    synchronized(sm.getSelection(SELECTION_METADATA)) {
    for (Iterator<String> iter = sm.getSelection(SELECTION_METADATA).iterator(); iter.hasNext();) {
      String uuid = iter.next();

      //--- check access

      Metadata info = context.getBean(MetadataRepository.class).findOneByUuid(uuid);
      if (info == null) {
        notFound.add(uuid);
      } else if (!accessMan.isOwner(context, String.valueOf(info.getId()))) {
        notOwner.add(info.getId());
      } else {

        //--- remove old operations
        boolean skip = false;

        //--- in case of owner, privileges for groups 0,1 and GUEST are
        //--- disabled and are not sent to the server. So we cannot remove them
        boolean isAdmin = Profile.Administrator == us.getProfile();
        boolean isReviewer= Profile.Reviewer == us.getProfile();

        if (us.getUserIdAsInt() == info.getSourceInfo().getOwner() && !isAdmin && !isReviewer) {
                    skip = true;
                }

        dm.deleteMetadataOper(context, "" + info.getId(), skip);
View Full Code Here

 
            @SuppressWarnings("unchecked")
            List<Element> requestedGroups = request.getChildren(SearchParameter.GROUP);

            Set<Integer> userGroups = gc.getBean(AccessManager.class).getUserGroups(srvContext.getUserSession(), srvContext.getIpAddress(), false);
            UserSession userSession = srvContext.getUserSession();
            // unless you are logged in as Administrator, check if you are allowed to query the groups in the query
            if (userSession == null || userSession.getProfile() == null ||
                (userSession.getProfile() != Profile.Administrator && userSession.isAuthenticated())) {
              if(!CollectionUtils.isEmpty(requestedGroups)) {
                    for(Element group : requestedGroups) {
                        if(! "".equals(group.getText())
                            && ! userGroups.contains(Integer.valueOf(group.getText()))) {
                            throw new UnAuthorizedException("You are not authorized to do this.", null);
                        }
                    }
                }
            }

            // remove elements from user input that compromise this request
            for (String fieldName : UserQueryInput.SECURITY_FIELDS){
                request.removeChildren(fieldName);
            }

      // if 'restrict to' is set then don't add any other user/group info
      if ((request.getChild(SearchParameter.GROUP) == null) ||
                (StringUtils.isEmpty(request.getChild(SearchParameter.GROUP).getText().trim()))) {
        for (Integer group : userGroups) {
          request.addContent(new Element(SearchParameter.GROUP).addContent(""+group));
                }
                String owner = null;
                if (userSession != null) {
                    owner = userSession.getUserId();
                }
                if (owner != null) {
          request.addContent(new Element(SearchParameter.OWNER).addContent(owner));
                }
          //--- in case of an admin show all results
                if (userSession != null) {
                    if (userSession.isAuthenticated()) {
                        if (userSession.getProfile() == Profile.Administrator) {
                            request.addContent(new Element(SearchParameter.ISADMIN).addContent("true"));
                        } else if (userSession.getProfile() == Profile.Reviewer) {
                            request.addContent(new Element(SearchParameter.ISREVIEWER).addContent("true"));
                        }
                    }
                }
            }
View Full Code Here

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);

    SearchManager searchMan = gc.getBean(SearchManager.class);

    // possibly close old searcher
    UserSession  session     = context.getUserSession();
    Object oldSearcher = session.getProperty(Geonet.Session.SEARCH_RESULT);

    if (oldSearcher != null)
      if (oldSearcher instanceof LuceneSearcher)
        ((LuceneSearcher)oldSearcher).close();

    // perform the search and save search result into session

    context.info("Creating UnusedSearcher");

    MetaSearcher searcher = searchMan.newSearcher(SearchManager.UNUSED, Geonet.File.SEARCH_LUCENE);

    searcher.search(context, params, null);
    session.setProperty(Geonet.Session.SEARCH_RESULT, searcher);

    context.info("Getting unused summary");

    return searcher.getSummary();
  }
View Full Code Here

  //---
  //--------------------------------------------------------------------------

  public Element exec(Element params, ServiceContext context) throws Exception
  {
    UserSession session = context.getUserSession();

    //-----------------------------------------------------------------------
    //--- handle current tab

    Element elCurrTab = params.getChild(Params.CURRTAB);
    boolean removeSchemaLocation = Util.getParam(params, "removeSchemaLocation", "false").equals("true");

    if (elCurrTab != null)
      session.setProperty(Geonet.Session.METADATA_SHOW, elCurrTab.getText());

    //-----------------------------------------------------------------------
    //--- check access

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
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.