mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'release/V2.6'
This commit is contained in:
@@ -73,7 +73,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
public abstract class BaseAPI
|
||||
{
|
||||
// logger
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BaseAPI.class);
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(BaseAPI.class);
|
||||
|
||||
/** exception key in JSON response body */
|
||||
private static final String EXCEPTION_KEY = "exception";
|
||||
@@ -216,6 +216,7 @@ public abstract class BaseAPI
|
||||
client.getAlfrescoUrl(),
|
||||
URLEncodedUtils.format(parameters, "UTF-8"));
|
||||
}
|
||||
LOGGER.info("On GET {}, received following response: ", requestURL);
|
||||
client.close();
|
||||
return doGetRequest(username, password, requestURL);
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ import org.alfresco.rest.core.v0.BaseAPI;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.utils.URLEncodedUtils;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -56,6 +57,9 @@ public class SearchAPI extends BaseAPI
|
||||
/** faceted search API endpoint */
|
||||
private static final String FACETED_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/faceted/rmsearch?{1}";
|
||||
|
||||
/** share live search API endpoint */
|
||||
private static final String SHARE_LIVE_SEARCH_DOCS_ENDPOINT = "{0}alfresco/s/slingshot/live-search-docs?{1}";
|
||||
|
||||
/** RM search URL template */
|
||||
private static final String RM_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/{1}?{2}";
|
||||
|
||||
@@ -138,6 +142,20 @@ public class SearchAPI extends BaseAPI
|
||||
return facetedRequest(username, password, parameters, FACETED_SEARCH_ENDPOINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute share live search for documents.
|
||||
*
|
||||
* @param searchUser
|
||||
* @param searchPassword
|
||||
* @param searchTerm
|
||||
* @return search results (see API reference for more details)
|
||||
*/
|
||||
public JSONObject liveSearchForDocuments(String searchUser, String searchPassword, String searchTerm)
|
||||
{
|
||||
return facetedRequest(searchUser, searchPassword, Arrays.asList(new BasicNameValuePair("t", searchTerm)),
|
||||
SHARE_LIVE_SEARCH_DOCS_ENDPOINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute faceted search for term.
|
||||
* @param searchUser
|
||||
@@ -165,6 +183,20 @@ public class SearchAPI extends BaseAPI
|
||||
return getItemNames(facetedSearchForTerm(username, password, term));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to search for documents as a user using share live search.
|
||||
* @param username to search as
|
||||
* @param password for username
|
||||
* @param term search term
|
||||
* @return list of document names found
|
||||
*/
|
||||
public List<String> liveSearchForDocumentsAsUser(String username, String password, String term) throws JSONException
|
||||
{
|
||||
JSONObject searchResult = liveSearchForDocuments(username, password, term);
|
||||
LOGGER.info(searchResult.toString(3));
|
||||
return getItemNames(searchResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to extract list of names from search result.
|
||||
* @param searchResult
|
||||
|
Reference in New Issue
Block a user