Search in sources :

Example 96 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogNodeManagerController method event.

@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (editLink == source) {
        doEditCategory(ureq);
    } else if (nominateLink == source) {
        doEditOwners(ureq);
    } else if (contactLink == source) {
        doContact(ureq);
    } else if (deleteLink == source) {
        doConfirmDelete(ureq);
    } else if (moveLink == source) {
        doMoveCategory(ureq);
    } else if (addCategoryLink == source) {
        doAddCategory(ureq);
    } else if (addResourceLink == source) {
        doAddResource(ureq);
    } else if (source instanceof Link) {
        Link link = (Link) source;
        if ("select_node".equals(link.getCommand())) {
            Long categoryNodeKey = (Long) link.getUserObject();
            CatalogEntry entry = catalogManager.getCatalogNodeByKey(categoryNodeKey);
            selectCatalogEntry(ureq, entry);
        }
    } else if ("img_select".equals(event.getCommand())) {
        String node = ureq.getParameter("node");
        if (StringHelper.isLong(node)) {
            try {
                Long categoryNodeKey = new Long(node);
                CatalogEntry entry = catalogManager.getCatalogNodeByKey(categoryNodeKey);
                selectCatalogEntry(ureq, entry);
            } catch (NumberFormatException e) {
                logWarn("Not a valid long: " + node, e);
            }
        }
    }
    super.event(ureq, source, event);
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) Link(org.olat.core.gui.components.link.Link)

Example 97 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogNodeManagerController method doContact.

private void doContact(UserRequest ureq) {
    removeAsListenerAndDispose(cmc);
    removeAsListenerAndDispose(contactCtrl);
    ContactList caretaker = new ContactList(translate("contact.to.groupname.caretaker"));
    List<Identity> owners = new ArrayList<Identity>();
    CatalogEntry parent = catalogEntry;
    while (parent != null && owners.isEmpty()) {
        SecurityGroup parentOwner = parent.getOwnerGroup();
        if (parentOwner != null) {
            owners = securityManager.getIdentitiesOfSecurityGroup(parentOwner);
        }
        parent = parent.getParent();
    }
    for (int i = owners.size(); i-- > 0; ) {
        caretaker.add(owners.get(i));
    }
    // create e-mail Message
    ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
    cmsg.addEmailTo(caretaker);
    contactCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
    listenTo(contactCtrl);
    // open form in dialog
    cmc = new CloseableModalController(getWindowControl(), "close", contactCtrl.getInitialComponent(), true, translate("contact.caretaker"));
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ContactFormController(org.olat.modules.co.ContactFormController) ArrayList(java.util.ArrayList) CatalogEntry(org.olat.repository.CatalogEntry) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) SecurityGroup(org.olat.basesecurity.SecurityGroup) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 98 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogTest method testGetOwners.

@Test
public void testGetOwners() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).path("owners").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<UserVO> voes = parseUserArray(body);
    assertNotNull(voes);
    CatalogEntry entry = catalogManager.loadCatalogEntry(entry1.getKey());
    List<Identity> identities = BaseSecurityManager.getInstance().getIdentitiesOfSecurityGroup(entry.getOwnerGroup());
    assertNotNull(identities);
    assertEquals(identities.size(), voes.size());
    conn.shutdown();
}
Also used : UserVO(org.olat.user.restapi.UserVO) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) CatalogEntry(org.olat.repository.CatalogEntry) HttpResponse(org.apache.http.HttpResponse) Identity(org.olat.core.id.Identity) URI(java.net.URI) Test(org.junit.Test)

Example 99 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogTest method testBasicSecurityPutCall.

@Test
public void testBasicSecurityPutCall() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("rest-catalog-two", "A6B7C8"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).queryParam("name", "Not-sub-entry-3").queryParam("description", "Not-sub-entry-description-3").queryParam("type", String.valueOf(CatalogEntry.TYPE_NODE)).build();
    HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    assertEquals(401, response.getStatusLine().getStatusCode());
    List<CatalogEntry> children = catalogManager.getChildrenOf(entry1);
    boolean saved = false;
    for (CatalogEntry child : children) {
        if ("Not-sub-entry-3".equals(child.getName())) {
            saved = true;
            break;
        }
    }
    assertFalse(saved);
    conn.shutdown();
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 100 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogTest method testUpdateCatalogEntryForm.

@Test
public void testUpdateCatalogEntryForm() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry2.getKey().toString()).build();
    HttpPost method = conn.createPost(uri, MediaType.APPLICATION_JSON);
    conn.addEntity(method, new BasicNameValuePair("name", "Entry-2-c"), new BasicNameValuePair("description", "Entry-description-2-c"), new BasicNameValuePair("type", String.valueOf(CatalogEntry.TYPE_NODE)));
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    CatalogEntryVO vo = conn.parse(response, CatalogEntryVO.class);
    assertNotNull(vo);
    CatalogEntry updatedEntry = catalogManager.loadCatalogEntry(entry2);
    assertEquals("Entry-2-c", updatedEntry.getName());
    assertEquals("Entry-description-2-c", updatedEntry.getDescription());
    conn.shutdown();
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) CatalogEntryVO(org.olat.restapi.support.vo.CatalogEntryVO) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) CatalogEntry(org.olat.repository.CatalogEntry) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Aggregations

CatalogEntry (org.olat.repository.CatalogEntry)122 Test (org.junit.Test)30 CatalogEntryVO (org.olat.restapi.support.vo.CatalogEntryVO)30 URI (java.net.URI)28 HttpResponse (org.apache.http.HttpResponse)28 Identity (org.olat.core.id.Identity)28 ArrayList (java.util.ArrayList)20 Path (javax.ws.rs.Path)18 SecurityGroup (org.olat.basesecurity.SecurityGroup)18 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Produces (javax.ws.rs.Produces)14 HttpPut (org.apache.http.client.methods.HttpPut)12 GET (javax.ws.rs.GET)10 WebApplicationException (javax.ws.rs.WebApplicationException)10 HttpPost (org.apache.http.client.methods.HttpPost)10 OLATResourceable (org.olat.core.id.OLATResourceable)10 ContextEntry (org.olat.core.id.context.ContextEntry)10 LockResult (org.olat.core.util.coordinate.LockResult)10 CatalogManager (org.olat.repository.manager.CatalogManager)8 Link (org.olat.core.gui.components.link.Link)6