Commit c1931ff3 by Tuukka Kivilahti

Merge branch 'master' into barcodefuckup

Conflicts:
	code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
	code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/reader/ReaderView.java
2 parents 58505cc7 009690c8
Showing with 736 additions and 88 deletions
...@@ -36,14 +36,21 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -36,14 +36,21 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "ALTER TABLE products ALTER COLUMN vat TYPE NUMERIC(4,3)" }); dbUpdates.add(new String[] { "ALTER TABLE products ALTER COLUMN vat TYPE NUMERIC(4,3)" });
dbUpdates.add(new String[] { "ALTER TABLE actionlog_messages DROP COLUMN crew" }); dbUpdates.add(new String[] { "ALTER TABLE actionlog_messages DROP COLUMN crew" });
dbUpdates.add(new String[] { "delete from application_permissions where application ilike '%terminal%'" }); dbUpdates.add(new String[] { "delete from application_permissions where application ilike '%terminal%'" });
dbUpdates.add(new String[] { "DELETE TABLE card_barcode"}); dbUpdates.add(new String[] {
dbUpdates.add(new String[] { "ALTER TABLE printed_cards DROP COLUMN barcode;"}); "ALTER TABLE org_roles ADD ldap_role boolean not null default false",
dbUpdates.add(new String[] { "ALTER TABLE printed_cards DROP COLUMN rfid_uid;"}); "ALTER TABLE org_roles ADD ldap_weight integer NOT NULL default 100"
dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN event_users_id integer REFERENCES event_users(id) DEFAULT null;"}); });
dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN places_id integer REFERENCES places(id) DEFAULT null;"}); // barcodefuckup
dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN products_id integer REFERENCES products(id) DEFAULT null;"}); dbUpdates.add(new String[] {
dbUpdates.add(new String[] { "ALTER TABLE reader_events ADD COLUMN type text NOT NULL;"}); "DELETE TABLE card_barcode",
dbUpdates.add(new String[] { "ALTER TABLE reader_events DROP COLUMN gamepoint;"}); "ALTER TABLE printed_cards DROP COLUMN barcode;",
"ALTER TABLE printed_cards DROP COLUMN rfid_uid;",
"ALTER TABLE reader_events ADD COLUMN event_users_id integer REFERENCES event_users(id) DEFAULT null;",
"ALTER TABLE reader_events ADD COLUMN places_id integer REFERENCES places(id) DEFAULT null;",
"ALTER TABLE reader_events ADD COLUMN products_id integer REFERENCES products(id) DEFAULT null;",
"ALTER TABLE reader_events ADD COLUMN type text NOT NULL;",
"ALTER TABLE reader_events DROP COLUMN gamepoint;"
});
} }
......
package fi.codecrew.moya.beans;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.beanutil.LdapUserHandler;
import fi.codecrew.moya.model.LanEventPrivatePropertyKey;
/**
* Session Bean implementation class LdapBean
*/
@Stateless
@LocalBean
public class LdapBean implements LdapBeanLocal {
@EJB
private EventBean eventbean;
/**
* Default constructor.
*/
public LdapConnection getConnection() {
String ldapurl = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.LDAP_URL);
String userBase = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.LDAP_USER_OU);
String groupBase = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.LDAP_GROUP_OU);
LdapConnection conn = null;
if (ldapurl != null && !ldapurl.isEmpty() && userBase != null && !userBase.isEmpty() && groupBase != null && !groupBase.isEmpty()) {
String bindDn = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.LDAP_BIND_DN);
String bindPw = eventbean.getPrivatePropertyString(LanEventPrivatePropertyKey.LDAP_BIND_PW);
conn = new LdapConnection(ldapurl, userBase, groupBase, bindDn, bindPw);
}
return conn;
}
private static class LdapConnection extends LdapUserHandler
{
public LdapConnection(String ldapUri, String userBaseDn, String groupBaseDn, String mgmtUser, String mgmtPass) {
super(ldapUri, userBaseDn, groupBaseDn, mgmtUser, mgmtPass);
}
}
}
...@@ -113,9 +113,12 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -113,9 +113,12 @@ public class PlaceBean implements PlaceBeanLocal {
} }
/** /**
* Calculate the price of reserved places for the user Optional parameter newPlace can be given when the place is added to the price calculations; * Calculate the price of reserved places for the user Optional parameter
* newPlace can be given when the place is added to the price calculations;
* *
* User parameter can be used to select another user than the currently logged in user, but if user does not have enough rights an exception will be thrown * User parameter can be used to select another user than the currently
* logged in user, but if user does not have enough rights an exception will
* be thrown
* *
*/ */
...@@ -246,11 +249,23 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -246,11 +249,23 @@ public class PlaceBean implements PlaceBeanLocal {
// } // }
// logger.debug("timeouting places"); // logger.debug("timeouting places");
// placeFacade.releasePlaces(permbean.getCurrentUser()); // placeFacade.releasePlaces(permbean.getCurrentUser());
// } // }
@Override @Override
@RolesAllowed({ MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS }) @RolesAllowed({ MapPermission.S_BUY_PLACES, MapPermission.S_MANAGE_OTHERS })
public PlaceGroup buySelectedPlaces(EventUser user) throws BortalCatchableException { public PlaceGroup buySelectedPlaces(EventUser user) throws BortalCatchableException {
return buyOrReserveSelectedPlaces(user, true);
}
@Override
@RolesAllowed({ MapPermission.S_MANAGE_OTHERS })
public PlaceGroup reserveSelectedPlaces(EventUser eventuser) throws BortalCatchableException {
return buyOrReserveSelectedPlaces(eventuser, false);
}
/**
* Reserves places and creates accountevents for the places.
*/
public PlaceGroup buyOrReserveSelectedPlaces(EventUser user, boolean createAccountevents) throws BortalCatchableException {
if (user == null) { if (user == null) {
user = permbean.getCurrentUser(); user = permbean.getCurrentUser();
} else { } else {
...@@ -268,18 +283,19 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -268,18 +283,19 @@ public class PlaceBean implements PlaceBeanLocal {
} }
// PlaceGroup pg = pgbean.createPlaceGroup(user); // PlaceGroup pg = pgbean.createPlaceGroup(user);
if (!createAccountevents)
{
BigDecimal totalprice = addAndCalcPrice(user, null);
BigDecimal balance = user.getAccountBalance();
if (balance.compareTo(totalprice) < 0 && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) {
logger.info("User {} Could not buy things because account balance {} is too low for purchase {}", new Object[] { user, balance, totalprice });
return null;
}
BigDecimal totalprice = addAndCalcPrice(user, null); for (Entry<Product, Integer> line : getPlaceProductcount(places).entrySet()) {
BigDecimal balance = user.getAccountBalance(); productPBean.createAccountEvent(line.getKey(), new BigDecimal(line.getValue()), user, Calendar.getInstance());
if (balance.compareTo(totalprice) < 0 && !permbean.hasPermission(MapPermission.MANAGE_OTHERS)) { }
logger.info("User {} Could not buy things because account balance {} is too low for purchase {}", new Object[] { user, balance, totalprice });
return null;
}
for (Entry<Product, Integer> line : getPlaceProductcount(places).entrySet()) {
productPBean.createAccountEvent(line.getKey(), new BigDecimal(line.getValue()), user, Calendar.getInstance());
} }
PlaceGroup pg = new PlaceGroup(event, Calendar.getInstance(), Calendar.getInstance(), true); PlaceGroup pg = new PlaceGroup(event, Calendar.getInstance(), Calendar.getInstance(), true);
pg.setCreator(user); pg.setCreator(user);
pgfacade.create(pg); pgfacade.create(pg);
...@@ -596,4 +612,5 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -596,4 +612,5 @@ public class PlaceBean implements PlaceBeanLocal {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
} }
...@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory; ...@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.IAppPermission; import fi.codecrew.moya.enums.apps.IAppPermission;
import fi.codecrew.moya.enums.apps.UserPermission; import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.RoleFacade; import fi.codecrew.moya.facade.RoleFacade;
import fi.codecrew.moya.facade.UserFacade; import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.model.ApplicationPermission; import fi.codecrew.moya.model.ApplicationPermission;
...@@ -51,6 +52,11 @@ public class RoleBean implements RoleBeanLocal { ...@@ -51,6 +52,11 @@ public class RoleBean implements RoleBeanLocal {
@EJB @EJB
private UserFacade userFacade; private UserFacade userFacade;
@EJB
private EventUserFacade eventuserfacade;
private EventBeanLocal permbean;
// VIEW_ALL pitää olla että voidaan hakea roolien perusteella. // VIEW_ALL pitää olla että voidaan hakea roolien perusteella.
@Override @Override
@RolesAllowed({ UserPermission.S_READ_ROLES, UserPermission.S_VIEW_ALL }) @RolesAllowed({ UserPermission.S_READ_ROLES, UserPermission.S_VIEW_ALL })
...@@ -161,6 +167,27 @@ public class RoleBean implements RoleBeanLocal { ...@@ -161,6 +167,27 @@ public class RoleBean implements RoleBeanLocal {
return role; return role;
} }
private void checkRoleLdap()
{
}
@Override
@RolesAllowed(UserPermission.S_WRITE_ROLES)
public Role addRole(EventUser eventuser, Role role)
{
eventuser = eventuserfacade.reload(eventuser);
role = roleFacade.reload(role);
if (!eventuser.getRoles().contains(role)) {
eventuser.getRoles().add(role);
}
if (!role.getUsers().contains(eventuser)) {
role.getUsers().add(eventuser);
}
return role;
}
@Override @Override
@RolesAllowed(UserPermission.S_WRITE_ROLES) @RolesAllowed(UserPermission.S_WRITE_ROLES)
public void saveRoles(EventUser usr, List<Role> usersRoles) { public void saveRoles(EventUser usr, List<Role> usersRoles) {
......
...@@ -167,6 +167,8 @@ public class UserBean implements UserBeanLocal { ...@@ -167,6 +167,8 @@ public class UserBean implements UserBeanLocal {
// private EventUser currentEventuser; // private EventUser currentEventuser;
// private ArrayList<Role> currentEventuserRoles; // private ArrayList<Role> currentEventuserRoles;
// HUOMHUOM! Älä määrittele tätä UserBeanLocal interfacelle.
// Käytä Viewien puolelta findUsersRoles joka tarkistaa käyttäjän oikeudet ensin.
public Set<Role> localFindUsersRoles(EventUser u) { public Set<Role> localFindUsersRoles(EventUser u) {
// if (currentEventuser != null && u.equals(currentEventuser)) { // if (currentEventuser != null && u.equals(currentEventuser)) {
// logger.debug("Returnin cached eventuserroles for user {}: {}", // logger.debug("Returnin cached eventuserroles for user {}: {}",
...@@ -448,12 +450,6 @@ public class UserBean implements UserBeanLocal { ...@@ -448,12 +450,6 @@ public class UserBean implements UserBeanLocal {
// return userFacade.find(id); // return userFacade.find(id);
// } // }
@Override
@RolesAllowed(UserPermission.S_VIEW_ALL)
public SearchResult<User> getUsers(SearchQuery search) {
return userFacade.searchAllUsers(search);
}
// @Override // @Override
// public long getUsersCount(String search) { // public long getUsersCount(String search) {
// return userFacade.searchUserCount(search); // return userFacade.searchUserCount(search);
...@@ -683,17 +679,23 @@ public class UserBean implements UserBeanLocal { ...@@ -683,17 +679,23 @@ public class UserBean implements UserBeanLocal {
} }
@Override @Override
public SearchResult<User> getEventUsers(SearchQuery search) { @RolesAllowed(UserPermission.S_VIEW_ALL)
if (search.getSearch() == null || search.getSearch().isEmpty()) public SearchResult<User> getUsers(SearchQuery search) {
{ return userFacade.searchAllUsers(search);
throw new RuntimeException("You should be using getThisEventsUsers if not searching globally...");
// return userFacade.searchEventUsers(search);
} else {
return userFacade.searchAllUsers(search);
}
} }
// @Override
// public SearchResult<User> getEventUsers(SearchQuery search) {
// if (search.getSearch() == null || search.getSearch().isEmpty())
// {
// throw new RuntimeException("You should be using getThisEventsUsers if not searching globally...");
// // return userFacade.searchEventUsers(search);
// } else {
// return userFacade.searchAllUsers(search);
// }
//
// }
//
@Override @Override
public SearchResult<EventUser> getThisEventsUsers(UserSearchQuery searchQuery) { public SearchResult<EventUser> getThisEventsUsers(UserSearchQuery searchQuery) {
SearchResult<EventUser> returnUsers = eventUserFacade.searchEventUsers(searchQuery); SearchResult<EventUser> returnUsers = eventUserFacade.searchEventUsers(searchQuery);
...@@ -769,4 +771,9 @@ public class UserBean implements UserBeanLocal { ...@@ -769,4 +771,9 @@ public class UserBean implements UserBeanLocal {
return false; return false;
} }
@Override
public User getUser(Integer id) {
return userFacade.find(id);
}
} }
\ No newline at end of file
package fi.codecrew.moya.beans;
import javax.ejb.Local;
@Local
public interface LdapBeanLocal {
}
...@@ -63,10 +63,13 @@ public interface PlaceBeanLocal { ...@@ -63,10 +63,13 @@ public interface PlaceBeanLocal {
*/ */
byte[] generatePlacesPdf(float width, float height, double font1, double font2); byte[] generatePlacesPdf(float width, float height, double font1, double font2);
// public byte[] generatePlacesPdf(double width, double height, double font1, double font2); // public byte[] generatePlacesPdf(double width, double height, double font1, double font2);
List<GroupMembership> matchGroupMembershipsByInviteToken(String token); List<GroupMembership> matchGroupMembershipsByInviteToken(String token);
GroupMembership findGroupMembershipsByToken(String token); GroupMembership findGroupMembershipsByToken(String token);
PlaceGroup reserveSelectedPlaces(EventUser eventuser) throws BortalCatchableException;
} }
...@@ -36,4 +36,6 @@ public interface RoleBeanLocal { ...@@ -36,4 +36,6 @@ public interface RoleBeanLocal {
public List<Role> getRoles(EventUser selectedUser); public List<Role> getRoles(EventUser selectedUser);
Role addRole(EventUser eventuser, Role role);
} }
...@@ -26,7 +26,7 @@ public interface UserBeanLocal { ...@@ -26,7 +26,7 @@ public interface UserBeanLocal {
SearchResult<User> getUsers(SearchQuery search); SearchResult<User> getUsers(SearchQuery search);
SearchResult<User> getEventUsers(SearchQuery search); //SearchResult<User> getEventUsers(SearchQuery search);
EventUser mergeChanges(EventUser user); EventUser mergeChanges(EventUser user);
...@@ -40,6 +40,8 @@ public interface UserBeanLocal { ...@@ -40,6 +40,8 @@ public interface UserBeanLocal {
boolean resetPassword(User user, String password, String hash); boolean resetPassword(User user, String password, String hash);
public User getUser(Integer id);
/** /**
* Search EventUser entity by User entity ID * Search EventUser entity by User entity ID
* *
......
...@@ -22,6 +22,14 @@ public class UserSearchQuery extends SearchQuery { ...@@ -22,6 +22,14 @@ public class UserSearchQuery extends SearchQuery {
private BigDecimal accountSaldo; private BigDecimal accountSaldo;
private DatabaseValueCompare accountSaldoCompare = DatabaseValueCompare.NONE; private DatabaseValueCompare accountSaldoCompare = DatabaseValueCompare.NONE;
public UserSearchQuery() {
super();
}
public UserSearchQuery(int page, int pagesize, String sort, String search, QuerySortOrder direction) {
super(page, pagesize, sort, search, direction);
}
public DatabaseValueCompare[] getAccountCompareValues() public DatabaseValueCompare[] getAccountCompareValues()
{ {
return DatabaseValueCompare.values(); return DatabaseValueCompare.values();
...@@ -38,11 +46,11 @@ public class UserSearchQuery extends SearchQuery { ...@@ -38,11 +46,11 @@ public class UserSearchQuery extends SearchQuery {
public boolean isUsersWithUnusedCodes() { public boolean isUsersWithUnusedCodes() {
return usersWithUnusedCodes; return usersWithUnusedCodes;
} }
public void setUsersWithUnusedCodes(boolean usersWithUnusedCodes) { public void setUsersWithUnusedCodes(boolean usersWithUnusedCodes) {
this.usersWithUnusedCodes = usersWithUnusedCodes; this.usersWithUnusedCodes = usersWithUnusedCodes;
} }
public List<Role> getFilterRoles() { public List<Role> getFilterRoles() {
return filterRoles; return filterRoles;
} }
......
...@@ -107,7 +107,7 @@ public class EventUser extends GenericEntity { ...@@ -107,7 +107,7 @@ public class EventUser extends GenericEntity {
@OneToMany(mappedBy = "eventUser") @OneToMany(mappedBy = "eventUser")
private List<GameID> gameIDs; private List<GameID> gameIDs;
public List<GameID> getGameIDs() { public List<GameID> getGameIDs() {
return gameIDs; return gameIDs;
} }
...@@ -115,7 +115,7 @@ public class EventUser extends GenericEntity { ...@@ -115,7 +115,7 @@ public class EventUser extends GenericEntity {
public void setGameIDs(List<GameID> gameIDs) { public void setGameIDs(List<GameID> gameIDs) {
this.gameIDs = gameIDs; this.gameIDs = gameIDs;
} }
public EventUser getCreator() { public EventUser getCreator() {
return creator; return creator;
} }
...@@ -449,11 +449,9 @@ public class EventUser extends GenericEntity { ...@@ -449,11 +449,9 @@ public class EventUser extends GenericEntity {
return ret; return ret;
} }
public String getShortUserDescriptor() { public String getShortUserDescriptor() {
StringBuilder sb = new StringBuilder(); return user.getShortUserDescriptor();
sb.append(getNick()).append(" // ").append(getWholeName()).append(" // ").append(getEmail());
return sb.toString();
} }
} }
...@@ -8,6 +8,11 @@ public enum LanEventPrivatePropertyKey { ...@@ -8,6 +8,11 @@ public enum LanEventPrivatePropertyKey {
CHECKOUT_FI_MERCHANT_PASSWORD(Type.TEXT, null), CHECKOUT_FI_MERCHANT_PASSWORD(Type.TEXT, null),
CHECKOUT_FI_MERCHANT_ID(Type.TEXT, null), CHECKOUT_FI_MERCHANT_ID(Type.TEXT, null),
CHECKOUT_FI_KEY_EXPIRE(Type.DATE, null), CHECKOUT_FI_KEY_EXPIRE(Type.DATE, null),
LDAP_URL(Type.TEXT, null),
LDAP_BIND_DN(Type.TEXT, null),
LDAP_BIND_PW(Type.TEXT, null),
LDAP_USER_OU(Type.TEXT, null),
LDAP_GROUP_OU(Type.TEXT, null),
; ;
private enum Type { private enum Type {
......
...@@ -57,6 +57,28 @@ public class OrgRole extends GenericEntity { ...@@ -57,6 +57,28 @@ public class OrgRole extends GenericEntity {
@ManyToMany(mappedBy = "orgRoles") @ManyToMany(mappedBy = "orgRoles")
private List<Role> eventRoles; private List<Role> eventRoles;
@Column(name = "ldap_role", nullable = false)
private boolean ldapRole = false;
@Column(name = "ldap_weight", nullable = false)
private int ldapWeight = 100;
public boolean isLdapRole() {
return ldapRole;
}
public void setLdapRole(boolean ldapRole) {
this.ldapRole = ldapRole;
}
public int getLdapWeight() {
return ldapWeight;
}
public void setLdapWeight(int ldapWeight) {
this.ldapWeight = ldapWeight;
}
public OrgRole() { public OrgRole() {
super(); super();
} }
......
...@@ -14,7 +14,6 @@ import javax.persistence.EnumType; ...@@ -14,7 +14,6 @@ import javax.persistence.EnumType;
import javax.persistence.Enumerated; import javax.persistence.Enumerated;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.OrderBy; import javax.persistence.OrderBy;
...@@ -409,4 +408,10 @@ public class User extends GenericEntity implements IUser { ...@@ -409,4 +408,10 @@ public class User extends GenericEntity implements IUser {
return age; return age;
} }
public String getShortUserDescriptor() {
StringBuilder sb = new StringBuilder();
sb.append(getNick()).append(" // ").append(getWholeName()).append(" // ").append(getEmail());
return sb.toString();
}
} }
package fi.codecrew.moya.utilities;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
* Copyright Iudex / Tuomas Riihimäki
*
*/
public class ByteUtils {
public static int parseUnsigned(byte... b) {
if (b.length > 4) {
throw new RuntimeException("Integer should never have more than 4 bytes!");
}
return new BigInteger(1, b).intValue();
}
public static Long parseUnsignedLong(byte[] b) {
if (b.length > 8) {
throw new RuntimeException("Long should never have more than 4 bytes!");
}
return new BigInteger(1, b).longValue();
}
public static short parseSigned(byte b0, byte b1) {
return (short) (((b0 & 0xff) << 8) | (b1 & 0xff));
}
public static Integer parseSignedO(byte b, byte c) {
return Integer.valueOf(parseSigned(b, c));
}
public static Integer parseSigned(byte b1, byte b2, byte b3, byte b4) {
return (b1 & 0xff) << 24 | (b2 & 0xff) << 16 | (b3 & 0xff) << 8 | (b4 & 0xff);
}
public static void main(String[] ads)
{
System.out.println(parseUnsigned((byte) 0x31, (byte) 0x79));
// System.out.println(parseSignedDecimal("+5.123"));
// System.out.println(parseSignedDecimal("-5.123"));
// System.out.println(parseSignedDecimal(" - 5123"));
// System.out.println(parseSignedDecimal(null));
// System.out.println(parseSignedDecimal(""));
// System.out.println(parseSignedDecimal(" "));
}
public static BigDecimal parseSignedDecimal(String number) {
if (number == null || (number = number.trim()).isEmpty()) {
return null;
}
number = number.trim();
char firstChar = number.charAt(0);
boolean signPositive = true;
switch (firstChar) {
case '-':
signPositive = false;
case '+':
number = number.substring(1).trim();
}
BigDecimal ret = new BigDecimal(number);
if (!signPositive) {
ret = ret.negate();
}
return ret;
}
// public static int parseSignedInt(byte... b) {
// if (b.length > 4) {
// throw new
// RuntimeException("Integer should never have more than 4 bytes!");
// }
// // return new BigInteger(1, b).intValue();
//
// int value = (b[b.length - 1] & 0xff);
// if (b.length > 1) {
// value |= (b[b.length - 2] & 0xff) << 8;
// }
// if (b.length > 2) {
// value |= (b[b.length - 3] & 0xff) << 16;
// }
// if (b.length > 3) {
// value |= (b[b.length - 4] & 0xff) << 24;
// }
// return value;
// }
/**
* Copies the integer value to four bytes in the destination bytearray beginning from the offset
*
* Notice! This function handles signed integers: -1 -> 0xff 0xff 0xff 0xff
*
* @param dst
* @param offset
* @param value
*/
public static void intToBytearray(byte[] dst, int offset, int value) {
dst[offset++] = (byte) (value >>> 24);
dst[offset++] = (byte) (value >>> 16);
dst[offset++] = (byte) (value >>> 8);
dst[offset] = (byte) (value);
}
public static byte[] toArray(int... bytes) {
byte[] ret = new byte[bytes.length];
for (int i = 0; i < bytes.length; ++i) {
ret[i] = (byte) (bytes[i]);
}
return ret;
}
public static String toHexString(byte[] bytes) {
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
int val = ((int) b) & 0xff;
if (val < 0x10)
sb.append("0");
sb.append(Integer.toHexString(val));
}
return sb.toString();
}
}
package fi.codecrew.moya.utilities;
import java.security.MessageDigest;
public class MD4Digest extends MessageDigest {
/**
* The size in bytes of the input block to the tranformation algorithm.
*/
private static final int BLOCK_LENGTH = 64; // = 512 / 8;
/**
* 4 32-bit words (interim result)
*/
private int[] context = new int[4];
/**
* Number of bytes processed so far mod. 2 power of 64.
*/
private long count;
/**
* 512 bits input buffer = 16 x 32-bit words holds until reaches 512 bits.
*/
private byte[] buffer = new byte[BLOCK_LENGTH];
/**
* 512 bits work buffer = 16 x 32-bit words
*/
private int[] X = new int[16];
public MD4Digest() {
super("MD4");
engineReset();
}
@Override
public void engineUpdate(byte b) {
int i = (int) (count % BLOCK_LENGTH);
count++;
buffer[i] = b;
if (i == BLOCK_LENGTH - 1)
transform(buffer, 0);
}
@Override
protected void engineUpdate(byte[] input, int offset, int len) {
// make sure we don't exceed input's allocated size/length
if (offset < 0 || len < 0 || (long) offset + len > input.length)
throw new ArrayIndexOutOfBoundsException();
// compute number of bytes still unhashed; ie. present in buffer
int bufferNdx = (int) (count % BLOCK_LENGTH);
count += len; // update number of bytes
int partLen = BLOCK_LENGTH - bufferNdx;
int i = 0;
if (len >= partLen) {
System.arraycopy(input, offset, buffer, bufferNdx, partLen);
transform(buffer, 0);
for (i = partLen; i + BLOCK_LENGTH - 1 < len; i += BLOCK_LENGTH)
transform(input, offset + i);
bufferNdx = 0;
}
// buffer remaining input
if (i < len)
System.arraycopy(input, offset + i, buffer, bufferNdx, len - i);
}
@Override
protected byte[] engineDigest() {
// pad output to 56 mod 64; as RFC1320 puts it: congruent to 448 mod 512
int bufferNdx = (int) (count % BLOCK_LENGTH);
int padLen = (bufferNdx < 56) ? (56 - bufferNdx) : (120 - bufferNdx);
// padding is alwas binary 1 followed by binary 0s
byte[] tail = new byte[padLen + 8];
tail[0] = (byte) 0x80;
// append length before final transform:
// save number of bits, casting the long to an array of 8 bytes
// save low-order byte first.
for (int i = 0; i < 8; i++)
tail[padLen + i] = (byte) ((count * 8) >>> (8 * i));
engineUpdate(tail, 0, tail.length);
byte[] result = new byte[16];
// cast this MD4's context (array of 4 ints) into an array of 16 bytes.
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
result[i * 4 + j] = (byte) (context[i] >>> (8 * j));
// reset the engine
engineReset();
return result;
}
@Override
protected void engineReset() {
// initial values of MD4 i.e. A, B, C, D
// as per rfc-1320; they are low-order byte first
context[0] = 0x67452301;
context[1] = 0xEFCDAB89;
context[2] = 0x98BADCFE;
context[3] = 0x10325476;
count = 0L;
for (int i = 0; i < BLOCK_LENGTH; i++)
buffer[i] = 0;
}
/**
* MD4 basic transformation.
* <p>
* Transforms context based on 512 bits from input block starting from the offset'th byte.
*
* @param block
* input sub-array.
* @param offset
* starting position of sub-array.
*/
private void transform(byte[] block, int offset) {
// encodes 64 bytes from input block into an array of 16 32-bit
// entities. Use A as a temp var.
for (int i = 0; i < 16; i++)
X[i] = (block[offset++] & 0xFF) |
(block[offset++] & 0xFF) << 8 |
(block[offset++] & 0xFF) << 16 |
(block[offset++] & 0xFF) << 24;
int A = context[0];
int B = context[1];
int C = context[2];
int D = context[3];
A = FF(A, B, C, D, X[0], 3);
D = FF(D, A, B, C, X[1], 7);
C = FF(C, D, A, B, X[2], 11);
B = FF(B, C, D, A, X[3], 19);
A = FF(A, B, C, D, X[4], 3);
D = FF(D, A, B, C, X[5], 7);
C = FF(C, D, A, B, X[6], 11);
B = FF(B, C, D, A, X[7], 19);
A = FF(A, B, C, D, X[8], 3);
D = FF(D, A, B, C, X[9], 7);
C = FF(C, D, A, B, X[10], 11);
B = FF(B, C, D, A, X[11], 19);
A = FF(A, B, C, D, X[12], 3);
D = FF(D, A, B, C, X[13], 7);
C = FF(C, D, A, B, X[14], 11);
B = FF(B, C, D, A, X[15], 19);
A = GG(A, B, C, D, X[0], 3);
D = GG(D, A, B, C, X[4], 5);
C = GG(C, D, A, B, X[8], 9);
B = GG(B, C, D, A, X[12], 13);
A = GG(A, B, C, D, X[1], 3);
D = GG(D, A, B, C, X[5], 5);
C = GG(C, D, A, B, X[9], 9);
B = GG(B, C, D, A, X[13], 13);
A = GG(A, B, C, D, X[2], 3);
D = GG(D, A, B, C, X[6], 5);
C = GG(C, D, A, B, X[10], 9);
B = GG(B, C, D, A, X[14], 13);
A = GG(A, B, C, D, X[3], 3);
D = GG(D, A, B, C, X[7], 5);
C = GG(C, D, A, B, X[11], 9);
B = GG(B, C, D, A, X[15], 13);
A = HH(A, B, C, D, X[0], 3);
D = HH(D, A, B, C, X[8], 9);
C = HH(C, D, A, B, X[4], 11);
B = HH(B, C, D, A, X[12], 15);
A = HH(A, B, C, D, X[2], 3);
D = HH(D, A, B, C, X[10], 9);
C = HH(C, D, A, B, X[6], 11);
B = HH(B, C, D, A, X[14], 15);
A = HH(A, B, C, D, X[1], 3);
D = HH(D, A, B, C, X[9], 9);
C = HH(C, D, A, B, X[5], 11);
B = HH(B, C, D, A, X[13], 15);
A = HH(A, B, C, D, X[3], 3);
D = HH(D, A, B, C, X[11], 9);
C = HH(C, D, A, B, X[7], 11);
B = HH(B, C, D, A, X[15], 15);
context[0] += A;
context[1] += B;
context[2] += C;
context[3] += D;
}
private int FF(int a, int b, int c, int d, int x, int s) {
int t = a + ((b & c) | (~b & d)) + x;
return t << s | t >>> (32 - s);
}
private int GG(int a, int b, int c, int d, int x, int s) {
int t = a + ((b & (c | d)) | (c & d)) + x + 0x5A827999;
return t << s | t >>> (32 - s);
}
private int HH(int a, int b, int c, int d, int x, int s) {
int t = a + (b ^ c ^ d) + x + 0x6ED9EBA1;
return t << s | t >>> (32 - s);
}
}
package fi.codecrew.moya.utilities;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Copyright Iudex / Tuomas Riihimäki
*
*/
public class NTLMFunctions {
private static final Charset UTF16LE_ENCODING = Charset.forName("UTF-16LE");
private static final Logger logger = LoggerFactory.getLogger(NTLMFunctions.class);
public static String getNTHash(String passAttr)
{
StringBuilder pwd = new StringBuilder();
// pwd.append('"');
pwd.append(passAttr);
// pwd.append('"');
String ret = null;
try {
byte pwdBytes[] = pwd.toString().getBytes(UTF16LE_ENCODING);
//MD4 algo = new MD4();
MessageDigest algo = new MD4Digest();
byte[] bytes = algo.digest(pwdBytes);
ret = ByteUtils.toHexString(bytes);
//logger.info("hex: {}", ret);
} finally {
}
return ret;
}
}
...@@ -20,12 +20,13 @@ public class SearchQuery implements Serializable { ...@@ -20,12 +20,13 @@ public class SearchQuery implements Serializable {
super(); super();
} }
public SearchQuery(int page, int pagesize, String sort, String search, boolean direction) { public SearchQuery(int page, int pagesize, String sort, String search, QuerySortOrder direction) {
super(); super();
this.page = page; this.page = page;
this.pagesize = pagesize; this.pagesize = pagesize;
this.sort = sort; this.sort = sort;
this.search = search; this.search = search;
this.sortDirection = direction;
} }
public int getPage() { public int getPage() {
...@@ -42,14 +43,15 @@ public class SearchQuery implements Serializable { ...@@ -42,14 +43,15 @@ public class SearchQuery implements Serializable {
} }
public int getPagesize() { public int getPagesize() {
if (pagesize < 1) {
pagesize = 20;
}
return pagesize; return pagesize;
} }
public void setPagesize(int pagesize) { public void setPagesize(int pagesize) {
this.pagesize = pagesize; if (pagesize < 1)
pagesize = 20;
else
this.pagesize = pagesize;
} }
public String getSort() { public String getSort() {
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:role="http://java.sun.com/jsf/composite/tools/role"> xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:role="http://java.sun.com/jsf/composite/tools/role">
<composite:interface> <composite:interface>
...@@ -10,6 +11,7 @@ ...@@ -10,6 +11,7 @@
<composite:implementation> <composite:implementation>
<p> <p>
<h:form id="roleform"> <h:form id="roleform">
<f:facet name="errorMessage"> <f:facet name="errorMessage">
...@@ -20,33 +22,65 @@ ...@@ -20,33 +22,65 @@
</h:form> </h:form>
</p> </p>
<h2>#{i18n['role.permissionheader']}</h2> <h:form id="addmember">
<p> <h:outputText value="#{i18n['roleView.adduser']}" />
<h:form id="permissionform">
<h:commandButton id="save1" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" /> <p:autoComplete id="useradder" value="#{roleView.addableUser}" completeMethod="#{roleView.searchUser}" converter="#{userConverter}" var="usr" itemValue="#{usr}"
<h:dataTable border="1" id="bortalApps" value="#{roleView.rolePermissions}" var="bapp"> itemLabel="#{usr.shortUserDescriptor}">
<h:column> <p:ajax onerror="location.reload(true);" update=":editor:addmember,:editor:memberlist" event="itemSelect" listener="#{roleView.addUser}" />
<f:facet name="header"> </p:autoComplete>
<h:outputText value="#{i18n['applicationPermission.name']}" />
</f:facet>
<h:outputText value="#{bapp.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['applicationPermission.description']}" />
</f:facet>
<h:outputText value="#{i18n[bapp.key]}" />
</h:column>
<h:column>
<h:selectManyCheckbox id="permissions" layout="pageDirection" value="#{bapp.selected}">
<f:selectItems value="#{bapp.permissions}" var="per" itemLabel="#{i18n[per.i18nKey]}" />
</h:selectManyCheckbox>
</h:column>
</h:dataTable>
<h:commandButton id="save2" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" />
</h:form> </h:form>
</p> <h:dataTable id="memberlist" value="#{roleView.role.users}" var="usr">
<h:column>
<h:outputText value="#{usr.login}" />
</h:column>
<h:column>
<h:outputText value="#{usr.nick}" />
</h:column>
<h:column>
<h:outputText value="#{usr.wholeName}" />
</h:column>
<h:column>
<h:outputText value="#{usr.email}" />
</h:column>
</h:dataTable>
<button id="roledisplayer" onclick='$("#roleeditor").show(); $(this).hide();'>#{i18n['role.showPermissioneditor']}</button>
<div id="roleeditor" style="display: none">
<button onclick='$("#roleeditor").hide(); $("#roledisplayer").show();'>#{i18n['role.hidePermissioneditor']}</button>
<h2>#{i18n['role.permissionheader']}</h2>
<p>
<h:form id="permissionform">
<h:commandButton id="save1" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" />
<h:dataTable border="1" id="bortalApps" value="#{roleView.rolePermissions}" var="bapp">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['applicationPermission.name']}" />
</f:facet>
<h:outputText value="#{bapp.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['applicationPermission.description']}" />
</f:facet>
<h:outputText value="#{i18n[bapp.key]}" />
</h:column>
<h:column>
<h:selectManyCheckbox id="permissions" layout="pageDirection" value="#{bapp.selected}">
<f:selectItems value="#{bapp.permissions}" var="per" itemLabel="#{i18n[per.i18nKey]}" />
</h:selectManyCheckbox>
</h:column>
</h:dataTable>
<h:commandButton id="save2" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" />
</h:form>
</p>
</div>
</composite:implementation> </composite:implementation>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<f:event type="preRenderView" listener="#{roleView.initViewFromId()}" /> <f:event type="preRenderView" listener="#{roleView.initViewFromId()}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<role:edit /> <role:edit id="editor"/>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -150,7 +150,7 @@ public class MapAdminView { ...@@ -150,7 +150,7 @@ public class MapAdminView {
if (placebean.reservePlace(place, eventuser)) if (placebean.reservePlace(place, eventuser))
{ {
try { try {
placebean.buySelectedPlaces(eventuser); placebean.reserveSelectedPlaces(eventuser);
return Response.ok().build(); return Response.ok().build();
} catch (BortalCatchableException e) { } catch (BortalCatchableException e) {
logger.warn("Wtf! Bortalerror"); logger.warn("Wtf! Bortalerror");
......
...@@ -12,6 +12,7 @@ import fi.codecrew.moya.beans.UserBeanLocal; ...@@ -12,6 +12,7 @@ import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.rest.pojo.SimpleEventuserRoot; import fi.codecrew.moya.rest.pojo.SimpleEventuserRoot;
import fi.codecrew.moya.util.UserSearchQuery; import fi.codecrew.moya.util.UserSearchQuery;
import fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder;
import fi.codecrew.moya.utilities.SearchResult; import fi.codecrew.moya.utilities.SearchResult;
@RequestScoped @RequestScoped
...@@ -26,10 +27,8 @@ public class UserRestView { ...@@ -26,10 +27,8 @@ public class UserRestView {
@GET @GET
@Path("/eventusers") @Path("/eventusers")
public SimpleEventuserRoot getEventUsers() { public SimpleEventuserRoot getEventUsers() {
UserSearchQuery q = new UserSearchQuery(); UserSearchQuery q = new UserSearchQuery(0, 0, null, null, QuerySortOrder.UNSORTED);
q.setPagesize(0);
SearchResult<EventUser> users = userbean.getThisEventsUsers(q); SearchResult<EventUser> users = userbean.getThisEventsUsers(q);
return SimpleEventuserRoot.parse(users.getResults()); return SimpleEventuserRoot.parse(users.getResults());
} }
} }
...@@ -24,6 +24,7 @@ import fi.codecrew.moya.model.Place; ...@@ -24,6 +24,7 @@ import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PlaceGroup; import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
import fi.codecrew.moya.utilities.SearchQuery; import fi.codecrew.moya.utilities.SearchQuery;
import fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder;
import fi.codecrew.moya.web.annotations.SelectedUser; import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
...@@ -158,7 +159,7 @@ public class PlaceView extends GenericCDIView { ...@@ -158,7 +159,7 @@ public class PlaceView extends GenericCDIView {
public String searchUser() { public String searchUser() {
super.beginConversation(); super.beginConversation();
userlist = new ListDataModel<User>(userbean.getUsers(new SearchQuery(0, 0, null, searchuser, false)).getResults()); userlist = new ListDataModel<User>(userbean.getUsers(new SearchQuery(0, 20, null, searchuser, QuerySortOrder.DESCENDING)).getResults());
return null; return null;
} }
......
...@@ -27,6 +27,7 @@ import fi.codecrew.moya.model.ReaderType; ...@@ -27,6 +27,7 @@ import fi.codecrew.moya.model.ReaderType;
import fi.codecrew.moya.model.Role; import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
import fi.codecrew.moya.utilities.SearchQuery; import fi.codecrew.moya.utilities.SearchQuery;
import fi.codecrew.moya.utilities.SearchQuery.QuerySortOrder;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.shop.UserCardWrapper; import fi.codecrew.moya.web.cdiview.shop.UserCardWrapper;
import fi.codecrew.moya.web.cdiview.user.UserView; import fi.codecrew.moya.web.cdiview.user.UserView;
...@@ -131,7 +132,24 @@ public class ReaderView extends GenericCDIView { ...@@ -131,7 +132,24 @@ public class ReaderView extends GenericCDIView {
logger.info("re {}", re.getPrintedCard()); logger.info("re {}", re.getPrintedCard());
userview.setUser(re.getPrintedCard().getUser()); userview.setUser(re.getPrintedCard().getUser());
return "/useradmin/edit"; return "/useradmin/edit";
}*/
}
public String searchforuser()
{
if (usersearch == null || usersearch.length() < 2) {
super.addFaceMessage("user.tooShortSearch");
} else {
userlist = UserCardWrapper.initWrapper(userbean.getUsers(new SearchQuery(0, 20, null, usersearch, QuerySortOrder.DESCENDING)).getResults(), userbean);
}
return null;
}
*/
public List<Product> getAutoProducts() { public List<Product> getAutoProducts() {
......
...@@ -15,11 +15,16 @@ import org.slf4j.LoggerFactory; ...@@ -15,11 +15,16 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.RoleBeanLocal; import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.BortalApplication; import fi.codecrew.moya.enums.BortalApplication;
import fi.codecrew.moya.enums.apps.IAppPermission; import fi.codecrew.moya.enums.apps.IAppPermission;
import fi.codecrew.moya.enums.apps.UserPermission; import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.ApplicationPermission; import fi.codecrew.moya.model.ApplicationPermission;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Role; import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.util.UserSearchQuery;
import fi.codecrew.moya.utilities.SearchResult;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.helpers.BortalApplicationWrapper; import fi.codecrew.moya.web.helpers.BortalApplicationWrapper;
...@@ -41,6 +46,10 @@ public class RoleView extends GenericCDIView { ...@@ -41,6 +46,10 @@ public class RoleView extends GenericCDIView {
private transient EventBeanLocal eventbean; private transient EventBeanLocal eventbean;
private ArrayList<BortalApplicationWrapper> rolePermissions; private ArrayList<BortalApplicationWrapper> rolePermissions;
@EJB
private UserBeanLocal userbean;
private User addableUser;
private static final Logger logger = LoggerFactory.getLogger(RoleView.class); private static final Logger logger = LoggerFactory.getLogger(RoleView.class);
...@@ -59,6 +68,23 @@ public class RoleView extends GenericCDIView { ...@@ -59,6 +68,23 @@ public class RoleView extends GenericCDIView {
} }
} }
public void addUser()
{
EventUser eu = userbean.getEventUser(addableUser);
role = rolebean.addRole(eu, role);
addableUser = null;
}
public List<User> searchUser(String user)
{
// By default this returns only 20 first results.
UserSearchQuery usq = new UserSearchQuery();
usq.setSearch(user);
usq.setOnlyThisEvent(false);
SearchResult<User> ret = userbean.getUsers(usq);
return ret.getResults();
}
public boolean isCanReadRoles() { public boolean isCanReadRoles() {
return permbean.hasPermission(UserPermission.READ_ROLES); return permbean.hasPermission(UserPermission.READ_ROLES);
} }
...@@ -170,4 +196,12 @@ public class RoleView extends GenericCDIView { ...@@ -170,4 +196,12 @@ public class RoleView extends GenericCDIView {
initPermissions(); initPermissions();
} }
public User getAddableUser() {
return addableUser;
}
public void setAddableUser(User addableUser) {
this.addableUser = addableUser;
}
} }
...@@ -76,11 +76,11 @@ public class UserSearchView extends PaginationView<User> { ...@@ -76,11 +76,11 @@ public class UserSearchView extends PaginationView<User> {
this.setRowCount(new Long(sr.getResultcount()).intValue()); this.setRowCount(new Long(sr.getResultcount()).intValue());
setResultcount(sr.getResultcount()); setResultcount(sr.getResultcount());
setEventUserResults(sr.getResults()); setEventUserResults(sr.getResults());
return sr.getResults(); return sr.getResults();
} }
@Override @Override
public void setRowIndex(int rowIndex) { public void setRowIndex(int rowIndex) {
if (getPageSize() == 0) { if (getPageSize() == 0) {
...@@ -99,7 +99,7 @@ public class UserSearchView extends PaginationView<User> { ...@@ -99,7 +99,7 @@ public class UserSearchView extends PaginationView<User> {
this.setEventUserResults(eventusers.getResults()); this.setEventUserResults(eventusers.getResults());
} }
else { else {
super.setResult(userbean.getEventUsers(getSearchQuery())); super.setResult(userbean.getUsers(getSearchQuery()));
} }
super.beginConversation(); super.beginConversation();
} }
......
package fi.codecrew.moya.web.converter;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.utilities.jsf.GenericIntegerEntityConverter;
@Named
@RequestScoped
public class UserConverter extends GenericIntegerEntityConverter<User> {
@EJB
private UserBeanLocal userbean;
@Override
protected User find(Integer id) {
return userbean.getUser(id);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!