/* (non-Javadoc)
   * @see org.hibernate.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object)
   */
  public Object nullSafeGet(ResultSet rs, String[] names, Object owner)
      throws HibernateException, SQLException {
    byte[] bytes = rs.getBytes(names[0]);
    if (rs.wasNull()) {
      return null;
    }

    // TODO figure out how to inject this
    HomeFactory homeFactory = (HomeFactory) ComponentManager.getInstance().get("xmlHomeFactory");
    WritableObjectHome home = (WritableObjectHome) homeFactory.getHome("agent");

    StructuredArtifact artifact = (StructuredArtifact) home.createInstance();
    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
    SAXBuilder saxBuilder = new SAXBuilder();
    saxBuilder.setFeature(
        "http://apache.org/xml/features/disallow-doctype-decl", true); // SAK-23245
    try {
      Document doc = saxBuilder.build(in);
      artifact.setBaseElement(doc.getRootElement());
    } catch (JDOMException e) {
      throw new HibernateException(e);
    } catch (IOException e) {
      throw new HibernateException(e);
    }
    return artifact;
  }
  protected void resolveTransientFields() {
    // These are spelled out instead of using imports, to be explicit
    org.sakaiproject.component.api.ComponentManager compMgr =
        org.sakaiproject.component.cover.ComponentManager.getInstance();

    usageSessionServiceAdaptor =
        (UsageSessionServiceAdaptor) compMgr.get("org.sakaiproject.event.api.UsageSessionService");
  }
示例#3
0
  /** inject dependencies */
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    ComponentManager manager = org.sakaiproject.component.cover.ComponentManager.getInstance();

    if (securityService == null) {
      securityService = (SecurityService) manager.get(SecurityService.class.getName());
    }
    if (serverConfigurationService == null) {
      serverConfigurationService =
          (ServerConfigurationService) manager.get(ServerConfigurationService.class.getName());
    }
    if (sessionManager == null) {
      sessionManager = (SessionManager) manager.get(SessionManager.class.getName());
    }
  }
 public IdManager getIdManager() {
   if (idManager == null) {
     idManager = (IdManager) ComponentManager.getInstance().get("idManager");
   }
   return idManager;
 }
示例#5
0
 protected StructuredArtifactValidationService getStructuredArtifactValidationService() {
   return (StructuredArtifactValidationService)
       ComponentManager.getInstance().get(StructuredArtifactValidationService.class);
 }
 public void init() {
   ComponentManager cm = org.sakaiproject.component.cover.ComponentManager.getInstance();
   realmService = (AuthzGroupService) load(cm, AuthzGroupService.class.getName());
 }
示例#7
0
  @Override
  public void init(ServletConfig config) throws ServletException {

    super.init(config);

    siteEmailPreferenceSetter =
        (SiteEmailPreferenceSetter)
            ComponentManager.getInstance()
                .get("org.sakaiproject.lti.api.SiteEmailPreferenceSetter");
    if (siteEmailPreferenceSetter == null) {
      throw new ServletException("Failed to set siteEmailPreferenceSetter.");
    }

    siteMembershipUpdater =
        (SiteMembershipUpdater)
            ComponentManager.getInstance().get("org.sakaiproject.lti.api.SiteMembershipUpdater");
    if (siteMembershipUpdater == null) {
      throw new ServletException("Failed to set siteMembershipUpdater.");
    }

    siteMembershipsSynchroniser =
        (SiteMembershipsSynchroniser)
            ComponentManager.getInstance()
                .get("org.sakaiproject.lti.api.SiteMembershipsSynchroniser");
    if (siteMembershipsSynchroniser == null) {
      throw new ServletException("Failed to set siteMembershipsSynchroniser.");
    }

    userFinderOrCreator =
        (UserFinderOrCreator)
            ComponentManager.getInstance().get("org.sakaiproject.lti.api.UserFinderOrCreator");
    if (userFinderOrCreator == null) {
      throw new ServletException("Failed to set userFinderOrCreator.");
    }

    userPictureSetter =
        (UserPictureSetter)
            ComponentManager.getInstance().get("org.sakaiproject.lti.api.UserPictureSetter");
    if (userPictureSetter == null) {
      throw new ServletException("Failed to set userPictureSettter.");
    }

    userLocaleSetter =
        (UserLocaleSetter)
            ComponentManager.getInstance().get("org.sakaiproject.lti.api.UserLocaleSetter");
    if (userLocaleSetter == null) {
      throw new ServletException("Failed to set userLocaleSettter.");
    }

    ltiService =
        (LTIService) ComponentManager.getInstance().get("org.sakaiproject.lti.api.LTIService");
    if (ltiService == null) {
      throw new ServletException("Failed to set ltiService.");
    }

    ApplicationContext ac =
        WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());

    // load all instance of BLTIProcessor in component mgr by type detection
    Collection processors = ac.getParent().getBeansOfType(BLTIProcessor.class).values();
    bltiProcessors = new ArrayList(processors);
    // sort in using getOrder() method

    // sort them so the execution order is determined consistenly - by getOrder()
    Collections.sort(
        bltiProcessors,
        new Comparator() {
          public int compare(Object o1, Object o2) {
            return ((Comparable) ((BLTIProcessor) (o1)).getOrder())
                .compareTo(((BLTIProcessor) (o2)).getOrder());
          }
        });
  }