public String[] importBookmarks(String type,String username,String password,String check,String sscfPersonUri,String serviceAddr)
{
String[] result = new String[2];
if(username!=null)
{
BookmarksImport bi = BookmarksImport.getBookmarksImport(type,username,password,sscfPersonUri,serviceAddr);
//check only the credentials
if(check!=null&&bi!=null)
{
if(bi.credentialsCheck())
{
//check if import has been already done
SscfTagger st = SscfTagger.getSscfTaggerIfExists(bi.getRootUri().toString(), sscfPersonUri, null, null);
if(st==null)
{
System.out.println("Credentials OK");
result[0] = TaskStatusInfo.CHECKED.getMessage();
return result;
}
result[0] = TaskStatusInfo.EXISTS.getMessage();
return result;
}else if (bi instanceof FlickrBookmarksImport){
result[0] = TaskStatusInfo.REDIRECTING.getMessage();
result[1] = ((FlickrBookmarksImport)bi).getFlickrLoginFormParams();
return result;
}
BookmarksImport.removeBookmarksImport(type,username,sscfPersonUri);
return null;
}
if(bi!=null&&bi.isAlive())
{
result[0] = TaskStatusInfo.INPROGRESS.getMessage();
result[1] = bi.getMessage();
}
else if(bi!=null&&!bi.isStarted())
{
bi.start();
result[0] = TaskStatusInfo.STARTED.getMessage();
}
else if(bi!=null)
{
if(bi.getMessage()!=null)
result[0] = bi.getMessage();
if(bi.getRootUri()!=null)
result[1] = bi.getRootUri().toString();
BookmarksImport.removeBookmarksImport(type,username,sscfPersonUri);
}
//notify synchronization resource loader that resources of user were changed
ResourcesLoader.setLastChangeDate(username, new Date());