Package org.structr.schema.action

Source Code of org.structr.schema.action.Actions

/**
* Copyright (C) 2010-2014 Morgner UG (haftungsbeschränkt)
*
* This file is part of Structr <http://structr.org>.
*
* Structr is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Structr 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Structr.  If not, see <http://www.gnu.org/licenses/>.
*/
package org.structr.schema.action;

import org.structr.common.SecurityContext;
import org.structr.common.error.FrameworkException;
import org.structr.core.GraphObject;

/**
*
* @author Christian Morgner
*/
public class Actions {

  public enum Type {

    Create("onCreation","SecurityContext securityContext, ErrorBuffer errorBuffer", "securityContext, errorBuffer"),
    Save("onModification", "SecurityContext securityContext, ErrorBuffer errorBuffer", "securityContext, errorBuffer"),
    Delete("onDeletion", "SecurityContext securityContext, ErrorBuffer errorBuffer, PropertyMap properties", "securityContext, errorBuffer, properties"),
    Custom("", "", "");

    Type(final String method, final String signature, final String parameters) {
      this.method = method;
      this.signature = signature;
      this.parameters = parameters;
    }

    private String method = null;
    private String signature = null;
    private String parameters = null;

    public String getMethod() {
      return method;
    }

    public String getSignature() {
      return signature;
    }

    public String getParameters() {
      return parameters;
    }
  }

  // ----- public static methods -----
  public static boolean execute(final SecurityContext securityContext, final GraphObject entity, final String source) throws FrameworkException {

    final ActionContext context = new ActionContext();

    // ignore result for now
    entity.replaceVariables(securityContext, context, source);

    // check for errors raised by scripting
    if (context.hasError()) {
      throw new FrameworkException(422, context.getErrorBuffer());
    }

    // false means SUCCESS!
    return false;
  }
}
TOP

Related Classes of org.structr.schema.action.Actions

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.