org.soulwing.credo.service.group.CreateGroupServiceBean.java Source code

Java tutorial

Introduction

Here is the source code for org.soulwing.credo.service.group.CreateGroupServiceBean.java

Source

/*
 * File created on Apr 15, 2014 
 *
 * Copyright (c) 2014 Virginia Polytechnic Institute and State University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package org.soulwing.credo.service.group;

import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.inject.Inject;

import org.apache.commons.lang.Validate;
import org.soulwing.credo.service.Errors;
import org.soulwing.credo.service.GroupAccessException;
import org.soulwing.credo.service.MergeConflictException;
import org.soulwing.credo.service.PassphraseException;

/**
 * A {@link CreateGroupService} implemented as an EJB.
 *
 * @author Carl Harris
 */
@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class CreateGroupServiceBean implements CreateGroupService {

    @Inject
    protected GroupEditorFactory editorFactory;

    /**
     * {@inheritDoc}
     */
    @Override
    public GroupEditor newGroup() {
        return editorFactory.newEditor();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void saveGroup(GroupEditor editor, Errors errors) throws EditException, NoSuchGroupException,
            GroupAccessException, PassphraseException, MergeConflictException {
        Validate.isTrue(editor instanceof ConfigurableGroupEditor);
        ((ConfigurableGroupEditor) editor).save(errors);
    }

}