Example usage for com.liferay.portal.kernel.util Time SECOND

List of usage examples for com.liferay.portal.kernel.util Time SECOND

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util Time SECOND.

Prototype

long SECOND

To view the source code for com.liferay.portal.kernel.util Time SECOND.

Click Source Link

Usage

From source file:com.liferay.calendar.portlet.CalendarPortlet.java

License:Open Source License

protected long[] getReminders(PortletRequest portletRequest) {
    long firstReminder = ParamUtil.getInteger(portletRequest, "reminderValue0");
    long firstReminderDuration = ParamUtil.getInteger(portletRequest, "reminderDuration0");
    long secondReminder = ParamUtil.getInteger(portletRequest, "reminderValue1");
    long secondReminderDuration = ParamUtil.getInteger(portletRequest, "reminderDuration1");

    return new long[] { firstReminder * firstReminderDuration * Time.SECOND,
            secondReminder * secondReminderDuration * Time.SECOND };
}

From source file:com.liferay.calendar.util.CalendarICalDataHandler.java

License:Open Source License

protected void importICalEvent(long calendarId, VEvent vEvent) throws Exception {

    Calendar calendar = CalendarLocalServiceUtil.getCalendar(calendarId);

    // Title//from  w ww.ja  v  a2s .c  o  m

    User user = UserLocalServiceUtil.getUser(calendar.getUserId());

    Map<Locale, String> titleMap = new HashMap<Locale, String>();

    Summary summary = vEvent.getSummary();

    if (summary != null) {
        String title = ModelHintsUtil.trimString(CalendarBooking.class.getName(), "title", summary.getValue());

        titleMap.put(user.getLocale(), title);
    }

    // Description

    Map<Locale, String> descriptionMap = new HashMap<Locale, String>();

    Description description = vEvent.getDescription();

    if (description != null) {
        descriptionMap.put(user.getLocale(), description.getValue());
    }

    // Location

    String locationString = StringPool.BLANK;

    Location location = vEvent.getLocation();

    if (location != null) {
        locationString = location.getValue();
    }

    // Dates

    DtStart dtStart = vEvent.getStartDate();

    Date startDate = dtStart.getDate();

    DtEnd dtEnd = vEvent.getEndDate();

    Date endDate = dtEnd.getDate();

    // All day

    boolean allDay = false;

    if (isICalDateOnly(dtStart)) {
        allDay = true;

        long time = endDate.getTime();

        endDate.setTime(time - 1);
    }

    // Recurrence

    RRule rrule = (RRule) vEvent.getProperty(Property.RRULE);

    String recurrence = StringPool.BLANK;

    if (rrule != null) {
        recurrence = StringUtil.trim(rrule.toString());

        PropertyList propertyList = vEvent.getProperties(Property.EXDATE);

        if (!propertyList.isEmpty()) {
            StringBundler sb = new StringBundler();

            Iterator<ExDate> iterator = propertyList.iterator();

            while (iterator.hasNext()) {
                ExDate exDate = iterator.next();

                DateList dateList = exDate.getDates();

                ListIterator<Date> listIterator = dateList.listIterator();

                while (listIterator.hasNext()) {
                    Date date = listIterator.next();

                    java.util.Calendar jCalendar = JCalendarUtil.getJCalendar(date.getTime());

                    int year = jCalendar.get(java.util.Calendar.YEAR);
                    int month = jCalendar.get(java.util.Calendar.MONTH) + 1;
                    int day = jCalendar.get(java.util.Calendar.DATE);
                    int hour = jCalendar.get(java.util.Calendar.HOUR_OF_DAY);
                    int minute = jCalendar.get(java.util.Calendar.MINUTE);
                    int second = jCalendar.get(java.util.Calendar.SECOND);

                    sb.append(String.format(_EXDATE_FORMAT, year, month, day, hour, minute, second));

                    if (listIterator.hasNext()) {
                        sb.append(StringPool.COMMA);
                    }
                }

                if (iterator.hasNext()) {
                    sb.append(StringPool.COMMA);
                }
            }

            recurrence = recurrence.concat(StringPool.NEW_LINE).concat(_EXDATE).concat(sb.toString());
        }
    }

    // Reminders

    ComponentList componentList = vEvent.getAlarms();

    long[] reminders = new long[componentList.size()];
    String[] reminderTypes = new String[componentList.size()];

    int i = 0;

    for (Iterator<VAlarm> iterator = componentList.iterator(); iterator.hasNext();) {

        VAlarm vAlarm = iterator.next();

        Action action = vAlarm.getAction();

        String value = StringUtil.lowerCase(action.getValue());

        if (!isActionSupported(value)) {
            continue;
        }

        reminderTypes[i] = value;

        Trigger trigger = vAlarm.getTrigger();

        long time = 0;

        DateTime dateTime = trigger.getDateTime();

        Dur dur = trigger.getDuration();

        if ((dateTime == null) && (dur == null)) {
            continue;
        }

        if (dateTime != null) {
            time = startDate.getTime() - dateTime.getTime();

            if (time < 0) {
                continue;
            }
        } else {
            if (!dur.isNegative()) {
                continue;
            }

            time += dur.getWeeks() * Time.WEEK;
            time += dur.getDays() * Time.DAY;
            time += dur.getHours() * Time.HOUR;
            time += dur.getMinutes() * Time.MINUTE;
            time += dur.getSeconds() * Time.SECOND;
        }

        reminders[i] = time;

        i++;
    }

    long firstReminder = 0;
    String firstReminderType = null;
    long secondReminder = 0;
    String secondReminderType = null;

    if (i > 0) {
        firstReminder = reminders[0];
        firstReminderType = reminderTypes[0];
    }

    if (i > 1) {
        secondReminder = reminders[1];
        secondReminderType = reminderTypes[1];
    }

    // Attendees

    PropertyList propertyList = vEvent.getProperties(Property.ATTENDEE);

    List<Long> childCalendarIds = new ArrayList<Long>();

    for (Iterator<Attendee> iterator = propertyList.iterator(); iterator.hasNext();) {

        Attendee attendee = iterator.next();

        URI uri = attendee.getCalAddress();

        if (uri == null) {
            continue;
        }

        User attendeeUser = UserLocalServiceUtil.fetchUserByEmailAddress(calendar.getCompanyId(),
                uri.getSchemeSpecificPart());

        if ((attendeeUser == null) || (calendar.getUserId() == attendeeUser.getUserId())) {

            continue;
        }

        ServiceContext serviceContext = new ServiceContext();

        serviceContext.setCompanyId(calendar.getCompanyId());
        serviceContext.setScopeGroupId(calendar.getGroupId());

        CalendarResource calendarResource = CalendarResourceUtil
                .getUserCalendarResource(attendeeUser.getUserId(), serviceContext);

        if (calendarResource == null) {
            continue;
        }

        childCalendarIds.add(calendarResource.getDefaultCalendarId());
    }

    long[] childCalendarIdsArray = ArrayUtil
            .toArray(childCalendarIds.toArray(new Long[childCalendarIds.size()]));

    // Merge calendar booking

    CalendarBooking calendarBooking = null;

    String uuid = null;

    Uid uid = vEvent.getUid();

    if (uid != null) {
        uuid = uid.getValue();

        calendarBooking = CalendarBookingLocalServiceUtil.fetchCalendarBooking(uuid, calendar.getGroupId());
    }

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);
    serviceContext.setAttribute("sendNotification", Boolean.FALSE);
    serviceContext.setScopeGroupId(calendar.getGroupId());

    if (calendarBooking == null) {
        serviceContext.setUuid(uuid);

        CalendarBookingServiceUtil.addCalendarBooking(calendarId, childCalendarIdsArray,
                CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, titleMap, descriptionMap,
                locationString, startDate.getTime(), endDate.getTime(), allDay, recurrence, firstReminder,
                firstReminderType, secondReminder, secondReminderType, serviceContext);
    } else {
        CalendarBookingServiceUtil.updateCalendarBooking(calendarBooking.getCalendarBookingId(), calendarId,
                childCalendarIdsArray, titleMap, descriptionMap, locationString, startDate.getTime(),
                endDate.getTime(), allDay, recurrence, firstReminder, firstReminderType, secondReminder,
                secondReminderType, calendarBooking.getStatus(), serviceContext);
    }
}

