简体   繁体   English

更新网站属性会使所有页面消失(Sakai 2.9.3)

[英]Updating site property make all pages vanish (Sakai 2.9.3)

I'm updating my a site property through a job. 我正在通过工作更新我的网站资产。 The job runs ok, it does the work right and updates the property I want it to update properly and never failed. 作业运行正常,它正确地工作并更新我希望它正确更新并永不失败的属性。

But, when I save the site, it mess my pages, making them vanish. 但是,当我保存网站时,它会弄乱我的网页,使它们消失。 Worst, it don't always happen @.@ what is driving me crazy! 最糟糕的是,它并不总是发生在@。@是什么让我发疯! =( =(

I'm sure the job is running right because once I get all pages back (through worksite setup and site editor) thing get working all. 我确信这项工作正在运行,因为一旦我获得所有页面(通过工地设置和网站编辑器),事情就会全部运转。 Here the method where I update the property (I have already tried both options of property edition ways: 这里是我更新属性的方法(我已经尝试了两种属性编辑方式的选项:

@Override
public void updateStringProperty(Site site, String name, String value) {
    try {
        // ResourcePropertiesEdit rpe = site.getPropertiesEdit();
        // rpe.addProperty(name, value);

        ResourceProperties rp = site.getProperties();
        rp.addProperty(name, value);

        siteService.save(site);
    } catch (IdUnusedException e) {
        e.printStackTrace();
    } catch (PermissionException e) {
        e.printStackTrace();
    }
}

It's written on the proxy layer, in which my application talks with Sakai interfaces to read/write data onto Sakai databse (You can see the instance of the site come from above) and it's how I get the list of sites to apply changes (also sakai proxy layer): 它写在代理层上,我的应用程序与Sakai接口进行对话,将数据读/写到Sakai数据库(你可以看到网站的实例来自上面),这就是我如何得到应用更改的网站列表(也是sakai代理层):

@Override
public List<Site> getReadInWebSites(Long course) {
    Map<String, String> m = new HashMap<String, String>();
    m.put(Property.COURSE.getName(), Long.toString(course));
    m.put(Property.COURSEFINISHED.getName(), Boolean.toString(false));

    return new ArrayList<Site>(siteService.getSites(SelectionType.ANY,
            null, null, m, SortType.CREATED_BY_ASC, null));
}

Thanks in advance! 提前致谢!

EDIT: New info, when I try to access the site (before rebuild its structure through worksite setup, I get this Warn in the log: 编辑:新信息,当我尝试访问该网站时(在通过工地设置重建其结构之前,我在日志中得到这个警告:

org.sakaiproject.portal.charon.site.DefaultSiteViewImpl - Failed to set canAddSite for current user. Defaulting to false ...

This is because when Sakai Sites are loaded with getSites they are lazy objects and don't have all their member variables loaded. 这是因为当Sakai Sites加载getSites它们是惰性对象,并且没有加载所有成员变量。 This is far from ideal and the SiteService should really either throw an exception when you do this or load the required data. 这远非理想,当您执行此操作或加载所需数据时,SiteService实际上应该抛出异常。

However to get it working when you're modifying a site fully load the site first before you make changes. 但是,要在修改站点时使其正常工作,请在进行更改之前先完全加载站点。

Site site = siteService.getSite(site.getId());
ResourceProperties rp = site.getProperties();
rp.addProperty(name, value);
siteService.save(site);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM