Example #1
0
 private void parse(Properties properties, String prefix) {
   properties.clear();
   for (String found : found(prefix)) {
     Property property = new Property(StringUtils.removeStartIgnoreCase(found, prefix));
     properties.setProperty(property.getName(), property.getValue());
   }
 }
Example #2
0
  public static String toWkt(GeometryCollection gc) {
    StringBuffer result;
    if (gc.isValid() == false) {
      result = new StringBuffer("GEOMETRYCOLLECTION EMPTY");
    } else {
      // 1st figure out if all the collection is the same type
      Geometry type = null;
      for (Geometry g : gc.getGeometries()) {
        if (type == null) {
          type = g;
        } else if (!type.getClass().isInstance(g)) {
          type = null;
          break;
        }
      }

      if (type == null) {
        result = new StringBuffer("GEOMETRYCOLLECTION EMPTY");
      } else {
        String strip = null;
        if (GeometryCollection.class.isInstance(type)) {
          result = new StringBuffer("GEOMETRYCOLLECTION(");
        } else if (Point.class.isInstance(type)) {
          result = new StringBuffer("MULTIPOINT(");
          strip = "POINT";
        } else if (LineString.class.isInstance(type)) {
          result = new StringBuffer("MULTILINESTRING(");
          strip = "LINESTRING";
        } else if (Polygon.class.isInstance(type)) {
          result = new StringBuffer("MULTIPOLYGON(");
          strip = "POLYGON";
        } else {
          result = new StringBuffer("GEOMETRYCOLLECTION EMPTY");
        }

        String sep = "";
        for (Geometry g : gc.getGeometries()) {
          result.append(sep);

          // strip the name if it a multi... type
          result.append(StringUtils.removeStartIgnoreCase(toWkt(g), strip));

          sep = ",";
        }
        result.append(")");
      }
    }

    return result.toString();
  }
  @Test
  public void testResolveNames() {
    Set<String> addresses = new HashSet<String>();
    initializeCredentials();
    ResolveNames request = new ResolveNames();
    request.setContactDataShape(DefaultShapeNamesType.ALL_PROPERTIES);
    request.setReturnFullContactData(true);
    request.setSearchScope(ResolveNamesSearchScopeType.ACTIVE_DIRECTORY_CONTACTS);
    request.setUnresolvedEntry("ctcudd");

    ResolveNamesResponse response = ewsClient.resolveNames(request);
    ArrayOfResponseMessagesType arrayOfResponseMessages = response.getResponseMessages();
    List<JAXBElement<? extends ResponseMessageType>> responseMessages =
        arrayOfResponseMessages
            .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages();
    for (JAXBElement<? extends ResponseMessageType> element : responseMessages) {
      ResolveNamesResponseMessageType rnrmt = (ResolveNamesResponseMessageType) element.getValue();
      ArrayOfResolutionType arrayOfResolutionType = rnrmt.getResolutionSet();
      List<ResolutionType> resolutions = arrayOfResolutionType.getResolutions();
      for (ResolutionType resolution : resolutions) {
        ContactItemType contact = resolution.getContact();
        EmailAddressDictionaryType emailAddresses = contact.getEmailAddresses();
        List<EmailAddressDictionaryEntryType> entries = emailAddresses.getEntries();
        for (EmailAddressDictionaryEntryType entry : entries) {
          String value = entry.getValue();
          if (StringUtils.isNotBlank(value)) {
            value = value.toLowerCase();
            value = StringUtils.removeStartIgnoreCase(value, "smtp:");
            addresses.add(value);
          }
        }
      }
    }
    for (String s : addresses) {
      log.info(s);
    }
  }