test_class.file: utils/src/test/java/com/cloud/utils/UriUtilsTest.java
test_class.identifier: UriUtilsTest
test_case.body: @Test
      public void getUpdateUri() {
          // no password param, no request for encryption
          Assert.assertEquals("http://localhost/foo/bar?param=true", UriUtils
                  .getUpdateUri("http://localhost/foo/bar?param=true", false));
          // there is password param but still no request for encryption, should
          // be unchanged
          Assert.assertEquals("http://localhost/foo/bar?password=1234", UriUtils
                  .getUpdateUri("http://localhost/foo/bar?password=1234", false));
          // if there is password param and encryption is requested then it may or
          // may not be changed depending on how the EncrytionUtils is setup, but
          // at least it needs to start with the same url
          Assert.assertTrue(UriUtils.getUpdateUri(
                  "http://localhost/foo/bar?password=1234", true).startsWith(
                  "http://localhost/foo/bar"));
  
          //just to see if it is still ok with multiple parameters
          Assert.assertEquals("http://localhost/foo/bar?param1=true&param2=12345", UriUtils
                  .getUpdateUri("http://localhost/foo/bar?param1=true&param2=12345", false));
  
          //XXX: Interesting cases not covered:
          // * port is ignored and left out from the return value
      }
test_case.class_method_signature: UriUtilsTest.getUpdateUri()
test_case.full_signature: @Test public void getUpdateUri()
test_case.identifier: getUpdateUri
test_case.invocations: assertEquals getUpdateUri assertEquals getUpdateUri assertTrue startsWith getUpdateUri assertEquals getUpdateUri
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void getUpdateUri()
focal_class.declarator: s_logger = LoggerFactory.getLogger(UriUtils.class.getName())
focal_class.modifier: public static final
focal_class.original_string: public static final Logger s_logger = LoggerFactory.getLogger(UriUtils.class.getName());
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.file: utils/src/main/java/com/cloud/utils/UriUtils.java
focal_class.identifier: UriUtils
focal_class.class_method_signature: UriUtils.formNfsUri(String host, String path)
focal_class.full_signature: public static String formNfsUri(String host, String path)
focal_class.identifier: formNfsUri
focal_class.modifiers: public static
focal_class.parameters: (String host, String path)
focal_class.return: String
focal_class.signature: String formNfsUri(String host, String path)
focal_class.class_method_signature: UriUtils.formIscsiUri(String host, String iqn, Integer lun)
focal_class.full_signature: public static String formIscsiUri(String host, String iqn, Integer lun)
focal_class.identifier: formIscsiUri
focal_class.modifiers: public static
focal_class.parameters: (String host, String iqn, Integer lun)
focal_class.return: String
focal_class.signature: String formIscsiUri(String host, String iqn, Integer lun)
focal_class.class_method_signature: UriUtils.formFileUri(String path)
focal_class.full_signature: public static String formFileUri(String path)
focal_class.identifier: formFileUri
focal_class.modifiers: public static
focal_class.parameters: (String path)
focal_class.return: String
focal_class.signature: String formFileUri(String path)
focal_class.class_method_signature: UriUtils.encodeURIComponent(String url)
focal_class.full_signature: public static String encodeURIComponent(String url)
focal_class.identifier: encodeURIComponent
focal_class.modifiers: public static
focal_class.parameters: (String url)
focal_class.return: String
focal_class.signature: String encodeURIComponent(String url)
focal_class.class_method_signature: UriUtils.getCifsUriParametersProblems(URI uri)
focal_class.full_signature: public static String getCifsUriParametersProblems(URI uri)
focal_class.identifier: getCifsUriParametersProblems
focal_class.modifiers: public static
focal_class.parameters: (URI uri)
focal_class.return: String
focal_class.signature: String getCifsUriParametersProblems(URI uri)
focal_class.class_method_signature: UriUtils.hostAndPathPresent(URI uri)
focal_class.full_signature: public static boolean hostAndPathPresent(URI uri)
focal_class.identifier: hostAndPathPresent
focal_class.modifiers: public static
focal_class.parameters: (URI uri)
focal_class.return: boolean
focal_class.signature: boolean hostAndPathPresent(URI uri)
focal_class.class_method_signature: UriUtils.cifsCredentialsPresent(URI uri)
focal_class.full_signature: public static boolean cifsCredentialsPresent(URI uri)
focal_class.identifier: cifsCredentialsPresent
focal_class.modifiers: public static
focal_class.parameters: (URI uri)
focal_class.return: boolean
focal_class.signature: boolean cifsCredentialsPresent(URI uri)
focal_class.class_method_signature: UriUtils.getUpdateUri(String url, boolean encrypt)
focal_class.full_signature: public static String getUpdateUri(String url, boolean encrypt)
focal_class.identifier: getUpdateUri
focal_class.modifiers: public static
focal_class.parameters: (String url, boolean encrypt)
focal_class.return: String
focal_class.signature: String getUpdateUri(String url, boolean encrypt)
focal_class.class_method_signature: UriUtils.getUserDetails(String query)
focal_class.full_signature: private static List<NameValuePair> getUserDetails(String query)
focal_class.identifier: getUserDetails
focal_class.modifiers: private static
focal_class.parameters: (String query)
focal_class.return: List<NameValuePair>
focal_class.signature: List<NameValuePair> getUserDetails(String query)
focal_class.class_method_signature: UriUtils.getRemoteSize(String url)
focal_class.full_signature: public static Long getRemoteSize(String url)
focal_class.identifier: getRemoteSize
focal_class.modifiers: public static
focal_class.parameters: (String url)
focal_class.return: Long
focal_class.signature: Long getRemoteSize(String url)
focal_class.class_method_signature: UriUtils.validateUrl(String url)
focal_class.full_signature: public static Pair<String, Integer> validateUrl(String url)
focal_class.identifier: validateUrl
focal_class.modifiers: public static
focal_class.parameters: (String url)
focal_class.return: Pair<String, Integer>
focal_class.signature: Pair<String, Integer> validateUrl(String url)
focal_class.class_method_signature: UriUtils.validateUrl(String format, String url)
focal_class.full_signature: public static Pair<String, Integer> validateUrl(String format, String url)
focal_class.identifier: validateUrl
focal_class.modifiers: public static
focal_class.parameters: (String format, String url)
focal_class.return: Pair<String, Integer>
focal_class.signature: Pair<String, Integer> validateUrl(String format, String url)
focal_class.class_method_signature: UriUtils.checkUrlExistence(String url)
focal_class.full_signature: public static void checkUrlExistence(String url)
focal_class.identifier: checkUrlExistence
focal_class.modifiers: public static
focal_class.parameters: (String url)
focal_class.return: void
focal_class.signature: void checkUrlExistence(String url)
focal_class.class_method_signature: UriUtils.checkFormat(String format, String uripath)
focal_class.full_signature: private static void checkFormat(String format, String uripath)
focal_class.identifier: checkFormat
focal_class.modifiers: private static
focal_class.parameters: (String format, String uripath)
focal_class.return: void
focal_class.signature: void checkFormat(String format, String uripath)
focal_class.class_method_signature: UriUtils.getInputStreamFromUrl(String url, String user, String password)
focal_class.full_signature: public static InputStream getInputStreamFromUrl(String url, String user, String password)
focal_class.identifier: getInputStreamFromUrl
focal_class.modifiers: public static
focal_class.parameters: (String url, String user, String password)
focal_class.return: InputStream
focal_class.signature: InputStream getInputStreamFromUrl(String url, String user, String password)
focal_method.body: public static String getUpdateUri(String url, boolean encrypt) {
          String updatedPath = null;
          try {
              String query = URIUtil.getQuery(url);
              URIBuilder builder = new URIBuilder(url);
              builder.removeQuery();
  
              StringBuilder updatedQuery = new StringBuilder();
              List<NameValuePair> queryParams = getUserDetails(query);
              ListIterator<NameValuePair> iterator = queryParams.listIterator();
              while (iterator.hasNext()) {
                  NameValuePair param = iterator.next();
                  String value = null;
                  if ("password".equalsIgnoreCase(param.getName()) &&
                          param.getValue() != null) {
                      value = encrypt ? DBEncryptionUtil.encrypt(param.getValue()) : DBEncryptionUtil.decrypt(param.getValue());
                  } else {
                      value = param.getValue();
                  }
  
                  if (updatedQuery.length() == 0) {
                      updatedQuery.append(param.getName()).append('=')
                              .append(value);
                  } else {
                      updatedQuery.append('&').append(param.getName())
                              .append('=').append(value);
                  }
              }
  
              String schemeAndHost = "";
              URI newUri = builder.build();
              if (newUri.getScheme() != null) {
                  schemeAndHost = newUri.getScheme() + "://" + newUri.getHost();
              }
  
              updatedPath = schemeAndHost + newUri.getPath() + "?" + updatedQuery;
          } catch (URISyntaxException e) {
              throw new CloudRuntimeException("Couldn't generate an updated uri. " + e.getMessage());
          }
  
          return updatedPath;
      }
focal_method.class_method_signature: UriUtils.getUpdateUri(String url, boolean encrypt)
focal_method.full_signature: public static String getUpdateUri(String url, boolean encrypt)
focal_method.identifier: getUpdateUri
focal_method.invocations: getQuery removeQuery getUserDetails listIterator hasNext next equalsIgnoreCase getName getValue encrypt getValue decrypt getValue getValue length append append append getName append append append append getName build getScheme getScheme getHost getPath getMessage
focal_method.modifiers: public static
focal_method.parameters: (String url, boolean encrypt)
focal_method.return: String
focal_method.signature: String getUpdateUri(String url, boolean encrypt)