Search in sources :

Example 21 with FileVO

use of org.olat.restapi.support.vo.FileVO in project OpenOLAT by OpenOLAT.

the class VFSWebservice method createFileVO.

public static FileVO createFileVO(VFSItem item, UriInfo uriInfo) {
    UriBuilder builder = uriInfo.getAbsolutePathBuilder();
    String uri = builder.path(normalize(item.getName())).build().toString();
    FileVO link = new FileVO("self", uri, item.getName());
    if (item instanceof VFSLeaf) {
        link.setSize(((VFSLeaf) item).getSize());
    }
    return link;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) FileVO(org.olat.restapi.support.vo.FileVO) UriBuilder(javax.ws.rs.core.UriBuilder)

Example 22 with FileVO

use of org.olat.restapi.support.vo.FileVO in project OpenOLAT by OpenOLAT.

the class UserMgmtTest method testUserGroupFolder.

@Test
public void testUserGroupFolder() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login(id1.getName(), "A6B7C8"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("folders").path("group").path(g2.getKey().toString()).build();
    HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    InputStream body = response.getEntity().getContent();
    List<FileVO> folders = parseFileArray(body);
    assertNotNull(folders);
    assertFalse(folders.isEmpty());
    // private and public
    assertEquals(1, folders.size());
    FileVO portrait = folders.get(0);
    assertEquals("portrait.jpg", portrait.getTitle());
    conn.shutdown();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) FileVO(org.olat.restapi.support.vo.FileVO) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Example 23 with FileVO

use of org.olat.restapi.support.vo.FileVO in project OpenOLAT by OpenOLAT.

the class UserMgmtTest method testOtherUserPersonalFolderOfId3.

@Test
public void testOtherUserPersonalFolderOfId3() throws Exception {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login(id1.getName(), "A6B7C8"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id3.getKey().toString()).path("folders").path("personal").build();
    HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    InputStream body = response.getEntity().getContent();
    List<FileVO> files = parseFileArray(body);
    assertNotNull(files);
    assertFalse(files.isEmpty());
    // private and public
    assertEquals(1, files.size());
    FileVO portrait = files.get(0);
    assertEquals("portrait.jpg", portrait.getTitle());
    conn.shutdown();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) FileVO(org.olat.restapi.support.vo.FileVO) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Example 24 with FileVO

use of org.olat.restapi.support.vo.FileVO in project OpenOLAT by OpenOLAT.

the class UserMgmtTest method testUserPersonalFolder.

@Test
public void testUserPersonalFolder() throws Exception {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login(id1.getName(), "A6B7C8"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id1.getKey().toString()).path("folders").path("personal").build();
    HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    InputStream body = response.getEntity().getContent();
    List<FileVO> files = parseFileArray(body);
    assertNotNull(files);
    assertFalse(files.isEmpty());
    // private and public
    assertEquals(2, files.size());
    conn.shutdown();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) FileVO(org.olat.restapi.support.vo.FileVO) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Example 25 with FileVO

use of org.olat.restapi.support.vo.FileVO in project OpenOLAT by OpenOLAT.

the class UserMgmtTest method testOtherUserPersonalFolder.

@Test
public void testOtherUserPersonalFolder() throws Exception {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login(id1.getName(), "A6B7C8"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("users").path(id2.getKey().toString()).path("folders").path("personal").build();
    HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    InputStream body = response.getEntity().getContent();
    List<FileVO> files = parseFileArray(body);
    assertNotNull(files);
    assertTrue(files.isEmpty());
    // private and public
    assertEquals(0, files.size());
    conn.shutdown();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) FileVO(org.olat.restapi.support.vo.FileVO) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Aggregations

FileVO (org.olat.restapi.support.vo.FileVO)34 URI (java.net.URI)26 HttpResponse (org.apache.http.HttpResponse)26 Test (org.junit.Test)24 InputStream (java.io.InputStream)22 HttpGet (org.apache.http.client.methods.HttpGet)22 VFSContainer (org.olat.core.util.vfs.VFSContainer)14 ByteArrayInputStream (java.io.ByteArrayInputStream)10 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10 HttpPut (org.apache.http.client.methods.HttpPut)8 UriBuilder (javax.ws.rs.core.UriBuilder)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 Identity (org.olat.core.id.Identity)4 SystemItemFilter (org.olat.core.util.vfs.filters.SystemItemFilter)4 MessageVO (org.olat.modules.fo.restapi.MessageVO)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 SharedFolderHandler (org.olat.repository.handlers.SharedFolderHandler)4 BufferedImage (java.awt.image.BufferedImage)2 File (java.io.File)2 URL (java.net.URL)2