/* (non-Javadoc)
   * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
   */
  @Override
  public String getText(Object element) {
    StandardFieldColumn column = (StandardFieldColumn) element;
    IARESProject project = com.hundsun.ares.studio.core.util.ResourcesUtil.getARESProject(bundle);
    IMetadataService service =
        DataServiceManager.getInstance().getService(project, IMetadataService.class);
    if (service != null) {
      IStandardField filed = service.getStandardField(column.getStandardField());
      if (filed != null) {
        switch (type) {
          case ChineseName:
            return StringUtils.defaultString(filed.getChineseName());
          case Desciption:
            StringBuffer text = new StringBuffer();
            IDictionaryType dictType = filed.getDictionaryType();
            if (dictType instanceof DeDictionaryType) {
              for (DeDictionaryItem item : ((DeDictionaryType) dictType).getItems()) {
                String value = StringUtils.defaultString(item.getValue());
                String chineseName = StringUtils.defaultString(item.getChineseName());
                text.append(value);
                text.append(":");
                text.append(chineseName);
                text.append(" ");
              }
            }
            return StringUtils.defaultString(
                StringUtils.defaultIfBlank(text.toString(), filed.getDescription()));
          case Type:
            return StringUtils.defaultString(filed.getDataTypeId());
        }
      }
    }

    return StringUtils.EMPTY;
  }
  /** @see org.displaytag.util.RequestHelper#getParameterMap() */
  public Map getParameterMap() {

    Map map = new HashMap();

    // get the parameters names
    Enumeration parametersName = this.request.getParameterNames();

    while (parametersName.hasMoreElements()) {
      // ... get the value
      String paramName = (String) parametersName.nextElement();

      request.getParameter(paramName);
      // put key/value in the map
      String[] originalValues =
          (String[])
              ObjectUtils.defaultIfNull(this.request.getParameterValues(paramName), new String[0]);
      String[] values = new String[originalValues.length];

      for (int i = 0; i < values.length; i++) {
        try {
          values[i] =
              URLEncoder.encode(
                  StringUtils.defaultString(originalValues[i]),
                  StringUtils.defaultString(
                      response.getCharacterEncoding(), "UTF8")); // $NON-NLS-1$
        } catch (UnsupportedEncodingException e) {
          throw new UnhandledException(e);
        }
      }
      map.put(paramName, values);
    }

    // return the Map
    return map;
  }
