mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Revert "Merge branch 'feature/RM-5416_REST_API_Tests_for_Folder_Classification_1' into 'master'"
This reverts merge request !569
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
@@ -35,7 +34,6 @@ import org.alfresco.rest.model.RestHtmlResponse;
|
||||
import org.alfresco.rest.model.RestSiteModel;
|
||||
import org.alfresco.rest.model.RestSiteModelsCollection;
|
||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||
import org.alfresco.rest.requests.search.SearchAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
||||
import org.alfresco.utility.model.StatusModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
@@ -147,24 +145,16 @@ public class RMRestWrapper
|
||||
return restWrapper.withCoreAPI();
|
||||
}
|
||||
|
||||
/** Get the Alfresco Search API. */
|
||||
public SearchAPI withSearchAPI()
|
||||
{
|
||||
return restWrapper.withSearchAPI();
|
||||
}
|
||||
|
||||
/**
|
||||
* You can handle the request sent to server by calling this method. If for example you want to sent multipart form
|
||||
* data you can use:
|
||||
*
|
||||
* <pre>
|
||||
* restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
|
||||
* .addFormParam("renditions", "doclib").addFormParam("autoRename", true);
|
||||
* You can handle the request sent to server by calling this method.
|
||||
* If for example you want to sent multipart form data you can use: <pre>
|
||||
* restClient.configureRequestSpec()
|
||||
* .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
|
||||
* .addFormParam("renditions", "doclib")
|
||||
* .addFormParam("autoRename", true);
|
||||
*
|
||||
* restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
|
||||
* </pre>
|
||||
*
|
||||
* This will create the node using the multipart data defined.
|
||||
* </pre> This will create the node using the multipart data defined.
|
||||
*/
|
||||
public RequestSpecBuilder configureRequestSpec()
|
||||
{
|
||||
|
@@ -24,7 +24,6 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import static lombok.AccessLevel.PROTECTED;
|
||||
@@ -33,7 +32,6 @@ import javax.annotation.Resource;
|
||||
|
||||
import org.alfresco.rest.requests.Node;
|
||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||
import org.alfresco.rest.requests.search.SearchAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
|
||||
@@ -67,7 +65,7 @@ import lombok.Setter;
|
||||
public class RestAPIFactory
|
||||
{
|
||||
@Autowired
|
||||
@Getter(value = PROTECTED)
|
||||
@Getter (value = PROTECTED)
|
||||
private DataUser dataUser;
|
||||
|
||||
@Resource(name = "RMRestWrapper")
|
||||
@@ -87,12 +85,6 @@ public class RestAPIFactory
|
||||
return getRmRestWrapper().withCoreAPI();
|
||||
}
|
||||
|
||||
private SearchAPI getSearchAPI(UserModel userModel)
|
||||
{
|
||||
getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
|
||||
return getRmRestWrapper().withSearchAPI();
|
||||
}
|
||||
|
||||
public Node getNodeAPI(RepoTestModel model) throws Exception
|
||||
{
|
||||
return getCoreAPI(null).usingNode(model);
|
||||
|
@@ -24,7 +24,6 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.v0;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
@@ -51,8 +50,7 @@ import org.springframework.stereotype.Component;
|
||||
public class SearchAPI extends BaseAPI
|
||||
{
|
||||
/** http client factory */
|
||||
@Autowired
|
||||
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
|
||||
@Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
|
||||
|
||||
/** faceted search API endpoint */
|
||||
private static final String FACETED_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/faceted/rmsearch?{1}";
|
||||
@@ -61,26 +59,28 @@ public class SearchAPI extends BaseAPI
|
||||
private static final String RM_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/{1}?{2}";
|
||||
|
||||
/** RM document search filters */
|
||||
private static final String RM_DEFAULT_RECORD_FILTERS = "records/true,undeclared/true,vital/false,folders/false,categories/false,frozen/false,cutoff/false";
|
||||
private static final String RM_DEFAULT_RECORD_FILTERS =
|
||||
"records/true,undeclared/true,vital/false,folders/false,categories/false,frozen/false,cutoff/false";
|
||||
|
||||
/**
|
||||
* Perform search request on search endpoint as a user.
|
||||
* <p>
|
||||
* This method is applicable only to endpoints that support HTTP GET requests and return JSON body as response.
|
||||
*
|
||||
* @param searchEndpoint
|
||||
* @param searchUser
|
||||
* @param searchPassword
|
||||
* @return search results as a {@link JSONObject}, please refer to API documentation for details
|
||||
*/
|
||||
private JSONObject doSearch(String searchEndpoint, String searchUser, String searchPassword)
|
||||
private JSONObject doSearch(
|
||||
String searchEndpoint,
|
||||
String searchUser,
|
||||
String searchPassword)
|
||||
{
|
||||
return facetedRequest(searchUser, searchPassword, null, searchEndpoint);
|
||||
return facetedRequest(searchUser, searchPassword, null, searchEndpoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic rm search.
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
* @param site
|
||||
@@ -88,36 +88,45 @@ public class SearchAPI extends BaseAPI
|
||||
* @param filters
|
||||
* @return search results (see API reference for more details), null for any errors
|
||||
*/
|
||||
public JSONObject rmSearch(String username, String password, String site, String query, String filters)
|
||||
public JSONObject rmSearch(
|
||||
String username,
|
||||
String password,
|
||||
String site,
|
||||
String query,
|
||||
String filters)
|
||||
{
|
||||
List<BasicNameValuePair> searchParameters = new ArrayList<BasicNameValuePair>();
|
||||
searchParameters.add(new BasicNameValuePair("query", query));
|
||||
searchParameters.add(new BasicNameValuePair("filters", filters));
|
||||
|
||||
String requestURL = MessageFormat.format(RM_SEARCH_ENDPOINT,
|
||||
alfrescoHttpClientFactory.getObject().getAlfrescoUrl(), (site != null) ? site : RM_SITE_ID,
|
||||
URLEncodedUtils.format(searchParameters, "UTF-8"));
|
||||
String requestURL = MessageFormat.format(
|
||||
RM_SEARCH_ENDPOINT,
|
||||
alfrescoHttpClientFactory.getObject().getAlfrescoUrl(),
|
||||
(site != null) ? site : RM_SITE_ID,
|
||||
URLEncodedUtils.format(searchParameters, "UTF-8"));
|
||||
|
||||
return doSearch(requestURL, username, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search as a user for records on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS <br>
|
||||
* Search as a user for records on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS
|
||||
* <br>
|
||||
* If more fine-grained control of search parameters is required, use rmSearch() directly.
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
* @param query
|
||||
* @return list of record names
|
||||
*/
|
||||
public List<String> searchForRecordsAsUser(String username, String password, String query)
|
||||
public List<String> searchForRecordsAsUser(
|
||||
String username,
|
||||
String password,
|
||||
String query)
|
||||
{
|
||||
return getItemNames(rmSearch(username, password, "rm", query, RM_DEFAULT_RECORD_FILTERS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic faceted search.
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
* @param parameters
|
||||
@@ -130,7 +139,6 @@ public class SearchAPI extends BaseAPI
|
||||
|
||||
/**
|
||||
* Execute faceted search for term.
|
||||
*
|
||||
* @param searchUser
|
||||
* @param searchPassword
|
||||
* @param searchTerm
|
||||
@@ -138,12 +146,14 @@ public class SearchAPI extends BaseAPI
|
||||
*/
|
||||
public JSONObject facetedSearchForTerm(String searchUser, String searchPassword, String searchTerm)
|
||||
{
|
||||
return facetedSearch(searchUser, searchPassword, Arrays.asList(new BasicNameValuePair("term", searchTerm)));
|
||||
return facetedSearch(
|
||||
searchUser,
|
||||
searchPassword,
|
||||
Arrays.asList(new BasicNameValuePair("term", searchTerm)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to search for documents as a user using faceted search.
|
||||
*
|
||||
* @param username to search as
|
||||
* @param password for username
|
||||
* @param term search term
|
||||
@@ -156,7 +166,6 @@ public class SearchAPI extends BaseAPI
|
||||
|
||||
/**
|
||||
* Helper method to extract list of names from search result.
|
||||
*
|
||||
* @param searchResult
|
||||
* @return list of document or record names in search result
|
||||
* @throws RuntimeException for malformed search response
|
||||
|
Reference in New Issue
Block a user