Get and process the URL from the properties map

@param properties
@return The processed URL
@throws RottenTomatoesException
515613
private static String getUrlFromProps(Map<String, String> properties) throws RottenTomatoesException {
        if (properties.containsKey(PROPERTY_URL) && StringUtils.isNotBlank(properties.get(PROPERTY_URL))) {
            String url = properties.get(PROPERTY_URL);

            // If we have the ID, then we need to replace the "{movie-id}" in the URL
            if (properties.containsKey(PROPERTY_ID) && StringUtils.isNotBlank(properties.get(PROPERTY_ID))) {
                url = url.replace(MOVIE_ID, String.valueOf(properties.get(PROPERTY_ID)));
                // We don't need this property anymore
                properties.remove(PROPERTY_ID);
            }
            // We don't need this property anymore
            properties.remove(PROPERTY_URL);
            return url;
        } else {
            throw new RottenTomatoesException(ApiExceptionType.INVALID_URL, "No URL specified");
        }
    }
219432
public static Map<String, ?> propsToStringKeyMap(Properties properties) {
    ImmutableMap.Builder<String, Object> mapBuilder = ImmutableMap.builder();
    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
      mapBuilder.put(entry.getKey().toString(), entry.getValue());
    }
    return mapBuilder.build();
  }
507451
@Override
    public Collection<PropertySourceLoader> getPropertySourceLoaders() {
        Collection<PropertySourceLoader> propertySourceLoaderList = this.propertySourceLoaderList;
        if (propertySourceLoaderList == null) {
            synchronized (this) { // double check
                propertySourceLoaderList = this.propertySourceLoaderList;
                if (propertySourceLoaderList == null) {
                    propertySourceLoaderList = evaluatePropertySourceLoaders();
                    this.propertySourceLoaderList = propertySourceLoaderList;
                }
            }
        }
        return propertySourceLoaderList;
    }
701993
@Override
    public String asString(Properties properties) {
        try {
            return super.asString(properties);
        } catch (TransformerException e) {
            throw wrapExceptionAsRuntimeException(e);
        }
    }
1194882
public Map<String, Object> convertPropertiesToMap(Properties properties) {
        return properties.entrySet().stream()
                .collect(toLinkedMap(
                        e -> e.getKey().toString(),
                        e -> e.getValue()));
    }