From source file:com.liferay.calendar.util.CalendarICalDataHandler.java

License:Open Source License

protected Dur toICalDur(long reminder) {
    int weeks = (int) (reminder / Time.WEEK);

    if (weeks > 0) {
        return new Dur(weeks);
    }/*from w  ww .j a v  a2s.co  m*/

    int days = (int) (reminder / Time.DAY);

    if (days > 0) {
        return new Dur(days, 0, 0, 0);
    }

    int hours = (int) (reminder / Time.HOUR);

    if (hours > 0) {
        return new Dur(0, hours, 0, 0);
    }

    int minutes = (int) (reminder / Time.MINUTE);

    if (minutes > 0) {
        return new Dur(0, 0, minutes, 0);
    }

    int seconds = (int) (reminder / Time.SECOND);

    if (seconds > 0) {
        return new Dur(0, 0, 0, seconds);
    }

    return null;
}

From source file:com.liferay.document.library.repository.cmis.internal.CMISRepository.java

License:Open Source License

protected Hits doSearch(SearchContext searchContext, Query query) throws Exception {

    long startTime = System.currentTimeMillis();

    Session session = getSession();//from ww  w  .  j a v a 2 s.  co m

    RepositoryInfo repositoryInfo = session.getRepositoryInfo();

    RepositoryCapabilities repositoryCapabilities = repositoryInfo.getCapabilities();

    QueryConfig queryConfig = searchContext.getQueryConfig();

    CapabilityQuery capabilityQuery = repositoryCapabilities.getQueryCapability();

    queryConfig.setAttribute("capabilityQuery", capabilityQuery.value());

    String productName = repositoryInfo.getProductName();
    String productVersion = repositoryInfo.getProductVersion();

    queryConfig.setAttribute("repositoryProductName", productName);
    queryConfig.setAttribute("repositoryProductVersion", productVersion);

    String queryString = _cmisSearchQueryBuilder.buildQuery(searchContext, query);

    if (_cmisRepositoryDetector.isNuxeo5_4()) {
        queryString += " AND (" + PropertyIds.IS_LATEST_VERSION + " = true)";
    }

    if (_log.isDebugEnabled()) {
        _log.debug("CMIS search query: " + queryString);
    }

    boolean searchAllVersions = _cmisRepositoryDetector.isNuxeo5_5OrHigher();

    ItemIterable<QueryResult> queryResults = session.query(queryString, searchAllVersions);

    int start = searchContext.getStart();
    int end = searchContext.getEnd();

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS)) {
        start = 0;
    }

    int total = 0;

    List<com.liferay.portal.kernel.search.Document> documents = new ArrayList<>();
    List<String> snippets = new ArrayList<>();
    List<Float> scores = new ArrayList<>();

    for (QueryResult queryResult : queryResults) {
        total++;

        if (total <= start) {
            continue;
        }

        if ((total > end) && (end != QueryUtil.ALL_POS)) {
            continue;
        }

        com.liferay.portal.kernel.search.Document document = new DocumentImpl();

        String objectId = queryResult.getPropertyValueByQueryName(PropertyIds.OBJECT_ID);

        if (_log.isDebugEnabled()) {
            _log.debug("Search result object ID " + objectId);
        }

        FileEntry fileEntry = null;

        try {
            fileEntry = toFileEntry(objectId, true);
        } catch (Exception e) {
            if (_log.isDebugEnabled()) {
                Throwable cause = e.getCause();

                if (cause != null) {
                    cause = cause.getCause();
                }

                if (cause instanceof CmisObjectNotFoundException) {
                    _log.debug("Search result ignored for CMIS document which "
                            + "has a version with an invalid object ID " + cause.getMessage());
                } else {
                    _log.debug("Search result ignored for invalid object ID", e);
                }
            }

            total--;

            continue;
        }

        DocumentHelper documentHelper = new DocumentHelper(document);

        documentHelper.setEntryKey(fileEntry.getModelClassName(), fileEntry.getFileEntryId());

        document.addKeyword(Field.TITLE, fileEntry.getTitle());

        documents.add(document);

        if (queryConfig.isScoreEnabled()) {
            Object scoreObj = queryResult.getPropertyValueByQueryName("HITS");

            if (scoreObj != null) {
                scores.add(Float.valueOf(scoreObj.toString()));
            } else {
                scores.add(1.0F);
            }
        } else {
            scores.add(1.0F);
        }

        snippets.add(StringPool.BLANK);
    }

    float searchTime = (float) (System.currentTimeMillis() - startTime) / Time.SECOND;

    Hits hits = new HitsImpl();

    hits.setDocs(documents.toArray(new com.liferay.portal.kernel.search.Document[documents.size()]));
    hits.setLength(total);
    hits.setQuery(query);
    hits.setQueryTerms(new String[0]);
    hits.setScores(ArrayUtil.toFloatArray(scores));
    hits.setSearchTime(searchTime);
    hits.setSnippets(snippets.toArray(new String[snippets.size()]));
    hits.setStart(startTime);

    return hits;
}

