Search in sources :

Example 11 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class ProvTestUtil method createCalendarResource.

public CalendarResource createCalendarResource(String localPart, Domain domain, Map<String, Object> attrs) throws Exception {
    if (attrs == null) {
        attrs = new HashMap<String, Object>();
        attrs.put(Provisioning.A_displayName, localPart);
        attrs.put(Provisioning.A_zimbraCalResType, Provisioning.CalResType.Equipment.name());
    }
    String crName = TestUtil.getAddress(localPart, domain.getName());
    CalendarResource cr = prov.get(CalendarResourceBy.name, crName);
    assertNull(cr);
    cr = prov.createCalendarResource(crName, "test123", attrs);
    assertNotNull(cr);
    flushCache(CacheEntryType.account, CacheEntryBy.id, cr.getId());
    cr = prov.get(CalendarResourceBy.name, crName);
    assertNotNull(cr);
    assertEquals(crName.toLowerCase(), cr.getName().toLowerCase());
    createdEntries.add(cr);
    return cr;
}
Also used : CalendarResource(com.zimbra.cs.account.CalendarResource)

Example 12 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class TestSearchCalendarResources method searchByFilter.

private void searchByFilter(boolean ldap, String domainName) throws Exception {
    SoapTransport transport = authUser(TestUtil.getAddress(AUTHED_USER, domainName));
    Element request = Element.create(transport.getRequestProtocol(), AccountConstants.SEARCH_CALENDAR_RESOURCES_REQUEST);
    request.addAttribute(MailConstants.A_QUERY_OFFSET, 1);
    request.addAttribute(MailConstants.A_QUERY_LIMIT, 1);
    Element eSearchFilter = request.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER);
    Element eConds = eSearchFilter.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER_MULTICOND);
    Element eCondResType = eConds.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER_SINGLECOND);
    eCondResType.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_ATTR, "zimbraCalResType");
    eCondResType.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_OP, Operator.eq.name());
    eCondResType.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_VALUE, "Location");
    Element eCondResCapacity = eConds.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER_SINGLECOND);
    eCondResCapacity.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_ATTR, "zimbraCalResCapacity");
    eCondResCapacity.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_OP, Operator.ge.name());
    eCondResCapacity.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_VALUE, "15");
    Element eCondResSite = eConds.addElement(AccountConstants.E_ENTRY_SEARCH_FILTER_SINGLECOND);
    eCondResSite.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_ATTR, "zimbraCalResSite");
    eCondResSite.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_OP, Operator.has.name());
    eCondResSite.addAttribute(AccountConstants.A_ENTRY_SEARCH_FILTER_VALUE, SITE_WORD_1);
    Element response = transport.invoke(request);
    boolean paginationSupported = response.getAttributeBool(AccountConstants.A_PAGINATION_SUPPORTED);
    boolean found1 = false;
    boolean found2 = false;
    boolean found3 = false;
    List<CalendarResource> resources = new ArrayList<CalendarResource>();
    for (Element eResource : response.listElements(AccountConstants.E_CALENDAR_RESOURCE)) {
        CalendarResource resource = new MockCalendarResource(eResource);
        resources.add(resource);
        if (resource.getName().equals(TestUtil.getAddress(ROOM_1, domainName))) {
            found1 = true;
        }
        if (resource.getName().equals(TestUtil.getAddress(ROOM_2, domainName))) {
            found2 = true;
        }
        if (resource.getName().equals(TestUtil.getAddress(ROOM_3, domainName))) {
            found3 = true;
        }
    }
    if (ldap) {
        // pagination is not supported
        Assert.assertFalse(paginationSupported);
        // offset and limit are not honored
        Assert.assertEquals(2, resources.size());
        // not matching capacity requirement
        Assert.assertTrue(!found1);
        Assert.assertTrue(found2);
        Assert.assertTrue(found3);
    } else {
        // pagination is supported
        Assert.assertTrue(paginationSupported);
        // offset and limit are honored
        Assert.assertEquals(1, resources.size());
        // not matching capacity requirement
        Assert.assertTrue(!found1);
        Assert.assertTrue(!found2);
        // not within specified offset, at offset 0
        Assert.assertTrue(found3);
    // (gal sync acount mailbox search is by dateDesc order)
    }
}
Also used : Element(com.zimbra.common.soap.Element) ArrayList(java.util.ArrayList) CalendarResource(com.zimbra.cs.account.CalendarResource) SoapTransport(com.zimbra.common.soap.SoapTransport)