Beispiel #3
0
  /**
   * Gets details for a given user. These details include first names, last name, email, prefix,
   * last login date, and created on date.
   *
   * @param loggedInUser The current user
   * @param login The login for the user you want the details for
   * @return Returns a Map containing the details for the given user.
   * @throws FaultException A FaultException is thrown if the user doesn't have access to lookup the
   *     user corresponding to login or if the user does not exist.
   * @xmlrpc.doc Returns the details about a given user.
   * @xmlrpc.param #param("string", "sessionKey")
   * @xmlrpc.param #param_desc("string", "login", "User's login name.")
   * @xmlrpc.returntype #struct("user details") #prop_desc("string", "first_names", "deprecated, use
   *     first_name") #prop("string", "first_name") #prop("string", "last_name") #prop("string",
   *     "email") #prop("int", "org_id") #prop("string", "org_name") #prop("string", "prefix")
   *     #prop("string", "last_login_date") #prop("string", "created_date") #prop_desc("boolean",
   *     "enabled", "true if user is enabled, false if the user is disabled") #prop_desc("boolean",
   *     "use_pam", "true if user is configured to use PAM authentication") #struct_end()
   */
  public Map getDetails(User loggedInUser, String login) throws FaultException {
    User target = XmlRpcUserHelper.getInstance().lookupTargetUser(loggedInUser, login);
    LocalizationService ls = LocalizationService.getInstance();

    Map ret = new HashMap();
    ret.put("first_names", StringUtils.defaultString(target.getFirstNames()));
    ret.put("first_name", StringUtils.defaultString(target.getFirstNames()));
    ret.put("last_name", StringUtils.defaultString(target.getLastName()));
    ret.put("email", StringUtils.defaultString(target.getEmail()));
    ret.put("prefix", StringUtils.defaultString(target.getPrefix()));

    // Last login date
    String lastLoggedIn =
        target.getLastLoggedIn() == null ? "" : ls.formatDate(target.getLastLoggedIn());
    ret.put("last_login_date", lastLoggedIn);

    // Created date
    String created = target.getCreated() == null ? "" : ls.formatDate(target.getCreated());
    ret.put("created_date", created);
    ret.put("org_id", loggedInUser.getOrg().getId());
    ret.put("org_name", loggedInUser.getOrg().getName());

    if (target.isDisabled()) {
      ret.put("enabled", Boolean.FALSE);
    } else {
      ret.put("enabled", Boolean.TRUE);
    }
    ret.put("use_pam", target.getUsePamAuthentication());

    return ret;
  }
  /**
   * Saves a value edited directly inside the tree. This can also be a lable
   *
   * @return name of the view
   */
  public String saveValue() {
    String saveName = this.getRequest().getParameter("saveName"); // $NON-NLS-1$
    Tree tree = getTree();

    // value to save is a node data's value (config admin)
    boolean isNodeDataValue =
        "true"
            .equals(this.getRequest().getParameter("isNodeDataValue")); // $NON-NLS-1$ //$NON-NLS-2$

    // value to save is a node data's type (config admin)
    boolean isNodeDataType =
        "true"
            .equals(this.getRequest().getParameter("isNodeDataType")); // $NON-NLS-1$ //$NON-NLS-2$

    String value =
        StringUtils.defaultString(this.getRequest().getParameter("saveValue")); // $NON-NLS-1$
    displayValue = StringUtils.EMPTY;
    // value to save is a content's meta information
    boolean isMeta =
        "true".equals(this.getRequest().getParameter("isMeta")); // $NON-NLS-1$ //$NON-NLS-2$
    // value to save is a label (name of page, content node or node data)
    boolean isLabel =
        "true".equals(this.getRequest().getParameter("isLabel")); // $NON-NLS-1$ //$NON-NLS-2$

    if (isNodeDataValue || isNodeDataType) {
      tree.setPath(StringUtils.substringBeforeLast(path, "/")); // $NON-NLS-1$
      saveName = StringUtils.substringAfterLast(path, "/"); // $NON-NLS-1$
    } else {
      // "/modules/templating/Templates/x"
      tree.setPath(path);
    }

    if (isLabel) {
      displayValue = rename(value);
    } else if (isNodeDataType) {
      int type = Integer.valueOf(value).intValue();
      synchronized (ExclusiveWrite.getInstance()) {
        displayValue = tree.saveNodeDataType(saveName, type);
      }
    } else {
      synchronized (ExclusiveWrite.getInstance()) {
        displayValue = tree.saveNodeData(saveName, value, isMeta);
      }
    }

    // if there was a displayValue passed show it instead of the written value
    displayValue =
        StringUtils.defaultString(
            this.getRequest().getParameter("displayValue"), value); // $NON-NLS-1$

    // @todo should be handled in a better way but, at the moment, this is better than nothing
    if (path.startsWith("/subscribers/")) { // $NON-NLS-1$
      Subscriber.reload();
    } else if (path.startsWith("/server/MIMEMapping")) { // $NON-NLS-1$
      MIMEMapping.reload();
    }

    return VIEW_VALUE;
  }
