星期二, 1月 31, 2012

[Flickr] Flickr API

最近想要來開發一些Flickr的小工具,讓自已貼圖更方便!!
找了其他一個.NET的Flickr .NET API Library ,以下是一些教學資源~

12/02/07 Update:測試心得,登入驗證無法登入通過,想直接自已寫一個api了 XD


以下記錄一些參考連結
官方教學:http://www.flickr.com/services/api/
OAuth and Flickr – Part 2

星期一, 1月 30, 2012

[Alfresco] Pagination of Lucene

使用javascript API的search.query(searchParameters)方法時,
當skipCount超過一千筆時,會無法取得回傳的結果,
導致客製化分頁會失敗。

找到以下這篇跟我遇到一樣的問題:
Improve the skipCount function not to check the permissions.

記錄一下:
This is an enhancement request for paging offset in FTS query called "skipcount". Alfresco don't have to check permission of skipped items when we specify the skipCount. 

(*1 system.max.permissionChecks 1000 as the default) 

I know the paging search itself won't be affected by the permission check as far as I tested it with an out of box webscripts named "children.get. js". So, in this case it works very fine, because this webscript uses "group.getChildGroups(maxItems, skipCount)" with ModelUtil.paging internally, so with this webscripts I can correctly get the result more than the specified number to the permission check. I attached the webscript, please find the sample-webscripts.zip for your reference. 


But, the problem is that if we use the paging offset in FTS query called "skipcount" combined with the Lucene search query in the WebScripts as follows, then it will be affected by the permission check. I attached the webscirpts named paging-result.zip for your reference. 

    var skipCount = 0 + args["skip"]; 
    var searchParams = {}; 
    searchParams.query = "cm\:name:document*"; 
    searchParams.language = "fts-alfresco"; 
    var paging = {}; 
    paging.maxItems = 100; 
    paging.skipCount = skipCount; 
    paging.totalItems = 100, 
    searchParams.page = paging; 
    var results = search.query(searchParams); 
    model["length"] = results.length; 
    model["results"] = results; 

In this case, when we specify the skipcount below the number of system.max.permissionCheck for example 1000 as the default, and set a proper paging value, then it will return the correct result, but the problem is when we specify skipcount over 1,000, then webscripts returns no results (zero items). 
So, the work around is to set over 1,000 to the "system.acl.maxPermissionChecks" , then we can get the results correctly. But increasing this parameter will give more stress to Alfresco server, so that would be nice if we could improve the function of skipCount since Alfresco don't have to check the permission of skipped items when we specify the skipCount. 


請在repository.properties修正以下二個參數
#
# Properties to limit resources spent on individual searches
#
# The maximum time spent pruning results
system.acl.maxPermissionCheckTimeMillis=100000
# The maximum number of results to perform permission checks against
system.acl.maxPermissionChecks=10000

不過當存取超過10000的時候發生以下例外錯誤!!(待續)
目前限制只能取到一層的一萬筆,當該層超過一萬筆後就拿不到資料!!
Transactional update cache 'org.alfresco.cache.node.aspectsTransactionalCache' is full (10000)

星期四, 1月 12, 2012

[Java] 自訂Exception

簡單的自訂例外處理
public class HttpClientException extends Exception{
 
 private String protocol = null;
 private String endpoint = null;
 private String httpMethod = null;
 private String postParameters = null;
 private int statuscode = 0;
 private String msg = null;
 
 public HttpClientException(String msg){
  super(msg);
 }
 
 public HttpClientException(String endpoint,String httpMethod,String postParameters,int statuscode,String msg){
  this.endpoint = endpoint;
  //detect protocal from endpoint
  if(this.endpoint.contains("https"))
   this.protocol = "HTTPS";
  else
   this.protocol = "HTTP";
  
  this.httpMethod = httpMethod;
  this.postParameters = postParameters;
  this.statuscode = statuscode;
  this.msg = msg;
 }
 
 public String getEndPoint(){
  return this.protocol + " Request Endpoint:" + this.endpoint;
 }
 
 public String getHttpMethod(){
  return this.protocol +  " Request Method:" + this.httpMethod;
 }
 
 public String getRequestBody(){
  if(this.postParameters != null)
   return this.protocol + " Request Body:" + this.postParameters;
  else
   return "Can't get request body.";
 }
 
 public String getStatusCode(){
  return this.protocol + " Status Code:" + this.statuscode;
 }
 
 public String getErrorMessage(){
  return this.protocol + " Error Message:" + this.msg;
 }
}

星期三, 1月 11, 2012

[Java] 字串比對搜尋

Java字串搜尋的方法:

  String endpoint = "http://www.google.com.tw";
  System.out.println("string index of http:" + endpoint.indexOf("http://"));
  
  endpoint = "https://www.google.com.tw";
  System.out.println("string index of https:" + endpoint.indexOf("https://"));
  
  System.out.println("string re:" + endpoint.matches("^https://.*"));
  System.out.println("string contain:" + endpoint.contains("http"));

星期一, 1月 09, 2012

[Alfresco] Dot symbol in account

先前寫了一個範例關於在URL上面有uid含有dot符號會發生問題!!
原本以為是alfresco不支援,結果是自已搞錯了XD
會發生以下錯誤!!
GET http:///alfresco/service/test/person/?alf_ticket=
UserName: ken.tsai
後端顯示找不到這個uid的錯誤,因為uid被截斷了
ERROR [extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 00100007 Web Script format 'tsai' is not registered

參考一下原本的範例程式,發現在webscript xml的描述檔把原本的
   any
改為
   argument
就成功解決了。

後續的釐清程序之後再補

Reference:
Alfresco Web Scripts Wiki

星期一, 1月 02, 2012

console.log throws error on IE8


經測試可用的程式碼如下:
(function($){
 
 $.console = function(logger){
  if(typeof window["console"] != "undefined"){
   console.log(logger);
  }
 };
 
})(jQuery);

缺點要改用自已寫的方式,優點是在ie8有無使用開發者工具都能正常執行網頁。
Reference:
console.log throws error on Internet Explorer IE

其他你感興趣的文章

Related Posts with Thumbnails