protected boolean isHeaderAllowed(String headerName) throws ServletException { // content-length header will be automatically added by the HTTP client // host header causes request failures when it does not match the proxy host see x-forwaded-for comment above // Origin is added by chrome / safari in post/put/delete same-origin requests. if(StringUtil.equalsIgnoreCase(headerName, "content-length") || StringUtil.equalsIgnoreCase(headerName, "host") || StringUtil.equalsIgnoreCase(headerName, "origin")) { return false; } return true; } protected boolean forwardCookies(HttpRequestBase method, HttpServletRequest request) {
/** * Returns an int to represent the given month (ex : 1 for January) * Returns -1 if the given string doesn't match any month * Try to match with complete name and then with short names */ private static int computeMonth(String ss, Locale loc) { DateFormatSymbols sym = new DateFormatSymbols(loc); String[] monthsArray = sym.getMonths(); String[] shortMonthsArray = sym.getShortMonths(); for (int i=0; i<monthsArray.length; i++) { if (StringUtil.equalsIgnoreCase(monthsArray[i], ss)) { return i+1; } } if (ss.endsWith(".")) { //$NON-NLS-1$ ss = ss.substring(0, ss.length()-1); } for (int i=0; i<shortMonthsArray.length; i++) { if (shortMonthsArray[i].endsWith(".")) { //$NON-NLS-1$ shortMonthsArray[i] = shortMonthsArray[i].substring(0, shortMonthsArray[i].length()-1); } if (StringUtil.equalsIgnoreCase(shortMonthsArray[i], ss)) { return i+1; } } return -1; }
/** * Returns an int to represent the given month (ex : 1 for January) * Returns -1 if the given string doesn't match any month * Try to match with complete name and then with short names */ private static int computeMonth(String ss, Locale loc) { DateFormatSymbols sym = new DateFormatSymbols(loc); String[] monthsArray = sym.getMonths(); String[] shortMonthsArray = sym.getShortMonths(); for (int i=0; i<monthsArray.length; i++) { if (StringUtil.equalsIgnoreCase(monthsArray[i], ss)) { return i+1; } } if (ss.endsWith(".")) { //$NON-NLS-1$ ss = ss.substring(0, ss.length()-1); } for (int i=0; i<shortMonthsArray.length; i++) { if (shortMonthsArray[i].endsWith(".")) { //$NON-NLS-1$ shortMonthsArray[i] = shortMonthsArray[i].substring(0, shortMonthsArray[i].length()-1); } if (StringUtil.equalsIgnoreCase(shortMonthsArray[i], ss)) { return i+1; } } return -1; }
/** * Returns an int to represent the given month (ex : 1 for January) * Returns -1 if the given string doesn't match any month * Try to match with complete name and then with short names */ private static int computeMonth(String ss, Locale loc) { DateFormatSymbols sym = new DateFormatSymbols(loc); String[] monthsArray = sym.getMonths(); String[] shortMonthsArray = sym.getShortMonths(); for (int i=0; i<monthsArray.length; i++) { if (StringUtil.equalsIgnoreCase(monthsArray[i], ss)) { return i+1; } } if (ss.endsWith(".")) { //$NON-NLS-1$ ss = ss.substring(0, ss.length()-1); } for (int i=0; i<shortMonthsArray.length; i++) { if (shortMonthsArray[i].endsWith(".")) { //$NON-NLS-1$ shortMonthsArray[i] = shortMonthsArray[i].substring(0, shortMonthsArray[i].length()-1); } if (StringUtil.equalsIgnoreCase(shortMonthsArray[i], ss)) { return i+1; } } return -1; }
/** * Returns an int to represent the given month (ex : 1 for January) * Returns -1 if the given string doesn't match any month * Try to match with complete name and then with short names */ private static int computeMonth(String ss, Locale loc) { DateFormatSymbols sym = new DateFormatSymbols(loc); String[] monthsArray = sym.getMonths(); String[] shortMonthsArray = sym.getShortMonths(); for (int i=0; i<monthsArray.length; i++) { if (StringUtil.equalsIgnoreCase(monthsArray[i], ss)) { return i+1; } } if (ss.endsWith(".")) { //$NON-NLS-1$ ss = ss.substring(0, ss.length()-1); } for (int i=0; i<shortMonthsArray.length; i++) { if (shortMonthsArray[i].endsWith(".")) { //$NON-NLS-1$ shortMonthsArray[i] = shortMonthsArray[i].substring(0, shortMonthsArray[i].length()-1); } if (StringUtil.equalsIgnoreCase(shortMonthsArray[i], ss)) { return i+1; } } return -1; }
public Community getCommunity() { if(community==null){ if(StringUtil.equalsIgnoreCase(getAsString(ASJsonPath.TargetObjectType),"community")){ community = new Community(dataHandler); } } return community; }
/** * Update Community Logo, supported for connections * * @param file * image to be uploaded as Community Logo * @param communityId * @throws ClientServicesException */ public void updateCommunityLogo(java.io.File file, String communityId) throws ClientServicesException{ Map<String, String> parameters = new HashMap<String, String>(); parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityId); String name = file.getName(); int dot = StringUtil.lastIndexOfIgnoreCase(name, "."); String ext = ""; if (dot > -1) { ext = name.substring(dot + 1); // add one for the dot! } if (!StringUtil.isEmpty(ext)) { Map<String, String> headers = new HashMap<String, String>(); if (StringUtil.equalsIgnoreCase(ext,"jpg")) { headers.put("Content-Type", "image/jpeg"); // content-type should be image/jpeg for file extension - jpeg/jpg } else { headers.put("Content-Type", "image/" + ext); } // the url doesn't have atom in base String url = "/communities/service/html/image"; getClientService().put(url, parameters, headers, file, ClientService.FORMAT_NULL); } }
/** * Check if a Topic is a question * * @method isQuestion * @return boolean */ public boolean isQuestion(){ boolean question = false; if(StringUtil.isNotEmpty(getAsString(ForumsXPath.flag))){ List<String> flags = Arrays.asList(getDataHandler().getAsString(ForumsXPath.flag).split(" ")); for (int i = 0; i < flags.size(); i++) { if(StringUtil.equalsIgnoreCase(flags.get(i), FlagType.QUESTION.getFlagType())){ question = true; break; } } } return question; }
/** * Check if Reply is deleted * * @method isDeleted * @return boolean */ public boolean isDeleted(){ boolean deleted = false; if(StringUtil.isNotEmpty(getAsString(ForumsXPath.flag))){ List<String> flags = Arrays.asList(getDataHandler().getAsString(ForumsXPath.flag).split(" ")); for (int i = 0; i < flags.size(); i++) { if(StringUtil.equalsIgnoreCase(flags.get(i), FlagType.DELETED.getFlagType())){ deleted = true; break; } } } return deleted; }
/** * Check if a Topic is answered * * @method isAnswered * @return boolean */ public boolean isAnswered(){ boolean answered = false; if(StringUtil.isNotEmpty(getAsString(ForumsXPath.flag))){ List<String> flags = Arrays.asList(getDataHandler().getAsString(ForumsXPath.flag).split(" ")); for (int i = 0; i < flags.size(); i++) { if(StringUtil.equalsIgnoreCase(flags.get(i), FlagType.ANSWERED.getFlagType())){ answered = true; break; } } } return answered; }
/** * Check if a Topic is locked * * @method isLocked * @return boolean */ public boolean isLocked(){ boolean lock = false; if(StringUtil.isNotEmpty(getAsString(ForumsXPath.flag))){ List<String> flags = Arrays.asList(getDataHandler().getAsString(ForumsXPath.flag).split(" ")); for (int i = 0; i < flags.size(); i++) { if(StringUtil.equalsIgnoreCase(flags.get(i), FlagType.LOCK.getFlagType())){ lock = true; break; } } } return lock; }
/** * Check if a Topic is pinned * * @method isPinned * @return boolean */ public boolean isPinned(){ boolean pin = false; if(StringUtil.isNotEmpty(getAsString(ForumsXPath.flag))){ List<String> flags = Arrays.asList(getDataHandler().getAsString(ForumsXPath.flag).split(" ")); for (int i = 0; i < flags.size(); i++) { if(StringUtil.equalsIgnoreCase(flags.get(i), FlagType.PIN.getFlagType())){ pin = true; break; } } } return pin; }
/** * Check if Reply is accepted as answer * * @method isAnswer * @return boolean */ public boolean isAnswer(){ boolean answer = false; if(StringUtil.isNotEmpty(getAsString(ForumsXPath.flag))){ List<String> flags = Arrays.asList(getDataHandler().getAsString(ForumsXPath.flag).split(" ")); for (int i = 0; i < flags.size(); i++) { if(StringUtil.equalsIgnoreCase(flags.get(i), FlagType.ANSWER.getFlagType())){ answer = true; break; } } } return answer; } /**
public static java.util.Date parseUtilDate(String s) { String CURRENT_DATE_TIME ="now"; //$NON-NLS-1$ if(StringUtil.isEmpty(s)) { return null; } if(StringUtil.equalsIgnoreCase(s, CURRENT_DATE_TIME)) { java.util.Date nowResult = new java.util.Date(); return nowResult; } // Try an XMI parsing try { java.util.Date result = (java.util.Date)readXMIDate(s, java.util.Date.class); if(result!=null) { return result; } } catch(Exception e) { //need to check for a bare Time format try { long resultTime = readXMIDateStrict(s, false, false); if (resultTime > 0) { java.util.Date nowResult = new java.util.Date(); return nowResult; } } catch (Exception eTime){} } return null; }
if (StringUtil.equalsIgnoreCase(ext, JPG)) {
String url = composeRequestUrl(args); Response response = null; if (StringUtil.equalsIgnoreCase(method, METHOD_GET)) { HttpGet httpGet = new HttpGet(url); response = execRequest(httpGet, args, content); } else if (StringUtil.equalsIgnoreCase(method, METHOD_POST)) { HttpPost httpPost = new HttpPost(url); response = execRequest(httpPost, args, content); } else if (StringUtil.equalsIgnoreCase(method, METHOD_PUT)) { HttpPut httpPut = new HttpPut(url); response = execRequest(httpPut, args, content); } else if (StringUtil.equalsIgnoreCase(method, METHOD_DELETE)) { HttpDelete httpDelete = new HttpDelete(url); response = execRequest(httpDelete, args, content); } else if (StringUtil.equalsIgnoreCase(method,METHOD_DELETE_BODY)){ HttpDeleteWithBody httpDelete = new HttpDeleteWithBody(url); response = execRequest(httpDelete, args, content);
/** * Get the index of a specific string begining at a specific index. * The string are compared by value and not by the object pointer. * @param item the string to look for * @param index the index where to start the search * @return the index of that string (-1 if it does'nt esist) */ public final int indexOf( Object item, int index ) { int size = size(); String s = (String)item; if( caseInsensitive ) { for( int i=index; i<size; i++ ) { if( StringUtil.equalsIgnoreCase(getString(i),s) ) { return i; } } return -1; } else { for( int i=index; i<size; i++ ) { if( StringUtil.equals(getString(i),s) ) { return i; } } return -1; } }
/** * Get the index of a specific string begining at a specific index. * The string are compared by value and not by the object pointer. * @param item the string to look for * @param index the index where to start the search * @return the index of that string (-1 if it does'nt esist) */ public final int indexOf( Object item, int index ) { int size = size(); String s = (String)item; if( caseInsensitive ) { for( int i=index; i<size; i++ ) { if( StringUtil.equalsIgnoreCase(getString(i),s) ) { return i; } } return -1; } else { for( int i=index; i<size; i++ ) { if( StringUtil.equals(getString(i),s) ) { return i; } } return -1; } }
@Override public void setSignatureMethod(String signatureMethod) { oAuthHandler.setSignatureMethod(signatureMethod); if (StringUtil.equalsIgnoreCase(Configuration.HMAC_SIGNATURE, signatureMethod)) { this.setOauthHandler(new HMACOAuth1Handler(getConsumerKey(), getConsumerSecret(), getCredentialStore(), getAppId(), getServiceName(), getRequestTokenURL(), getAuthorizationURL(), getAccessTokenURL(), getSignatureMethod(), isForceTrustSSLCertificate(), getApplicationAccessToken())); } } @Override
|| StringUtil.equalsIgnoreCase(communityId, null)) { throw new ClientServicesException(null, Messages.Invalid_CommunityId);