Example 13 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class TestSearchCalendarResources method chineseChar.

@Test
public void chineseChar() throws Exception {
    Map<String, Object> attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_displayName, "\u4e2d\u6587");
    attrs.put(Provisioning.A_zimbraCalResType, Provisioning.CalResType.Location.name());
    attrs.put(Provisioning.A_zimbraCalResSite, "\u4e2d\u6587");
    CalendarResource cr = provUtil.createCalendarResource("chineseChar", domain, attrs);
    String crName = cr.getName();
    /*
         * 
         filter="(&(&(&(|(displayName=*\E4\B8\AD\E6\96\87*)(cn=*\E4\B8\AD\E6\96\87*)(sn=*\E4\B8\AD\E6\96\87*)(givenName=*\E4\B8\AD\E6\96\87*)(?mail=*\E4\B8\AD\E6\96\87*)(?zimbraMailDeliveryAddress=*\E4\B8\AD\E6\96\87*)(?zimbraMailAlias=*\E4\B8\AD\E6\96\87*))(objectClass=zimbraCalendarResource)(zimbraAccountStatus=active))(!(zimbraHideInGal=TRUE))(!(zimbraIsSystemResource=TRUE)))(&(zimbraCalResType=location)(zimbraCalResSite=*\E4\B8\AD\E6\96\87*)))"
         */
    SoapTransport transport = authUser("user1@phoebe.mbp");
    SearchCalendarResourcesRequest req = new SearchCalendarResourcesRequest("\u4e2d\u6587");
    EntrySearchFilterMultiCond conds = new EntrySearchFilterMultiCond();
    EntrySearchFilterSingleCond cond;
    cond = new EntrySearchFilterSingleCond();
    cond.setAttr(Provisioning.A_zimbraCalResType);
    cond.setOp("eq");
    cond.setValue("Location");
    conds.addCondition(cond);
    cond = new EntrySearchFilterSingleCond();
    cond.setAttr(Provisioning.A_zimbraCalResSite);
    cond.setOp("has");
    cond.setValue("\u4e2d\u6587");
    conds.addCondition(cond);
    EntrySearchFilterInfo filter = new EntrySearchFilterInfo();
    filter.setCondition(conds);
    req.setSearchFilter(filter);
    SearchCalendarResourcesResponse resp = invokeJaxb(transport, req);
    List<CalendarResourceInfo> crInfo = resp.getCalendarResources();
    assertEquals(1, crInfo.size());
    assertEquals(crName, crInfo.get(0).getName());
}
Also used : SearchCalendarResourcesResponse(com.zimbra.soap.account.message.SearchCalendarResourcesResponse) CalendarResourceInfo(com.zimbra.soap.account.type.CalendarResourceInfo) EntrySearchFilterMultiCond(com.zimbra.soap.account.type.EntrySearchFilterMultiCond) SearchCalendarResourcesRequest(com.zimbra.soap.account.message.SearchCalendarResourcesRequest) CalendarResource(com.zimbra.cs.account.CalendarResource) EntrySearchFilterInfo(com.zimbra.soap.account.type.EntrySearchFilterInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) EntrySearchFilterSingleCond(com.zimbra.soap.account.type.EntrySearchFilterSingleCond) Test(org.junit.Test)

Example 14 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class TestSearchCalendarResources method reservedChar.