From source file:com.liferay.document.library.repository.external.ExtRepositoryAdapter.java

License:Open Source License

@Override
public Hits search(SearchContext searchContext, Query query) throws SearchException {

    long startTime = System.currentTimeMillis();

    List<ExtRepositorySearchResult<?>> extRepositorySearchResults = null;

    try {//from   w w w  .  j a v a 2 s. co m
        extRepositorySearchResults = _extRepository.search(searchContext, query,
                new ExtRepositoryQueryMapperImpl(this));
    } catch (PortalException | SystemException e) {
        throw new SearchException("Unable to perform search", e);
    }

    QueryConfig queryConfig = searchContext.getQueryConfig();

    List<Document> documents = new ArrayList<>();
    List<String> snippets = new ArrayList<>();
    List<Float> scores = new ArrayList<>();

    int total = 0;

    for (ExtRepositorySearchResult<?> extRepositorySearchResult : extRepositorySearchResults) {

        try {
            ExtRepositoryObjectAdapter<?> extRepositoryEntryAdapter = _toExtRepositoryObjectAdapter(
                    ExtRepositoryObjectAdapterType.OBJECT, extRepositorySearchResult.getObject());

            Document document = new DocumentImpl();

            document.addKeyword(Field.ENTRY_CLASS_NAME, extRepositoryEntryAdapter.getModelClassName());
            document.addKeyword(Field.ENTRY_CLASS_PK, extRepositoryEntryAdapter.getPrimaryKey());
            document.addKeyword(Field.TITLE, extRepositoryEntryAdapter.getName());

            documents.add(document);

            if (queryConfig.isScoreEnabled()) {
                scores.add(extRepositorySearchResult.getScore());
            } else {
                scores.add(1.0F);
            }

            snippets.add(extRepositorySearchResult.getSnippet());

            total++;
        } catch (PortalException | SystemException e) {
            if (_log.isWarnEnabled()) {
                _log.warn("Invalid entry returned from search", e);
            }
        }
    }

    float searchTime = (float) (System.currentTimeMillis() - startTime) / Time.SECOND;

    Hits hits = new HitsImpl();

    hits.setDocs(documents.toArray(new Document[documents.size()]));
    hits.setLength(total);
    hits.setQueryTerms(new String[0]);
    hits.setScores(ArrayUtil.toFloatArray(scores));
    hits.setSearchTime(searchTime);
    hits.setSnippets(snippets.toArray(new String[snippets.size()]));
    hits.setStart(startTime);

    return hits;
}

