"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java" between
apache-openmeetings-6.1.0-src.tar.gz and apache-openmeetings-6.2.0-src.tar.gz

About: OpenMeetings is a browser-based software that allows you to set up instantly a conference in the Web. You can use your microphone or webcam, share documents on a white board, share your screen or record meetings. Source code.

FileWebService.java  (apache-openmeetings-6.1.0-src):FileWebService.java  (apache-openmeetings-6.2.0-src)
skipping to change at line 55 skipping to change at line 55
import org.apache.openmeetings.db.dto.basic.ServiceResult.Type; import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
import org.apache.openmeetings.db.dto.file.FileExplorerObject; import org.apache.openmeetings.db.dto.file.FileExplorerObject;
import org.apache.openmeetings.db.dto.file.FileItemDTO; import org.apache.openmeetings.db.dto.file.FileItemDTO;
import org.apache.openmeetings.db.entity.file.FileItem; import org.apache.openmeetings.db.entity.file.FileItem;
import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.db.entity.user.User;
import org.apache.openmeetings.db.entity.user.User.Right; import org.apache.openmeetings.db.entity.user.User.Right;
import org.apache.openmeetings.db.util.AuthLevelUtil; import org.apache.openmeetings.db.util.AuthLevelUtil;
import org.apache.openmeetings.util.process.ProcessResultList; import org.apache.openmeetings.util.process.ProcessResultList;
import org.apache.openmeetings.webservice.error.InternalServiceException; import org.apache.openmeetings.webservice.error.InternalServiceException;
import org.apache.openmeetings.webservice.error.ServiceException; import org.apache.openmeetings.webservice.error.ServiceException;
import org.apache.openmeetings.webservice.schema.FileExplorerObjectWrapper;
import org.apache.openmeetings.webservice.schema.FileItemDTOListWrapper;
import org.apache.openmeetings.webservice.schema.FileItemDTOWrapper;
import org.apache.openmeetings.webservice.schema.ServiceResultWrapper;
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 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;
/** /**
* *
* Contains methods to import and upload files into the Files section of the * Contains methods to import and upload files into the Files section of the
* conference room and the personal drive of any USER * conference room and the personal drive of any USER
* *
* @author sebawagner * @author sebawagner
* *
*/ */
@Service("fileWebService") @Service("fileWebService")
@WebService(serviceName="org.apache.openmeetings.webservice.FileWebService", tar getNamespace = TNS) @WebService(serviceName="org.apache.openmeetings.webservice.FileWebService", tar getNamespace = 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 = "FileService")
@Path("/file") @Path("/file")
public class FileWebService extends BaseWebService { public class FileWebService extends BaseWebService {
private static final Logger log = LoggerFactory.getLogger(FileWebService. class); private static final Logger log = LoggerFactory.getLogger(FileWebService. class);
@Autowired @Autowired
private FileProcessor fileProcessor; private FileProcessor fileProcessor;
/** /**
* deletes files or folders based on it id * deletes files or folders based on it id
* *
* @param sid * @param sid
* The SID of the User. This SID must be marked as logged in * The SID of the User. This SID must be marked as logged in
* @param id * @param id
* the id of the file or folder * the id of the file or folder
* @return {@link ServiceResult} with result type * @return {@link ServiceResult} with result type
* @throws {@link ServiceException} in case of any errors * @throws {@link ServiceException} in case of any errors
*/ */
@DELETE @DELETE
@Path("/{id}") @Path("/{id}")
public ServiceResult delete(@QueryParam("sid") @WebParam(name="sid") Stri @Operation(
ng sid description = "deletes files or folders based on it id",
, @PathParam("id") @WebParam(name="id") Long id responses = {
@ApiResponse(responseCode = "200", descri
ption = "ServiceResult with result type",
content = @Content(schema = @Sche
ma(implementation = ServiceResultWrapper.class))),
@ApiResponse(responseCode = "500", descri
ption = "Error in case of invalid credentials or server error")
}
)
public ServiceResult delete(
@Parameter(required = true, description = "The SID of the
User. This SID must be marked as Loggedin") @QueryParam("sid") @WebParam(name="
sid") String sid
, @Parameter(required = true, description = "the id of th
e file or folder") @PathParam("id") @WebParam(name="id") Long id
) throws ServiceException ) throws ServiceException
{ {
FileItem f = fileDao.get(id); FileItem f = fileDao.get(id);
return performCall(sid, sd -> { return performCall(sid, sd -> {
Long userId = sd.getUserId(); Long userId = sd.getUserId();
Set<Right> rights = getRights(userId); Set<Right> rights = getRights(userId);
return AuthLevelUtil.hasWebServiceLevel(rights) return AuthLevelUtil.hasWebServiceLevel(rights)
|| (AuthLevelUtil.hasUserLevel(rights) && userId.equals(f.getOwnerId())); || (AuthLevelUtil.hasUserLevel(rights) && userId.equals(f.getOwnerId()));
} }
, sd -> { , sd -> {
skipping to change at line 117 skipping to change at line 138
return new ServiceResult("Deleted", Type.SUCCESS) ; return new ServiceResult("Deleted", Type.SUCCESS) ;
}); });
} }
/** /**
* *
* deletes a file by its external Id and type * deletes a file by its external Id and type
* *
* @param sid * @param sid
* The SID of the User. This SID must be marked as logged in * The SID of the User. This SID must be marked as logged in
* @param externalId
* the od of the file or folder
* @param externalType * @param externalType
* the externalType * the externalType
* @param externalId
* the id of the file or folder
* @return {@link ServiceResult} with result type * @return {@link ServiceResult} with result type
* @throws {@link ServiceException} in case of any errors * @throws {@link ServiceException} in case of any errors
*/ */
@DELETE @DELETE
@Path("/{externaltype}/{externalid}") @Path("/{externaltype}/{externalid}")
@Operation(
description = "deletes a file by its external Id and type
",
responses = {
@ApiResponse(responseCode = "200", descri
ption = "ServiceResult with result type",
content = @Content(schema = @Sche
ma(implementation = ServiceResultWrapper.class))),
@ApiResponse(responseCode = "500", descri
ption = "Error in case of invalid credentials or server error")
}
)
public ServiceResult deleteExternal( public ServiceResult deleteExternal(
@WebParam(name="sid") @QueryParam("sid") String sid @Parameter(required = true, description = "The SID of the
, @WebParam(name="externaltype") @PathParam("externaltype User. This SID must be marked as Loggedin") @WebParam(name="sid") @QueryParam("
") String externalType sid") String sid
, @WebParam(name="externalid") @PathParam("externalid") S , @Parameter(required = true, description = "the external
tring externalId Type") @WebParam(name="externaltype") @PathParam("externaltype") String external
Type
, @Parameter(required = true, description = "the id of th
e file or folder") @WebParam(name="externalid") @PathParam("externalid") String
externalId
) throws ServiceException ) throws ServiceException
{ {
return performCall(sid, User.Right.SOAP, sd -> { return performCall(sid, User.Right.SOAP, sd -> {
FileItem f = fileDao.get(externalId, externalType); FileItem f = fileDao.get(externalId, externalType);
fileDao.delete(f); fileDao.delete(f);
return new ServiceResult("Deleted", Type.SUCCESS); return new ServiceResult("Deleted", Type.SUCCESS);
}); });
} }
/** /**
* to add a folder to the private drive, set parentId = 0 and isOwner to 1/true and * to add a folder to the private drive, set parentId = 0 and isOwner to 1/true and
* externalUserId/externalUserType to a valid USER * externalUserId/externalUserType to a valid USER
* *
* @param sid * @param sid
* The SID of the User. This SID must be marked as logged in * The SID of the User. This SID must be marked as logged in
* @param file * @param file
* the The file to be added * the The file attributes to be added
* @param stream * @param stream
* the The file to be added * the The file to be added
* @return - Object created * @return - Object created
* @throws {@link ServiceException} in case of any errors * @throws {@link ServiceException} in case of any errors
*/ */
@WebMethod @WebMethod
@POST @POST
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/") @Path("/")
public FileItemDTO add(@WebParam(name="sid") @QueryParam("sid") String si @Operation(
d description = "to add a folder to the private drive, set
, @Multipart(value = "file", type = MediaType.APPLICATION parentId = 0 and isOwner to 1/true and\n"
_JSON) @WebParam(name="file") FileItemDTO file + " externalUserId/externalUserType to a
, @Multipart(value = "stream", type = MediaType.APPLICATI valid USER",
ON_OCTET_STREAM, required = false) @WebParam(name="stream") InputStream stream responses = {
@ApiResponse(responseCode = "200", descri
ption = "Object created",
content = @Content(schema = @Sche
ma(implementation = FileItemDTOWrapper.class))),
@ApiResponse(responseCode = "500", descri
ption = "Error in case of invalid credentials or server error")
}
)
public FileItemDTO add(
@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 The file
attributes to be added") @Multipart(value = "file", type = MediaType.APPLICATIO
N_JSON) @WebParam(name="file") FileItemDTO file
, @Parameter(required = true, description = "the The file
to be added") @Multipart(value = "stream", type = MediaType.APPLICATION_OCTET_S
TREAM, required = false) @WebParam(name="stream") InputStream stream
) throws ServiceException ) throws ServiceException
{ {
return performCall(sid, User.Right.SOAP, sd -> { return performCall(sid, User.Right.SOAP, sd -> {
FileItem f = file == null ? null : file.get(); FileItem f = file == null ? null : file.get();
if (f == null || f.getId() != null) { if (f == null || f.getId() != null) {
throw new InternalServiceException("Bad id"); throw new InternalServiceException("Bad id");
} }
f.setInsertedBy(sd.getUserId()); f.setInsertedBy(sd.getUserId());
if (stream != null) { if (stream != null) {
try { try {
skipping to change at line 190 skipping to change at line 229
}); });
} }
/** /**
* Get all files by external type * Get all files by external type
* *
* @param sid * @param sid
* The SID of the User. This SID must be marked as logged in * The SID of the User. This SID must be marked as logged in
* @param externalType * @param externalType
* External type for file listing * External type for file listing
* @return - the list of file for given external type * @return - the list of files for given external type
* @throws {@link ServiceException} in case of any errors * @throws {@link ServiceException} in case of any errors
*/ */
@WebMethod @WebMethod
@GET @GET
@Path("/{externaltype}") @Path("/{externaltype}")
public List<FileItemDTO> getAllExternal(@WebParam(name="sid") @QueryParam @Operation(
("sid") String sid description = "Get all files by external type",
, @WebParam(name="externaltype") @PathParam("externaltype responses = {
") String externalType @ApiResponse(responseCode = "200", descri
ption = "the list of files for given external type",
content = @Content(schema = @Sche
ma(implementation = FileItemDTOListWrapper.class))),
@ApiResponse(responseCode = "500", descri
ption = "Error in case of invalid credentials or server error")
}
)
public List<FileItemDTO> getAllExternal(
@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 = "External typ
e for file listing") @WebParam(name="externaltype") @PathParam("externaltype") S
tring externalType
) throws ServiceException ) throws ServiceException
{ {
log.debug("getAllExternal::externalType {}", externalType); log.debug("getAllExternal::externalType {}", externalType);
return performCall(sid, User.Right.SOAP, sd -> FileItemDTO.list(f ileDao.getExternal(externalType))); return performCall(sid, User.Right.SOAP, sd -> FileItemDTO.list(f ileDao.getExternal(externalType)));
} }
/** /**
* Get a File Explorer Object by a given ROOM * Get a File Explorer Object by a given ROOM
* *
* @param sid * @param sid
* The SID of the User. This SID must be marked as logged in * The SID of the User. This SID must be marked as logged in
* @param roomId * @param roomId
* ROOM Id * ROOM Id
* @return - File Explorer Object by a given ROOM * @return - File Explorer Object by a given ROOM
* @throws {@link ServiceException} in case of any errors * @throws {@link ServiceException} in case of any errors
*/ */
@WebMethod @WebMethod
@GET @GET
@Path("/room/{id}") @Path("/room/{id}")
public FileExplorerObject getRoom(@WebParam(name="sid") @QueryParam("sid" @Operation(
) String sid description = "Get a File Explorer Object by a given ROOM
, @WebParam(name="id") @PathParam("id") long roomId ",
responses = {
@ApiResponse(responseCode = "200", descri
ption = "File Explorer Object by a given ROOM",
content = @Content(schema
= @Schema(implementation = FileExplorerObjectWrapper.class))),
@ApiResponse(responseCode = "500", descri
ption = "Error in case of invalid credentials or server error")
}
)
public FileExplorerObject getRoom(
@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 = "ROOM Id") @W
ebParam(name="id") @PathParam("id") long roomId
) throws ServiceException ) throws ServiceException
{ {
log.debug("getRoom::roomId {}", roomId); log.debug("getRoom::roomId {}", roomId);
return performCall(sid, User.Right.SOAP, sd -> { return performCall(sid, User.Right.SOAP, sd -> {
FileExplorerObject fileExplorerObject = new FileExplorerO bject(); FileExplorerObject fileExplorerObject = new FileExplorerO bject();
// Home File List // Home File List
List<FileItem> fList = fileDao.getByOwner(sd.getUserId()) ; List<FileItem> fList = fileDao.getByOwner(sd.getUserId()) ;
fileExplorerObject.setUser(fList, fileDao.getSize(fList)) ; fileExplorerObject.setUser(fList, fileDao.getSize(fList)) ;
skipping to change at line 253 skipping to change at line 310
* @param parentId * @param parentId
* the parent folder id * the parent folder id
* @param roomId * @param roomId
* the room id * the room id
* @return - list of file explorer items * @return - list of file explorer items
* @throws {@link ServiceException} in case of any errors * @throws {@link ServiceException} in case of any errors
*/ */
@WebMethod @WebMethod
@GET @GET
@Path("/room/{id}/{parent}") @Path("/room/{id}/{parent}")
public List<FileItemDTO> getRoomByParent(@WebParam(name="sid") @QueryPara @Operation(
m("sid") String sid description = "Get list of FileItemDTO by parent",
, @WebParam(name="id") @PathParam("id") long roomId responses = {
, @WebParam(name="parent") @PathParam("parent") long pare @ApiResponse(responseCode = "200", descri
ntId ption = "list of file explorer items",
content = @Content(schema
= @Schema(implementation = FileItemDTOListWrapper.class))),
@ApiResponse(responseCode = "500", descri
ption = "Error in case of invalid credentials or server error")
}
)
public List<FileItemDTO> getRoomByParent(
@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 parent f
older id") @WebParam(name="id") @PathParam("id") long roomId
, @Parameter(required = true, description = "the room id"
) @WebParam(name="parent") @PathParam("parent") long parentId
) throws ServiceException ) throws ServiceException
{ {
log.debug("getRoomByParent {}", parentId); log.debug("getRoomByParent {}", parentId);
return performCall(sid, User.Right.ROOM, sd -> { return performCall(sid, User.Right.ROOM, sd -> {
List<FileItem> list; List<FileItem> list;
if (parentId < 0) { if (parentId < 0) {
if (parentId == -1) { if (parentId == -1) {
list = fileDao.getByOwner(sd.getUserId()) ; list = fileDao.getByOwner(sd.getUserId()) ;
} else { } else {
list = fileDao.getByRoom(roomId); list = fileDao.getByRoom(roomId);
skipping to change at line 290 skipping to change at line 356
* @param id * @param id
* file or folder id * file or folder id
* @param name * @param name
* new file or folder name * new file or folder name
* @return - resulting file object * @return - resulting file object
* @throws {@link ServiceException} in case of any errors * @throws {@link ServiceException} in case of any errors
*/ */
@WebMethod @WebMethod
@POST @POST
@Path("/rename/{id}/{name}") @Path("/rename/{id}/{name}")
public FileItemDTO rename(@WebParam(name="sid") @QueryParam("sid") String @Operation(
sid description = "update a file or folder name",
, @WebParam(name="id") @PathParam("id") long id responses = {
, @WebParam(name="name") @PathParam("name") String name @ApiResponse(responseCode = "200", descri
ption = "resulting file object",
content = @Content(schema
= @Schema(implementation = FileItemDTOWrapper.class))),
@ApiResponse(responseCode = "500", descri
ption = "Error in case of invalid credentials or server error")
}
)
public FileItemDTO rename(
@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 = "file or fold
er id") @WebParam(name="id") @PathParam("id") long id
, @Parameter(required = true, description = "new file or
folder name") @WebParam(name="name") @PathParam("name") String name
) throws ServiceException ) throws ServiceException
{ {
log.debug("rename {}", id); log.debug("rename {}", id);
return performCall(sid, User.Right.SOAP, sd -> { return performCall(sid, User.Right.SOAP, sd -> {
FileItem f = fileDao.rename(id, name); FileItem f = fileDao.rename(id, name);
return f == null ? null : new FileItemDTO(f); return f == null ? null : new FileItemDTO(f);
}); });
} }
/** /**
skipping to change at line 319 skipping to change at line 394
* @param roomId * @param roomId
* room this file need to be moved * room this file need to be moved
* @param parentId * @param parentId
* new parent folder id * new parent folder id
* @return - resulting file object * @return - resulting file object
* @throws {@link ServiceException} in case of any errors * @throws {@link ServiceException} in case of any errors
*/ */
@WebMethod @WebMethod
@POST @POST
@Path("/move/{roomid}/{id}/{parentid}") @Path("/move/{roomid}/{id}/{parentid}")
public FileItemDTO move(@WebParam(name="sid") @QueryParam("sid") String s @Operation(
id description = "move a file or folder",
, @WebParam(name="id") @PathParam("id") long id responses = {
, @WebParam(name="roomid") @PathParam("roomid") long room @ApiResponse(responseCode = "200", descri
Id ption = "resulting file object",
, @WebParam(name="parentid") @PathParam("parentid") long content = @Content(schema
parentId = @Schema(implementation = FileItemDTOWrapper.class))),
@ApiResponse(responseCode = "500", descri
ption = "Error in case of invalid credentials or server error")
}
)
public FileItemDTO move(
@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 = "current file
or folder id to be moved") @WebParam(name="id") @PathParam("id") long id
, @Parameter(required = true, description = "room this fi
le need to be moved") @WebParam(name="roomid") @PathParam("roomid") long roomId
, @Parameter(required = true, description = "new parent f
older id") @WebParam(name="parentid") @PathParam("parentid") long parentId
) throws ServiceException ) throws ServiceException
{ {
log.debug("move {}", id); log.debug("move {}", id);
return performCall(sid, User.Right.SOAP, sd -> { return performCall(sid, User.Right.SOAP, sd -> {
FileItem f = fileDao.move(id, parentId, sd.getUserId(), r oomId); FileItem f = fileDao.move(id, parentId, sd.getUserId(), r oomId);
return f == null ? null : new FileItemDTO(f); return f == null ? null : new FileItemDTO(f);
}); });
} }
} }
 End of changes. 16 change blocks. 
41 lines changed or deleted 173 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)