Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

Commit

Permalink
Removed com.stormpath.sdk.resource.Status Enum in favor of resource-s…
Browse files Browse the repository at this point in the history
…pecific Status Enum classes to help ensure backwards compatibility moving forward (Enums cannot be subclassed for resource-specific states which would prevent us from enabling any resource-specific customization in the future).
  • Loading branch information
lhazlewood committed Jul 15, 2013
1 parent 96f8858 commit 761ea56
Show file tree
Hide file tree
Showing 24 changed files with 120 additions and 165 deletions.
13 changes: 6 additions & 7 deletions api/src/main/java/com/stormpath/sdk/application/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.stormpath.sdk.resource.Resource;
import com.stormpath.sdk.resource.ResourceException;
import com.stormpath.sdk.resource.Saveable;
import com.stormpath.sdk.resource.Status;
import com.stormpath.sdk.tenant.Tenant;

import java.util.Map;
Expand Down Expand Up @@ -69,20 +68,20 @@ public interface Application extends Resource, Saveable, Deletable {
void setDescription(String description);

/**
* Returns the application's Status. Application users may login to an enabled application. They may not login
* Returns the application's status. Application users may login to an enabled application. They may not login
* to a disabled application.
*
* @return the application's Status.
* @return the application's status.
*/
Status getStatus();
ApplicationStatus getStatus();

/**
* Sets the application's Status. Application users may login to an enabled application. They may not login
* Sets the application's status. Application users may login to an enabled application. They may not login
* to a disabled application.
*
* @param status the application's Status.
* @param status the application's status.
*/
void setStatus(Status status);
void setStatus(ApplicationStatus status);

/**
* Returns a paginated list of all accounts that may login to the application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* constructed by using the {@link Applications} utility class, for example:
* <pre>
* Applications.where(Applications.name().containsIgnoreCase("CRM"))
* .and(Applications.status().eq(Status.ENABLED))
* .and(Applications.status().eq(ApplicationStatus.ENABLED))
* .orderByName()
* .expandAccounts(10, 10)
* .limitTo(10));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.stormpath.sdk.application;

/**
* @since 0.8
*/
public enum ApplicationStatus {

/**
* Accounts may login to enabled applications.
*/
ENABLED,

/**
* Accounts may not login to disabled applications.
*/
DISABLED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* Application-specific <a href="http://en.wikipedia.org/wiki/Fluent_interface">fluent DSL</a> queries. fpr example:
* <pre>
* <b>Applications.where(Applications.name()</b>.containsIgnoreCase("Foo")<b>)</b>
* .and(<b>Applications.status()</b>.eq(Status.ENABLED))
* .and(<b>Applications.status()</b>.eq(ApplicationStatus.ENABLED))
* .orderByName().descending()
* .expandAccounts(10, 10)
* .offsetBy(50)
Expand All @@ -41,7 +41,7 @@
* ...
*
* <b>where(name()</b>.containsIgnoreCase("Foo")<b>)</b>
* .and(<b>status()</b>.eq(Status.ENABLED))
* .and(<b>status()</b>.eq(ApplicationStatus.ENABLED))
* .orderByName().descending()
* .expandAccounts(10, 10)
* .offsetBy(50)
Expand Down Expand Up @@ -150,15 +150,15 @@ public static StringExpressionFactory description() {
* Creates a new {@link EqualsExpressionFactory} instance reflecting the Application {@link Application#getStatus() status}
* property, to be used to construct a status Criterion when building an {@link ApplicationCriteria} query. For example:
* <pre>
* Applications.where(<b>Applications.status()</b>.eq(Status.ENABLED);
* Applications.where(<b>Applications.status()</b>.eq(ApplicationStatus.ENABLED);
* </pre>
* The above example invokes the returned factory's <code>eq()</code> method. This
* produces a status-specific {@link Criterion} which is added to the criteria query (via the
* {@link #where(com.stormpath.sdk.query.Criterion) where} method). For example, the following code is equivalent:
* <pre>
* ApplicationCriteria criteria = Applications.criteria();
* StringExpressionFactory statusExpressionFactory = Applications.status();
* Criterion statusEqualsEnabled = statusExpressionFactory.eq(Status.ENABLED);
* Criterion statusEqualsEnabled = statusExpressionFactory.eq(ApplicationStatus.ENABLED);
* criteria.add(statusEqualsEnabled);
* </pre>
* The first code example is clearly more succinct and readable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* Directory-specific <a href="http://en.wikipedia.org/wiki/Fluent_interface">fluent DSL</a> queries. fpr example:
* <pre>
* <b>Directories.where(Directories.name()</b>.containsIgnoreCase("Foo")<b>)</b>
* .and(<b>Directories.status()</b>.eq(Status.ENABLED))
* .and(<b>Directories.status()</b>.eq(DirectoryStatus.ENABLED))
* .orderByName().descending()
* .expandAccounts(10, 10)
* .offsetBy(50)
Expand All @@ -39,7 +39,7 @@
* ...
*
* <b>where(name()</b>.containsIgnoreCase("Foo")<b>)</b>
* .and(<b>status()</b>.eq(Status.ENABLED))
* .and(<b>status()</b>.eq(DirectoryStatus.ENABLED))
* .orderByName().descending()
* .expandAccounts(10, 10)
* .offsetBy(50)
Expand Down Expand Up @@ -144,15 +144,15 @@ public static StringExpressionFactory description() {
* Creates a new {@link EqualsExpressionFactory} instance reflecting the Directory {@link Directory#getStatus() status}
* property, to be used to construct a status Criterion when building an {@link DirectoryCriteria} query. For example:
* <pre>
* Directories.where(<b>Directories.status()</b>.eq(Status.ENABLED);
* Directories.where(<b>Directories.status()</b>.eq(DirectoryStatus.ENABLED);
* </pre>
* The above example invokes the returned factory's <code>eq()</code> method. This
* produces a status-specific {@link Criterion} which is added to the criteria query (via the
* {@link #where(com.stormpath.sdk.query.Criterion) where} method). For example, the following code is equivalent:
* <pre>
* DirectoryCriteria criteria = Directories.criteria();
* StringExpressionFactory statusExpressionFactory = Directories.status();
* Criterion statusEqualsEnabled = statusExpressionFactory.eq(Status.ENABLED);
* Criterion statusEqualsEnabled = statusExpressionFactory.eq(DirectoryStatus.ENABLED);
* criteria.add(statusEqualsEnabled);
* </pre>
* The first code example is clearly more succinct and readable.
Expand Down
17 changes: 8 additions & 9 deletions api/src/main/java/com/stormpath/sdk/directory/Directory.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.stormpath.sdk.resource.Deletable;
import com.stormpath.sdk.resource.Resource;
import com.stormpath.sdk.resource.Saveable;
import com.stormpath.sdk.resource.Status;
import com.stormpath.sdk.tenant.Tenant;

import java.util.Map;
Expand Down Expand Up @@ -74,24 +73,24 @@ public interface Directory extends Resource, Saveable, Deletable {
/**
* Returns the directory's status.
* <p/>
* An {@link Status#ENABLED} directory may be used by applications to login accounts
* found within the directory. A {@link Status#DISABLED} directory prevents its accounts from being used to login
* to applications.
* An {@link DirectoryStatus#ENABLED enabled} directory may be used by applications to login accounts found within
* the directory. A {@link DirectoryStatus#DISABLED disabled} directory prevents its accounts from being used to
* login to applications.
*
* @return the directory's status.
*/
Status getStatus();
DirectoryStatus getStatus();

/**
* Sets the directory's status.
* <p/>
* An {@link Status#ENABLED} directory may be used by applications to login accounts
* found within the directory. A {@link Status#DISABLED} directory prevents its accounts from being used to login
* to applications.
* An {@link DirectoryStatus#ENABLED enabled} directory may be used by applications to login accounts found within
* the directory. A {@link DirectoryStatus#DISABLED disabled} directory prevents its accounts from being used to
* login to applications.
*
* @param status the status to apply.
*/
void setStatus(Status status);
void setStatus(DirectoryStatus status);

/**
* Creates a new account instance in the directory using the Directory's default registration workflow setting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* constructed by using the {@link Directories} utility class, for example:
* <pre>
* Directories.where(Directories.name().containsIgnoreCase("CRM"))
* .and(Directories.status().eq(Status.ENABLED))
* .and(Directories.status().eq(DirectoryStatus.ENABLED))
* .orderByName()
* .expandAccounts(10, 10)
* .limitTo(10));
Expand Down
17 changes: 17 additions & 0 deletions api/src/main/java/com/stormpath/sdk/directory/DirectoryStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.stormpath.sdk.directory;

/**
* @since 0.8
*/
public enum DirectoryStatus {

/**
* Accounts in enabled Directories may login to applications.
*/
ENABLED,

/**
* Accounts in disabled Directories may not login to applications.
*/
DISABLED,
}
5 changes: 2 additions & 3 deletions api/src/main/java/com/stormpath/sdk/group/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.stormpath.sdk.resource.Deletable;
import com.stormpath.sdk.resource.Resource;
import com.stormpath.sdk.resource.Saveable;
import com.stormpath.sdk.resource.Status;
import com.stormpath.sdk.tenant.Tenant;

import java.util.Map;
Expand Down Expand Up @@ -72,7 +71,7 @@ public interface Group extends Resource, Saveable, Deletable, Iterable<Account>
*
* @return the Group's status
*/
Status getStatus();
GroupStatus getStatus();

/**
* Sets the Group's status. If a group is mapped to an Application as an Account Store (for login purposes),
Expand All @@ -81,7 +80,7 @@ public interface Group extends Resource, Saveable, Deletable, Iterable<Account>
*
* @param status the Group's status.
*/
void setStatus(Status status);
void setStatus(GroupStatus status);

/**
* Returns the Stormpath Tenant that owns this Group resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* constructed by using the {@link Groups} utility class, for example:
* <pre>
* Groups.where(Groups.name().containsIgnoreCase("admin"))
* .and(Groups.status().eq(Status.ENABLED))
* .and(Groups.status().eq(GroupStatus.ENABLED))
* .orderByName()
* .expandAccounts(10, 10)
* .limitTo(10));
Expand Down
18 changes: 18 additions & 0 deletions api/src/main/java/com/stormpath/sdk/group/GroupStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.stormpath.sdk.group;

/**
* @since 0.8
*/
public enum GroupStatus {

/**
* Accounts in enabled Groups mapped to applications may login to those applications.
*/
ENABLED,

/**
* Accounts in disabled Groups mapped to applications may not login to those applications.
*/
DISABLED,

}
8 changes: 4 additions & 4 deletions api/src/main/java/com/stormpath/sdk/group/Groups.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* Group-specific <a href="http://en.wikipedia.org/wiki/Fluent_interface">fluent DSL</a> queries. fpr example:
* <pre>
* <b>Groups.where(Groups.name()</b>.containsIgnoreCase("Foo")<b>)</b>
* .and(<b>Groups.status()</b>.eq(Status.ENABLED))
* .and(<b>Groups.status()</b>.eq(GroupStatus.ENABLED))
* .orderByName().descending()
* .expandAccounts(10, 10)
* .offsetBy(50)
Expand All @@ -39,7 +39,7 @@
* ...
*
* <b>where(name()</b>.containsIgnoreCase("Foo")<b>)</b>
* .and(<b>status()</b>.eq(Status.ENABLED))
* .and(<b>status()</b>.eq(GroupStatus.ENABLED))
* .orderByName().descending()
* .expandAccounts(10, 10)
* .offsetBy(50)
Expand Down Expand Up @@ -148,15 +148,15 @@ public static StringExpressionFactory description() {
* Creates a new {@link EqualsExpressionFactory} instance reflecting the Group {@link Group#getStatus() status}
* property, to be used to construct a status Criterion when building an {@link GroupCriteria} query. For example:
* <pre>
* Groups.where(<b>Groups.status()</b>.eq(Status.ENABLED);
* Groups.where(<b>Groups.status()</b>.eq(GroupStatus.ENABLED);
* </pre>
* The above example invokes the returned factory's <code>eq()</code> method. This
* produces a status-specific {@link Criterion} which is added to the criteria query (via the
* {@link #where(com.stormpath.sdk.query.Criterion) where} method). For example, the following code is equivalent:
* <pre>
* GroupCriteria criteria = Groups.criteria();
* StringExpressionFactory statusExpressionFactory = Groups.status();
* Criterion statusEqualsEnabled = statusExpressionFactory.eq(Status.ENABLED);
* Criterion statusEqualsEnabled = statusExpressionFactory.eq(GroupStatus.ENABLED);
* criteria.add(statusEqualsEnabled);
* </pre>
* The first code example is clearly more succinct and readable.
Expand Down
26 changes: 0 additions & 26 deletions api/src/main/java/com/stormpath/sdk/resource/Status.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,79 +23,7 @@ import org.testng.annotations.Test
*/
class DefaultCriteriaTest {


@Test
void test() {

/*
criteria
.property("username").iContains("foo")
.givenName().iEquals("blah")
.status().equals(Status.ENABLED);
.expandDirectories(10, 20)
.limit(10)
.offset(50)
criteria
.property("username").containsIgnoreCase("foo")
.givenName().equalsIgnoreCase("blah")
.expandDirectories(10, 20)
.limit(10)
.offset(50)
criteria
.eqIgnoreCase(Application.USERNAME, "foo")
.startsWithIgnoreCase(Application.DESCRIPTION, "blah")
.expand("directories", 10, 20)
.expand("tenant")
criteria
.add(Application.USERNAME.iContains("foo"))
.add(Application.DESCRIPTION.iStartsWith("Hello"))
.add(Application.STATUS.equals(Status.DISABLED))
.expandDirectories(25)
.offset(10)
.limit(50)
criteria
.add(DefaultApplicationCriteria.USERNAME.iContains("foo"))
.add(DefaultApplicationCriteria.DESCRIPTION.iStartsWith("Hello"))
.add(DefaultApplicationCriteria.STATUS.equals(Status.DISABLED))
.expandDirectories(25)
.offset(10)
.limit(50)
criteria
.add(USERNAME.iContains("foo"))
.add(DESCRIPTION.iStartsWith("Hello"))
.add(STATUS.equals(Status.DISABLED))
.expandDirectories(25)
.offset(10)
.limit(50)
c.add(c.username().iContains("foo"))
.add(c.description().iStartsWith("Hello"))
.add(c.status().equals(Status.DISABLED))
.expandDirectories(25)
.offset(10)
.limit(50)
Applications.criteria()
.add(Applications.NAME.ieq("foo"))
.name().ieq("foo")
.
.name().equals
*/





}


}
Loading

0 comments on commit 761ea56

Please sign in to comment.