Beispiel #5
0
 private void addMetacardCrs(
     final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {
   StringBuilder crs = new StringBuilder();
   crs.append("urn:ogc:def:crs:");
   crs.append(StringUtils.defaultString(pathValueTracker.getPathValue(CRS_AUTHORITY_PATH)));
   crs.append(COLON);
   crs.append(StringUtils.defaultString(pathValueTracker.getPathValue(CRS_VERSION_PATH)));
   crs.append(COLON);
   crs.append(StringUtils.defaultString(pathValueTracker.getPathValue(CRS_CODE_PATH)));
   metacard.setAttribute(GmdMetacardType.GMD_CRS, crs.toString());
 }
Beispiel #6
0
  private void logDeviceInformation(Guid vmId, Map device) {
    String message =
        "Received a {} Device without an address when processing VM {} devices, skipping device";
    String deviceType = (String) device.get(VdsProperties.Device);

    if (shouldLogDeviceDetails(deviceType)) {
      Map<String, Object> deviceInfo = device;
      log.info(message + ": {}", StringUtils.defaultString(deviceType), vmId, deviceInfo);
    } else {
      log.info(message, StringUtils.defaultString(deviceType), vmId);
    }
  }
  private void initialize() {
    String filename = StringUtils.defaultString(level.getName());
    GridData gridDataLabel = new GridData();
    gridDataLabel.widthHint = 100;
    gridDataLabel.verticalAlignment = GridData.CENTER;
    gridDataLabel.horizontalAlignment = GridData.END;
    GridData gridDataText = new GridData();
    gridDataText.heightHint = -1;
    gridDataText.widthHint = 150;
    GridLayout gridLayoutMy = new GridLayout();
    gridLayoutMy.numColumns = 2;
    gridLayoutMy.marginWidth = 25;
    gridLayoutMy.verticalSpacing = 5;
    gridLayoutMy.horizontalSpacing = 20;
    gridLayoutMy.marginHeight = 25;
    gridLayoutMy.makeColumnsEqualWidth = false;
    GridData gridDataMy = new GridData();
    gridDataMy.grabExcessHorizontalSpace = true;
    gridDataMy.verticalAlignment = GridData.CENTER;
    gridDataMy.horizontalSpan = 1;
    gridDataMy.horizontalAlignment = GridData.FILL;
    this.setLayoutData(gridDataMy);
    this.setLayout(gridLayoutMy);
    Label labelTitle = new Label(this, SWT.RIGHT);
    labelTitle.setText(
        "*   ".concat(LabelHolder.get("dialog.pojo.level.fields.title"))); // $NON-NLS-1$
    labelTitle.setLayoutData(gridDataLabel);
    textTitle = new Text(this, SWT.BORDER);
    textTitle.setTextLimit(256);
    textTitle.setLayoutData(gridDataText);
    textTitle.setText(StringUtils.defaultString(level.getTitle()));
    Label labelName = new Label(this, SWT.RIGHT);
    labelName.setText(
        "*   ".concat(LabelHolder.get("dialog.pojo.level.fields.name"))); // $NON-NLS-1$
    labelName.setLayoutData(gridDataLabel);
    textName = new Text(this, SWT.BORDER);
    textName.setTextLimit(256);
    textName.setLayoutData(gridDataText);
    textName.setText(filename);
    textName.addVerifyListener(new FileNameVerifier());
    textName.addModifyListener(new ModifyListenerClearErrorMessages(dialogCreator));

    Collection<String> forbiddenNames = new ArrayList<String>();
    Collection<Level> sisters = level.getParent().getSublevels();
    if (CollectionUtils.isNotEmpty(sisters))
      for (Level otherLevel : sisters) forbiddenNames.add(otherLevel.getName());
    if (StringUtils.isNotBlank(filename)) forbiddenNames.remove(filename);
    if (level.getId()
        == APoormansObject
            .UNSET_VALUE) // suggestion of the file name should work just with new  objects
    textTitle.addModifyListener(
          new FilenameSuggestorListener(dialogCreator, textName, forbiddenNames));
  }
  private String formatNameInternal(final Customer customer, final String format) {
    if (customer != null) {

      final Map<String, String> values = new HashMap<String, String>();
      values.put("salutation", StringUtils.defaultString(customer.getSalutation()));
      values.put("firstname", StringUtils.defaultString(customer.getFirstname()));
      values.put("middlename", StringUtils.defaultString(customer.getMiddlename()));
      values.put("lastname", StringUtils.defaultString(customer.getLastname()));

      return new StrSubstitutor(values, "{{", "}}").replace(format);
    }
    return StringUtils.EMPTY;
  }
Beispiel #9
0
 private License(Map<String, String> properties) {
   this.additionalProperties = new HashMap<>(properties);
   product = StringUtils.defaultString(get("Product", properties), get("Plugin", properties));
   organization =
       StringUtils.defaultString(get("Organisation", properties), get("Name", properties));
   expirationDate =
       StringUtils.defaultString(get("Expiration", properties), get("Expires", properties));
   type = get("Type", properties);
   server = get("Server", properties);
   // SONAR-4340 Don't expose Digest and Obeo properties
   additionalProperties.remove("Digest");
   additionalProperties.remove("Obeo");
 }
 protected void setTableAttributes(TableHandler tableHandler) {
   Table table = tableHandler.getTable();
   setAttribute("currentpage", table.getCurrentPage());
   setAttribute("rowcount", table.getRowCount());
   setAttribute("maxrowspage", table.getMaxRowsPerPage());
   setAttribute("headerposition", table.getHeaderPosition());
   setAttribute(
       "htmlstyleedit",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getHtmlStyle())));
   setAttribute(
       "rowevenstyleedit",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowEvenStyle())));
   setAttribute(
       "rowoddstyleedit",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowOddStyle())));
   setAttribute(
       "rowhoverstyleedit",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowHoverStyle())));
   setAttribute(
       "htmlclass", StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getHtmlClass())));
   setAttribute(
       "rowevenclass",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowEventClass())));
   setAttribute(
       "rowoddclass",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowOddClass())));
   setAttribute(
       "rowhoverclass",
       StringUtils.defaultString(StringEscapeUtils.escapeHtml(table.getRowHoverClass())));
   setAttribute("htmlstyleview", table.getHtmlStyle());
 }
 public int compareTo(final EingangsrechnungDO o) {
   int r = this.datum.compareTo(o.datum);
   if (r != 0) {
     return -r;
   }
   String s1 = StringUtils.defaultString(this.kreditor);
   String s2 = StringUtils.defaultString(o.kreditor);
   r = s1.compareTo(s2);
   if (r != 0) {
     return -r;
   }
   s1 = StringUtils.defaultString(this.referenz);
   s2 = StringUtils.defaultString(o.referenz);
   return s1.compareTo(s2);
 }
