Package org.dspace.core

Examples of org.dspace.core.Context


    }

    @Override
    protected List<T> getWSObject(QueryResponse response)
    {
        Context context = null;
        List<T> results = new LinkedList<T>();
        try
        {
            context = new Context();
            for (SolrDocument solrDocument : response.getResults())
            {
                T aa = (T) getSearchServices().findDSpaceObject(context,
                        solrDocument);
                results.add(aa);
            }

        }
        catch (SQLException e)
        {
            log.error(e.getMessage(), e);
        }
        finally
        {
            if (context != null && context.isValid())
            {
                context.abort();
            }
        }
        return results;
    }
View Full Code Here


            response.sendError(HttpServletResponse.SC_NOT_FOUND,
                    "Grant page not found");
            return null;
        }

        Context context = UIUtil.obtainContext(request);

        EPerson currentUser = context.getCurrentUser();
       
        if ((grant.getStatus() == null || grant.getStatus().booleanValue() == false)
                && !AuthorizeManager.isAdmin(context))
        {
           
View Full Code Here

            HttpServletResponse response) throws SQLException, Exception
    {

        // check admin authorization
        Boolean isAdmin = null; // anonymous access
        Context context = UIUtil.obtainContext(request);

        if (AuthorizeManager.isAdmin(context))
        {
            isAdmin = true; // admin
        }
View Full Code Here

        AnagraficaObjectAreaDTO anagraficaObjectDTO = (AnagraficaObjectAreaDTO) command;

        // check admin authorization
        boolean isAdmin = false;
        Context context = UIUtil.obtainContext(request);
        if (AuthorizeManager.isAdmin(context))
        {
            isAdmin = true;
        }
View Full Code Here

        if (paramId != null)
        {
            id = Integer.parseInt(paramId);
        }
        Project grant = getApplicationService().get(Project.class, id);
        Context context = UIUtil.obtainContext(request);
        if (!AuthorizeManager.isAdmin(context))
        {
            throw new AuthorizeException("Only system admin can edit");
        }
        else
View Full Code Here

   * technical documentation for further details.
   */
  public static void main(String[] args) throws ParseException, SQLException {
    // TODO move logic in ImportExportUtils
    log.info("#### START IMPORT: -----" + new Date() + " ----- ####");
    Context dspaceContext = new Context();
    dspaceContext.setIgnoreAuthorization(true);
    DSpace dspace = new DSpace();
    ApplicationService applicationService = dspace.getServiceManager()
        .getServiceByName("applicationService",
            ApplicationService.class);
    CommandLineParser parser = new PosixParser();

    String xmlFilePath = null;

    Options options = new Options();
    options.addOption("rpmode", "rpmode", false, "if this check exist then import from internal database");
    options.addOption("f", "file", true, "File xml to import");
    options.addOption("h", "help", false, "help");

    options.addOption("status", "status", false, "Get active RPs only");
    options.addOption("active", "active", false,
        "Set active true newly created grants public");
    options.addOption("newly", "newly", false,
        "Get only newly grants find on rps");

    // RPs status flag. Default is get public RPs
    boolean status = false;
    // RGs active flag. Default is inactive.
    boolean active = false;
    // Import only newly grants (with new grantCode)
    boolean newly = false;

    CommandLine line = parser.parse(options, args);

    if (line.hasOption('h')) {
      HelpFormatter myhelp = new HelpFormatter();
      myhelp.printHelp("ScriptHRURP \n", options);
      System.out
          .println("\n\nUSAGE:\n ScriptHKURG [<-status> <-rpmode mode>|<-f file>] [<-active> <-newly>] \n");
      System.out
          .println("Please note: Script import in database mode (-rpmode) or file mode (-f), default is status false and active false and newly false (get only RPs with status false and from its projects create inactive grants and all grants finded on rps)");
      System.exit(0);
    }

    if (!line.hasOption("rpmode")) {
      if (!line.hasOption("f")) {
        xmlFilePath = ImportExportUtils.GRANT_PATH_DEFAULT_XML;
      } else {
        xmlFilePath = line.getOptionValue("f");
      }
    } else {
      if (line.hasOption("status")) {
        status = true;
      } else {
        status = false;
      }
      if (line.hasOption("newly")) {
        newly = true;
      } else {
        newly = false;
      }
    }
   
    if (line.hasOption("active")) {
      active = true;
    } else {
      active = false;
    }

    try {
      if (xmlFilePath != null) {
        String path = ConfigurationManager
            .getProperty(CrisConstants.CFG_MODULE, "researchergrant.file.import.path");
        File dir = new File(path);
        ImportExportUtils.importGrantsXML(new FileInputStream(
            xmlFilePath), dir, applicationService, dspaceContext,
            active);
      } else {
        ImportExportUtils.importGrants(applicationService,
            dspaceContext, status, active, newly);
      }
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }
    log.info("#### END IMPORT: -----" + new Date() + " ----- ####");
    dspaceContext.complete();
  }
View Full Code Here

    public void reject(int itemID, String authorityKey)
    {
        init();
        ResearcherPage cris = applicationService
                .getResearcherByAuthorityKey(authorityKey);
        Context context = null;

        try
        {
            context = new Context();
            context.turnOffAuthorisationSystem();
            List<String> list = new ArrayList<String>();
            list.add(String.valueOf(itemID));
            relationPreferenceService.unlink(context, cris, "publications",
                    list);
            context.restoreAuthSystemState();
        }
        catch (SQLException e)
        {
            log.error(e.getMessage(), e);
        }
        finally
        {
            if(context!=null && context.isValid()) {
                context.abort();
            }
        }

    }
View Full Code Here

    public void reject(int[] itemIDs, String authorityKey)
    {
        init();
        ResearcherPage cris = applicationService
                .getResearcherByAuthorityKey(authorityKey);
        Context context = null;
        try
        {
            context = new Context();
            context.turnOffAuthorisationSystem();
            List<String> list = new ArrayList<String>();
            for(int itemID : itemIDs) {
                list.add(String.valueOf(itemID));   
            }
           
            relationPreferenceService.unlink(context, cris, "publications",
                    list);
            context.restoreAuthSystemState();
        }
        catch (SQLException e)
        {
            log.error(e.getMessage(), e);
        }
        finally
        {
            if(context!=null && context.isValid()) {
                context.abort();
            }
        }
       
    }
View Full Code Here

   * the technical documentation for further details.
   */
  public static void main(String[] args) throws ParseException, SQLException {
    // TODO move logic in ImportExportUtils
    log.info("#### START IMPORT: -----" + new Date() + " ----- ####");
    Context dspaceContext = new Context();
    dspaceContext.setIgnoreAuthorization(true);
    DSpace dspace = new DSpace();
        ApplicationService applicationService = dspace.getServiceManager().getServiceByName(
                "applicationService", ApplicationService.class);
       
    String excelFilePath = null;

    CommandLineParser parser = new PosixParser();

    Options options = new Options();
    options.addOption("h", "help", false, "help");

    options.addOption("f", "file", true, "File xml to import");

    // allen's added argument
    options.addOption("active", "active", false,
        "Set newly created epersons active");
    options.addOption("inactive", "inactive", false,
        "Set newly created epersons inactive");
     
    // active or inactive for newly created epersons. Default is inactive.
    boolean status = false;

    CommandLine line = parser.parse(options, args);

    if (line.hasOption('h')) {
      HelpFormatter myhelp = new HelpFormatter();
      myhelp.printHelp("ScriptHRURP \n", options);
      System.out
          .println("\n\nUSAGE:\n ScriptHKURP <-f path_file_xml> \n");
      System.out
          .println("Please note: -f is not mandatory, if -f is not specified then default path_file_xml is : "
              + ImportExportUtils.PATH_DEFAULT_XML);
      System.exit(0);
    }

    if (!line.hasOption("f")) {
      excelFilePath = ImportExportUtils.PATH_DEFAULT_XML;
    } else {
      excelFilePath = line.getOptionValue("f");
    }

    // allen: use -active to make newly created eperson active.
    // allen: -inactive is optional. Default is already inactive.
    if (line.hasOption("active")) {
      status = true;
    } else {
      status = false;
    }
   
    String path = ConfigurationManager
        .getProperty(CrisConstants.CFG_MODULE, "researcherpage.file.import.path");
    File dir = new File(path);
    try {
      ImportExportUtils.importResearchersXML(new FileInputStream(excelFilePath),
          dir, applicationService, dspaceContext, status);
    } catch (Exception e) {
      log.error(e.getMessage());
    }
    log.info("#### END IMPORT: -----" + new Date() + " ----- ####");
    dspaceContext.complete();
  }
View Full Code Here

        boolean test = line.hasOption("t");

        if (test)
            log.setLevel(Level.DEBUG);
        Context context = null;
        try
        {
            context = new Context();
            Researcher researcher = new Researcher();
            ApplicationService applicationService = researcher
                    .getApplicationService();

            List<CrisComponentsService> serviceComponent = researcher
                    .getAllCrisComponents();
            for (CrisComponentsService service : serviceComponent)
            {
                for (ICRISComponent component : service.getComponents()
                        .values())
                {
                    RelationConfiguration relationConfiguration = component
                            .getRelationConfiguration();
                    if (Item.class.isAssignableFrom(relationConfiguration.getRelationClass()))
                    {
                        Integer key = CrisConstants.getEntityType(component.getTarget());
                        String query = relationConfiguration.getQuery();
                        if(!mapRelationFields.containsKey(key)) {
                            List<String> rels = new LinkedList<String>();
                            rels.add(query);
                            mapRelationFields.put(key, rels);
                        }
                        else {
                            mapRelationFields.get(key).add(query);
                        }
                    }
                }
            }
            processDaily(researcher, applicationService, context, test);
        }
        catch (Exception e)
        {
            log.error(e.getMessage(), e);
        }
        finally
        {
            if (context != null && context.isValid())
            {
                // Nothing is actually written
                context.abort();
            }
        }
        log.info("#### END: -----" + new Date() + " ----- ####");
        System.exit(0);
    }
View Full Code Here

TOP

Related Classes of org.dspace.core.Context

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.