// 2012-10-19 johnpfeiffer
// TODO: builder pattern
// TODO: unit tests
import java.sql.Timestamp;
import java.util.Comparator;
public class NetworkAccount
{
public static final String CLASSVERSION = "0.6";
private String oid;
private String accountId;
private String name;
private String loginUrl;
private String logoutUrl;
private Timestamp createDatetime;
private short disabled;
private short deleted;
private short internalAuthenticationEnabled;
private short externalAuthenticationEnabled;
private String repositoryManagerServiceId;
NetworkAccount( String oid , String accountId , String name , String loginUrl , String logoutUrl , Timestamp createDatetime , short disabled , short deleted ,
short internalAuthenticationEnabled , short externalAuthenticationEnabled , String repositoryManagerServiceId )
{
if( oid != null && accountId != null && name != null && createDatetime != null ) // loginUrl, logoutURL, RepositoryService can be Null
{
if( disabled != -1 && deleted != -1 && internalAuthenticationEnabled != -1 && externalAuthenticationEnabled != -1 )
{
this.oid = oid;
this.accountId = accountId;
this.name = name;
this.loginUrl = loginUrl;
this.logoutUrl = logoutUrl;
this.createDatetime = createDatetime;
this.disabled = disabled;
this.deleted = deleted;
this.internalAuthenticationEnabled = internalAuthenticationEnabled;
this.externalAuthenticationEnabled = externalAuthenticationEnabled;
this.repositoryManagerServiceId = repositoryManagerServiceId;
}else
{
throw new IllegalArgumentException( "ERROR: disabled, deleted, or internal/externalAuthenticationEnabled have not been initialized (-1)" );
}
}else
{
throw new IllegalArgumentException( "ERROR: oid, accountId , name , or createDatetime is null" );
}
}
protected String getVersion()
{
return CLASSVERSION;
}
protected String getOid()
{
return oid;
}
protected String getAccountId()
{
return accountId;
}
protected String getName()
{
return name;
}
protected String loginUrl()
{
return loginUrl;
}
protected String logoutUrl()
{
return logoutUrl;
}
protected Timestamp getCreateDatetime()
{
return createDatetime;
}
protected boolean isDisabled()
{
boolean result = false;
if( disabled != 0 )
{
result = true;
}
return result;
}
protected boolean isDeleted()
{
boolean result = false;
if( deleted != 0 )
{
result = true;
}
return result;
}
protected boolean isInternalAuthenticationEnabled()
{
boolean result = false;
if( internalAuthenticationEnabled != 0 )
{
result = true;
}
return result;
}
protected boolean isExternalAuthenticationEnabled()
{
boolean result = false;
if( externalAuthenticationEnabled != 0 )
{
result = true;
}
return result;
}
protected String getRepositoryManagerServiceId()
{
return repositoryManagerServiceId;
}
// inner class?
protected static Comparator <NetworkAccount> COMPARE_BY_NAME = new Comparator <NetworkAccount>()
{
public int compare( NetworkAccount first , NetworkAccount other )
{
return first.name.compareTo( other.name );
}
};
protected static Comparator <NetworkAccount> COMPARE_BY_CREATEDATETIME = new Comparator <NetworkAccount>()
{
public int compare( NetworkAccount first , NetworkAccount other )
{
return first.getCreateDatetime().compareTo( other.getCreateDatetime() );
}
};
} // end class