Beispiel #12
0
  /**
   * Sets the details for a given user. Settable details include: first names, last name, email,
   * prefix, and password.
   *
   * @param loggedInUser The current user user.
   * @param login The login for the user you want to edit
   * @param details A map containing the new details values
   * @return Returns 1 if edit was successful, an error is thrown otherwise
   * @throws FaultException A FaultException is thrown if the user doesn't have access to lookup the
   *     user corresponding to login or if the user does not exist.
   * @xmlrpc.doc Updates the details of a user.
   * @xmlrpc.param #param("string", "sessionKey")
   * @xmlrpc.param #param_desc("string", "login", "User's login name.")
   * @xmlrpc.param #struct("user details") #prop_desc("string", "first_names", "deprecated, use
   *     first_name") #prop("string", "first_name") #prop("string", "last_name") #prop("string",
   *     "email") #prop("string", "prefix") #prop("string", "password") #struct_end()
   * @xmlrpc.returntype #return_int_success()
   */
  public int setDetails(User loggedInUser, String login, Map details) throws FaultException {

    validateMap(USER_EDITABLE_DETAILS.keySet(), details);

    // Lookup user handles the logic for making sure that the loggedInUser
    // has access to the login they are trying to edit.
    User target = XmlRpcUserHelper.getInstance().lookupTargetUser(loggedInUser, login);

    UpdateUserCommand uuc = new UpdateUserCommand(target);

    // Process each entry passed in by the user
    for (Object userKey : details.keySet()) {

      // Check to make sure we have an internal key mapping to prevent issues
      // if the user passes in cruft
      String internalKey = USER_EDITABLE_DETAILS.get(userKey);
      if (internalKey != null) {
        String newValue = StringUtils.defaultString((String) details.get(userKey));
        prepareAttributeUpdate(internalKey, uuc, newValue);
      }
    }

    try {
      uuc.updateUser();
    } catch (IllegalArgumentException iae) {
      throw new UserNotUpdatedException(iae.getMessage());
    }

    // If we made it here without an exception, then we are a.o.k.
    return 1;
  }