From source file:com.liferay.journal.content.search.web.internal.util.ContentHits.java

License:Open Source License

public void recordHits(Hits hits, long groupId, boolean privateLayout, int start, int end) throws Exception {

    // This can later be optimized according to LEP-915.

    List<Document> docs = new ArrayList<>();
    List<Float> scores = new ArrayList<>();

    Document[] docsArray = hits.getDocs();

    for (int i = 0; i < docsArray.length; i++) {
        Document doc = hits.doc(i);

        String articleId = doc.get(Field.ARTICLE_ID);
        long articleGroupId = GetterUtil.getLong(doc.get(Field.GROUP_ID));

        int layoutIdsCount = JournalContentSearchLocalServiceUtil.getLayoutIdsCount(groupId, privateLayout,
                articleId);/*from  w ww .  j  a va 2 s.  co  m*/

        if ((layoutIdsCount > 0) || (!isShowListed() && (articleGroupId == groupId))) {

            docs.add(hits.doc(i));
            scores.add(hits.score(i));
        }
    }

    int length = docs.size();

    hits.setLength(length);

    if (end > length) {
        end = length;
    }

    docs = docs.subList(start, end);
    scores = scores.subList(start, end);

    hits.setDocs(docs.toArray(new Document[docs.size()]));
    hits.setScores(ArrayUtil.toFloatArray(scores));

    hits.setSearchTime((float) (System.currentTimeMillis() - hits.getStart()) / Time.SECOND);
}

