Skip to content

Commit

Permalink
merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hamblen committed Aug 7, 2009
2 parents 2832c46 + 20d1a3a commit a98b8be
Show file tree
Hide file tree
Showing 19 changed files with 190 additions and 101 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
.project
.settings
target
lib_managed/
2 changes: 2 additions & 0 deletions README.txt
Expand Up @@ -6,6 +6,8 @@ http://databinder.net/

Version History

1.2.1 Updates Databinder to the latest Wicket and Hibernate versions.

1.2 This release represents a significant refactor of the Databinder toolkit to allow it to work with any underlying persistence technology. Core functionality now resides in modules like databinder-models, while specific functionality is in databinder-models-hib for Hibernate, or databinder-models-ao for ActiveObjects. The "databinder" dependency that was used through 1.1 is now databinder-app and databinder-app-hib for Hibernate applications.

Migration to the new codebase is fairly straightforward. The first step is to refer to the appropriate new Maven artifact name, databinder-app-hib for most applications. Then update dependencies for your IDE, as there are number of class and page renames to work through. Some changes were made to accomodate the new persistence-agnostic structure, others are there just to bundle desired, breaking changes in one release. There aren't any major significant conceptual changes. The renames are as follows:
Expand Down
Expand Up @@ -110,7 +110,7 @@ public boolean signIn(String username, String password) {
* @return true if signed in, false if credentials incorrect
*/
public boolean signIn(final String username, final String password, boolean setCookie) {
signOut();
clearUser();
T potential = getUser(username);
if (potential != null && (potential).getPassword().matches(password))
signIn(potential, setCookie);
Expand Down Expand Up @@ -219,12 +219,18 @@ protected void detach() {
userModel.detach();
}

/** Nullifies userModel and clears authentication cookies. */
public void signOut() {
/** Nullifies userModela nd clears authentication cookies. */
protected void clearUser() {
userModel = null;
CookieRequestCycle requestCycle = (CookieRequestCycle) RequestCycle.get();
requestCycle.clearCookie(getUserCookieName());
requestCycle.clearCookie(getAuthCookieName());
}

/** Signs out and invalidates session. */
public void signOut() {
clearUser();
getSessionStore().invalidate(RequestCycle.get().getRequest());
}

}
Expand Up @@ -14,6 +14,7 @@
import org.apache.wicket.authorization.strategies.role.Roles;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;

/**
* User administration page. Lists all users, allows editing usernames, passwords, and roles.
Expand Down Expand Up @@ -56,15 +57,15 @@ protected void onSubmit() {
@SuppressWarnings("unchecked")
@Override
protected void setPassword(String password) {
if (form.getEntityModel().isBound())
if (getUserForm().getEntityModel().isBound())
super.setPassword(password);
else
((Map)form.getModelObject()).put("passwordHash", UserHelper.getHash(password));
((Map)getUserForm().getModelObject()).put("passwordHash", UserHelper.getHash(password));
}

@Override
protected Button deleteButton(String id) {
return form.new DeleteButton(id);
return getUserForm().new DeleteButton(id);
}

@Override
Expand Down
Expand Up @@ -40,13 +40,13 @@ protected Button deleteButton(String id) {
return new Button("delete") {
@Override
public void onSubmit() {
Databinder.getHibernateSession().delete(form.getModelObject());
Databinder.getHibernateSession().delete(getUserForm().getModelObject());
Databinder.getHibernateSession().getTransaction().commit();
form.clearPersistentObject();
}
@Override
public boolean isEnabled() {
return !((AuthSession)getSession()).getUser().equals(form.getModelObject())
return !((AuthSession)getSession()).getUser().equals(getUserForm().getModelObject())
&& getBindingModel().isBound();
}
}.setDefaultFormProcessing(false);
Expand Down
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.zip.DataFormatException;

import net.databinder.auth.AuthApplication;
import net.databinder.auth.AuthSession;
Expand Down Expand Up @@ -48,6 +49,10 @@
@AuthorizeInstantiation(Roles.ADMIN)
public abstract class UserAdminPageBase<T extends DataUser> extends WebPage {
protected Form<T> form;
protected Form<T> getUserForm() {
return form;
}

public UserAdminPageBase() {
add(new DataStyleLink("css"));
add(new Label("title", new ResourceModel("data.auth.user_admin", "User Administration")));
Expand Down
Expand Up @@ -15,11 +15,11 @@ import net.sf.ehcache.CacheManager
import net.sf.ehcache.Ehcache
import net.sf.ehcache.Element

import net.databinder.dispatch.HttpServer
import net.databinder.dispatch.Http

abstract class HttpPostConverter extends AbstractConverter[String] {

def service = new HttpServer("localhost", 8180)
def service = new Http("localhost", 8180)
def path_name: String

def convertToObject(value: String, locale: Locale): String = null
Expand All @@ -28,7 +28,7 @@ abstract class HttpPostConverter extends AbstractConverter[String] {

override def convertToString(source: Object, locale: Locale) = try {
HttpPostConverter.cache(path_name, source.hashCode()) {
(service("/" + path_name) << "input" -> source).as_str
(service("/" + path_name) << Map("input" -> source)).as_str
}
} catch {
case e =>
Expand Down
9 changes: 0 additions & 9 deletions databinder-dispatch/Rakefile

This file was deleted.

4 changes: 4 additions & 0 deletions databinder-dispatch/project/build.properties
@@ -0,0 +1,4 @@
#Project properties
#Sat Feb 21 09:31:49 EST 2009
project.name=databinder-dispatch
project.version=1.2.2-SNAPSHOT
6 changes: 6 additions & 0 deletions databinder-dispatch/project/build/src/Dispatch.scala
@@ -0,0 +1,6 @@
import sbt._

class Dispatch(info: ProjectInfo) extends DefaultProject(info)
{
val httpclient = "org.apache.httpcomponents" % "httpclient" % "4.0-beta2"
}
6 changes: 2 additions & 4 deletions databinder-dispatch/scratch.scala
Expand Up @@ -48,7 +48,5 @@ implicit def any2anyExtras(x: Any) = new AnyExtras(x)

import net.databinder.dispatch._

val svc = Http.host("services.newsgator.com").on_x(_.addHeader("X-NGAPIToken", token)).auth(user, pass)
svc("/ngws/svc/Location.aspx") >>> System.out


val friday = new Database("friday")
friday.all_docs
@@ -1,6 +1,8 @@
package net.databinder.dispatch
package net.databinder.dispatch.couch

import java.io.InputStream
import java.net.URLEncoder.encode
import org.apache.http.HttpHost

trait Doc extends Schema {
val _id = String(Symbol("_id"))
Expand All @@ -9,6 +11,33 @@ trait Doc extends Schema {

object Doc extends Doc

object Couch {
def apply(host: String) = new Http(host, 5984)
def apply(): Http = Couch("127.0.0.1")
}


case class Database(name: String) {
class H(val http: Http) extends Database(name) {
def apply(id: String): Http#Request = http("/" + name + "/" + encode(id))
def all_docs = {
val Some(rows) = (this("_all_docs") >> { new Store(_) })(Listing.rows)
for {
Some(row) <- rows
id <- (new Store(row))(ListItem.id)
} yield id
}
}
def apply(http: Http) = new H(http)

object ListItem extends Schema {
val id = String('id)
}
object Listing extends Schema {
val rows = List[Map[Symbol, Option[Any]]]('rows)
}
}

object Revise extends Schema {
val id = String('id)
val rev = String('rev)
Expand Down

0 comments on commit a98b8be

Please sign in to comment.