1023198
@Override
    public String getProxyURL() {
        try {
            if (hasProperty(PROXY_FOR)) {
                return getProperty(PROXY_FOR).getString();
            }
            return null;
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
239761
public static UrlParser parse(final String url, Properties prop) throws SQLException {
    if (url != null
        && (url.startsWith("jdbc:mariadb:") || url.startsWith("jdbc:mysql:") && !url
        .contains(DISABLE_MYSQL_URL))) {
      UrlParser urlParser = new UrlParser();
      parseInternal(urlParser, url, (prop == null) ? new Properties() : prop);
      return urlParser;
    }
    return null;
  }
31024
static public Map<String,Object> propertiesToMap(Dictionary<?, ?> properties)
    {
        Map<String,Object> map = null;
        if (properties != null)
        {
	        map = new Hashtable<String,Object>();
	        Enumeration<?> keys = properties.keys();
	        while (keys.hasMoreElements())
	        {
	        	Object key = keys.nextElement();
                map.put((String)key, properties.get(key));	            
	        }
        }
        return map;
    }
1141355
public UrlPath urlPath() {
        if (null == urlPath) {
            urlPath = UrlPath.of(null == processedUrl ? req().url() : processedUrl);
        }
        return urlPath;
    }
883130
public Object getAsRaw(String property) {
		if (super.has(property)) {
			return get(property).getAsRaw();
		}
		return null;
	}
707278
public RunRemoteProcessMessageData setupUserProperties(Map<String, Object> properties)
    {
        try {
            Record recUser = this.getMainRecord();
            
            String processClassName = (String)properties.get(RunRemoteProcessMessageData.PROCESS_CLASS_NAME);
            
            // Step 1 - Get the web site prefix
            String sitePrefix = (String)properties.get(MenusMessageData.SITE_PREFIX);
            String fullSitePrefix = sitePrefix;
            String strDomain = (String)properties.get(DBParams.DOMAIN);
            if (strDomain == null)
            {
                strDomain = this.getProperty(DBParams.DOMAIN);
                if ((strDomain == null) || (strDomain.length() == 0))
                    strDomain = DEFAULT_DOMAIN;
                if (strDomain.indexOf('.') != strDomain.lastIndexOf('.'))
                    strDomain = strDomain.substring(strDomain.indexOf('.') + 1);
            }
            String homeMenu = (String)properties.get(MenusMessageData.SITE_HOME_MENU);
        
            // Next, Create a main site menu for this new domain.
            Record recMenus = this.getRecord(Menus.MENUS_FILE);
            recMenus.addNew();
            String siteTemplate = (String)properties.get(SITE_TEMPLATE_CODE_PARAM);
            recMenus.getField(Menus.CODE).setString(siteTemplate);
            int iOldOrder = recMenus.getDefaultOrder();
            recMenus.setKeyArea(Menus.CODE_KEY);
            BaseBuffer buffer = null;
            if (recMenus.seek(null))
            {
                buffer = new VectorBuffer(null);
                buffer.fieldsToBuffer(recMenus);
            }
            else
                return null;        // Error - Site template does not exist
            recMenus.setKeyArea(iOldOrder);
            
            recMenus.addNew();
            if (buffer != null)     // Always
                buffer.bufferToFields(recMenus, DBConstants.DISPLAY, DBConstants.INIT_MOVE);
            
            recMenus.getField(Menus.SEQUENCE).setValue(100);
            String siteNameTemplate = (String)properties.get(SITE_NAME_TEMPLATE_PARAM);
            if (siteNameTemplate == null)
                siteNameTemplate = "{0}''s Demo site";
            String siteName = MessageFormat.format(siteNameTemplate, sitePrefix.toUpperCase().substring(0,1) + sitePrefix.substring(1));
            recMenus.getField(Menus.NAME).setString(siteName);
            ((PropertiesField)recMenus.getField(Menus.PARAMS)).setProperty(MAIN_USER_PARAM, recUser.getField(UserInfo.USER_NAME).toString());
            String templateArchivePath = ((PropertiesField)recMenus.getField(Menus.PARAMS)).getProperty(DBConstants.USER_ARCHIVE_FOLDER);
            if ((templateArchivePath == null) || (templateArchivePath.length() == 0))
                templateArchivePath = Utility.addToPath(DEFAULT_ARCHIVE_FOLDER, CURRENT_TEST_DATA_DIR);
            
            int iErrorCode = DBConstants.DUPLICATE_KEY;
            int iCounter = 0;
            while (iErrorCode == DBConstants.DUPLICATE_KEY)
            {
                try {
                    fullSitePrefix = sitePrefix;
                    if (iCounter > 0)
                        fullSitePrefix += Integer.toString(iCounter);
        
                    recMenus.getField(Menus.CODE).setString(fullSitePrefix + '.' + strDomain);
        
                    recMenus.add();
                    iErrorCode = DBConstants.NORMAL_RETURN;
                } catch (DBException ex) {
                    iErrorCode = ex.getErrorCode();
                    if (iErrorCode != DBConstants.DUPLICATE_KEY)
                    {
                        ex.printStackTrace();
                        return null;     // Error
                    }
                    iCounter++;
                    if (iCounter >= 100)
                        break;
                }
            }
            // Now we have this user's domain: sitePrefix
            
            // Update the user's account to show they own this new domain
            if (iErrorCode == DBConstants.NORMAL_RETURN)
            {
                iOldOrder = recUser.getDefaultOrder();
                recUser.setKeyArea(UserInfo.ID_KEY);
                recUser.edit();
                ((PropertiesField)recUser.getField(UserInfo.PROPERTIES)).setProperty(MenusMessageData.DOMAIN_NAME, recMenus.getField(Menus.CODE).toString());
                ((PropertiesField)recUser.getField(UserInfo.PROPERTIES)).setProperty(DBParams.HOME, homeMenu);
                recUser.set();
                recUser.setKeyArea(iOldOrder);
            }
            
            TreeMessage message = new TreeMessage(null, null);
            RunRemoteProcessMessageData runRemoteProcessRequest = new RunRemoteProcessMessageData(message, null);
        
            CreateSiteMessageData createSiteRequest = new CreateSiteMessageData(runRemoteProcessRequest, null);
            runRemoteProcessRequest.addMessageDataDesc(createSiteRequest);
            MessageRecordDesc userInfoMessageData = (MessageRecordDesc)createSiteRequest.getMessageDataDesc(UserInfo.USER_INFO_FILE);
            MessageRecordDesc menusMessageData = (MessageRecordDesc)createSiteRequest.getMessageDataDesc(Menus.MENUS_FILE);
            
            String user = this.getProperty(DBParams.USER_NAME);
            String auth = this.getProperty(DBParams.AUTH_TOKEN);
            runRemoteProcessRequest.put(RunRemoteProcessMessageData.PROCESS_CLASS_NAME, processClassName);
            runRemoteProcessRequest.put(DBParams.USER_NAME, user);
            runRemoteProcessRequest.put(DBParams.AUTH_TOKEN, auth);
            
            userInfoMessageData.putRawRecordData(recUser);  // User, password
        
            menusMessageData.put(MenusMessageData.DOMAIN_NAME, fullSitePrefix + '.' + strDomain);
            menusMessageData.put(MenusMessageData.SITE_PREFIX, fullSitePrefix);
            menusMessageData.put(MenusMessageData.SITE_NAME, siteName);
            menusMessageData.put(MenusMessageData.XSL_TEMPLATE_PATH, templateArchivePath);
            menusMessageData.put(MenusMessageData.SITE_TEMPLATE_MENU, siteTemplate);
            menusMessageData.put(MenusMessageData.SITE_HOME_MENU, homeMenu);
        
            return runRemoteProcessRequest;
            
        } catch (DBException ex) {
            return null;
        }
    }
165767
public List<Review> getMoviesReviews(int movieId, String reviewType, int pageLimit, int page, String country) throws RottenTomatoesException {
        properties.clear();
        properties.put(ApiBuilder.PROPERTY_ID, String.valueOf(movieId));
        properties.put(ApiBuilder.PROPERTY_URL, URL_MOVIES_REVIEWS);
        properties.put(ApiBuilder.PROPERTY_REVIEW_TYPE, reviewType);
        properties.put(ApiBuilder.PROPERTY_PAGE_LIMIT, ApiBuilder.validatePageLimit(pageLimit));
        properties.put(ApiBuilder.PROPERTY_PAGE, ApiBuilder.validatePage(page));
        properties.put(ApiBuilder.PROPERTY_COUNTRY, ApiBuilder.validateCountry(country));

        WrapperLists wrapper = response.getResponse(WrapperLists.class, properties);
        if (wrapper != null && wrapper.getReviews() != null) {
            return wrapper.getReviews();
        } else {
            return Collections.emptyList();
        }
    }
375147
public String getJnlpURL(String strJnlpURL, Map<String,Object> propApplet, Map<String,Object> properties)
    {
        String strBaseURL = (String)properties.get(DBParams.BASE_URL);
        if (strBaseURL == null)
            strBaseURL = DBConstants.BLANK;
        else if ((!strBaseURL.startsWith("/")) && (!strBaseURL.startsWith("http:")))
            strBaseURL = "//" + strBaseURL;
        if (!strBaseURL.startsWith("http:"))
            strBaseURL = "http:" + strBaseURL;
        StringBuffer sbJnlpURL = new StringBuffer(strBaseURL);

        if ((strJnlpURL == null) || (strJnlpURL.length() == 0))
        	strJnlpURL = DEFAULT_JNLP_URL;
        sbJnlpURL.append(strJnlpURL);
        
        sbJnlpURL.append("&" + DBParams.APPLET + "=" + propApplet.get(DBParams.APPLET));
        try {
            for (Map.Entry<String,Object> entry : properties.entrySet())
            {
                String strKey = entry.getKey();
                Object objValue = entry.getValue();
                String strValue = null;
                if (objValue != null)
                    strValue = objValue.toString();
                if (strValue != null)
//x                    if (strValue.length() > 0)
                        sbJnlpURL.append("&" + strKey + "=" + URLEncoder.encode(strValue, DBConstants.URL_ENCODING));
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return sbJnlpURL.toString();
    }
800712
public static Map<String, ?> getMapFromProperties(Properties properties, String prefix) {
        Map<String, Object> result = new HashMap<String, Object>();
        for (String key : properties.stringPropertyNames()) {
            if (key.startsWith(prefix)) {
                String name = key.substring(prefix.length());
                result.put(name, properties.getProperty(key));
            }
        }
        return result;
    }
1346388
private String getServerURL(String entityBaseURL, String entityAlias, String processingURL) {

        return getServerURL(entityBaseURL, entityAlias, processingURL, null);

    }
429202
public static void loadPropertiesFromURL(URL url) {
        if (url == null) {
            return;
        }
        InputStream in = null;
        try {
            in = url.openStream();
            properties.load(in);
        } catch (IOException e) {
            AnalysisContext.logError("Unable to load properties from " + url, e);
        } finally {
            IO.close(in);
        }
    }
308268
public String getUrl(String mockupType) {
        return mockupType == null ? null : mockupTypes.getProperty(mockupType);
    }