Skip to content

Commit a1babe5

Browse files
committed
Manually decode form parameters
1 parent 8a4bd6c commit a1babe5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

GenotypeAssays/src/org/labkey/genotypeassays/GenotypeAssaysController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
import org.labkey.api.security.RequiresPermission;
3131
import org.labkey.api.security.permissions.ReadPermission;
3232
import org.labkey.api.security.permissions.UpdatePermission;
33+
import org.labkey.api.util.PageFlowUtil;
3334
import org.labkey.api.util.Pair;
3435
import org.labkey.api.util.URLHelper;
3536
import org.labkey.api.view.HtmlView;
3637
import org.springframework.validation.BindException;
3738
import org.springframework.validation.Errors;
3839
import org.springframework.web.servlet.ModelAndView;
3940

41+
import java.util.Arrays;
4042
import java.util.HashMap;
4143
import java.util.List;
4244
import java.util.Map;
@@ -130,7 +132,8 @@ public ApiResponse execute(CacheAnalysesForm form, BindException errors)
130132
return null;
131133
}
132134

133-
Pair<List<Integer>, List<Integer>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, form.getAlleleNames());
135+
String[] alleleNames = Arrays.stream(form.getAlleleNames()).map(PageFlowUtil::decode).toArray(String[]::new);
136+
Pair<List<Integer>, List<Integer>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, alleleNames);
134137
resultProperties.put("runsCreated", ret.first);
135138
resultProperties.put("runsDeleted", ret.second);
136139
}

GenotypeAssays/src/org/labkey/genotypeassays/GenotypeAssaysManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import java.util.List;
6161
import java.util.Map;
6262
import java.util.Set;
63+
import java.util.concurrent.atomic.AtomicInteger;
6364

6465
public class GenotypeAssaysManager
6566
{
@@ -121,13 +122,15 @@ public Pair<List<Integer>, List<Integer>> cacheAnalyses(final ViewContext ctx, f
121122
final Map<Integer, List<Map<String, Object>>> rowHash = new HashMap<>();
122123
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new HashMap<>();
123124

125+
AtomicInteger records = new AtomicInteger();
124126
TableSelector tsAlignments = new TableSelector(tableAlignments, cols.values(), new SimpleFilter(FieldKey.fromString("key"), Arrays.asList(pks), CompareType.IN), null);
125127
tsAlignments.forEach(new Selector.ForEachBlock<ResultSet>()
126128
{
127129
@Override
128130
public void exec(ResultSet object) throws SQLException
129131
{
130132
Results rs = new ResultsImpl(object, cols);
133+
records.getAndIncrement();
131134

132135
int analysisId = rs.getInt(FieldKey.fromString("analysis_id"));
133136
String lineages = rs.getString(FieldKey.fromString("lineages"));
@@ -167,6 +170,11 @@ public void exec(ResultSet object) throws SQLException
167170
}
168171
});
169172

173+
if (records.get() != pks.length)
174+
{
175+
throw new IllegalStateException("The number of records found did not match the number supplied. This indicates a problem with the import.");
176+
}
177+
170178
if (!rowHash.isEmpty())
171179
{
172180
processSet(SBT_LINEAGE_ASSAY_TYPE, rowHash, assayDataTable, u, ctx, toDeleteByAnalysis, ap, protocol, runsCreated);

0 commit comments

Comments
 (0)