@Test
@Bug(bug = 67045)
public void reservedChar() throws Exception {
    Map<String, Object> attrs = Maps.newHashMap();
    attrs.put(Provisioning.A_displayName, "name()");
    attrs.put(Provisioning.A_zimbraCalResType, Provisioning.CalResType.Location.name());
    attrs.put(Provisioning.A_zimbraCalResSite, "Site()");
    attrs.put(Provisioning.A_zimbraCalResCapacity, "10");
    attrs.put(Provisioning.A_zimbraCalResBuilding, "Building()");
    attrs.put(Provisioning.A_zimbraNotes, "Notes()");
    attrs.put(Provisioning.A_zimbraCalResFloor, "()");
    CalendarResource cr = provUtil.createCalendarResource("reservedChar", domain, attrs);
    String crName = cr.getName();
    /*
        <SearchCalendarResourcesRequest xmlns="urn:zimbraAccount" 
            attrs="fullName,email,zimbraCalResLocationDisplayName,zimbraCalResContactEmail,notes,zimbraCalResType">
            <name>()</name>
            <searchFilter>
                <conds>
                  <cond op="eq" value="Location" attr="zimbraCalResType"/>
                  <cond op="has" value="()" attr="zimbraCalResSite"/>
                  <cond op="ge" value="9" attr="zimbraCalResCapacity"/>
                  <cond op="has" value="()" attr="zimbraCalResBuilding"/>
                  <cond op="has" value="()" attr="zimbraNotes"/>
                  <cond op="eq" value="()" attr="zimbraCalResFloor"/>
                </conds>
            </searchFilter>
        </SearchCalendarResourcesRequest>
        
        Expected filer:
        filter="(&(&(&(|(displayName=*\28\29*)(cn=*\28\29*)(sn=*\28\29*)(givenName=*\28\29*)(mail=*\28\29*)(zimbraMailDeliveryAddress=*\28\29*)(zimbraMailAlias=*\28\29*))(objectClass=zimbraCalendarResource)(zimbraAccountStatus=active))(!(zimbraHideInGal=TRUE))(!(zimbraIsSystemResource=TRUE)))(&(zimbraCalResType=location)(zimbraCalResSite=*\28\29*)(zimbraCalResCapacity>=9)(zimbraCalResBuilding=*\28\29*)(zimbraNotes=*\28\29*)(zimbraCalResFloor=\28\29)))"
        */
    SoapTransport transport = authUser("user1@phoebe.mbp");
    SearchCalendarResourcesRequest req = new SearchCalendarResourcesRequest("()");
    EntrySearchFilterMultiCond conds = new EntrySearchFilterMultiCond();
    EntrySearchFilterSingleCond cond;
    cond = new EntrySearchFilterSingleCond();
    cond.setAttr(Provisioning.A_zimbraCalResType);
    cond.setOp("eq");
    cond.setValue("Location");
    conds.addCondition(cond);
    cond = new EntrySearchFilterSingleCond();
    cond.setAttr(Provisioning.A_zimbraCalResSite);
    cond.setOp("has");
    cond.setValue("()");
    conds.addCondition(cond);
    cond = new EntrySearchFilterSingleCond();
    cond.setAttr(Provisioning.A_zimbraCalResCapacity);
    cond.setOp("ge");
    cond.setValue("9");
    conds.addCondition(cond);
    cond = new EntrySearchFilterSingleCond();
    cond.setAttr(Provisioning.A_zimbraCalResBuilding);
    cond.setOp("has");
    cond.setValue("()");
    conds.addCondition(cond);
    cond = new EntrySearchFilterSingleCond();
    cond.setAttr(Provisioning.A_zimbraNotes);
    cond.setOp("has");
    cond.setValue("()");
    conds.addCondition(cond);
    cond = new EntrySearchFilterSingleCond();
    cond.setAttr(Provisioning.A_zimbraCalResFloor);
    cond.setOp("eq");
    cond.setValue("()");
    conds.addCondition(cond);
    EntrySearchFilterInfo filter = new EntrySearchFilterInfo();
    filter.setCondition(conds);
    req.setSearchFilter(filter);
    SearchCalendarResourcesResponse resp = invokeJaxb(transport, req);
    List<CalendarResourceInfo> crInfo = resp.getCalendarResources();
    assertEquals(1, crInfo.size());
    assertEquals(crName, crInfo.get(0).getName());
}
Also used : SearchCalendarResourcesResponse(com.zimbra.soap.account.message.SearchCalendarResourcesResponse) CalendarResourceInfo(com.zimbra.soap.account.type.CalendarResourceInfo) EntrySearchFilterMultiCond(com.zimbra.soap.account.type.EntrySearchFilterMultiCond) SearchCalendarResourcesRequest(com.zimbra.soap.account.message.SearchCalendarResourcesRequest) CalendarResource(com.zimbra.cs.account.CalendarResource) EntrySearchFilterInfo(com.zimbra.soap.account.type.EntrySearchFilterInfo) SoapTransport(com.zimbra.common.soap.SoapTransport) EntrySearchFilterSingleCond(com.zimbra.soap.account.type.EntrySearchFilterSingleCond) Test(org.junit.Test) Bug(com.zimbra.qa.QA.Bug)

