IBM Domino - 在 Java XPage 中获取资源可用性规则

IBM Domino - get resource availability rules in Java XPage

我需要检查房间的可用性选项是否当前在 java xpage rest api 中可用。在设置自定义可用性选项后,我尝试查看资源预订数据库,但没有获得太多信息。 如何以编程方式检查可用性规则?我知道有空闲时间这样的东西 api,但它不是很有用,我不想使用其他服务。

我在数据库中找到了我房间的文件,它看起来像这样:

{
    "@href":"\/RoomRese.nsf\/api\/data\/documents\/unid\/D6D558B1387CEA11C125842D002605C0",
    "@unid":"D6D558B1387CEA11C125842D002605C0",
    "@noteid":"902",
    "@created":"2019-07-04T06:55:18Z",
    "@modified":"2019-07-17T13:41:45Z",
    "@authors":"CN=Test User\/O=Server",
    "@form":"Resource",
    "actiontype":"SAVE",
    "ResourceType":"1",
    "Site":"Site",
    "ConferenceDatabase":"stconf.nsf",
    "InternetAddress":"room1@test.test",
    "Sunday":"1",
    "Monday":"2",
    "Tuesday":"3",
    "Wednesday":"4",
    "Thursday":"5",
    "Friday":"6",
    "Saturday":"7",
    "TimeZone":"Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=27$ZN=Central European",
    "SundayAvailable":"1",
    "MondayAvailable":"2",
    "TuesdayAvailable":"3",
    "ThursdayAvailable":"5",
    "FridayAvailable":"6",
    "SaturdayAvailable":"7",
    "LimitHow":"1",
    "LimitDays":90,
    "LimitDate":"2019-10-02",
    "OtherComments":
    {
        "type":"multipart",
        "content":        [
                    {
            "contentType":"text\/html; charset=US-ASCII",
            "contentDisposition":"inline",
            "data":"<html><body><\/body><\/html>\r\n\r\n"
          }
        ]
    },
    "Type":"Resource",
    "Author":"CN=Test User\/O=Site",
    "CommonNameResourceName":"Room 1",
    "ResourceName":"CN=Room 1\/O=Site",
    "Capacity":44,
    "AlwaysAvailable":0,
    "AutoProcessType":"0",
    "Owner":"CN=Room 1\/O=Site"
}

我可以看到这些 'MondayAvailabile' 等,但只有简单的数字,我不知道它们是什么意思。 我怎样才能在 java 中做到这一点?

我试过使用 session.freeTimeSearch() 但它不起作用,至少在服务器端不起作用。这是我的代码:

        Session = resourceDB.getParent();
        DateRange = session.createDateRange();
        range.setStartDateTime(tStart);
        range.setEndDateTime(tEnd);

        int duration = tEnd.timeDifference(tStart);
        System.out.println("Range: " + range.getStartDateTime().toString() + " <-> " + range.getEndDateTime().toString());
        System.out.println("Duration calculated: " + duration);

        try {
            Vector<?> frs = session.freeTimeSearch(range, duration/2, "Room 1/Test Site",true);

            if(frs == null || frs.size() <= 0) {
                System.out.println("NO FREETIME !!!! " + tStart.toString() + " -> " + tEnd.toString());
                return true;
            } else {
                for(int i = 0; i < frs.size(); i++) {
                    DateRange dr = (DateRange)frs.elementAt(i);
                    System.out.println("Found " + dr.getStartDateTime().toString() + " <-> " + dr.getEndDateTime().toString());

                }
            }
        } catch (NotesException ex) {
            System.out.println("ERROR: "+ ex.getMessage());
        }

输出是这样的:

Range: 07/18/2019 03:00:00 PM CEDT <-> 07/18/2019 03:30:00 PM CEDT
Duration calculated: 1800
NO FREETIME !!!! 07/18/2019 03:00:00 PM CEDT -> 07/18/2019 03:30:00 PM CEDT

我做了 duration/2 因为我认为 daterange 的完整持续时间可能不起作用,但它是一样的。

更新!!愚蠢的我,它有效! duration 参数应该以分钟为单位,而从 timeDifference 返回的持续时间以秒为单位,因此简单地除以 60 就可以解决所有问题!

有一个JavaAPI查询空闲时间。看看Session.freeTimeSearch().