john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

OxygenSpace

// 2012-10-30 johnpfeiffer

import java.util.List;
import com.oxygen.sdk.O2Agent;
import com.oxygen.sdk.O2Space;
import com.oxygen.sdk.exception.O2NetworkException;
import com.oxygen.sdk.exception.O2RuleException;
import com.oxygen.sdk.exception.O2UnexpectedException;

public class OxygenSpace
{
    public static final String CLASSVERSION = "0.18";
    O2Space space;

    OxygenSpace( O2Space newSpace )
    {
        space = newSpace;
    }

    // last name match initializes the object, otherwise null
    protected static O2Space getInstanceByName( O2Agent agent , String targetName ) throws O2NetworkException , O2UnexpectedException, O2RuleException
    {
        O2Space spaceConstructor = null;
        if( agent == null )
        {
            throw new IllegalArgumentException( "Oxygen agent cannot be null" );
        }
        if( targetName == null )
        {
            throw new IllegalArgumentException( "targetName cannot be null" );
        }
        if( targetName.isEmpty() )
        {
            throw new IllegalArgumentException( "targetName cannot be empty" );
        }

        List <O2Space> spaceList = null;
        spaceList = agent.listSpaces();
        for( O2Space currentSpace : spaceList )
        {
            if( targetName.equals( currentSpace.getName() ) )
            {
                spaceConstructor = currentSpace;
            }
        }
        return spaceConstructor;
    }

    protected static O2Space getInstanceById( O2Agent agent , String targetId ) throws O2NetworkException , O2UnexpectedException, O2RuleException
    {
        O2Space spaceConstructor = null;
        if( agent == null )
        {
            throw new IllegalArgumentException( "Oxygen agent cannot be null" );
        }
        if( targetId == null )
        {
            throw new IllegalArgumentException( "targetId cannot be null" );
        }
        List <O2Space> spaceList = null;
        spaceList = agent.listSpaces();
        for( O2Space currentSpace : spaceList )
        {
            if( targetId.equals( currentSpace.getID() ) )
            {
                spaceConstructor = currentSpace;
            }
        }
        return spaceConstructor;
    }

    protected String version()
    {
        return CLASSVERSION;
    }

    protected O2Space get()
    {
        return space;
    }

    protected String getName()
    {
        return space.getName();
    }

    protected String getId()
    {
        return space.getID();
    }

    protected String getOwner()
    {
        return space.getOwnerOxygenID();
    }

    protected boolean canWrite()
    {
        return space.canWrite();
    }

} // end class

  • « eclipse uml class diagram objectaid
  • OxygenUploadCLI »

Published

Oct 31, 2012

Category

java-oxygencloud

~185 words

Tags

  • java 252
  • oxygencloud 19
  • oxygenspace 1