Beispiel #13
0
  /**
   * Adds new devices recognized by libvirt
   *
   * @param vmId
   * @param device
   */
  private Guid addNewVmDevice(Guid vmId, Map device, String logicalName) {
    Guid newDeviceId = Guid.Empty;
    String typeName = (String) device.get(VdsProperties.Type);
    String deviceName = (String) device.get(VdsProperties.Device);

    // do not allow null or empty device or type values
    if (StringUtils.isEmpty(typeName) || StringUtils.isEmpty(deviceName)) {
      log.error("Empty or NULL values were passed for a VM '{}' device, Device is skipped", vmId);
    } else {
      String address = ((Map<String, String>) device.get(VdsProperties.Address)).toString();
      String alias = StringUtils.defaultString((String) device.get(VdsProperties.Alias));
      Object o = device.get(VdsProperties.SpecParams);
      newDeviceId = Guid.newGuid();
      VmDeviceId id = new VmDeviceId(newDeviceId, vmId);
      VmDevice newDevice =
          new VmDevice(
              id,
              VmDeviceGeneralType.forValue(typeName),
              deviceName,
              address,
              0,
              o == null ? new HashMap<String, Object>() : (Map<String, Object>) o,
              false,
              true,
              Boolean.getBoolean((String) device.get(VdsProperties.ReadOnly)),
              alias,
              null,
              null,
              logicalName);
      newVmDevices.add(newDevice);
      log.debug("New device was marked for adding to VM '{}' Devices : '{}'", vmId, newDevice);
    }

    return newDeviceId;
  }
 private String getNameForField(Field field) {
   IdentifyUsing identificationUsing = field.getAnnotation(IdentifyUsing.class);
   if (identificationUsing != null) {
     return StringUtils.defaultString(identificationUsing.elementname());
   }
   return StringUtils.EMPTY;
 }
  /**
   * retrieve if delegatable
   *
   * @param action
   * @param attributeDefName
   * @return if delegatable or grant
   */
  private AttributeAssignDelegatable retrieveDelegatable(
      String action, AttributeDefName attributeDefName) {

    if (AttributeDefType.perm != attributeDefName.getAttributeDef().getAttributeDefType()) {
      throw new RuntimeException(
          "Can only delegate a permission: "
              + attributeDefName.getAttributeDef().getAttributeDefType());
    }

    Set<PermissionEntry> permissionEntries =
        GrouperDAOFactory.getFactory()
            .getPermissionEntry()
            .findByMemberIdAndAttributeDefNameId(
                GrouperSession.staticGrouperSession().getMemberUuid(), attributeDefName.getId());

    boolean isGrant = false;
    boolean isDelegate = false;
    action = StringUtils.defaultString(action, AttributeDef.ACTION_DEFAULT);
    for (PermissionEntry permissionEntry : permissionEntries) {
      if (permissionEntry.isEnabled() && StringUtils.equals(action, permissionEntry.getAction())) {
        AttributeAssignDelegatable localDelegatable =
            permissionEntry.getAttributeAssignDelegatable();
        isGrant = isGrant || (localDelegatable == AttributeAssignDelegatable.GRANT);
        isDelegate = isDelegate || localDelegatable.delegatable();
      }
    }
    if (isGrant) {
      return AttributeAssignDelegatable.GRANT;
    }
    if (isDelegate) {
      return AttributeAssignDelegatable.TRUE;
    }
    return AttributeAssignDelegatable.FALSE;
  }
Beispiel #16
0
 /**
  * setter for the "href" tag attribute.
  *
  * @param value attribute value
  */
 public void setHref(String value) {
   // call encodeURL to preserve session id when cookies are disabled
   String encodedHref =
       ((HttpServletResponse) this.pageContext.getResponse())
           .encodeURL(StringUtils.defaultString(value));
   this.href = new DefaultHref(encodedHref);
 }
