Search in sources :

Example 16 with FileItem

use of org.apache.openmeetings.db.entity.file.FileItem in project openmeetings by apache.

the class WbPanel method saveWb.

public String saveWb(Long roomId, Long wbId, String name) {
    Whiteboard wb = wbm.get(roomId).get(wbId);
    FileItem f = new FileItem();
    f.setType(BaseFileItem.Type.WmlFile);
    f.setRoomId(roomId);
    f.setHash(UUID.randomUUID().toString());
    f.setName(name);
    f = fileDao.update(f);
    return wb.save(f.getFile().toPath());
}
Also used : FileItem(org.apache.openmeetings.db.entity.file.FileItem) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 17 with FileItem

use of org.apache.openmeetings.db.entity.file.FileItem in project openmeetings by apache.

the class BackupExport method exportFile.

/*
	 * ##################### File-Explorer
	 */
private void exportFile(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
    List<FileItem> list = fileItemDao.get();
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    bindDate(registry, list);
    writeList(serializer, zos, "fileExplorerItems.xml", "fileExplorerItems", list);
    progressHolder.setProgress(65);
}
Also used : FileItem(org.apache.openmeetings.db.entity.file.FileItem) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 18 with FileItem

use of org.apache.openmeetings.db.entity.file.FileItem in project openmeetings by apache.

the class FileWebService method delete.

/**
 * deletes files or folders based on it id
 *
 * @param sid
 *            The SID of the User. This SID must be marked as logged in
 * @param id
 *            the id of the file or folder
 * @return {@link ServiceResult} with result type
 */
@DELETE
@Path("/{id}")
public ServiceResult delete(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") Long id) {
    FileItem f = fileDao.get(id);
    return performCall(sid, sd -> {
        Long userId = sd.getUserId();
        Set<Right> rights = getRights(userId);
        return AuthLevelUtil.hasWebServiceLevel(rights) || (AuthLevelUtil.hasUserLevel(rights) && userId.equals(f.getOwnerId()));
    }, sd -> {
        if (f == null) {
            return new ServiceResult("Bad id", Type.ERROR);
        }
        fileDao.delete(f);
        return new ServiceResult("Deleted", Type.SUCCESS);
    });
}
Also used : FileItem(org.apache.openmeetings.db.entity.file.FileItem) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) Right(org.apache.openmeetings.db.entity.user.User.Right) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 19 with FileItem

use of org.apache.openmeetings.db.entity.file.FileItem in project openmeetings by apache.

the class FileWebService method deleteExternal.

/**
 * deletes a file by its external Id and type
 *
 * @param sid
 *            The SID of the User. This SID must be marked as logged in
 * @param externalId
 *            the od of the file or folder
 * @param externalType
 *            the externalType
 * @return {@link ServiceResult} with result type
 */
@DELETE
@Path("/{externaltype}/{externalid}")
public ServiceResult deleteExternal(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "externaltype") @PathParam("externaltype") String externalType, @WebParam(name = "externalid") @PathParam("externalid") String externalId) {
    return performCall(sid, User.Right.Soap, sd -> {
        FileItem f = fileDao.get(externalId, externalType);
        fileDao.delete(f);
        return new ServiceResult("Deleted", Type.SUCCESS);
    });
}
Also used : FileItem(org.apache.openmeetings.db.entity.file.FileItem) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 20 with FileItem

use of org.apache.openmeetings.db.entity.file.FileItem in project openmeetings by apache.

the class FileWebService method getRoom.

/**
 * Get a File Explorer Object by a given Room
 *
 * @param sid
 *            The SID of the User. This SID must be marked as logged in
 * @param roomId
 *            Room Id
 * @return - File Explorer Object by a given Room
 */
@WebMethod
@GET
@Path("/room/{id}")
public FileExplorerObject getRoom(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "id") @PathParam("id") long roomId) {
    log.debug("getRoom::roomId {}", roomId);
    return performCall(sid, User.Right.Room, sd -> {
        FileExplorerObject fileExplorerObject = new FileExplorerObject();
        // Home File List
        List<FileItem> fList = fileDao.getByOwner(sd.getUserId());
        fileExplorerObject.setUser(fList, fileDao.getSize(fList));
        // Public File List
        List<FileItem> rList = fileDao.getByRoom(roomId);
        fileExplorerObject.setRoom(rList, fileDao.getSize(rList));
        return fileExplorerObject;
    });
}
Also used : FileItem(org.apache.openmeetings.db.entity.file.FileItem) FileExplorerObject(org.apache.openmeetings.db.dto.file.FileExplorerObject) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

FileItem (org.apache.openmeetings.db.entity.file.FileItem)20 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)12 Path (javax.ws.rs.Path)4 ArrayList (java.util.ArrayList)3 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)3 Recording (org.apache.openmeetings.db.entity.record.Recording)3 ProcessResultList (org.apache.openmeetings.util.process.ProcessResultList)3 Serializer (org.simpleframework.xml.Serializer)3 Registry (org.simpleframework.xml.convert.Registry)3 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)3 Persister (org.simpleframework.xml.core.Persister)3 Strategy (org.simpleframework.xml.strategy.Strategy)3 File (java.io.File)2 WebMethod (javax.jws.WebMethod)2 DELETE (javax.ws.rs.DELETE)2 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)2 FileItemDTO (org.apache.openmeetings.db.dto.file.FileItemDTO)2 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)2 JSONObject (com.github.openjson.JSONObject)1 FileInputStream (java.io.FileInputStream)1