All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.bonita.facade.impl.AbstractRemoteWebAPIImpl Maven / Gradle / Ivy

/**
 * Copyright (C) 2010-2012 BonitaSoft S.A.
 * BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
 * This library 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
 * version 2.1 of the License.
 * This library 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 this
 * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA  02110-1301, USA.
 **/
package org.ow2.bonita.facade.impl;

import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.ow2.bonita.facade.APIAccessor;
import org.ow2.bonita.facade.WebAPI;
import org.ow2.bonita.facade.exception.CategoryAlreadyExistsException;
import org.ow2.bonita.facade.exception.CategoryNotFoundException;
import org.ow2.bonita.facade.exception.DocumentAlreadyExistsException;
import org.ow2.bonita.facade.exception.DocumentationCreationException;
import org.ow2.bonita.facade.exception.ProcessNotFoundException;
import org.ow2.bonita.facade.internal.AbstractRemoteWebAPI;
import org.ow2.bonita.facade.runtime.ActivityInstance;
import org.ow2.bonita.facade.runtime.Category;
import org.ow2.bonita.facade.runtime.Document;
import org.ow2.bonita.facade.runtime.Label;
import org.ow2.bonita.facade.uuid.CategoryUUID;
import org.ow2.bonita.facade.uuid.ProcessDefinitionUUID;
import org.ow2.bonita.facade.uuid.ProcessInstanceUUID;
import org.ow2.bonita.identity.auth.DomainOwner;
import org.ow2.bonita.identity.auth.PasswordOwner;
import org.ow2.bonita.identity.auth.RESTUserOwner;
import org.ow2.bonita.identity.auth.UserOwner;
import org.ow2.bonita.light.LightProcessDefinition;
import org.ow2.bonita.light.LightProcessInstance;

/**
 * 
 * @author Elias Ricken de Medeiros, Matthieu Chaffotte
 * 
 */
public class AbstractRemoteWebAPIImpl implements AbstractRemoteWebAPI {

  protected Map apis = new HashMap();

  protected WebAPI getAPI(final Map options) {
    if (options == null) {
      throw new IllegalArgumentException("The options are null or not well set.");
    }
    final String queryList = options.get(APIAccessor.QUERYLIST_OPTION);
    final String user = options.get(APIAccessor.USER_OPTION);
    final String domain = options.get(APIAccessor.DOMAIN_OPTION);
    UserOwner.setUser(user);
    DomainOwner.setDomain(domain);

    final String restUser = options.get(APIAccessor.REST_USER_OPTION);
    if (restUser != null) {
      RESTUserOwner.setUser(restUser);
      final String restPswd = options.get(APIAccessor.PASSWORD_HASH_OPTION);
      PasswordOwner.setPassword(restPswd);
    }

    if (!apis.containsKey(queryList)) {
      apis.put(queryList, new StandardAPIAccessorImpl().getWebAPI(queryList));
    }
    return apis.get(queryList);
  }

  @Override
  public void deletePhantomCases(final Map options) throws RemoteException {
    getAPI(options).deletePhantomCases();
  }

  @Override
  public void addCasesToLabel(final String ownerName, final String labelName, final Set caseList,
      final Map options) throws RemoteException {
    getAPI(options).addCasesToLabel(ownerName, labelName, caseList);
  }

  @Override
  public void addLabel(final String labelName, final String ownerName, final String editableCSSStyleName,
      final String readonlyCSSStyleName, final String previewCSSStyleName, final boolean isVisible,
      final boolean hasToBeDisplayed, final String iconCSSStyle, final Set caseList,
      final int displayOrder, final boolean isSystemLabel, final Map options) throws RemoteException {
    getAPI(options).addLabel(labelName, ownerName, editableCSSStyleName, readonlyCSSStyleName, previewCSSStyleName,
        isVisible, hasToBeDisplayed, iconCSSStyle, caseList, displayOrder, isSystemLabel);
  }

  @Override
  public Label getLabel(final String ownerName, final String labelName, final Map options)
      throws RemoteException {
    return getAPI(options).getLabel(ownerName, labelName);
  }

  @Override
  public Set




© 2015 - 2025 Weber Informatics LLC | Privacy Policy