Skip to content
Snippets Groups Projects
Commit 89a3c6e7 authored by gwen-soleil's avatar gwen-soleil
Browse files

add an check on constructor input size.

parent 5bc630cb
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
package fr.soleil.archiving.snap.api.tools; package fr.soleil.archiving.snap.api.tools;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -171,13 +172,17 @@ public class SnapContext { ...@@ -171,13 +172,17 @@ public class SnapContext {
* identifier, creation date, reason, description and, the * identifier, creation date, reason, description and, the
* <I>list of attributes</I> that are included in the context. * <I>list of attributes</I> that are included in the context.
*/ */
public SnapContext(final String[] argin) { public SnapContext(final String[] argin) throws SnapshotingException {
if(argin.length < 6){
throw new SnapshotingException("argin size must be at least 6: "+ Arrays.toString(argin));
}
setAuthor_name(argin[0]); setAuthor_name(argin[0]);
setName(argin[1]); setName(argin[1]);
setId(Integer.parseInt(argin[2])); setId(Integer.parseInt(argin[2]));
setCreation_date(java.sql.Date.valueOf(argin[3])); setCreation_date(java.sql.Date.valueOf(argin[3]));
setReason(argin[4]); setReason(argin[4]);
setDescription(argin[5]); setDescription(argin[5]);
// Attribute list construction // Attribute list construction
for (int i = 6; i < argin.length; i++) { for (int i = 6; i < argin.length; i++) {
attributeList.add(new AttributeLight(argin[i])); attributeList.add(new AttributeLight(argin[i]));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment