se.alingsas.alfresco.share.evaluator.documentlibrary.action.DocumentSecrecyIsSet.java Source code

Java tutorial

Introduction

Here is the source code for se.alingsas.alfresco.share.evaluator.documentlibrary.action.DocumentSecrecyIsSet.java

Source

/*
 * Copyright (C) 2012-2013 Alingss Kommun
 *
 * This file is part of Alfresco customizations made for Alingss Kommun
 *
 * The Alfresco customizations made for Alingss Kommun is free software: 
 * you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * The Alfresco customizations made for Alingss Kommun is distributed in the 
 * hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with the Alfresco customizations made for Alingss Kommun. 
 * If not, see <http://www.gnu.org/licenses/>.
 */

package se.alingsas.alfresco.share.evaluator.documentlibrary.action;

/**
 * @author Marcus Svensson - Redpill Linpro AB
 *
 */

import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.web.evaluator.BaseEvaluator;
import org.json.simple.JSONObject;
import org.springframework.util.StringUtils;

/**
 * Evaluator to determine if a document is completed or not
 * 
 * @author Marcus Svensson - Redpill Linpro AB
 * 
 */
public class DocumentSecrecyIsSet extends BaseEvaluator {

    private static final String DOC_SECRECY_PROPERTY = "akdm:documentSecrecy";

    /*
     * (non-Javadoc)
     * 
     * @see
     * org.alfresco.web.evaluator.BaseEvaluator#evaluate(org.json.simple.JSONObject
     * )
     */
    @Override
    public boolean evaluate(JSONObject jsonObject) {
        try {
            String property = (String) getProperty(jsonObject, DOC_SECRECY_PROPERTY);

            if (StringUtils.hasText(property)) {
                return true;
            }
            return false;
        } catch (Exception err) {
            throw new AlfrescoRuntimeException(
                    "JSONException whilst running action evaluator: " + err.getMessage());
        }
    }

}