From source file:com.liferay.message.boards.service.test.MBMessageLocalServiceTest.java

License:Open Source License

@Test
public void testThreadLastPostDate() throws Exception {
    Date date = new Date();

    MBMessage parentMessage = addMessage(null, false, date);

    MBMessage firstReplyMessage = addMessage(parentMessage, false, new Date(date.getTime() + Time.SECOND));

    MBMessage secondReplyMessage = addMessage(parentMessage, false, new Date(date.getTime() + Time.SECOND * 2));

    DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat(PropsValues.INDEX_DATE_FORMAT_PATTERN);

    MBThread mbThread = parentMessage.getThread();

    Assert.assertEquals(dateFormat.format(mbThread.getLastPostDate()),
            dateFormat.format(secondReplyMessage.getModifiedDate()));

    MBMessageLocalServiceUtil.deleteMessage(secondReplyMessage.getMessageId());

    mbThread = parentMessage.getThread();

    Assert.assertEquals(dateFormat.format(mbThread.getLastPostDate()),
            dateFormat.format(firstReplyMessage.getModifiedDate()));
}

From source file:com.liferay.portlet.InvokerPortletImpl.java

License:Open Source License

public void render(RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {

    PortletException portletException = (PortletException) renderRequest
            .getAttribute(_portletId + PortletException.class.getName());

    if (portletException != null) {
        throw portletException;
    }//  w ww  .  ja va2 s .co m

    StopWatch stopWatch = null;

    if (_log.isDebugEnabled()) {
        stopWatch = new StopWatch();

        stopWatch.start();
    }

    String remoteUser = renderRequest.getRemoteUser();

    if ((remoteUser == null) || (_expCache == null) || (_expCache.intValue() == 0)) {

        invokeRender(renderRequest, renderResponse);
    } else {
        RenderResponseImpl renderResponseImpl = (RenderResponseImpl) renderResponse;

        StringServletResponse stringResponse = (StringServletResponse) renderResponseImpl
                .getHttpServletResponse();

        PortletSession portletSession = renderRequest.getPortletSession();

        long now = System.currentTimeMillis();

        Layout layout = (Layout) renderRequest.getAttribute(WebKeys.LAYOUT);

        Map<String, InvokerPortletResponse> sessionResponses = getResponses(portletSession);

        String sessionResponseId = encodeResponseKey(layout.getPlid(), _portletId,
                LanguageUtil.getLanguageId(renderRequest));

        InvokerPortletResponse response = sessionResponses.get(sessionResponseId);

        if (response == null) {
            String title = invokeRender(renderRequest, renderResponse);

            response = new InvokerPortletResponse(title, stringResponse.getString(),
                    now + Time.SECOND * _expCache.intValue());

            sessionResponses.put(sessionResponseId, response);
        } else if ((response.getTime() < now) && (_expCache.intValue() > 0)) {
            String title = invokeRender(renderRequest, renderResponse);

            response.setTitle(title);
            response.setContent(stringResponse.getString());
            response.setTime(now + Time.SECOND * _expCache.intValue());
        } else {
            renderResponseImpl.setTitle(response.getTitle());
            stringResponse.getWriter().print(response.getContent());
        }
    }

    Map<String, String[]> properties = ((RenderResponseImpl) renderResponse).getProperties();

    if (properties.containsKey("clear-request-parameters")) {
        Map<String, String[]> renderParameters = ((RenderRequestImpl) renderRequest).getRenderParameters();

        renderParameters.clear();
    }

    if (_log.isDebugEnabled()) {
        _log.debug("render for " + _portletId + " takes " + stopWatch.getTime() + " ms");
    }
}

From source file:com.liferay.portlet.journalcontentsearch.util.ContentHits.java

License:Open Source License

public void recordHits(Hits hits, long groupId, boolean privateLayout, int start, int end) throws Exception {

    // This can later be optimized according to LEP-915.

    List<Document> docs = new ArrayList<Document>();
    List<Float> scores = new ArrayList<Float>();
    List<String> snippets = new ArrayList<String>();

    for (int i = 0; i < hits.getLength(); i++) {
        Document doc = hits.doc(i);

        long articleGroupId = GetterUtil.getLong(doc.get(Field.GROUP_ID));
        String articleId = doc.get("articleId");

        if (JournalContentSearchLocalServiceUtil.getLayoutIdsCount(groupId, privateLayout, articleId) > 0) {

            docs.add(hits.doc(i));//from   w ww.  j  a  v a  2  s . c om
            scores.add(hits.score(i));
            snippets.add(hits.snippet(i));
        } else if (!isShowListed() && (articleGroupId == groupId)) {
            docs.add(hits.doc(i));
            scores.add(hits.score(i));
            snippets.add(hits.snippet(i));
        }
    }

    int length = docs.size();

    hits.setLength(length);

    if (end > length) {
        end = length;
    }

    docs = docs.subList(start, end);
    scores = scores.subList(start, end);
    snippets = snippets.subList(start, end);

    hits.setDocs(docs.toArray(new Document[docs.size()]));
    hits.setScores(scores.toArray(new Float[docs.size()]));
    hits.setSnippets(snippets.toArray(new String[docs.size()]));

    hits.setSearchTime((float) (System.currentTimeMillis() - hits.getStart()) / Time.SECOND);
}

From source file:com.liferay.repository.external.ExtRepositoryAdapter.java

License:Open Source License

@Override
public Hits search(SearchContext searchContext, Query query) throws SearchException {

    long startTime = System.currentTimeMillis();

    List<ExtRepositorySearchResult<?>> extRepositorySearchResults = null;

    try {// w  ww .  j  a  v a  2s.  c o  m
        extRepositorySearchResults = _extRepository.search(searchContext, query,
                new ExtRepositoryQueryMapperImpl(this));
    } catch (PortalException pe) {
        throw new SearchException("Unable to perform search", pe);
    } catch (SystemException se) {
        throw new SearchException("Unable to perform search", se);
    }

    QueryConfig queryConfig = searchContext.getQueryConfig();

    List<Document> documents = new ArrayList<Document>();
    List<String> snippets = new ArrayList<String>();
    List<Float> scores = new ArrayList<Float>();

    int total = 0;

    for (ExtRepositorySearchResult<?> extRepositorySearchResult : extRepositorySearchResults) {

        try {
            ExtRepositoryObjectAdapter<?> extRepositoryEntryAdapter = _toExtRepositoryObjectAdapter(
                    ExtRepositoryObjectAdapterType.OBJECT, extRepositorySearchResult.getObject());

            Document document = new DocumentImpl();

            document.addKeyword(Field.ENTRY_CLASS_NAME, extRepositoryEntryAdapter.getModelClassName());
            document.addKeyword(Field.ENTRY_CLASS_PK, extRepositoryEntryAdapter.getPrimaryKey());
            document.addKeyword(Field.TITLE, extRepositoryEntryAdapter.getName());

            documents.add(document);

            if (queryConfig.isScoreEnabled()) {
                scores.add(extRepositorySearchResult.getScore());
            } else {
                scores.add(1.0F);
            }

            snippets.add(extRepositorySearchResult.getSnippet());

            total++;
        } catch (SystemException se) {
            if (_log.isWarnEnabled()) {
                _log.warn("Invalid entry returned from search", se);
            }
        } catch (PortalException pe) {
            if (_log.isWarnEnabled()) {
                _log.warn("Invalid entry returned from search", pe);
            }
        }
    }

    float searchTime = (float) (System.currentTimeMillis() - startTime) / Time.SECOND;

    Hits hits = new HitsImpl();

    hits.setDocs(documents.toArray(new Document[documents.size()]));
    hits.setLength(total);
    hits.setQueryTerms(new String[0]);
    hits.setScores(ArrayUtil.toFloatArray(scores));
    hits.setSearchTime(searchTime);
    hits.setSnippets(snippets.toArray(new String[snippets.size()]));
    hits.setStart(startTime);

    return hits;
}