Example 15 with CalendarResource

use of com.zimbra.cs.account.CalendarResource in project zm-mailbox by Zimbra.

the class TestSetPassword method delegatedAdminWithSetPasswordRight.

@Test
public void delegatedAdminWithSetPasswordRight() throws Exception {
    Account acct = createAcctAndSetPasswordpolicy();
    CalendarResource cr = createCRAndSetPasswordpolicy();
    Account adminAcct = provUtil.createDelegatedAdmin(genAcctNameLocalPart("admin"), domain);
    prov.grantRight(TargetType.account.getCode(), TargetBy.name, acct.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, adminAcct.getName(), null, Right.RT_setAccountPassword, null);
    prov.grantRight(TargetType.calresource.getCode(), TargetBy.name, cr.getName(), GranteeType.GT_USER.getCode(), GranteeBy.name, adminAcct.getName(), null, Right.RT_setCalendarResourcePassword, null);
    verifyOK(adminAcct, acct, true);
    verifyOK(adminAcct, acct, false);
    verifyOK(adminAcct, cr, true);
    verifyOK(adminAcct, cr, false);
    provUtil.deleteAccount(acct);
    provUtil.deleteAccount(cr);
    provUtil.deleteAccount(adminAcct);
}
Also used : Account(com.zimbra.cs.account.Account) CalendarResource(com.zimbra.cs.account.CalendarResource) Test(org.junit.Test)

Aggregations

CalendarResource (com.zimbra.cs.account.CalendarResource)40 Account (com.zimbra.cs.account.Account)23 Element (com.zimbra.common.soap.Element)12 Provisioning (com.zimbra.cs.account.Provisioning)11 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)11 Test (org.junit.Test)8 ProvTest (com.zimbra.qa.unittest.prov.ProvTest)7 NamedEntry (com.zimbra.cs.account.NamedEntry)6 ArrayList (java.util.ArrayList)6 ServiceException (com.zimbra.common.service.ServiceException)5 Server (com.zimbra.cs.account.Server)4 Mailbox (com.zimbra.cs.mailbox.Mailbox)4 Invite (com.zimbra.cs.mailbox.calendar.Invite)4 RecurId (com.zimbra.cs.mailbox.calendar.RecurId)4 ZAttendee (com.zimbra.cs.mailbox.calendar.ZAttendee)4 HashMap (java.util.HashMap)4 ICalTimeZone (com.zimbra.common.calendar.ICalTimeZone)3 ParsedDateTime (com.zimbra.common.calendar.ParsedDateTime)3 JavaMailInternetAddress (com.zimbra.common.mime.shim.JavaMailInternetAddress)3 SoapTransport (com.zimbra.common.soap.SoapTransport)3