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.subtitles.reference; 017 018import service.tut.pori.subtitles.Definitions; 019import service.tut.pori.subtitles.SubtitlesCore.FileFormat; 020import service.tut.pori.subtitles.SubtitlesCore.SubtitleFormat; 021import core.tut.pori.http.StringResponse; 022import core.tut.pori.http.annotations.HTTPAuthenticationParameter; 023import core.tut.pori.http.annotations.HTTPMethodParameter; 024import core.tut.pori.http.annotations.HTTPService; 025import core.tut.pori.http.annotations.HTTPServiceMethod; 026import core.tut.pori.http.parameters.AuthenticationParameter; 027import core.tut.pori.http.parameters.LongParameter; 028import core.tut.pori.http.parameters.StringParameter; 029 030/** 031 * Reference implementation for client API methods. 032 * 033 * <h1>Implementation Service path {@value service.tut.pori.subtitles.Definitions#SERVICE_SUBS}</h1> 034 * 035 * @see service.tut.pori.subtitles.SubtitlesService 036 */ 037@HTTPService(name = service.tut.pori.subtitles.reference.Definitions.SERVICE_SUBS_REFERENCE_CLIENT) 038public class ClientService { 039 /** 040 * 041 * @param authenticatedUser 042 * @param guid video GUID 043 * @param fileFormat format of the subtitle file 044 * @param subtitleFormat one of the supported formatting options 045 * @param userIdFilter optional user id filter for media objects 046 * @return formatted subtitle file 047 * @see service.tut.pori.subtitles.SubtitlesCore.SubtitleFormat 048 * @see service.tut.pori.subtitles.SubtitlesCore.FileFormat 049 */ 050 @HTTPServiceMethod(name = Definitions.METHOD_GENERATE_SUBTITLES, acceptedMethods={core.tut.pori.http.Definitions.METHOD_GET}) 051 public StringResponse generateSubtitles( 052 @HTTPAuthenticationParameter(required = false) AuthenticationParameter authenticatedUser, 053 @HTTPMethodParameter(name=service.tut.pori.contentanalysis.Definitions.PARAMETER_GUID) StringParameter guid, 054 @HTTPMethodParameter(name=Definitions.PARAMETER_FILE_FORMAT) StringParameter fileFormat, 055 @HTTPMethodParameter(name=Definitions.PARAMETER_SUBTITLE_FORMAT) StringParameter subtitleFormat, 056 @HTTPMethodParameter(name=service.tut.pori.users.Definitions.PARAMETER_USER_ID, required = false) LongParameter userIdFilter 057 ) 058 { 059 return new StringResponse(SubtitlesReferenceCore.generateSubtitles(authenticatedUser.getUserIdentity(), guid.getValue(), FileFormat.fromFormatString(fileFormat.getValue()), SubtitleFormat.fromFormatString(subtitleFormat.getValue()), userIdFilter.getValues())); 060 } 061}