Skip to content

Commit

Permalink
Merge branch 'hotfix-4.1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
hplahar committed Dec 17, 2014
2 parents 91b96ac + e0fc6e5 commit e7f5756
Show file tree
Hide file tree
Showing 80 changed files with 989 additions and 849 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
JBEI Registry of Parts (JBEIR), JBEI Inventory of Composable Parts (ICE)
Copyright (c) 2009, The Regents of the University of California,
Copyright (c) 2009 - 2015, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of
any required approvals from the U.S. Dept. of Energy). All rights
reserved.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.jbei</groupId>
<artifactId>ice</artifactId>
<packaging>war</packaging>
<version>4.1.6</version>
<version>4.1.7</version>
<name>ice</name>
<description>Inventory of Composable Elements (ICE) for Synthetic Biology</description>
<repositories>
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/org/jbei/ice/lib/account/AccountController.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,26 @@ public Account get(long id) {
}

/**
* Changes user's password
* Reset a user's password
*
* @param email optional unique account identifier for user making request. If valid and an administrator
* then the newly created password is also sent
* @param targetEmail email address of user account to be changeds
* @param targetEmail email address of user account to be changed
* @return true if the user account is found with email specified in the parameter and password for it is
* successfully reset, false otherwise
*/
public AccountTransfer resetPassword(String email, String targetEmail) {
public boolean resetPassword(String targetEmail) {
Account account = getByEmail(targetEmail);
if (account == null)
throw new IllegalArgumentException("Cannot retrieve account for " + targetEmail);
return false;

String newPassword = Utils.generateUUID().substring(24);
String encryptedNewPassword = AccountUtils.encryptNewUserPassword(newPassword, account.getSalt());
account.setPassword(encryptedNewPassword);
try {
String newPassword = Utils.generateUUID().substring(24);
String encryptedNewPassword = AccountUtils.encryptNewUserPassword(newPassword, account.getSalt());
account.setPassword(encryptedNewPassword);

account = dao.update(account);
AccountTransfer transfer = account.toDataTransferObject();
transfer.setPassword(newPassword);
account = dao.update(account);
AccountTransfer transfer = account.toDataTransferObject();
transfer.setPassword(newPassword);

if (email == null || !isAdministrator(email)) {
String url = Utils.getConfigValue(ConfigurationKey.URI_PREFIX);
String projectName = Utils.getConfigValue(ConfigurationKey.PROJECT_NAME);
if (StringUtils.isEmpty(projectName))
Expand All @@ -110,8 +110,6 @@ public AccountTransfer resetPassword(String email, String targetEmail) {
String name = account.getFirstName();
if (StringUtils.isBlank(name)) {
name = account.getLastName();
if (StringUtils.isBlank(name))
name = email;
}

SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MMM d, yyyy 'at' HH:mm aaa, z");
Expand All @@ -127,9 +125,11 @@ public AccountTransfer resetPassword(String email, String targetEmail) {
.append("\n\nThank you.");

Emailer.send(account.getEmail(), subject, builder.toString());
return null;
} catch (Exception ex) {
Logger.error(ex);
return false;
}
return transfer;
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ public SecurityFilter(String id, HashSet<String> uuids) {
@Override
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
TermDocs docs = reader.termDocs(new Term("canRead", accountId));
while (docs.next()) {
bitSet.set(docs.doc());
TermDocs docs;
if (accountId != null) {
docs = reader.termDocs(new Term("canRead", accountId));
while (docs.next()) {
bitSet.set(docs.doc());
}
}

if (uuids != null) {
Expand Down
42 changes: 32 additions & 10 deletions src/main/java/org/jbei/ice/lib/entry/sample/SampleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public SampleController() {
// mainly used by the api to create a strain sample record
public Sample createStrainSample(Account account, String recordId, String rack, String location, String barcode,
String label, String strainNamePrefix) {

entryAuthorization.expectAdmin(account.getEmail());

// check if there is an existing sample with barcode
Expand Down Expand Up @@ -124,6 +125,10 @@ public PartSample createSample(String userId, long entryId, PartSample partSampl
currentStorage = storageDAO.create(currentStorage);
break;

case PLATE96:
currentStorage = createPlate96Location(mainLocation);
break;

default:
currentStorage = storageDAO.get(mainLocation.getId());
if (currentStorage == null) {
Expand Down Expand Up @@ -151,6 +156,19 @@ public PartSample createSample(String userId, long entryId, PartSample partSampl
return sample.toDataTransferObject();
}

/**
* Creates location records for a sample contained in a 96 well plate
* Provides support for 2-D barcoded systems
*/
protected Storage createPlate96Location(StorageLocation location) {
// String name = entry.getName();
// if (strainNamePrefix != null && name != null && !name.startsWith(strainNamePrefix)) {
// new EntryEditor().updateWithNextStrainName(strainNamePrefix, entry);
// }
// return sample;
return null;
}

public ArrayList<PartSample> retrieveEntrySamples(String userId, long entryId) {
Entry entry = DAOFactory.getEntryDAO().get(entryId);
if (entry == null)
Expand Down Expand Up @@ -180,6 +198,7 @@ public ArrayList<PartSample> retrieveEntrySamples(String userId, long entryId) {
location.setType(SampleType.GENERIC);
location.setDisplay(sample.getLabel());
generic.setLocation(location);
generic = setAccountInfo(generic, sample.getDepositor());
samples.add(generic);
continue;
}
Expand All @@ -204,22 +223,25 @@ public ArrayList<PartSample> retrieveEntrySamples(String userId, long entryId) {
partSample.setLabel(sample.getLabel());
partSample.setLocation(storageLocation);
partSample.setInCart(inCart);

Account account = DAOFactory.getAccountDAO().getByEmail(sample.getDepositor());
if (account != null)
partSample.setDepositor(account.toDataTransferObject());
else {
AccountTransfer accountTransfer = new AccountTransfer();
accountTransfer.setEmail(sample.getDepositor());
partSample.setDepositor(accountTransfer);
}

partSample = setAccountInfo(partSample, sample.getDepositor());
samples.add(partSample);
}

return samples;
}

protected PartSample setAccountInfo(PartSample partSample, String email) {
Account account = DAOFactory.getAccountDAO().getByEmail(email);
if (account != null)
partSample.setDepositor(account.toDataTransferObject());
else {
AccountTransfer accountTransfer = new AccountTransfer();
accountTransfer.setEmail(email);
partSample.setDepositor(accountTransfer);
}
return partSample;
}

public boolean delete(String userId, long partId, long sampleId) {
Sample sample = dao.get(sampleId);
if (sample == null)
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jbei/ice/lib/folder/FolderController.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ public FolderDetails retrieveFolderContents(String userId, long folderId, Column
if (userId != null) {
ArrayList<AccessPermission> permissions = getAndFilterFolderPermissions(userId, folder);
details.setAccessPermissions(permissions);
boolean canEdit = permissionsController.hasWritePermission(userId, folder);
details.setCanEdit(canEdit);
}

details.setPublicReadAccess(permissionsController.isPublicVisible(folder));
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/org/jbei/ice/lib/search/SearchController.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public SearchResults runWebSearch(SearchQuery query) {

// limit to 50
query.getParameters().setRetrieveCount(50);
query.getParameters().setStart(1);
query.getParameters().setStart(0);

LinkedList<SearchResult> resultsList = new LinkedList<>();
long total = 0;
Expand Down Expand Up @@ -112,12 +112,17 @@ public int compare(SearchResult o1, SearchResult o2) {
/**
* Executes search using parameters specified in the query.
*
* @param userId
* @param query
* @param userId unique user identifier making the request. This can be null if the request is via web of
* registries
* @param query wrapper around search query
* @return wrapper around the list of search results
*/
public SearchResults runLocalSearch(String userId, SearchQuery query) {
String queryString = query.getQueryString();
String queryString;
if (query.getQueryString() != null)
queryString = query.getQueryString().toLowerCase();
else
queryString = query.getQueryString();
Account account = null;
if (userId != null)
account = DAOFactory.getAccountDAO().getByEmail(userId);
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/org/jbei/ice/lib/search/blast/BlastPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,12 @@ public static void rebuildDatabase(boolean force) throws BlastException {
final Path blastFolder = Paths.get(dataDir, BLAST_DB_FOLDER);
File lockFile = Paths.get(blastFolder.toString(), LOCK_FILE_NAME).toFile();
if (lockFile.exists()) {
Logger.info("Blast db locked (lockfile - " + lockFile.getAbsolutePath() + "). Rebuild aborted!");
return;
if (lockFile.lastModified() <= (System.currentTimeMillis() - (1000 * 60 * 60 * 24)))
lockFile.delete();
else {
Logger.info("Blast db locked (lockfile - " + lockFile.getAbsolutePath() + "). Rebuild aborted!");
return;
}
}

try {
Expand Down Expand Up @@ -255,6 +259,7 @@ public static void rebuildDatabase(boolean force) throws BlastException {
} catch (OverlappingFileLockException l) {
Logger.warn("Could not obtain lock file for blast at " + blastFolder.toString());
} catch (IOException eio) {
FileUtils.deleteQuietly(lockFile);
throw new BlastException(eio);
}
FileUtils.deleteQuietly(lockFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public FolderDetails read(@Context UriInfo uriInfo,

try {
long id = Long.decode(folderId);
Logger.info("Retrieving folder " + id + " entries");
return controller.retrieveFolderContents(userId, id, field, asc, offset, limit);
} catch (NumberFormatException nfe) {
}
Expand Down
19 changes: 5 additions & 14 deletions src/main/java/org/jbei/ice/services/rest/UserResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.jbei.ice.lib.account.AccountController;
import org.jbei.ice.lib.account.AccountTransfer;
import org.jbei.ice.lib.account.PreferencesController;
import org.jbei.ice.lib.account.SessionHandler;
import org.jbei.ice.lib.account.model.Account;
import org.jbei.ice.lib.dao.DAOFactory;
import org.jbei.ice.lib.dto.AccountResults;
Expand Down Expand Up @@ -171,23 +170,15 @@ public AccountTransfer update(@Context UriInfo info, @PathParam("id") long userI
return controller.updateAccount(user, userId, transfer);
}

// reset or validate password (also include current session id for validation pending new method)
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/password")
public AccountTransfer resetPassword(@HeaderParam(value = "X-ICE-Authentication-SessionId") String sessionId,
AccountTransfer transfer) {
String userId = SessionHandler.getUserIdBySession(sessionId);
if (transfer.getPassword() != null && userId != null) {
return controller.authenticate(transfer);
}

// reset
AccountTransfer newUpdate = controller.resetPassword(userId, transfer.getEmail());
if (newUpdate == null)
return transfer;
return newUpdate;
public Response resetPassword(@Context UriInfo info, AccountTransfer transfer) {
boolean success = controller.resetPassword(transfer.getEmail());
if (!success)
return super.respond(Response.Status.NOT_FOUND);
return super.respond(Response.Status.OK);
}

@PUT
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/org/jbei/ice/servlet/InfoToModelFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,14 @@ private static Entry setCommon(Entry entry, PartData info) {
if (info.getName() != null)
entry.setName(info.getName());

Set<SelectionMarker> markers = getSelectionMarkers(info.getSelectionMarkers(), entry);
entry.setSelectionMarkers(markers);
if (info.getSelectionMarkers() != null) {
Set<SelectionMarker> markers = getSelectionMarkers(info.getSelectionMarkers(), entry);
entry.setSelectionMarkers(markers);
}

if (info.getReferences() != null)
entry.setReferences(info.getReferences());

entry.setReferences(info.getReferences());
if (StringUtils.isBlank(entry.getPartNumber()))
entry.setPartNumber(info.getPartId());

Expand Down Expand Up @@ -311,7 +315,8 @@ private static Set<SelectionMarker> getSelectionMarkers(ArrayList<String> marker
marker.setEntry(entry);
markers.add(marker);
}
}
} else
return null;

return markers;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/css/bootstrap.css.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main/webapp/css/bootstrap.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit e7f5756

Please sign in to comment.