Exemple #1
0
  protected String getLink(SocialActivity activity, ServiceContext serviceContext)
      throws Exception {

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(activity.getClassName());

    long classPK = activity.getClassPK();

    if ((trashHandler != null)
        && (trashHandler.isInTrash(classPK) || trashHandler.isInTrashContainer(classPK))) {

      PortletURL portletURL =
          TrashUtil.getViewContentURL(
              serviceContext.getRequest(), activity.getClassName(), classPK);

      if (portletURL == null) {
        return null;
      }

      return portletURL.toString();
    }

    String path = getPath(activity, serviceContext);

    if (Validator.isNull(path)) {
      return null;
    }

    if (!path.startsWith(StringPool.SLASH)) {
      return path;
    }

    return serviceContext.getPortalURL() + serviceContext.getPathMain() + path;
  }
  @Override
  public String getURLEditWorkflowTask(long workflowTaskId, ServiceContext serviceContext)
      throws PortalException {

    try {
      PortletURL portletURL =
          PortalUtil.getControlPanelPortletURL(
              serviceContext.getRequest(),
              PortletKeys.MY_WORKFLOW_TASK,
              PortletRequest.RENDER_PHASE);

      portletURL.setParameter("mvcPath", "/edit_workflow_task.jsp");
      portletURL.setParameter("workflowTaskId", String.valueOf(workflowTaskId));
      portletURL.setWindowState(WindowState.MAXIMIZED);

      return portletURL.toString();
    } catch (WindowStateException wse) {
      throw new PortalException(wse);
    }
  }
  @Override
  public String getURLEditWorkflowTask(long workflowTaskId, ServiceContext serviceContext)
      throws PortalException, SystemException {

    try {
      LiferayPortletURL liferayPortletURL =
          PortletURLFactoryUtil.create(
              serviceContext.getRequest(),
              PortletKeys.MY_WORKFLOW_TASKS,
              PortalUtil.getControlPanelPlid(serviceContext.getCompanyId()),
              PortletRequest.RENDER_PHASE);

      liferayPortletURL.setControlPanelCategory("my");
      liferayPortletURL.setParameter("struts_action", "/my_workflow_tasks/edit_workflow_task");
      liferayPortletURL.setParameter("workflowTaskId", String.valueOf(workflowTaskId));
      liferayPortletURL.setWindowState(WindowState.MAXIMIZED);

      return liferayPortletURL.toString();
    } catch (WindowStateException wse) {
      throw new PortalException(wse);
    }
  }
Exemple #4
0
  protected List<Serializable> getFieldValues(
      DDMStructure ddmStructure,
      String fieldName,
      String fieldNamespace,
      ServiceContext serviceContext)
      throws PortalException {

    DDMFormField ddmFormField = ddmStructure.getDDMFormField(fieldName);

    String fieldDataType = ddmFormField.getDataType();
    String fieldType = ddmFormField.getType();

    LocalizedValue predefinedValue = ddmFormField.getPredefinedValue();

    List<String> fieldNames = getFieldNames(fieldNamespace, fieldName, serviceContext);

    List<Serializable> fieldValues = new ArrayList<>(fieldNames.size());

    for (String fieldNameValue : fieldNames) {
      Serializable fieldValue = serviceContext.getAttribute(fieldNameValue);

      if (Validator.isNull(fieldValue)) {
        fieldValue = predefinedValue.getString(serviceContext.getLocale());
      }

      if (fieldType.equals(DDMImpl.TYPE_CHECKBOX) && Validator.isNull(fieldValue)) {

        fieldValue = "false";
      } else if (fieldDataType.equals(FieldConstants.DATE)) {
        Date fieldValueDate = null;

        if (Validator.isNull(fieldValue)) {
          int fieldValueMonth =
              GetterUtil.getInteger(serviceContext.getAttribute(fieldNameValue + "Month"));
          int fieldValueDay =
              GetterUtil.getInteger(serviceContext.getAttribute(fieldNameValue + "Day"));
          int fieldValueYear =
              GetterUtil.getInteger(serviceContext.getAttribute(fieldNameValue + "Year"));

          fieldValueDate = PortalUtil.getDate(fieldValueMonth, fieldValueDay, fieldValueYear);
        } else {
          try {
            fieldValueDate =
                DateUtil.parseDate(String.valueOf(fieldValue), serviceContext.getLocale());
          } catch (ParseException pe) {
            if (_log.isErrorEnabled()) {
              _log.error("Unable to parse date " + fieldValue);
            }
          }
        }

        if (fieldValueDate != null) {
          fieldValue = String.valueOf(fieldValueDate.getTime());
        }
      } else if (fieldDataType.equals(FieldConstants.IMAGE) && Validator.isNull(fieldValue)) {

        HttpServletRequest request = serviceContext.getRequest();

        if (request instanceof UploadRequest) {
          String imageFieldValue = getImageFieldValue((UploadRequest) request, fieldNameValue);

          if (Validator.isNotNull(imageFieldValue)) {
            fieldValue = imageFieldValue;
          }
        }
      }

      if (Validator.isNull(fieldValue)) {
        return null;
      }

      if (DDMImpl.TYPE_RADIO.equals(fieldType) || DDMImpl.TYPE_SELECT.equals(fieldType)) {

        String predefinedValueString = predefinedValue.getString(serviceContext.getLocale());

        if (!fieldValue.equals(predefinedValueString) && (fieldValue instanceof String)) {

          fieldValue = new String[] {String.valueOf(fieldValue)};

          fieldValue = JSONFactoryUtil.serialize(fieldValue);
        }
      }

      Serializable fieldValueSerializable =
          FieldConstants.getSerializable(fieldDataType, GetterUtil.getString(fieldValue));

      fieldValues.add(fieldValueSerializable);
    }

    return fieldValues;
  }