001/**
002 * Copyright 2015 Tampere University of Technology, Pori Department
003 * 
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 *   http://www.apache.org/licenses/LICENSE-2.0
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package service.tut.pori.contentsuggest.reference;
017
018import org.apache.log4j.Logger;
019
020import service.tut.pori.contentsuggest.AutoCompleteResult;
021import core.tut.pori.http.parameters.DataGroups;
022import core.tut.pori.http.parameters.Limits;
023import core.tut.pori.users.UserIdentity;
024
025/**
026 * The reference implementations for Content Suggest Service.
027 *
028 */ 
029public final class ContentSuggestReferenceCore {
030  private static final CSXMLObjectCreator CREATOR = new CSXMLObjectCreator();
031  private static final Logger LOGGER = Logger.getLogger(ContentSuggestReferenceCore.class);
032  
033  /**
034   * 
035   */
036  private ContentSuggestReferenceCore(){
037    // nothing needed
038  }
039  
040  /**
041   * 
042   * @param authenticatedUser 
043   * @param dataGroups
044   * @param limits
045   * @param query the user provided query. Note that the query is not validated and bears no relation to the returned results.
046   * @return response
047   * @throws IllegalArgumentException 
048   */
049  public static AutoCompleteResult suggest(UserIdentity authenticatedUser, DataGroups dataGroups, Limits limits, String query) throws IllegalArgumentException {
050    LOGGER.info((authenticatedUser == null ? "No logged in user." : "Ignoring the logged in user, id: "+authenticatedUser.getUserId()));  // only notify of the logged in status
051    return CREATOR.createAutoCompleteResult(limits, query);
052  }
053
054  /**
055   * 
056   * @param limits
057   * @return randomly generated result
058   */
059  public static AutoCompleteResult generateAutoCompleteResult(Limits limits) {
060    return CREATOR.createAutoCompleteResult(limits);
061  }
062}