Example #1
0
 protected void setUpLegacyContext() {
   if (getTestMethod().getAnnotation(Legacy.class) != null
       || getClass().getAnnotation(Legacy.class) != null) {
     LegacyUtils.beginLegacyContext();
     legacyContext = true;
   }
 }
Example #2
0
 protected void tearDownLegacyContext() {
   if (getTestMethod().getAnnotation(Legacy.class) != null
       || getClass().getAnnotation(Legacy.class) != null) {
     if (legacyContext) {
       LegacyUtils.endLegacyContext();
       legacyContext = false;
     }
   }
 }
 /**
  * @see ValueHolderFieldPair for information on why we need to do field sychronization related to
  *     weaving
  */
 protected void synchronizeEclipseLinkWeavings(Object persistableObject) {
   if (LegacyUtils.isKradDataManaged(persistableObject.getClass())) {
     List<ValueHolderFieldPair> fieldPairs =
         loadValueHolderFieldPairs(persistableObject.getClass());
     for (ValueHolderFieldPair fieldPair : fieldPairs) {
       fieldPair.synchronizeValueHolder(persistableObject);
     }
   }
 }
  /** @see org.kuali.rice.krad.service.DataObjectMetaDataService#getDataObjectIdentifierString */
  @Override
  public String getDataObjectIdentifierString(Object dataObject) {
    String identifierString = "";

    if (dataObject == null) {
      identifierString = "Null";
      return identifierString;
    }

    Class<?> dataObjectClass = dataObject.getClass();
    // if Legacy and a PersistableBusinessObject or if not Legacy and implement GlobalLyUnique use
    // the object id field
    if ((PersistableBusinessObject.class.isAssignableFrom(dataObjectClass))
        || (!LegacyUtils.useLegacyForObject(dataObject)
            && GloballyUnique.class.isAssignableFrom(dataObjectClass))) {
      String objectId =
          ObjectPropertyUtils.getPropertyValue(dataObject, UifPropertyPaths.OBJECT_ID);
      if (StringUtils.isBlank(objectId)) {
        objectId = UUID.randomUUID().toString();
        ObjectPropertyUtils.setPropertyValue(dataObject, UifPropertyPaths.OBJECT_ID, objectId);
      }
    }
    return identifierString;
  }
  @Override
  public void process(final HttpServletRequest request, final HttpServletResponse response)
      throws IOException, ServletException {
    // indicates that we are running in legacy KNS context
    LegacyUtils.beginLegacyContext();
    try {
      if (LOG.isInfoEnabled()) {
        LOG.info(
            new StringBuffer("Started processing request: '")
                .append(request.getRequestURI())
                .append("' w/ query string: '")
                .append(request.getQueryString())
                .append("'"));
      }

      try {
        strutsProcess(request, response);
      } catch (FileUploadLimitExceededException e) {
        ActionForward actionForward =
            processException(request, response, e, e.getActionForm(), e.getActionMapping());
        processForwardConfig(request, response, actionForward);
      } finally {
        KNSGlobalVariables.setKualiForm(null);
      }

      try {
        ActionForm form = WebUtils.getKualiForm(request);

        if (form != null && form instanceof KualiDocumentFormBase) {
          String docId = ((KualiDocumentFormBase) form).getDocId();
          if (docId != null) {
            MDC.put(MDC_DOC_ID, docId);
          }
        }

        String refreshCaller = request.getParameter(KRADConstants.REFRESH_CALLER);
        if (form != null
            && KualiDocumentFormBase.class.isAssignableFrom(form.getClass())
            && !KRADConstants.QUESTION_REFRESH.equalsIgnoreCase(refreshCaller)) {
          KualiDocumentFormBase docForm = (KualiDocumentFormBase) form;
          Document document = docForm.getDocument();
          String docFormKey = docForm.getFormKey();

          UserSession userSession =
              (UserSession) request.getSession().getAttribute(KRADConstants.USER_SESSION_KEY);

          if (WebUtils.isDocumentSession(document, docForm)) {
            getSessionDocumentService()
                .setDocumentForm(docForm, userSession, request.getRemoteAddr());
          }

          Boolean exitingDocument = (Boolean) request.getAttribute(KRADConstants.EXITING_DOCUMENT);

          if (exitingDocument != null && exitingDocument.booleanValue()) {
            // remove KualiDocumentFormBase object from session and
            // table.
            getSessionDocumentService()
                .purgeDocumentForm(
                    docForm.getDocument().getDocumentNumber(),
                    docFormKey,
                    userSession,
                    request.getRemoteAddr());
          }
        }

        if (LOG.isInfoEnabled()) {
          LOG.info(
              new StringBuffer("Finished processing request: '")
                  .append(request.getRequestURI())
                  .append("' w/ query string: '")
                  .append(request.getQueryString())
                  .append("'"));
        }

      } finally {
        // MDC docId key is set above, and also during super.process() in the call to
        // processActionForm
        MDC.remove(MDC_DOC_ID);
      }
    } finally {
      LegacyUtils.endLegacyContext();
    }
  }
 /**
  * Determines if JPA is enabled for the KNS and for the given class
  *
  * @param clazz the class to check for JPA enabling of
  * @return true if JPA is enabled for the class, false otherwise
  */
 public boolean isJpaEnabledForKradClass(Class clazz) {
   return !LegacyUtils.useLegacy(clazz);
 }