Search in sources :

Example 1 with FolderPermissions

use of org.jbei.ice.lib.folder.FolderPermissions in project ice by JBEI.

the class Manuscripts method update.

public Manuscript update(long id, Manuscript manuscript) {
    ManuscriptModel model = dao.get(id);
    if (model == null)
        return null;
    if (!StringUtils.isEmpty(manuscript.getTitle()))
        model.setTitle(manuscript.getTitle());
    if (!StringUtils.isEmpty(manuscript.getAuthorFirstName()))
        model.setAuthorFirstName(manuscript.getAuthorFirstName());
    if (!StringUtils.isEmpty(manuscript.getAuthorLastName()))
        model.setAuthorLastName(manuscript.getAuthorLastName());
    if (!StringUtils.isEmpty(manuscript.getParagonUrl()))
        model.setParagonUrl(manuscript.getParagonUrl());
    if (manuscript.getStatus() != null && manuscript.getStatus() != model.getStatus()) {
        // update status
        model.setStatus(manuscript.getStatus());
        FolderPermissions folderPermissions = new FolderPermissions(this.userId, model.getFolder().getId());
        if (model.getStatus() == ManuscriptStatus.ACCEPTED) {
            // make public
            setFolderType(model.getFolder(), FolderType.PUBLIC);
            folderPermissions.enablePublicReadAccess();
        } else {
            // remove public
            setFolderType(model.getFolder(), FolderType.PRIVATE);
            folderPermissions.disablePublicReadAccess();
        }
    }
    return dao.update(model).toDataTransferObject();
}
Also used : ManuscriptModel(org.jbei.ice.storage.model.ManuscriptModel) FolderPermissions(org.jbei.ice.lib.folder.FolderPermissions)

Aggregations

FolderPermissions (org.jbei.ice.lib.folder.FolderPermissions)1 ManuscriptModel (org.jbei.ice.storage.model.ManuscriptModel)1