Beispiel #17
0
  @Override
  protected void initState() {
    super.initState();
    config = InterMineContext.getWebConfig();
    String prefix = getPropertyPrefix();
    Properties namespaced = new NameSpacedProperties(prefix, webProperties);
    refType = namespaced.getProperty("referenceClass");
    featType = namespaced.getProperty("featureClass");
    domainPath = namespaced.getProperty("domain");
    identPath = namespaced.getProperty("paths.ident");
    lengthPath = namespaced.getProperty("paths.length", "length");
    referenceLabel = namespaced.getProperty("reference.label");
    referenceCat = namespaced.getProperty("reference.category");
    featureCat = namespaced.getProperty("feature.category");
    referenceKey = namespaced.getProperty("reference.key");

    String pathInfo = StringUtils.defaultString(request.getPathInfo(), "/").trim().substring(1);
    String[] parts = pathInfo.split("/", 2);
    if (parts.length != 2) {
      throw new ResourceNotFoundException("NOT FOUND");
    }
    domain = parts[0];
    fileName = parts[1];
    dataset = webProperties.getProperty("project.title") + "-" + domain;
  }
 private static String getUid(HttpServletRequest request) {
   String pathInfo = StringUtils.defaultString(request.getPathInfo(), "").replaceAll("^/", "");
   if (pathInfo.length() > 0) {
     return pathInfo;
   }
   return null;
 }
 public static JID full(String jid) {
   jid = StringUtils.defaultString(jid);
   return new JID(
       XmppStringUtils.parseLocalpart(jid),
       XmppStringUtils.parseDomain(jid),
       XmppStringUtils.parseResource(jid));
 }
  /**
   * Creates a {@link User} object containing the information in the {@link Attributes} object.
   *
   * @param directoryAttributes The directory-specific {Attributes} object to take the values from
   * @return A populated {User} object.
   */
  public UserTemplateWithAttributes mapUserFromAttributes(Attributes directoryAttributes)
      throws NamingException {
    if (directoryAttributes == null) {
      throw new UncategorizedLdapException("Cannot map from null attributes");
    }

    String username = getUsernameFromAttributes(directoryAttributes);

    UserTemplate user = new UserTemplate(username, directoryId);

    // active
    user.setActive(getUserActiveFromAttribute(directoryAttributes));

    // email address
    user.setEmailAddress(StringUtils.defaultString(getUserEmailFromAttribute(directoryAttributes)));

    // first (given) name
    user.setFirstName(getUserFirstNameFromAttribute(directoryAttributes));

    // surname
    user.setLastName(getUserLastNameFromAttribute(directoryAttributes));

    // display name
    user.setDisplayName(getUserDisplayNameFromAttribute(directoryAttributes));

    // pre-populate user names (first name, last name, display name may need to be constructed)
    User prepopulatedUser = UserUtils.populateNames(user);

    return UserTemplateWithAttributes.ofUserWithNoAttributes(prepopulatedUser);
  }
  /**
   * 调用Action方法
   *
   * @param method 方法名称
   * @param header header信息
   * @param params 参数信息
   * @return 返回调用结果
   */
  private String invokeAction(
      String method, Map<Object, Object> header, Map<Object, Object> params) {
    String response = null;
    try {
      Object action = getAction(method);
      // logger.info("action is ={}",action);
      if (null != action) {
        long bTime = System.currentTimeMillis();
        Class<?> parmTypes[] = new Class[] {Map.class, Map.class};
        int beginIndex = method.lastIndexOf('.') + 1;
        int endIndex = method.length();
        String methodName = StringUtils.defaultString(method.substring(beginIndex, endIndex), "");
        methodName = methodName.trim();
        // logger.info("action methodName is {} ",methodName);
        Method invokMethod = action.getClass().getMethod(methodName, parmTypes);
        Object args[] = new Object[2];
        args[0] = header;
        args[1] = params;
        response = (String) invokMethod.invoke(action, args);
        long eTime = System.currentTimeMillis();

      } else {
        response = GlobalConfJson.getErrMsgString("-1", "指定的服务不存在!");
      }
    } catch (Exception e) {
      logger.error("调用服务出错", e);
      response = GlobalConfJson.getErrMsgString("-1", "调用服务出错!");
    }
    return response;
  }
 // Allow name as /user/queries/:name and /user/queries?name=:name
 private String getName() {
   String name = StringUtils.defaultString(request.getPathInfo(), "");
   name = name.replaceAll("^/", "");
   if (StringUtils.isBlank(name)) {
     name = getRequiredParameter("name");
   }
   return name;
 }
 private void appendHeader(Notification notif, StringBuilder sb) {
   appendLine(
       sb,
       StringUtils.defaultString(
           notif.getFieldValue("componentName"), notif.getFieldValue("componentKey")));
   appendField(sb, "Rule", null, notif.getFieldValue("ruleName"));
   appendField(sb, "Message", null, notif.getFieldValue("message"));
 }
Beispiel #24
0
 static final void addTerm(
     String label, String valueIsNull, String term, Integer year, Map<String, Object> parameters) {
   if (term != null && term.length() > 0)
     parameters.put(
         label,
         StringUtils.defaultString(term) + " " + (year == null ? "" : "and " + year.toString()));
   else parameters.put(label, (year == null ? valueIsNull : year.toString()));
 }
