WbWebService.java (apache-openmeetings-6.1.0-src) | : | WbWebService.java (apache-openmeetings-6.2.0-src) | ||
---|---|---|---|---|
skipping to change at line 56 | skipping to change at line 56 | |||
import org.apache.cxf.feature.Features; | import org.apache.cxf.feature.Features; | |||
import org.apache.openmeetings.db.dto.basic.ServiceResult; | import org.apache.openmeetings.db.dto.basic.ServiceResult; | |||
import org.apache.openmeetings.db.dto.basic.ServiceResult.Type; | import org.apache.openmeetings.db.dto.basic.ServiceResult.Type; | |||
import org.apache.openmeetings.db.entity.basic.Client; | import org.apache.openmeetings.db.entity.basic.Client; | |||
import org.apache.openmeetings.db.entity.room.Room; | import org.apache.openmeetings.db.entity.room.Room; | |||
import org.apache.openmeetings.db.entity.room.Room.RoomElement; | import org.apache.openmeetings.db.entity.room.Room.RoomElement; | |||
import org.apache.openmeetings.db.entity.user.User; | import org.apache.openmeetings.db.entity.user.User; | |||
import org.apache.openmeetings.db.manager.IClientManager; | import org.apache.openmeetings.db.manager.IClientManager; | |||
import org.apache.openmeetings.db.manager.IWhiteboardManager; | import org.apache.openmeetings.db.manager.IWhiteboardManager; | |||
import org.apache.openmeetings.webservice.error.ServiceException; | import org.apache.openmeetings.webservice.error.ServiceException; | |||
import org.apache.openmeetings.webservice.schema.ServiceResultWrapper; | ||||
import org.apache.pdfbox.pdmodel.PDDocument; | import org.apache.pdfbox.pdmodel.PDDocument; | |||
import org.apache.pdfbox.pdmodel.PDPage; | import org.apache.pdfbox.pdmodel.PDPage; | |||
import org.apache.pdfbox.pdmodel.PDPageContentStream; | import org.apache.pdfbox.pdmodel.PDPageContentStream; | |||
import org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode; | import org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode; | |||
import org.apache.pdfbox.pdmodel.common.PDRectangle; | import org.apache.pdfbox.pdmodel.common.PDRectangle; | |||
import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; | import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; | |||
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; | import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; | |||
import org.slf4j.Logger; | import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | |||
import com.github.openjson.JSONArray; | import com.github.openjson.JSONArray; | |||
import io.swagger.v3.oas.annotations.Operation; | ||||
import io.swagger.v3.oas.annotations.Parameter; | ||||
import io.swagger.v3.oas.annotations.media.Content; | ||||
import io.swagger.v3.oas.annotations.media.Schema; | ||||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||||
import io.swagger.v3.oas.annotations.tags.Tag; | ||||
/** | /** | |||
* WbService contains methods to manipulate whiteboard contents | * WbService contains methods to manipulate whiteboard contents | |||
* | * | |||
*/ | */ | |||
@Service("wbWebService") | @Service("wbWebService") | |||
@WebService(serviceName="org.apache.openmeetings.webservice.WbWebService", targe tNamespace = TNS) | @WebService(serviceName="org.apache.openmeetings.webservice.WbWebService", targe tNamespace = TNS) | |||
@Features(features = "org.apache.cxf.ext.logging.LoggingFeature") | @Features(features = "org.apache.cxf.ext.logging.LoggingFeature") | |||
@Produces({MediaType.APPLICATION_JSON}) | @Produces({MediaType.APPLICATION_JSON}) | |||
@Tag(name = "WbService") | ||||
@Path("/wb") | @Path("/wb") | |||
public class WbWebService extends BaseWebService { | public class WbWebService extends BaseWebService { | |||
private static final Logger log = LoggerFactory.getLogger(WbWebService.cl ass); | private static final Logger log = LoggerFactory.getLogger(WbWebService.cl ass); | |||
@Autowired | @Autowired | |||
private IWhiteboardManager wbManager; | private IWhiteboardManager wbManager; | |||
@Autowired | @Autowired | |||
private IClientManager cm; | private IClientManager cm; | |||
/** | /** | |||
skipping to change at line 99 | skipping to change at line 108 | |||
* and create empty one(s) for room files specified | * and create empty one(s) for room files specified | |||
* | * | |||
* @param sid - The SID of the User. This SID must be marked as Loggedin | * @param sid - The SID of the User. This SID must be marked as Loggedin | |||
* @param id - id of the room to clean | * @param id - id of the room to clean | |||
* @return - serviceResult object with the result | * @return - serviceResult object with the result | |||
* @throws {@link ServiceException} in case of any errors | * @throws {@link ServiceException} in case of any errors | |||
*/ | */ | |||
@WebMethod | @WebMethod | |||
@GET | @GET | |||
@Path("/resetwb/{id}") | @Path("/resetwb/{id}") | |||
public ServiceResult resetWb(@WebParam(name="sid") @QueryParam("sid") Str | @Operation( | |||
ing sid | description = "This method will remove all whiteboards fr | |||
, @WebParam(name="id") @PathParam("id") long id | om given room\n" | |||
+ " and create empty one(s) for room file | ||||
s specified", | ||||
responses = { | ||||
@ApiResponse(responseCode = "200", descri | ||||
ption = "serviceResult object with the result", | ||||
content = @Content(schema | ||||
= @Schema(implementation = ServiceResultWrapper.class))), | ||||
@ApiResponse(responseCode = "500", descri | ||||
ption = "Error in case of invalid credentials or server error") | ||||
} | ||||
) | ||||
public ServiceResult resetWb( | ||||
@Parameter(required = true, description = "The SID of the | ||||
User. This SID must be marked as Loggedin") @WebParam(name="sid") @QueryParam(" | ||||
sid") String sid | ||||
, @Parameter(required = true, description = "id of the ro | ||||
om to clean") @WebParam(name="id") @PathParam("id") long id | ||||
) throws ServiceException | ) throws ServiceException | |||
{ | { | |||
log.debug("[resetWb] room id {}", id); | log.debug("[resetWb] room id {}", id); | |||
return performCall(sid, User.Right.SOAP, sd -> { | return performCall(sid, User.Right.SOAP, sd -> { | |||
wbManager.reset(id, sd.getUserId()); | wbManager.reset(id, sd.getUserId()); | |||
return new ServiceResult("", Type.SUCCESS); | return new ServiceResult("", Type.SUCCESS); | |||
}); | }); | |||
} | } | |||
/** | /** | |||
skipping to change at line 122 | skipping to change at line 141 | |||
* | * | |||
* @param sid - The SID of the User. This SID must be marked as Loggedin | * @param sid - The SID of the User. This SID must be marked as Loggedin | |||
* @param roomId - id of the room to clean | * @param roomId - id of the room to clean | |||
* @param wbId - id of the white board to clean | * @param wbId - id of the white board to clean | |||
* @return - serviceResult object with the result | * @return - serviceResult object with the result | |||
* @throws {@link ServiceException} in case of any errors | * @throws {@link ServiceException} in case of any errors | |||
*/ | */ | |||
@WebMethod | @WebMethod | |||
@GET | @GET | |||
@Path("/cleanwb/{roomid}/{wbid}") | @Path("/cleanwb/{roomid}/{wbid}") | |||
public ServiceResult cleanWb(@WebParam(name="sid") @QueryParam("sid") Str | @Operation( | |||
ing sid | description = "This method will do the same as clean WB i | |||
, @WebParam(name="roomid") @PathParam("roomid") long room | n the room (except for there will be no UNDO)", | |||
Id | responses = { | |||
, @WebParam(name="wbid") @PathParam("wbid") long wbId | @ApiResponse(responseCode = "200", descri | |||
ption = "serviceResult object with the result", | ||||
content = @Content(schema | ||||
= @Schema(implementation = ServiceResultWrapper.class))), | ||||
@ApiResponse(responseCode = "500", descri | ||||
ption = "Error in case of invalid credentials or server error") | ||||
} | ||||
) | ||||
public ServiceResult cleanWb( | ||||
@Parameter(required = true, description = "The SID of the | ||||
User. This SID must be marked as Loggedin") @WebParam(name="sid") @QueryParam(" | ||||
sid") String sid | ||||
, @Parameter(required = true, description = "id of the ro | ||||
om to clean") @WebParam(name="roomid") @PathParam("roomid") long roomId | ||||
, @Parameter(required = true, description = "id of the wh | ||||
ite board to clean") @WebParam(name="wbid") @PathParam("wbid") long wbId | ||||
) throws ServiceException | ) throws ServiceException | |||
{ | { | |||
log.debug("[cleanWb] room id {}, wb id {}", roomId, wbId); | log.debug("[cleanWb] room id {}, wb id {}", roomId, wbId); | |||
return performCall(sid, User.Right.SOAP, sd -> { | return performCall(sid, User.Right.SOAP, sd -> { | |||
wbManager.clearAll(roomId, wbId, null); | wbManager.clearAll(roomId, wbId, null); | |||
return new ServiceResult("", Type.SUCCESS); | return new ServiceResult("", Type.SUCCESS); | |||
}); | }); | |||
} | } | |||
/** | /** | |||
skipping to change at line 147 | skipping to change at line 175 | |||
* @param sid - The SID of the User. This SID must be marked as Loggedin | * @param sid - The SID of the User. This SID must be marked as Loggedin | |||
* @param roomId - id of the room to clean | * @param roomId - id of the room to clean | |||
* @param wbId - id of the white board to clean | * @param wbId - id of the white board to clean | |||
* @param slide - slide number (zero based) | * @param slide - slide number (zero based) | |||
* @return - serviceResult object with the result | * @return - serviceResult object with the result | |||
* @throws {@link ServiceException} in case of any errors | * @throws {@link ServiceException} in case of any errors | |||
*/ | */ | |||
@WebMethod | @WebMethod | |||
@GET | @GET | |||
@Path("/cleanslide/{roomid}/{wbid}/{slide}") | @Path("/cleanslide/{roomid}/{wbid}/{slide}") | |||
public ServiceResult cleanSlide(@WebParam(name="sid") @QueryParam("sid") | @Operation( | |||
String sid | description = "This method will do the same as clean slid | |||
, @WebParam(name="roomid") @PathParam("roomid") long room | e in the room (except for there will be no UNDO)", | |||
Id | responses = { | |||
, @WebParam(name="wbid") @PathParam("wbid") long wbId | @ApiResponse(responseCode = "200", descri | |||
, @WebParam(name="slide") @PathParam("slide") int slide | ption = "serviceResult object with the result", | |||
content = @Content(schema | ||||
= @Schema(implementation = ServiceResultWrapper.class))), | ||||
@ApiResponse(responseCode = "500", descri | ||||
ption = "Error in case of invalid credentials or server error") | ||||
} | ||||
) | ||||
public ServiceResult cleanSlide( | ||||
@Parameter(required = true, description = "The SID of the | ||||
User. This SID must be marked as Loggedin") @WebParam(name="sid") @QueryParam(" | ||||
sid") String sid | ||||
, @Parameter(required = true, description = "id of the ro | ||||
om to clean") @WebParam(name="roomid") @PathParam("roomid") long roomId | ||||
, @Parameter(required = true, description = "id of the wh | ||||
ite board to clean") @WebParam(name="wbid") @PathParam("wbid") long wbId | ||||
, @Parameter(required = true, description = "slide number | ||||
(zero based)") @WebParam(name="slide") @PathParam("slide") int slide | ||||
) throws ServiceException | ) throws ServiceException | |||
{ | { | |||
log.debug("[cleanSlide] room id {}, wb id {}, slide {}", roomId, wbId, slide); | log.debug("[cleanSlide] room id {}, wb id {}, slide {}", roomId, wbId, slide); | |||
return performCall(sid, User.Right.SOAP, sd -> { | return performCall(sid, User.Right.SOAP, sd -> { | |||
wbManager.cleanSlide(roomId, wbId, slide, null); | wbManager.cleanSlide(roomId, wbId, slide, null); | |||
return new ServiceResult("", Type.SUCCESS); | return new ServiceResult("", Type.SUCCESS); | |||
}); | }); | |||
} | } | |||
/** | /** | |||
* This method will recive WB as binary data (png) and store it to tempor ary PDF/PNG file | * This method will receive WB as binary data (png) and store it to tempo rary PDF/PNG file | |||
* | * | |||
* unlike other web service methods this one uses internal client sid | * unlike other web service methods this one uses internal client sid | |||
* NOT web service sid | * NOT web service sid | |||
* | * | |||
* @param sid - internal client sid | * @param sid - internal client sid | |||
* @param type - the type of document being saved PNG/PDF | * @param type - the type of document being saved PNG/PDF | |||
* @param data - binary data | * @param data - binary data | |||
* @return - serviceResult object with the result | * @return - serviceResult object with the result | |||
* @throws {@link ServiceException} in case of any errors | * @throws {@link ServiceException} in case of any errors | |||
*/ | */ | |||
@WebMethod | @WebMethod | |||
@POST | @POST | |||
@Path("/uploadwb/{type}") | @Path("/uploadwb/{type}") | |||
public ServiceResult uploadWb(@WebParam(name="sid") @QueryParam("sid") St | @Operation( | |||
ring sid | description = "This method will receive WB as binary data | |||
, @WebParam(name="type") @PathParam("type") String type | (png) and store it to temporary PDF/PNG file", | |||
, @WebParam(name="data") @FormParam("data") String data | responses = { | |||
@ApiResponse(responseCode = "200", descri | ||||
ption = "serviceResult object with the result", | ||||
content = @Content(schema | ||||
= @Schema(implementation = ServiceResultWrapper.class))), | ||||
@ApiResponse(responseCode = "500", descri | ||||
ption = "Error in case of invalid credentials or server error") | ||||
} | ||||
) | ||||
public ServiceResult uploadWb( | ||||
@Parameter(required = true, description = "The SID of the | ||||
User. This SID must be marked as Loggedin") @WebParam(name="sid") @QueryParam(" | ||||
sid") String sid | ||||
, @Parameter(required = true, description = "the type of | ||||
document being saved PNG/PDF") @WebParam(name="type") @PathParam("type") String | ||||
type | ||||
, @Parameter(required = true, description = "binary data" | ||||
) @WebParam(name="data") @FormParam("data") String data | ||||
) throws ServiceException | ) throws ServiceException | |||
{ | { | |||
log.debug("[uploadwb] type {}", type); | log.debug("[uploadwb] type {}", type); | |||
Client c = cm.getBySid(sid); | Client c = cm.getBySid(sid); | |||
final boolean allowed = c != null | final boolean allowed = c != null | |||
&& c.getRoom() != null | && c.getRoom() != null | |||
&& c.hasRight(Room.Right.MODERATOR) | && c.hasRight(Room.Right.MODERATOR) | |||
&& !c.getRoom().isHidden(RoomElement.ACTION_MENU) ; | && !c.getRoom().isHidden(RoomElement.ACTION_MENU) ; | |||
return performCall(null, sd -> allowed, sd -> { | return performCall(null, sd -> allowed, sd -> { | |||
try { | try { | |||
End of changes. 8 change blocks. | ||||
19 lines changed or deleted | 93 lines changed or added |