You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2006/01/12 18:19:58 UTC
svn commit: r368416 [1/2] - in /jakarta/tapestry/trunk/examples:
Vlib/src/java/org/apache/tapestry/vlib/
Vlib/src/java/org/apache/tapestry/vlib/pages/
Vlib/src/java/org/apache/tapestry/vlib/pages/admin/
Vlib/src/java/org/apache/tapestry/vlib/services/ ...
Author: hlship
Date: Thu Jan 12 09:19:45 2006
New Revision: 368416
URL: http://svn.apache.org/viewcvs?rev=368416&view=rev
Log:
Setup a reasonable checkstyle configuration, and fix a large number of errors and warnings -- this time, properly checked into trunk!
Modified:
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/ActivateCallback.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/EntitySelectionModel.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VirtualLibraryDelegate.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/Visit.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VlibPage.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ConfirmBookDelete.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/EditUsers.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/TransferBooksSelect.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/BookQuerySourceImpl.java
jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/RemoteCallback.java
jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/BorrowException.java
jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/LoginException.java
jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/RegistrationException.java
jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/AbstractEntityBean.java
jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/BookQueryBean.java
jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/KeyAllocatorBean.java
jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/OperationsBean.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/Visit.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/WorkbenchHomeService.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/WorkbenchValidationDelegate.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/chart/ChartPage.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/chart/PlotValue.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/table/VerbosityRating.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/DirectoryTableView.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/FileSystemTree.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/FileSystemTreeTable.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/ISelectedFolderSource.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/TestTreeNode.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/fsmodel/Drive.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/fsmodel/FileObject.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/fsmodel/FileSystem.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/fsmodel/FileSystemDataModel.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/fsmodel/FolderObject.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/fsmodel/NodeRenderFactory.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/tree/examples/fsmodel/SFObject.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/upload/Upload.java
jakarta/tapestry/trunk/examples/Workbench/src/java/org/apache/tapestry/workbench/upload/UploadResults.java
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/ActivateCallback.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/ActivateCallback.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/ActivateCallback.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/ActivateCallback.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@
import org.apache.tapestry.callback.ICallback;
/**
- * Callback implementation for pages which implement the {@link org.apache.tapestry.vlib.IActivate}
- * interface.
+ * Callback implementation for pages which implement the
+ * {@link org.apache.tapestry.vlib.IActivate} interface.
*
* @author Howard Lewis Ship
* @since 3.0
@@ -27,9 +27,10 @@
public class ActivateCallback implements ICallback
{
+
private static final long serialVersionUID = 931074851273839081L;
-
- private String _pageName;
+
+ private String _pageName;
public ActivateCallback(IActivate page)
{
@@ -43,9 +44,9 @@
public void performCallback(IRequestCycle cycle)
{
- IActivate page = (IActivate) cycle.getPage(_pageName);
+ IActivate page = (IActivate)cycle.getPage(_pageName);
page.validate(cycle);
page.activate();
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/EntitySelectionModel.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/EntitySelectionModel.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/EntitySelectionModel.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/EntitySelectionModel.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
public class EntitySelectionModel implements IPropertySelectionModel
{
+ /** Stores a primaryKey/label pair. */
private static class Entry
{
Integer primaryKey;
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VirtualLibraryDelegate.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VirtualLibraryDelegate.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VirtualLibraryDelegate.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VirtualLibraryDelegate.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -21,17 +21,18 @@
import org.apache.tapestry.valid.ValidationDelegate;
/**
- * Implementation of {@link org.apache.tapestry.valid.IValidationDelegate} which uses the correct
- * CSS class when rendering errors.
+ * Implementation of {@link org.apache.tapestry.valid.IValidationDelegate} which
+ * uses the correct CSS class when rendering errors.
*
* @author Howard Lewis Ship
*/
public class VirtualLibraryDelegate extends ValidationDelegate
{
+
private static final long serialVersionUID = -1295233610266112824L;
- public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
+ public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
{
if (isInError(component))
{
@@ -42,20 +43,16 @@
public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle)
{
- if (isInError(component))
- writer.end();
+ if (isInError(component)) writer.end();
}
- public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle,
- IFormComponent component, IValidator validator)
+ public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
+ IValidator validator)
{
- if (isInError())
- writer.attribute("class", "error");
+ if (isInError()) writer.attribute("class", "error");
}
- public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component,
- IValidator validator)
+ public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator)
{
}
-
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/Visit.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/Visit.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/Visit.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/Visit.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -20,14 +20,16 @@
import org.apache.tapestry.vlib.ejb.Person;
/**
- * The visit object for the {@link VirtualLibraryEngine}. Primarily, this is used to access the
- * home interfaces and EJB instances, and to identify who the logged in user is.
+ * The visit object for the {@link VirtualLibraryEngine}. Primarily, this is
+ * used to access the home interfaces and EJB instances, and to identify who the
+ * logged in user is.
*
* @author Howard Lewis Ship
*/
public class Visit implements Serializable
{
+
private static final long serialVersionUID = 8589862098677603655L;
/**
@@ -37,8 +39,8 @@
private Person _user;
/**
- * Returns the time the user last accessed the database, which may be null if the user hasn't
- * logged in yet.
+ * Returns the time the user last accessed the database, which may be null
+ * if the user hasn't logged in yet.
*/
public Timestamp getLastAccess()
@@ -56,7 +58,8 @@
}
/**
- * Returns the id of the logged in user, or null if the user is not logged in.
+ * Returns the id of the logged in user, or null if the user is not logged
+ * in.
*/
public Integer getUserId()
@@ -94,20 +97,18 @@
public boolean isLoggedInUser(Integer id)
{
- if (_user == null)
- return false;
+ if (_user == null) return false;
return _user.getId().equals(id);
}
/**
- * Invoked by pages after they perform an operation that changes the backend database in such a
- * way that cached data is no longer valid.
+ * Invoked by pages after they perform an operation that changes the backend
+ * database in such a way that cached data is no longer valid.
*/
public void clearCache()
{
_user = null;
}
-
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VlibPage.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VlibPage.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VlibPage.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/VlibPage.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -33,26 +33,27 @@
import org.apache.tapestry.vlib.services.ModelSource;
/**
- * Base page used for pages that should be protected by the {@link Login} page. If the user is not
- * logged in, they are redirected to the Login page first. Also, implements an error property and a
- * validationDelegate.
+ * Base page used for pages that should be protected by the {@link Login} page.
+ * If the user is not logged in, they are redirected to the Login page first.
+ * Also, implements an error property and a validationDelegate.
* <p>
* Meta properties (overridden in some subclasses)
* <dl>
* <dt>anonymous-access=false</dt>
* <dd>If true, the page may be accessed without the user being logged in.</dd>
* <dt>admin-page=false</dt>
- * <dd>If true, the user must be logged in as an administrator to access this page.</dd>
+ * <dd>If true, the user must be logged in as an administrator to access this
+ * page.</dd>
* </dl>
*
* @author Howard Lewis Ship
*/
-@Meta(
-{ "anonymous-access=false", "admin-page=false" })
-public abstract class VlibPage extends BasePage implements IErrorProperty, IMessageProperty,
- PageValidateListener, OperationsUser
+@Meta( { "anonymous-access=false", "admin-page=false" })
+public abstract class VlibPage extends BasePage implements IErrorProperty, IMessageProperty, PageValidateListener,
+ OperationsUser
{
+
@Bean(VirtualLibraryDelegate.class)
public abstract IValidationDelegate getValidationDelegate();
@@ -76,7 +77,7 @@
protected void setErrorField(String componentId, String message)
{
- IFormComponent component = (IFormComponent) getComponent(componentId);
+ IFormComponent component = (IFormComponent)getComponent(componentId);
IValidationDelegate delegate = getValidationDelegate();
@@ -85,7 +86,8 @@
}
/**
- * Returns true if the delegate indicates an error, or the error property is not null.
+ * Returns true if the delegate indicates an error, or the error property is
+ * not null.
*/
protected boolean isInError()
@@ -94,23 +96,20 @@
}
/**
- * Checks if the user is logged in. If not, they are sent to the {@link Login} page before
- * coming back to whatever this page is.
+ * Checks if the user is logged in. If not, they are sent to the
+ * {@link Login} page before coming back to whatever this page is.
*/
public void pageValidate(PageEvent event)
{
- if (isAdminPage())
- ensureUserIsLoggedInAsAdmin();
+ if (isAdminPage()) ensureUserIsLoggedInAsAdmin();
- if (!getAllowAnonymousAccess())
- ensureUserIsLoggedIn();
+ if (!getAllowAnonymousAccess()) ensureUserIsLoggedIn();
}
private void ensureUserIsLoggedIn()
{
- if (isUserLoggedIn())
- return;
+ if (isUserLoggedIn()) return;
// User not logged in ... redirect through the Login page.
@@ -122,7 +121,8 @@
}
/**
- * Returns true if the {@link Visit} exists, and the user is logged in as well.
+ * Returns true if the {@link Visit} exists, and the user is logged in as
+ * well.
*
* @return true if logged in
*/
@@ -146,11 +146,9 @@
if (!getVisitState().getUser().isAdmin())
{
- getErrorPresenter().presentError(
- "That function is restricted to administrators.",
- cycle);
+ getErrorPresenter().presentError("That function is restricted to administrators.", cycle);
throw new PageRedirectException(cycle.getPage());
}
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ConfirmBookDelete.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ConfirmBookDelete.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ConfirmBookDelete.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ConfirmBookDelete.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
import javax.ejb.RemoveException;
import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.tapestry.IPage;
-import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.annotations.InjectPage;
import org.apache.tapestry.annotations.Message;
import org.apache.tapestry.annotations.Meta;
@@ -30,8 +28,9 @@
import org.apache.tapestry.vlib.services.RemoteCallback;
/**
- * Presents a confirmation page before deleting a book. If the user selects "yes", the book is
- * deleted; otherwise the user is returned to the {@link MyLibrary} page.
+ * Presents a confirmation page before deleting a book. If the user selects
+ * "yes", the book is deleted; otherwise the user is returned to the
+ * {@link MyLibrary} page.
*
* @author Howard Lewis Ship
*/
@@ -39,6 +38,7 @@
@Meta("page-type=MyLibrary")
public abstract class ConfirmBookDelete extends BasePage implements OperationsUser
{
+
public abstract void setBookId(Integer bookId);
public abstract void setBookTitle(String title);
@@ -50,9 +50,9 @@
public abstract String bookDeleted(String title);
/**
- * Invoked (by {@link MyLibrary}) to select a book to be deleted. This method sets the
- * temporary page properties (bookPrimaryKey and bookTitle) and invoked
- * {@link IRequestCycle#setPage(IPage)}.
+ * Invoked (by {@link MyLibrary}) to select a book to be deleted. This
+ * method sets the temporary page properties (bookPrimaryKey and bookTitle)
+ * and invoked {@link IRequestCycle#setPage(IPage)}.
*/
public void selectBook(Integer bookId)
@@ -74,7 +74,9 @@
{
RemoteCallback<Book> callback = new RemoteCallback()
{
- public Book doRemote() throws RemoteException
+
+ public Book doRemote()
+ throws RemoteException
{
try
{
@@ -95,4 +97,4 @@
myLibrary.activate();
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -30,11 +30,11 @@
*
* @author Howard Lewis Ship
*/
-@Meta(
-{ "page-type=Search", "anonymous-access=true" })
+@Meta( { "page-type=Search", "anonymous-access=true" })
public abstract class ViewBook extends VlibPage implements IExternalPage, PageBeginRenderListener
{
+
private DateFormat _dateFormat;
@Persist
@@ -48,14 +48,15 @@
public void activateExternalPage(Object[] parameters, IRequestCycle cycle)
{
- Integer bookId = (Integer) parameters[0];
+ Integer bookId = (Integer)parameters[0];
setBookId(bookId);
}
private void readBook()
{
- // This doesn't handle invalid book id as nicely as the 3.0 code did, but I'm
+ // This doesn't handle invalid book id as nicely as the 3.0 code did,
+ // but I'm
// getting a bit lazy!
Book book = getRemoteTemplate().getBook(getBookId());
@@ -66,18 +67,13 @@
public DateFormat getDateFormat()
{
if (_dateFormat == null)
- _dateFormat = DateFormat.getDateTimeInstance(
- DateFormat.MEDIUM,
- DateFormat.SHORT,
- getLocale());
+ _dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, getLocale());
return _dateFormat;
}
public void pageBeginRender(PageEvent event)
{
- if (getBook() == null)
- readBook();
+ if (getBook() == null) readBook();
}
-
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -32,16 +32,17 @@
import org.apache.tapestry.vlib.services.RemoteCallback;
/**
- * Displays the book inventory list for a single {@link org.apache.tapestry.vlib.ejb.IPerson},
- * showing what books are owned by the person, who has them borrowed, etc. If the user is logged in,
- * then books can be borrowed from this page as well.
+ * Displays the book inventory list for a single
+ * {@link org.apache.tapestry.vlib.ejb.IPerson}, showing what books are owned
+ * by the person, who has them borrowed, etc. If the user is logged in, then
+ * books can be borrowed from this page as well.
*
* @author Howard Lewis Ship
*/
-@Meta(
-{ "page-type=Search", "anonymous-access=true" })
+@Meta( { "page-type=Search", "anonymous-access=true" })
public abstract class ViewPerson extends VlibPage implements IExternalPage, PageBeginRenderListener
{
+
public abstract Integer getPersonId();
@Persist
@@ -78,7 +79,7 @@
public void activateExternalPage(Object[] parameters, IRequestCycle cycle)
{
- Integer personId = (Integer) parameters[0];
+ Integer personId = (Integer)parameters[0];
setPersonId(personId);
@@ -93,8 +94,7 @@
{
int count = runQuery();
- if (getBrowser().getResultCount() != count)
- getBrowser().setResultCount(count);
+ if (getBrowser().getResultCount() != count) getBrowser().setResultCount(count);
}
private int runQuery()
@@ -104,7 +104,9 @@
RemoteCallback<Integer> callback = new RemoteCallback()
{
- public Integer doRemote() throws RemoteException
+
+ public Integer doRemote()
+ throws RemoteException
{
IBookQuery query = getQuery();
@@ -140,5 +142,4 @@
setPerson(person);
}
}
-
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/EditUsers.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/EditUsers.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/EditUsers.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/EditUsers.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -37,16 +37,16 @@
import org.apache.tapestry.vlib.services.RemoteCallback;
/**
- * Allows editting of the users. Simple flags about the user can be changed; additionally, the user
- * can have their password reset (to a random value, which is mailed to them), or the user can be
- * out-right deleted.
+ * Allows editting of the users. Simple flags about the user can be changed;
+ * additionally, the user can have their password reset (to a random value,
+ * which is mailed to them), or the user can be out-right deleted.
*
* @author Howard Lewis Ship
*/
-@Meta({"page-type=EditUsers", "admin-page=true"})
-public abstract class EditUsers extends VlibPage implements PageBeginRenderListener,
- PageDetachListener
+@Meta( { "page-type=EditUsers", "admin-page=true" })
+public abstract class EditUsers extends VlibPage implements PageBeginRenderListener, PageDetachListener
{
+
public abstract String getPassword();
public abstract void setPassword(String password);
@@ -73,8 +73,13 @@
@InjectComponent("password")
public abstract IFormComponent getPasswordField();
+ /**
+ * Converts from user ids to Users, and tracks users that need to have their
+ * password reset.
+ */
public class UserConverter extends DefaultPrimaryKeyConverter
{
+
private Set _resetPasswordValues;
public void clear()
@@ -103,8 +108,7 @@
public UserConverter getUserConverter()
{
- if (_userConverter == null)
- _userConverter = new UserConverter();
+ if (_userConverter == null) _userConverter = new UserConverter();
return _userConverter;
}
@@ -127,7 +131,9 @@
RemoteCallback<Person[]> callback = new RemoteCallback()
{
- public Person[] doRemote() throws RemoteException
+
+ public Person[] doRemote()
+ throws RemoteException
{
return getOperations().getPersons();
}
@@ -139,14 +145,13 @@
converter.clear();
- for (int i = 0; i < users.length; i++)
+ for(int i = 0; i < users.length; i++)
{
Integer id = users[i].getId();
// Skip the current user; you aren't allowed to edit yourself
- if (id.equals(userId))
- continue;
+ if (id.equals(userId)) continue;
converter.add(id, users[i]);
}
@@ -162,7 +167,7 @@
UserConverter converter = getUserConverter();
- final Person[] updates = (Person[]) converter.getValues().toArray(new Person[0]);
+ final Person[] updates = (Person[])converter.getValues().toArray(new Person[0]);
final Integer[] deletedIds = extractIds(converter.getDeletedValues());
final Integer[] resetPasswordIds = extractIds(converter.getResetPasswordValues());
@@ -179,16 +184,13 @@
RemoteCallback callback = new RemoteCallback()
{
- public Object doRemote() throws RemoteException
+
+ public Object doRemote()
+ throws RemoteException
{
try
{
- getOperations().updatePersons(
- updates,
- resetPasswordIds,
- password,
- deletedIds,
- adminId);
+ getOperations().updatePersons(updates, resetPasswordIds, password, deletedIds, adminId);
}
catch (RemoveException ex)
{
@@ -218,13 +220,13 @@
Iterator i = valueSet.iterator();
int index = 0;
- while (i.hasNext())
+ while(i.hasNext())
{
- Person person = (Person) i.next();
+ Person person = (Person)i.next();
result[index++] = person.getId();
}
return result;
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/TransferBooksSelect.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/TransferBooksSelect.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/TransferBooksSelect.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/admin/TransferBooksSelect.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,10 +29,10 @@
*
* @author Howard Lewis Ship
*/
-@Meta(
-{ "page-type=TransferBooks", "admin-page=true" })
+@Meta( { "page-type=TransferBooks", "admin-page=true" })
public abstract class TransferBooksSelect extends VlibPage
{
+
public abstract Integer getFromUserId();
public abstract Integer getToUserId();
@@ -65,4 +65,4 @@
next.activate(fromUserId, toUserId);
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/BookQuerySourceImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/BookQuerySourceImpl.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/BookQuerySourceImpl.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/BookQuerySourceImpl.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2005 The Apache Software Foundation
+// Copyright 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -24,8 +24,14 @@
import org.apache.tapestry.vlib.ejb.IBookQuery;
import org.apache.tapestry.vlib.ejb.IBookQueryHome;
+/**
+ * EJB Bean implementation for performing queires for books.
+ *
+ * @author Howard M. Lewis Ship
+ */
public class BookQuerySourceImpl implements BookQuerySource, RemoteExceptionListener
{
+
private NameLookup _nameLookup;
private IBookQueryHome _home;
@@ -36,7 +42,9 @@
{
RemoteCallback<IBookQuery> callback = new RemoteCallback()
{
- public IBookQuery doRemote() throws RemoteException
+
+ public IBookQuery doRemote()
+ throws RemoteException
{
try
{
@@ -55,8 +63,7 @@
private IBookQueryHome getHome()
{
- if (_home == null)
- _home = (IBookQueryHome) _nameLookup.lookup("vlib/BookQuery", IBookQueryHome.class);
+ if (_home == null) _home = (IBookQueryHome)_nameLookup.lookup("vlib/BookQuery", IBookQueryHome.class);
return _home;
}
Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/RemoteCallback.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/RemoteCallback.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/RemoteCallback.java (original)
+++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/services/RemoteCallback.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2005 The Apache Software Foundation
+// Copyright 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -19,16 +19,20 @@
/**
* Callback interface used when performing
*
+ * @param <T>
+ * the return type of the callback.
* @author Howard M. Lewis Ship
* @since 4.0
*/
public interface RemoteCallback<T>
{
+
/**
* Invoked by {@link RemoteTemplate}.
*
* @return
* @throws RemoteException
*/
- T doRemote() throws RemoteException;
+ T doRemote()
+ throws RemoteException;
}
Modified: jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/BorrowException.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/BorrowException.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/BorrowException.java (original)
+++ jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/BorrowException.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -23,10 +23,11 @@
public class BorrowException extends Exception
{
+
private static final long serialVersionUID = 7761447010967099141L;
- public BorrowException(String message)
+ public BorrowException(String message)
{
super(message);
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/LoginException.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/LoginException.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/LoginException.java (original)
+++ jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/LoginException.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -22,9 +22,10 @@
public class LoginException extends Exception
{
+
private static final long serialVersionUID = -1472279052871024178L;
-
- private boolean _passwordError;
+
+ private final boolean _passwordError;
public LoginException(String message, boolean passwordError)
{
@@ -34,8 +35,9 @@
}
/**
- * Returns true if the error is related to the password. Otherwise, the error is related to the
- * email address (either not found, or the user has been invalidated or otherwise locked out).
+ * Returns true if the error is related to the password. Otherwise, the
+ * error is related to the email address (either not found, or the user has
+ * been invalidated or otherwise locked out).
*/
public boolean isPasswordError()
@@ -43,4 +45,4 @@
return _passwordError;
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/RegistrationException.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/RegistrationException.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/RegistrationException.java (original)
+++ jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/RegistrationException.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -15,7 +15,8 @@
package org.apache.tapestry.vlib.ejb;
/**
- * Exception thrown by {@link IOperations#registerNewUser(String, String, String, String)} if the
+ * Exception thrown by
+ * {@link IOperations#registerNewUser(String, String, String, String)} if the
* registration is not allowed (usually, because of a duplicate email or name).
*
* @author Howard Lewis Ship
@@ -23,9 +24,10 @@
public class RegistrationException extends Exception
{
+
private static final long serialVersionUID = 1359775792320102947L;
-
- private Throwable _rootCause;
+
+ private final Throwable _rootCause;
public RegistrationException(Throwable rootCause)
{
@@ -43,11 +45,11 @@
public RegistrationException(String message)
{
- super(message);
+ this(message, null);
}
public Throwable getRootCause()
{
return _rootCause;
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/AbstractEntityBean.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/AbstractEntityBean.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/AbstractEntityBean.java (original)
+++ jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/AbstractEntityBean.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -27,21 +27,22 @@
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
+import ognl.Ognl;
+import ognl.OgnlException;
+
import org.apache.tapestry.contrib.ejb.XEJBException;
import org.apache.tapestry.vlib.ejb.IKeyAllocator;
import org.apache.tapestry.vlib.ejb.IKeyAllocatorHome;
-import ognl.Ognl;
-import ognl.OgnlException;
/**
- * Provides basic support for the entity context, empty or minimal implementations of the required
- * methods, and some utilties.
+ * Provides basic support for the entity context, empty or minimal
+ * implementations of the required methods, and some utilties.
*
* @author Howard Lewis Ship
*/
-public abstract class AbstractEntityBean implements EntityBean
-{
+public abstract class AbstractEntityBean implements EntityBean {
+
/**
* The EntityContext provided by the application server.
*/
@@ -53,8 +54,8 @@
private transient IKeyAllocatorHome _keyAllocatorHome;
/**
- * The environment naming context, which is configured for this bean in the deployment
- * descriptor.
+ * The environment naming context, which is configured for this bean in the
+ * deployment descriptor.
*/
private transient Context _environment;
@@ -73,27 +74,23 @@
* Gets a named object from the bean's environment naming context.
*/
- protected Object getEnvironmentObject(String name, Class objectClass) throws RemoteException,
- NamingException
+ protected Object getEnvironmentObject(String name, Class objectClass)
+ throws RemoteException, NamingException
{
Object result = null;
- if (_environment == null)
- {
+ if (_environment == null) {
Context initial = new InitialContext();
- _environment = (Context) initial.lookup("java:comp/env");
+ _environment = (Context)initial.lookup("java:comp/env");
}
Object raw = _environment.lookup(name);
- try
- {
+ try {
result = PortableRemoteObject.narrow(raw, objectClass);
- }
- catch (ClassCastException ex)
- {
- throw new RemoteException("Could not narrow " + raw + " (" + name + ") to class "
- + objectClass + ".");
+ } catch (ClassCastException ex) {
+ throw new RemoteException("Could not narrow " + raw + " (" + name
+ + ") to class " + objectClass + ".");
}
return result;
@@ -103,7 +100,8 @@
* Empty implementation; subclasses may override.
*/
- public void ejbActivate() throws EJBException, RemoteException
+ public void ejbActivate()
+ throws EJBException, RemoteException
{
// does nothing
}
@@ -112,7 +110,8 @@
* Empty implementation; subclasses may override.
*/
- public void ejbPassivate() throws EJBException, RemoteException
+ public void ejbPassivate()
+ throws EJBException, RemoteException
{
// does nothing
}
@@ -121,7 +120,8 @@
* Empty implementation; subclasses may override.
*/
- public void ejbRemove() throws EJBException, RemoteException
+ public void ejbRemove()
+ throws EJBException, RemoteException
{
// does nothing
}
@@ -130,7 +130,8 @@
* Does nothing.
*/
- public void ejbLoad() throws EJBException, RemoteException
+ public void ejbLoad()
+ throws EJBException, RemoteException
{
}
@@ -138,7 +139,8 @@
* Does nothing.
*/
- public void ejbStore() throws EJBException, RemoteException
+ public void ejbStore()
+ throws EJBException, RemoteException
{
}
@@ -146,39 +148,33 @@
* Uses the KeyAllocator session bean to allocate a necessary key.
*/
- protected Integer allocateKey() throws RemoteException
+ protected Integer allocateKey()
+ throws RemoteException
{
IKeyAllocator allocator;
- if (_keyAllocatorHome == null)
- {
- try
- {
+ if (_keyAllocatorHome == null) {
+ try {
Context initial = new InitialContext();
- Context environment = (Context) initial.lookup("java:comp/env");
+ Context environment = (Context)initial.lookup("java:comp/env");
Object raw = environment.lookup("ejb/KeyAllocator");
- _keyAllocatorHome = (IKeyAllocatorHome) PortableRemoteObject.narrow(
- raw,
- IKeyAllocatorHome.class);
- }
- catch (NamingException ex)
- {
- throw new XEJBException("Unable to locate IKeyAllocatorHome.", ex);
+ _keyAllocatorHome = (IKeyAllocatorHome)PortableRemoteObject
+ .narrow(raw, IKeyAllocatorHome.class);
+ } catch (NamingException ex) {
+ throw new XEJBException("Unable to locate IKeyAllocatorHome.",
+ ex);
}
}
// Get a reference to *some* KeyAllocator bean ... it may be fresh,
// or one reused from a pool.
- try
- {
+ try {
allocator = _keyAllocatorHome.create();
- }
- catch (CreateException ex)
- {
- throw new RemoteException("Unable to create a KeyAllocator from " + _keyAllocatorHome
- + ".", ex);
+ } catch (CreateException ex) {
+ throw new RemoteException("Unable to create a KeyAllocator from "
+ + _keyAllocatorHome + ".", ex);
}
// Finally, invoke the method that gets a key.
@@ -187,18 +183,20 @@
}
/**
- * Implemented in subclasses to provide a list of property names to be included in the entity
- * attributes map.
+ * Implemented in subclasses to provide a list of property names to be
+ * included in the entity attributes map.
*/
protected abstract String[] getAttributePropertyNames();
/**
- * Returns a {@link Map} of the properties of the bean. This Map is returned to the client,
- * where it can be modified and then used to update the entity bean in a single method
+ * Returns a {@link Map} of the properties of the bean. This Map is returned
+ * to the client, where it can be modified and then used to update the
+ * entity bean in a single method
* <p>
- * The properties included in the Map are defined by the {@link #getAttributePropertyNames()}
- * method, which is implemented by concrete subclasses.
+ * The properties included in the Map are defined by the
+ * {@link #getAttributePropertyNames()} method, which is implemented by
+ * concrete subclasses.
*/
public Map getEntityAttributes()
@@ -208,18 +206,14 @@
if (_attributePropertyNames == null)
_attributePropertyNames = getAttributePropertyNames();
- for (int i = 0; i < _attributePropertyNames.length; i++)
- {
+ for(int i = 0; i < _attributePropertyNames.length; i++) {
String key = _attributePropertyNames[i];
- try
- {
+ try {
Object value = Ognl.getValue(key, this);
result.put(key, value);
- }
- catch (OgnlException ex)
- {
+ } catch (OgnlException ex) {
}
}
@@ -227,13 +221,13 @@
}
/**
- * Updates the bean with property changes from the update {@link Map}. Only the keys defined by
- * {@link #getAttributePropertyNames()} will be accessed (keys and values that are not in that
- * list are ignored).
+ * Updates the bean with property changes from the update {@link Map}. Only
+ * the keys defined by {@link #getAttributePropertyNames()} will be accessed
+ * (keys and values that are not in that list are ignored).
* <p>
- * The corresponding bean property will only be updated if the key is present ... this means
- * that the update may contain just the <em>changed</em> keys. Remember that a Map may store
- * null values.
+ * The corresponding bean property will only be updated if the key is
+ * present ... this means that the update may contain just the
+ * <em>changed</em> keys. Remember that a Map may store null values.
*/
public void updateEntityAttributes(Map update)
@@ -241,20 +235,15 @@
if (_attributePropertyNames == null)
_attributePropertyNames = getAttributePropertyNames();
- for (int i = 0; i < _attributePropertyNames.length; i++)
- {
+ for(int i = 0; i < _attributePropertyNames.length; i++) {
String key = _attributePropertyNames[i];
- if (update.containsKey(key))
- {
+ if (update.containsKey(key)) {
Object value = update.get(key);
- try
- {
+ try {
Ognl.setValue(key, this, value);
- }
- catch (OgnlException ex)
- {
+ } catch (OgnlException ex) {
}
}
@@ -272,4 +261,4 @@
{
return _context;
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/BookQueryBean.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/BookQueryBean.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/BookQueryBean.java (original)
+++ jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/BookQueryBean.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,12 +29,14 @@
/**
* Implementation of a stateful session bean used to query the
- * {@link org.apache.tapestry.vlib.ejb.IBook} entity and cache the results. It can then download the
- * results, in chunks, to the client ... this is used to support clients that which to display the
- * results a page at a time (with random access to the pages of results).
+ * {@link org.apache.tapestry.vlib.ejb.IBook} entity and cache the results. It
+ * can then download the results, in chunks, to the client ... this is used to
+ * support clients that which to display the results a page at a time (with
+ * random access to the pages of results).
* <p>
- * To avoid a lot of duplicate code for things like finding the JDBC {@link Connection} and querying
- * the IBook entity, we subclass from {@link OperationsBean}.
+ * To avoid a lot of duplicate code for things like finding the JDBC
+ * {@link Connection} and querying the IBook entity, we subclass from
+ * {@link OperationsBean}.
*
* @see org.apache.tapestry.vlib.ejb.IBookQuery
* @see org.apache.tapestry.vlib.ejb.IBookQueryHome
@@ -43,9 +45,10 @@
public class BookQueryBean extends OperationsBean
{
+
private static final long serialVersionUID = 8782046868254488388L;
-
- /**
+
+ /**
* Stores the results from the most recent query.
*/
@@ -68,8 +71,7 @@
public int getResultCount()
{
- if (_results == null)
- return 0;
+ if (_results == null) return 0;
return _results.length;
}
@@ -82,13 +84,11 @@
{
Book[] result;
- if (offset < 0)
- return null;
+ if (offset < 0) return null;
int finalLength = Math.min(length, _results.length - offset);
- if (finalLength < 0)
- return null;
+ if (finalLength < 0) return null;
// Create a new array and copy the requested
// results into it.
@@ -100,7 +100,8 @@
}
/**
- * The master query is for querying by some mixture of title, author and publisher.
+ * The master query is for querying by some mixture of title, author and
+ * publisher.
*/
public int masterQuery(MasterQueryParameters parameters, SortOrdering sortOrdering)
@@ -270,12 +271,13 @@
}
}
- private void processQueryResults(ResultSet set) throws SQLException
+ private void processQueryResults(ResultSet set)
+ throws SQLException
{
List list = new ArrayList();
Object[] columns = new Object[Book.N_COLUMNS];
- while (set.next())
+ while(set.next())
{
Book book = convertRowToBook(set, columns);
@@ -283,11 +285,11 @@
}
_results = new Book[list.size()];
- _results = (Book[]) list.toArray(_results);
+ _results = (Book[])list.toArray(_results);
}
- private IStatement buildMasterQuery(Connection connection, MasterQueryParameters parameters,
- SortOrdering ordering) throws SQLException
+ private IStatement buildMasterQuery(Connection connection, MasterQueryParameters parameters, SortOrdering ordering)
+ throws SQLException
{
String title = parameters.getTitle();
String author = parameters.getAuthor();
@@ -323,8 +325,9 @@
return assembly.createStatement(connection);
}
- private IStatement buildPersonQuery(Connection connection, String personColumn,
- Integer personId, SortOrdering sortOrdering) throws SQLException
+ private IStatement buildPersonQuery(Connection connection, String personColumn, Integer personId,
+ SortOrdering sortOrdering)
+ throws SQLException
{
StatementAssembly assembly = buildBaseBookQuery();
@@ -338,8 +341,8 @@
return assembly.createStatement(connection);
}
- private IStatement buildBorrowerQuery(Connection connection, Integer borrowerId,
- SortOrdering sortOrdering) throws SQLException
+ private IStatement buildBorrowerQuery(Connection connection, Integer borrowerId, SortOrdering sortOrdering)
+ throws SQLException
{
StatementAssembly assembly = buildBaseBookQuery();
@@ -356,4 +359,4 @@
return assembly.createStatement(connection);
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/KeyAllocatorBean.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/KeyAllocatorBean.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/KeyAllocatorBean.java (original)
+++ jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/KeyAllocatorBean.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -30,26 +30,29 @@
import org.apache.tapestry.contrib.ejb.XEJBException;
/**
- * Implementation of the {@link org.apache.tapestry.vlib.ejb.IKeyAllocator} stateless session bean.
+ * Implementation of the {@link org.apache.tapestry.vlib.ejb.IKeyAllocator}
+ * stateless session bean.
* <p>
- * We're cheating a little; they KeyAllocator does have state, it just doesn't get persisted ever.
- * Since the operation on it is atomic ("gimme a key") it doesn't need to have conversational state
- * with its clients.
+ * We're cheating a little; they KeyAllocator does have state, it just doesn't
+ * get persisted ever. Since the operation on it is atomic ("gimme a key") it
+ * doesn't need to have conversational state with its clients.
* <p>
- * The KeyAllocator records in the database the "next key to allocate". When it needs a key, it
- * allocates a block of keys (by advancing the next key by a some number).
+ * The KeyAllocator records in the database the "next key to allocate". When it
+ * needs a key, it allocates a block of keys (by advancing the next key by a
+ * some number).
* <p>
- * If the KeyAllocator instance is purged from the pool, then some number of keys that it has
- * allocated will be lost. Big deal.
+ * If the KeyAllocator instance is purged from the pool, then some number of
+ * keys that it has allocated will be lost. Big deal.
*
* @author Howard Lewis Ship
*/
public class KeyAllocatorBean implements SessionBean
{
+
private static final long serialVersionUID = -6783018767284081244L;
- private static final String PROPERTY_NAME = "next-key";
+ private static final String PROPERTY_NAME = "next-key";
/**
* List of Integer instances; these are keys acquired from the database.
@@ -58,8 +61,8 @@
private LinkedList keys;
/**
- * Number of keys to allocate from the database at a time. Set from the ENC property
- * "blockSize".
+ * Number of keys to allocate from the database at a time. Set from the ENC
+ * property "blockSize".
*/
private int blockSize = 0;
@@ -71,7 +74,8 @@
private DataSource dataSource;
/**
- * Activates the bean. Gets the block size and DataSource from the environment.
+ * Activates the bean. Gets the block size and DataSource from the
+ * environment.
*/
public void ejbCreate()
@@ -83,7 +87,7 @@
try
{
initial = new InitialContext();
- environment = (Context) initial.lookup("java:comp/env");
+ environment = (Context)initial.lookup("java:comp/env");
}
catch (NamingException ex)
{
@@ -92,7 +96,7 @@
try
{
- blockSizeProperty = (Integer) environment.lookup("blockSize");
+ blockSizeProperty = (Integer)environment.lookup("blockSize");
}
catch (NamingException ex)
{
@@ -103,15 +107,14 @@
try
{
- dataSource = (DataSource) environment.lookup("jdbc/dataSource");
+ dataSource = (DataSource)environment.lookup("jdbc/dataSource");
}
catch (NamingException ex)
{
throw new XEJBException("Could not lookup data source.", ex);
}
- if (keys == null)
- keys = new LinkedList();
+ if (keys == null) keys = new LinkedList();
}
/**
@@ -135,9 +138,10 @@
}
/**
- * Does nothing. This is invoked when the bean moves from the method ready pool to the "does not
- * exist" state. The EJB container will lost its reference to the bean, and the garbage
- * collector will take it (including any keys it has cached from the database).
+ * Does nothing. This is invoked when the bean moves from the method ready
+ * pool to the "does not exist" state. The EJB container will lost its
+ * reference to the bean, and the garbage collector will take it (including
+ * any keys it has cached from the database).
*/
public void ejbRemove()
@@ -146,20 +150,20 @@
}
/**
- * Allocates a single key, going to the database only if it has no keys in its internal cache.
+ * Allocates a single key, going to the database only if it has no keys in
+ * its internal cache.
*/
public Integer allocateKey()
{
- if (keys.isEmpty())
- allocateBlock(1);
+ if (keys.isEmpty()) allocateBlock(1);
- return (Integer) keys.removeFirst();
+ return (Integer)keys.removeFirst();
}
/**
- * Allocates a block of keys, going to the database if there are insufficient keys in its
- * internal cache.
+ * Allocates a block of keys, going to the database if there are
+ * insufficient keys in its internal cache.
*/
public Integer[] allocateKeys(int count)
@@ -167,22 +171,21 @@
Integer[] result;
int i;
- if (keys.size() < count)
- allocateBlock(count);
+ if (keys.size() < count) allocateBlock(count);
result = new Integer[count];
- for (i = 0; i < count; i++)
+ for(i = 0; i < count; i++)
{
- result[i] = (Integer) keys.removeFirst();
+ result[i] = (Integer)keys.removeFirst();
}
return result;
}
/**
- * Allocates a block of keys from the database. Allocates count keys, or the configured block
- * size, whichever is greater.
+ * Allocates a block of keys from the database. Allocates count keys, or the
+ * configured block size, whichever is greater.
* <p>
* It is assumed that this operation takes place within a transaction.
*/
@@ -221,13 +224,12 @@
// Now, take those keys and advance nextKey
- for (i = 0; i < allocationCount; i++)
+ for(i = 0; i < allocationCount; i++)
keys.add(new Integer(nextKey++));
// Update nextKey back to the database.
- statement = connection.prepareStatement("update PROP\n" + "set PROP_VALUE = ?\n"
- + "where NAME = ?");
+ statement = connection.prepareStatement("update PROP\n" + "set PROP_VALUE = ?\n" + "where NAME = ?");
statement.setInt(1, nextKey);
statement.setString(2, PROPERTY_NAME);
@@ -295,4 +297,4 @@
throw new XEJBException("Unable to get database connection from pool.", ex);
}
}
-}
\ No newline at end of file
+}
Modified: jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/OperationsBean.java
URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/OperationsBean.java?rev=368416&r1=368415&r2=368416&view=diff
==============================================================================
--- jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/OperationsBean.java (original)
+++ jakarta/tapestry/trunk/examples/VlibBeans/src/java/org/apache/tapestry/vlib/ejb/impl/OperationsBean.java Thu Jan 12 09:19:45 2006
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005 The Apache Software Foundation
+// Copyright 2004, 2005, 2006 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -57,7 +57,8 @@
import org.apache.tapestry.vlib.ejb.SortOrdering;
/**
- * Implementation of the {@link org.apache.tapestry.vlib.ejb.IOperations} stateless session bean.
+ * Implementation of the {@link org.apache.tapestry.vlib.ejb.IOperations}
+ * stateless session bean.
* <p>
* Implenents a number of stateless operations for the front end.
*
@@ -66,9 +67,10 @@
public class OperationsBean implements SessionBean
{
+
private static final long serialVersionUID = -3942706099570269035L;
- private transient Context _environment;
+ private transient Context _environment;
private transient IBookHome _bookHome;
@@ -83,8 +85,9 @@
private transient DataSource _dataSource;
/**
- * Sets up the bean. Locates the {@link DataSource} for the bean as <code>jdbc/dataSource</code>
- * within the ENC; this data source is later used by {@link #getConnection()}.
+ * Sets up the bean. Locates the {@link DataSource} for the bean as
+ * <code>jdbc/dataSource</code> within the ENC; this data source is later
+ * used by {@link #getConnection()}.
*/
public void ejbCreate()
@@ -94,7 +97,7 @@
try
{
initial = new InitialContext();
- _environment = (Context) initial.lookup("java:comp/env");
+ _environment = (Context)initial.lookup("java:comp/env");
}
catch (NamingException e)
{
@@ -103,7 +106,7 @@
try
{
- _dataSource = (DataSource) _environment.lookup("jdbc/dataSource");
+ _dataSource = (DataSource)_environment.lookup("jdbc/dataSource");
}
catch (NamingException e)
{
@@ -142,16 +145,15 @@
* The {@link Book} value object is returned.
*/
- public Book borrowBook(Integer bookId, Integer borrowerId) throws FinderException,
- RemoteException, BorrowException
+ public Book borrowBook(Integer bookId, Integer borrowerId)
+ throws FinderException, RemoteException, BorrowException
{
IBookHome bookHome = getBookHome();
IPersonHome personHome = getPersonHome();
IBook book = bookHome.findByPrimaryKey(bookId);
- if (!book.getLendable())
- throw new BorrowException("Book may not be borrowed.");
+ if (!book.getLendable()) throw new BorrowException("Book may not be borrowed.");
// Verify that the borrower exists.
@@ -176,7 +178,8 @@
* Adds a new book, verifying that the publisher and holder actually exist.
*/
- public Integer addBook(Map attributes) throws CreateException, RemoteException
+ public Integer addBook(Map attributes)
+ throws CreateException, RemoteException
{
IBookHome home = getBookHome();
@@ -184,20 +187,20 @@
IBook book = home.create(attributes);
- return (Integer) book.getPrimaryKey();
+ return (Integer)book.getPrimaryKey();
}
/**
* Adds a book, which will be owned and held by the specified owner.
* <p>
- * The publisherName may either be the name of a known publisher, or a new name. A new
- * {@link IPublisher} will be created as necessary.
+ * The publisherName may either be the name of a known publisher, or a new
+ * name. A new {@link IPublisher} will be created as necessary.
* <p>
* Returns the newly created book, as a {@link Map} of attributes.
*/
- public Integer addBook(Map attributes, String publisherName) throws CreateException,
- RemoteException
+ public Integer addBook(Map attributes, String publisherName)
+ throws CreateException, RemoteException
{
IPublisher publisher = null;
IPublisherHome publisherHome = getPublisherHome();
@@ -210,11 +213,11 @@
}
catch (FinderException e)
{
- // Ignore, means that no publisher with the given name already exists.
+ // Ignore, means that no publisher with the given name already
+ // exists.
}
- if (publisher == null)
- publisher = publisherHome.create(publisherName);
+ if (publisher == null) publisher = publisherHome.create(publisherName);
attributes.put("publisherId", publisher.getPrimaryKey());
@@ -230,7 +233,8 @@
* The primary key of the book to update.
*/
- public void updateBook(Integer bookId, Map attributes) throws FinderException, RemoteException
+ public void updateBook(Integer bookId, Map attributes)
+ throws FinderException, RemoteException
{
IBookHome bookHome = getBookHome();
@@ -255,7 +259,7 @@
*/
public void updateBook(Integer bookId, Map attributes, String publisherName)
- throws CreateException, FinderException, RemoteException
+ throws CreateException, FinderException, RemoteException
{
IPublisher publisher = null;
@@ -270,8 +274,7 @@
// Ignore, means we need to create the Publisher
}
- if (publisher == null)
- publisher = publisherHome.create(publisherName);
+ if (publisher == null) publisher = publisherHome.create(publisherName);
// Don't duplicate all that other code!
@@ -280,8 +283,8 @@
updateBook(bookId, attributes);
}
- public void updatePerson(Integer personId, Map attributes) throws FinderException,
- RemoteException
+ public void updatePerson(Integer personId, Map attributes)
+ throws FinderException, RemoteException
{
IPersonHome home = getPersonHome();
@@ -312,9 +315,9 @@
set = statement.executeQuery();
- while (set.next())
+ while(set.next())
{
- Integer primaryKey = (Integer) set.getObject(1);
+ Integer primaryKey = (Integer)set.getObject(1);
String name = set.getString(2);
list.add(new Publisher(primaryKey, name));
@@ -332,12 +335,13 @@
// Convert from List to Publisher[]
- return (Publisher[]) list.toArray(new Publisher[list.size()]);
+ return (Publisher[])list.toArray(new Publisher[list.size()]);
}
/**
- * Fetchs all {@link IPerson} beans in the database and converts them to {@link Person} objects.
- * Returns the {@link Person}s sorted by last name, then first.
+ * Fetchs all {@link IPerson} beans in the database and converts them to
+ * {@link Person} objects. Returns the {@link Person}s sorted by last name,
+ * then first.
*/
public Person[] getPersons()
@@ -361,7 +365,7 @@
Object[] columns = new Object[Person.N_COLUMNS];
- while (set.next())
+ while(set.next())
{
list.add(convertRowToPerson(set, columns));
}
@@ -375,7 +379,7 @@
close(connection, statement, set);
}
- return (Person[]) list.toArray(new Person[list.size()]);
+ return (Person[])list.toArray(new Person[list.size()]);
}
/**
@@ -385,7 +389,8 @@
* if the Person does not exist.
*/
- public Person getPerson(Integer personId) throws FinderException
+ public Person getPerson(Integer personId)
+ throws FinderException
{
Connection connection = null;
IStatement statement = null;
@@ -407,8 +412,7 @@
set = statement.executeQuery();
- if (!set.next())
- throw new FinderException("Person #" + personId + " does not exist.");
+ if (!set.next()) throw new FinderException("Person #" + personId + " does not exist.");
Object[] columns = new Object[Person.N_COLUMNS];
result = convertRowToPerson(set, columns);
@@ -426,7 +430,8 @@
return result;
}
- public Person login(String email, String password) throws RemoteException, LoginException
+ public Person login(String email, String password)
+ throws RemoteException, LoginException
{
IPersonHome home = getPersonHome();
IPerson person = null;
@@ -441,20 +446,18 @@
throw new LoginException("Unknown e-mail address.", false);
}
- if (!person.getPassword().equals(password))
- throw new LoginException("Invalid password.", true);
+ if (!person.getPassword().equals(password)) throw new LoginException("Invalid password.", true);
try
{
- result = getPerson((Integer) person.getPrimaryKey());
+ result = getPerson((Integer)person.getPrimaryKey());
}
catch (FinderException ex)
{
throw new LoginException("Could not read person.", false);
}
- if (result.isLockedOut())
- throw new LoginException("You have been locked out of the Virtual Library.", false);
+ if (result.isLockedOut()) throw new LoginException("You have been locked out of the Virtual Library.", false);
// Set the last access time for any subsequent login.
@@ -463,7 +466,8 @@
return result;
}
- public Map getPersonAttributes(Integer personId) throws FinderException, RemoteException
+ public Map getPersonAttributes(Integer personId)
+ throws FinderException, RemoteException
{
IPersonHome home = getPersonHome();
@@ -479,7 +483,8 @@
* if the Book does not exist.
*/
- public Book getBook(Integer bookId) throws FinderException
+ public Book getBook(Integer bookId)
+ throws FinderException
{
Connection connection = null;
IStatement statement = null;
@@ -500,8 +505,7 @@
set = statement.executeQuery();
- if (!set.next())
- throw new FinderException("Book " + bookId + " does not exist.");
+ if (!set.next()) throw new FinderException("Book " + bookId + " does not exist.");
Object[] columns = new Object[Book.N_COLUMNS];
result = convertRowToBook(set, columns);
@@ -519,7 +523,8 @@
return result;
}
- public Map getBookAttributes(Integer bookId) throws FinderException, RemoteException
+ public Map getBookAttributes(Integer bookId)
+ throws FinderException, RemoteException
{
IBookHome home = getBookHome();
@@ -529,12 +534,12 @@
}
/**
- * Attempts to register a new user, first checking that the e-mail and names are unique. Returns
- * the primary key of the new {@link IPerson}.
+ * Attempts to register a new user, first checking that the e-mail and names
+ * are unique. Returns the primary key of the new {@link IPerson}.
*/
public Person registerNewUser(String firstName, String lastName, String email, String password)
- throws RegistrationException, CreateException, RemoteException
+ throws RegistrationException, CreateException, RemoteException
{
IPersonHome home;
@@ -555,7 +560,7 @@
IPerson person = home.create(attributes);
- Integer personId = (Integer) person.getPrimaryKey();
+ Integer personId = (Integer)person.getPrimaryKey();
try
{
@@ -567,7 +572,8 @@
}
}
- public Book deleteBook(Integer bookId) throws RemoveException, RemoteException
+ public Book deleteBook(Integer bookId)
+ throws RemoveException, RemoteException
{
IBookHome home = getBookHome();
Book result = null;
@@ -591,14 +597,12 @@
* Transfers a number of books to a new owner.
*/
- public void transferBooks(Integer newOwnerId, Integer[] bookIds) throws FinderException,
- RemoteException
+ public void transferBooks(Integer newOwnerId, Integer[] bookIds)
+ throws FinderException, RemoteException
{
- if (bookIds == null)
- throw new RemoteException("Must supply non-null list of books to transfer.");
+ if (bookIds == null) throw new RemoteException("Must supply non-null list of books to transfer.");
- if (newOwnerId == null)
- throw new RemoteException("Must provide an owner for the books.");
+ if (newOwnerId == null) throw new RemoteException("Must provide an owner for the books.");
// Verify that the new owner exists.
@@ -609,7 +613,7 @@
IBookHome home = getBookHome();
- for (int i = 0; i < bookIds.length; i++)
+ for(int i = 0; i < bookIds.length; i++)
{
IBook book = home.findByPrimaryKey(bookIds[i]);
@@ -617,14 +621,14 @@
}
}
- public void updatePublishers(Publisher[] updated, Integer[] deleted) throws FinderException,
- RemoveException, RemoteException
+ public void updatePublishers(Publisher[] updated, Integer[] deleted)
+ throws FinderException, RemoveException, RemoteException
{
IPublisherHome home = getPublisherHome();
if (updated != null)
{
- for (int i = 0; i < updated.length; i++)
+ for(int i = 0; i < updated.length; i++)
{
IPublisher publisher = home.findByPrimaryKey(updated[i].getId());
publisher.setName(updated[i].getName());
@@ -633,22 +637,22 @@
if (deleted != null)
{
- for (int i = 0; i < deleted.length; i++)
+ for(int i = 0; i < deleted.length; i++)
{
home.remove(deleted[i]);
}
}
}
- public void updatePersons(Person[] updated, Integer[] resetPassword, String newPassword,
- Integer[] deleted, Integer adminId) throws FinderException, RemoveException,
- RemoteException
+ public void updatePersons(Person[] updated, Integer[] resetPassword, String newPassword, Integer[] deleted,
+ Integer adminId)
+ throws FinderException, RemoveException, RemoteException
{
IPersonHome home = getPersonHome();
int count = Tapestry.size(updated);
- for (int i = 0; i < count; i++)
+ for(int i = 0; i < count; i++)
{
Person u = updated[i];
IPerson person = home.findByPrimaryKey(u.getId());
@@ -659,7 +663,7 @@
count = Tapestry.size(resetPassword);
- for (int i = 0; i < count; i++)
+ for(int i = 0; i < count; i++)
{
IPerson person = home.findByPrimaryKey(resetPassword[i]);
@@ -674,16 +678,17 @@
moveBooksFromDeletedPersons(deleted, adminId);
}
- for (int i = 0; i < count; i++)
+ for(int i = 0; i < count; i++)
home.remove(deleted[i]);
}
/**
- * Invoked to update all books owned by people about to be deleted, to reassign the books holder
- * back to the owner.
+ * Invoked to update all books owned by people about to be deleted, to
+ * reassign the books holder back to the owner.
*/
- private void returnBooksFromDeletedPersons(Integer deletedPersonIds[]) throws RemoveException
+ private void returnBooksFromDeletedPersons(Integer deletedPersonIds[])
+ throws RemoveException
{
StatementAssembly assembly = new StatementAssembly();
@@ -701,7 +706,7 @@
*/
private void moveBooksFromDeletedPersons(Integer deletedPersonIds[], Integer adminId)
- throws RemoveException
+ throws RemoveException
{
StatementAssembly assembly = new StatementAssembly();
@@ -716,7 +721,8 @@
}
- private void executeUpdate(StatementAssembly assembly) throws XRemoveException
+ private void executeUpdate(StatementAssembly assembly)
+ throws XRemoveException
{
Connection connection = null;
IStatement statement = null;
@@ -751,7 +757,8 @@
* This works with queries generated by {@link #buildBaseBookQuery()}.
*/
- protected Book convertRowToBook(ResultSet set, Object[] columns) throws SQLException
+ protected Book convertRowToBook(ResultSet set, Object[] columns)
+ throws SQLException
{
int column = 1;
@@ -760,11 +767,9 @@
columns[Book.DESCRIPTION_COLUMN] = set.getString(column++);
columns[Book.ISBN_COLUMN] = set.getString(column++);
columns[Book.OWNER_ID_COLUMN] = set.getObject(column++);
- columns[Book.OWNER_NAME_COLUMN] = buildName(set.getString(column++), set
- .getString(column++));
+ columns[Book.OWNER_NAME_COLUMN] = buildName(set.getString(column++), set.getString(column++));
columns[Book.HOLDER_ID_COLUMN] = set.getObject(column++);
- columns[Book.HOLDER_NAME_COLUMN] = buildName(set.getString(column++), set
- .getString(column++));
+ columns[Book.HOLDER_NAME_COLUMN] = buildName(set.getString(column++), set.getString(column++));
columns[Book.PUBLISHER_ID_COLUMN] = set.getObject(column++);
columns[Book.PUBLISHER_NAME_COLUMN] = set.getString(column++);
columns[Book.AUTHOR_COLUMN] = set.getString(column++);
@@ -777,29 +782,27 @@
private String buildName(String firstName, String lastName)
{
- if (firstName == null)
- return lastName;
+ if (firstName == null) return lastName;
return firstName + " " + lastName;
}
/**
* All queries must use this exact set of select columns, so that
- * {@link #convertRow(ResultSet, Object[])} can build the correct {@link Book} from each row.
+ * {@link #convertRow(ResultSet, Object[])} can build the correct
+ * {@link Book} from each row.
*/
- private static final String[] BOOK_SELECT_COLUMNS =
- { "book.BOOK_ID", "book.TITLE", "book.DESCRIPTION", "book.ISBN", "owner.PERSON_ID",
- "owner.FIRST_NAME", "owner.LAST_NAME", "holder.PERSON_ID", "holder.FIRST_NAME",
- "holder.LAST_NAME", "publisher.PUBLISHER_ID", "publisher.NAME", "book.AUTHOR",
+ private static final String[] BOOK_SELECT_COLUMNS = { "book.BOOK_ID", "book.TITLE", "book.DESCRIPTION",
+ "book.ISBN", "owner.PERSON_ID", "owner.FIRST_NAME", "owner.LAST_NAME", "holder.PERSON_ID",
+ "holder.FIRST_NAME", "holder.LAST_NAME", "publisher.PUBLISHER_ID", "publisher.NAME", "book.AUTHOR",
"book.HIDDEN", "book.LENDABLE", "book.DATE_ADDED" };
- private static final String[] BOOK_ALIAS_COLUMNS =
- { "BOOK book", "PERSON owner", "PERSON holder", "PUBLISHER publisher" };
+ private static final String[] BOOK_ALIAS_COLUMNS = { "BOOK book", "PERSON owner", "PERSON holder",
+ "PUBLISHER publisher" };
- private static final String[] BOOK_JOINS =
- { "book.OWNER_ID = owner.PERSON_ID", "book.HOLDER_ID = holder.PERSON_ID",
- "book.PUBLISHER_ID = publisher.PUBLISHER_ID" };
+ private static final String[] BOOK_JOINS = { "book.OWNER_ID = owner.PERSON_ID",
+ "book.HOLDER_ID = holder.PERSON_ID", "book.PUBLISHER_ID = publisher.PUBLISHER_ID" };
private static final Map BOOK_SORT_ASCENDING = new HashMap();
@@ -814,8 +817,7 @@
BOOK_SORT_ASCENDING.put(SortColumn.AUTHOR, "book.AUTHOR");
BOOK_SORT_DESCENDING.put(SortColumn.TITLE, "book.TITLE DESC");
- BOOK_SORT_DESCENDING
- .put(SortColumn.HOLDER, "holder.LAST_NAME DESC, holder.FIRST_NAME DESC");
+ BOOK_SORT_DESCENDING.put(SortColumn.HOLDER, "holder.LAST_NAME DESC, holder.FIRST_NAME DESC");
BOOK_SORT_DESCENDING.put(SortColumn.OWNER, "owner.FIRST_NAME DESC, owner.LAST_NAME DESC");
BOOK_SORT_DESCENDING.put(SortColumn.PUBLISHER, "publisher.NAME DESC");
BOOK_SORT_DESCENDING.put(SortColumn.AUTHOR, "book.AUTHOR DESC");
@@ -838,12 +840,14 @@
}
/**
- * Adds a sort ordering clause to the statement. If ordering is null, orders by book title.
+ * Adds a sort ordering clause to the statement. If ordering is null, orders
+ * by book title.
*
* @param assembly
* to update
* @param ordering
- * defines the column to sort on, and the order (ascending or descending)
+ * defines the column to sort on, and the order (ascending or
+ * descending)
* @since 3.0
*/
@@ -857,7 +861,7 @@
Map sorts = ordering.isDescending() ? BOOK_SORT_DESCENDING : BOOK_SORT_ASCENDING;
- String term = (String) sorts.get(ordering.getColumn());
+ String term = (String)sorts.get(ordering.getColumn());
assembly.newLine("ORDER BY ");
assembly.add(term);
@@ -865,12 +869,10 @@
protected void addSubstringSearch(StatementAssembly assembly, String column, String value)
{
- if (value == null)
- return;
+ if (value == null) return;
String trimmed = value.trim();
- if (trimmed.length() == 0)
- return;
+ if (trimmed.length() == 0) return;
// Here's the McKoi dependency: LOWER() is a database-specific
// SQL function.
@@ -882,8 +884,8 @@
}
/**
- * Closes the resultSet (if not null), then the statement (if not null), then the Connection (if
- * not null). Exceptions are written to System.out.
+ * Closes the resultSet (if not null), then the statement (if not null),
+ * then the Connection (if not null). Exceptions are written to System.out.
*/
protected void close(Connection connection, IStatement statement, ResultSet resultSet)
@@ -936,7 +938,7 @@
{
Object raw = _environment.lookup("ejb/Person");
- _personHome = (IPersonHome) PortableRemoteObject.narrow(raw, IPersonHome.class);
+ _personHome = (IPersonHome)PortableRemoteObject.narrow(raw, IPersonHome.class);
}
catch (NamingException ex)
{
@@ -956,9 +958,7 @@
{
Object raw = _environment.lookup("ejb/Publisher");
- _publisherHome = (IPublisherHome) PortableRemoteObject.narrow(
- raw,
- IPublisherHome.class);
+ _publisherHome = (IPublisherHome)PortableRemoteObject.narrow(raw, IPublisherHome.class);
}
catch (NamingException e)
{
@@ -978,7 +978,7 @@
{
Object raw = _environment.lookup("ejb/Book");
- _bookHome = (IBookHome) PortableRemoteObject.narrow(raw, IBookHome.class);
+ _bookHome = (IBookHome)PortableRemoteObject.narrow(raw, IBookHome.class);
}
catch (NamingException e)
{
@@ -1025,7 +1025,8 @@
* This works with queries generated by {@link #buildBasePersonQuery()}.
*/
- protected Person convertRowToPerson(ResultSet set, Object[] columns) throws SQLException
+ protected Person convertRowToPerson(ResultSet set, Object[] columns)
+ throws SQLException
{
int column = 1;
@@ -1040,13 +1041,14 @@
return new Person(columns);
}
- private Boolean getBoolean(ResultSet set, int index) throws SQLException
+ private Boolean getBoolean(ResultSet set, int index)
+ throws SQLException
{
return set.getBoolean(index) ? Boolean.TRUE : Boolean.FALSE;
}
private void validateUniquePerson(String firstName, String lastName, String email)
- throws RegistrationException
+ throws RegistrationException
{
Connection connection = null;
IStatement statement = null;
@@ -1071,8 +1073,7 @@
statement = assembly.createStatement(connection);
set = statement.executeQuery();
- if (set.next())
- throw new RegistrationException("Email address is already in use by another user.");
+ if (set.next()) throw new RegistrationException("Email address is already in use by another user.");
close(null, statement, set);
@@ -1090,8 +1091,7 @@
statement = assembly.createStatement(connection);
set = statement.executeQuery();
- if (set.next())
- throw new RegistrationException("Name provided is already in use by another user.");
+ if (set.next()) throw new RegistrationException("Name provided is already in use by another user.");
}
catch (SQLException e)
@@ -1104,7 +1104,8 @@
}
}
- public Book returnBook(Integer bookId) throws RemoteException, FinderException
+ public Book returnBook(Integer bookId)
+ throws RemoteException, FinderException
{
IBookHome bookHome = getBookHome();
IBook book = bookHome.findByPrimaryKey(bookId);
@@ -1116,4 +1117,4 @@
return getBook(bookId);
}
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org