Beispiel #25
0
 /**
  * setter for the "url" tag attribute. This has the same meaning of href, but prepends the context
  * path to the given URI.
  *
  * @param value attribute value
  */
 public void setUrl(String value) {
   HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
   // call encodeURL to preserve session id when cookies are disabled
   String encodedHref =
       ((HttpServletResponse) this.pageContext.getResponse())
           .encodeURL(StringUtils.defaultString(req.getContextPath() + value));
   this.href = new DefaultHref(encodedHref);
 }
Beispiel #26
0
 @Before
 public void setUp() throws Exception {
   // SSLv3 is not supported since SQ 4.5.2. Only TLS v1, v1.1 and v1.2 are
   // enabled by Tomcat.
   // The problem is that java 1.6 supports only TLSv1 but not v1.1 nor 1.2,
   // so version to be used must be explicitly set on JVM.
   initialHttpsProtocols = StringUtils.defaultString(System.getProperty(HTTPS_PROTOCOLS), "");
   System.setProperty(HTTPS_PROTOCOLS, "TLSv1");
 }
Beispiel #27
0
 @CheckForNull
 public FilePath getRootPath() {
   final SlaveComputer computer = getComputer();
   if (computer == null) {
     // if computer is null then channel is null and thus we were going to return null anyway
     return null;
   } else {
     return createPath(StringUtils.defaultString(computer.getAbsoluteRemoteFs(), remoteFS));
   }
 }
Beispiel #28
0
 /**
  * Builds a URI for this resource.
  *
  * @param data the data, not null
  * @param overrideVersionId the override version id, null uses information from data
  * @return the URI, not null
  */
 public static URI uri(final WebHolidayData data, final UniqueId overrideVersionId) {
   String holidayId = data.getBestHolidayUriId(null);
   String versionId =
       StringUtils.defaultString(
           overrideVersionId != null ? overrideVersionId.getVersion() : data.getUriVersionId());
   return data.getUriInfo()
       .getBaseUriBuilder()
       .path(WebHolidayVersionResource.class)
       .build(holidayId, versionId);
 }
 private String getDescription(MetadataItem mdItem) {
   // 标准字段提示具体的说明信息  TASK #8602 输入输出中标准字段参数,能显示具体的说明信息
   if (mdItem instanceof StandardField) {
     StandardField field = (StandardField) mdItem;
     StringBuffer text = new StringBuffer();
     String dictTypeStr = field.getDictionaryType();
     if (StringUtils.isNotBlank(dictTypeStr)) {
       ReferenceInfo dictReferenceInfo =
           ReferenceManager.getInstance()
               .getFirstReferenceInfo(project, IMetadataRefType.Dict, dictTypeStr, true);
       if (dictReferenceInfo != null) {
         DictionaryType objDictionaryType = (DictionaryType) dictReferenceInfo.getObject();
         if (objDictionaryType != null) {
           for (DictionaryItem item : objDictionaryType.getItems()) {
             String value = StringUtils.defaultString(item.getValue());
             String chineseName = StringUtils.defaultString(item.getChineseName());
             text.append(objDictionaryType.getName());
             text.append(":");
             text.append(objDictionaryType.getChineseName());
             text.append("-");
             text.append(value);
             text.append(":");
             text.append(chineseName);
             text.append("\r\n");
           }
         }
       }
     }
     if (StringUtils.isNotBlank(text.toString())
         && StringUtils.isNotBlank(field.getDescription())) {
       text.append("\r\n");
       text.append(field.getDescription());
     }
     String desc =
         StringUtils.defaultString(
             StringUtils.defaultIfBlank(text.toString(), field.getDescription()));
     if (StringUtils.isNotBlank(desc)) {
       return desc;
     }
   }
   return null;
 }
 /**
  * Split a comma separated set of includes/excludes into a set of strings.
  *
  * @param cludes a comma separated set of includes/excludes.
  * @return a set of strings.
  */
 @NonNull
 static SortedSet<String> splitCludes(@CheckForNull String cludes) {
   TreeSet<String> result = new TreeSet<String>();
   StringTokenizer tokenizer = new StringTokenizer(StringUtils.defaultString(cludes), ",");
   while (tokenizer.hasMoreTokens()) {
     String clude = tokenizer.nextToken().trim();
     if (StringUtils.isNotEmpty(clude)) {
       result.add(clude.trim());
     }
   }
   return result;
 }