• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 17319343703

29 Aug 2025 08:53AM UTC coverage: 12.007% (-0.3%) from 12.355%
17319343703

push

github

tkuhn
Fix forcedGet(...) also catching RuntimeExceptions

330 of 3844 branches covered (8.58%)

Branch coverage included in aggregate %.

949 of 6808 relevant lines covered (13.94%)

0.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/component/PublishForm.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.knowledgepixels.nanodash.*;
4
import com.knowledgepixels.nanodash.page.ExplorePage;
5
import com.knowledgepixels.nanodash.page.NanodashPage;
6
import com.knowledgepixels.nanodash.template.*;
7
import org.apache.commons.lang3.StringUtils;
8
import org.apache.wicket.Component;
9
import org.apache.wicket.RestartResponseException;
10
import org.apache.wicket.ajax.AjaxEventBehavior;
11
import org.apache.wicket.ajax.AjaxRequestTarget;
12
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
13
import org.apache.wicket.feedback.FeedbackMessage;
14
import org.apache.wicket.markup.html.WebMarkupContainer;
15
import org.apache.wicket.markup.html.WebPage;
16
import org.apache.wicket.markup.html.basic.Label;
17
import org.apache.wicket.markup.html.form.CheckBox;
18
import org.apache.wicket.markup.html.form.Form;
19
import org.apache.wicket.markup.html.form.FormComponent;
20
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
21
import org.apache.wicket.markup.html.list.ListItem;
22
import org.apache.wicket.markup.html.list.ListView;
23
import org.apache.wicket.markup.html.panel.FeedbackPanel;
24
import org.apache.wicket.markup.html.panel.Panel;
25
import org.apache.wicket.markup.repeater.Item;
26
import org.apache.wicket.markup.repeater.data.DataView;
27
import org.apache.wicket.markup.repeater.data.ListDataProvider;
28
import org.apache.wicket.model.IModel;
29
import org.apache.wicket.model.Model;
30
import org.apache.wicket.request.mapper.parameter.PageParameters;
31
import org.apache.wicket.validation.IValidatable;
32
import org.apache.wicket.validation.IValidator;
33
import org.apache.wicket.validation.ValidationError;
34
import org.eclipse.rdf4j.model.IRI;
35
import org.eclipse.rdf4j.model.Literal;
36
import org.eclipse.rdf4j.model.Statement;
37
import org.eclipse.rdf4j.model.ValueFactory;
38
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
39
import org.eclipse.rdf4j.model.vocabulary.FOAF;
40
import org.eclipse.rdf4j.model.vocabulary.RDFS;
41
import org.nanopub.MalformedNanopubException;
42
import org.nanopub.Nanopub;
43
import org.nanopub.NanopubCreator;
44
import org.nanopub.extra.security.SignNanopub;
45
import org.nanopub.extra.security.SignatureAlgorithm;
46
import org.nanopub.extra.security.TransformContext;
47
import org.nanopub.extra.server.PublishNanopub;
48
import org.nanopub.extra.services.ApiResponseEntry;
49
import org.nanopub.vocabulary.NPX;
50
import org.nanopub.vocabulary.NTEMPLATE;
51
import org.slf4j.Logger;
52
import org.slf4j.LoggerFactory;
53
import org.wicketstuff.select2.ChoiceProvider;
54
import org.wicketstuff.select2.Response;
55
import org.wicketstuff.select2.Select2Choice;
56

57
import java.lang.reflect.InvocationTargetException;
58
import java.util.*;
59

60
/**
61
 * Form for publishing a nanopublication.
62
 */
63
public class PublishForm extends Panel {
64

65
    private static final long serialVersionUID = 1L;
66
    private static final Logger logger = LoggerFactory.getLogger(PublishForm.class);
×
67

68
    private static ValueFactory vf = SimpleValueFactory.getInstance();
×
69

70
    private static String creatorPubinfoTemplateId = "https://w3id.org/np/RAukAcWHRDlkqxk7H2XNSegc1WnHI569INvNr-xdptDGI";
×
71
    private static String licensePubinfoTempalteId = "https://w3id.org/np/RA0J4vUn_dekg-U1kK3AOEt02p9mT2WO03uGxLDec1jLw";
×
72
    private static String defaultProvTemplateId = "https://w3id.org/np/RA7lSq6MuK_TIC6JMSHvLtee3lpLoZDOqLJCLXevnrPoU";
×
73
    private static String supersedesPubinfoTemplateId = "https://w3id.org/np/RAoTD7udB2KtUuOuAe74tJi1t3VzK0DyWS7rYVAq1GRvw";
×
74
    private static String derivesFromPubinfoTemplateId = "https://w3id.org/np/RARW4MsFkHuwjycNElvEVtuMjpf4yWDL10-0C5l2MqqRQ";
×
75

76
    private static String[] fixedPubInfoTemplates = new String[]{creatorPubinfoTemplateId, licensePubinfoTempalteId};
×
77

78
    /**
79
     * Fill modes for the nanopublication to be created.
80
     */
81
    public enum FillMode {USE, SUPERSEDE, DERIVE}
×
82

83
    protected Form<?> form;
84
    protected FeedbackPanel feedbackPanel;
85
    private final TemplateContext assertionContext;
86
    private TemplateContext provenanceContext;
87
    private List<TemplateContext> pubInfoContexts = new ArrayList<>();
×
88
    private Map<String, TemplateContext> pubInfoContextMap = new HashMap<>();
×
89
    private List<TemplateContext> requiredPubInfoContexts = new ArrayList<>();
×
90
    private String targetNamespace;
91
    private Class<? extends WebPage> confirmPageClass;
92

93
    /**
94
     * Constructor for the PublishForm.
95
     *
96
     * @param id               the Wicket component ID
97
     * @param pageParams       the parameters for the page, which may include information on how to fill the form
98
     * @param publishPageClass the class of the page to redirect to after successful publication
99
     * @param confirmPageClass the class of the confirmation page to show after publication
100
     */
101
    public PublishForm(String id, final PageParameters pageParams, Class<? extends WebPage> publishPageClass, Class<? extends WebPage> confirmPageClass) {
102
        super(id);
×
103
        setOutputMarkupId(true);
×
104
        this.confirmPageClass = confirmPageClass;
×
105

106
        WebMarkupContainer linkMessageItem = new WebMarkupContainer("link-message-item");
×
107
        if (pageParams.get("link-message").isNull()) {
×
108
            linkMessageItem.add(new Label("link-message", ""));
×
109
            linkMessageItem.setVisible(false);
×
110
        } else {
111
            linkMessageItem.add(new Label("link-message", Utils.sanitizeHtml(pageParams.get("link-message").toString())).setEscapeModelStrings(false));
×
112
        }
113
        add(linkMessageItem);
×
114

115
        final Nanopub fillNp;
116
        final FillMode fillMode;
117
        boolean fillOnlyAssertion = false;
×
118
        if (!pageParams.get("use").isNull()) {
×
119
            fillNp = Utils.getNanopub(pageParams.get("use").toString());
×
120
            fillMode = FillMode.USE;
×
121
        } else if (!pageParams.get("use-a").isNull()) {
×
122
            fillNp = Utils.getNanopub(pageParams.get("use-a").toString());
×
123
            fillMode = FillMode.USE;
×
124
            fillOnlyAssertion = true;
×
125
        } else if (!pageParams.get("supersede").isNull()) {
×
126
            fillNp = Utils.getNanopub(pageParams.get("supersede").toString());
×
127
            fillMode = FillMode.SUPERSEDE;
×
128
            targetNamespace = pageParams.get("supersede").toString().replaceFirst("RA[A-Za-z0-9-_]{43}$", "");
×
129
        } else if (!pageParams.get("supersede-a").isNull()) {
×
130
            fillNp = Utils.getNanopub(pageParams.get("supersede-a").toString());
×
131
            fillMode = FillMode.SUPERSEDE;
×
132
            fillOnlyAssertion = true;
×
133
        } else if (!pageParams.get("derive").isNull()) {
×
134
            fillNp = Utils.getNanopub(pageParams.get("derive").toString());
×
135
            fillMode = FillMode.DERIVE;
×
136
        } else if (!pageParams.get("derive-a").isNull()) {
×
137
            fillNp = Utils.getNanopub(pageParams.get("derive-a").toString());
×
138
            fillMode = FillMode.DERIVE;
×
139
            fillOnlyAssertion = true;
×
140
        } else if (!pageParams.get("fill-all").isNull()) {
×
141
            // TODO: This is deprecated and should be removed at some point
142
            fillNp = Utils.getNanopub(pageParams.get("fill-all").toString());
×
143
            fillMode = FillMode.USE;
×
144
        } else if (!pageParams.get("fill").isNull()) {
×
145
            // TODO: This is deprecated and should be removed at some point
146
            fillNp = Utils.getNanopub(pageParams.get("fill").toString());
×
147
            fillMode = FillMode.SUPERSEDE;
×
148
        } else {
149
            fillNp = null;
×
150
            fillMode = null;
×
151
        }
152

153
        final TemplateData td = TemplateData.get();
×
154

155
        // TODO Properly integrate this namespace feature:
156
        String templateId = pageParams.get("template").toString();
×
157
        if (td.getTemplate(templateId).getTargetNamespace() != null) {
×
158
            targetNamespace = td.getTemplate(templateId).getTargetNamespace();
×
159
        }
160
        if (!pageParams.get("target-namespace").isNull()) {
×
161
            targetNamespace = pageParams.get("target-namespace").toString();
×
162
        }
163
        if (targetNamespace == null) {
×
164
            targetNamespace = Template.DEFAULT_TARGET_NAMESPACE;
×
165
        }
166
        String targetNamespaceLabel = targetNamespace + "...";
×
167
        targetNamespace = targetNamespace + "ARTIFACTCODE-PLACEHOLDER/";
×
168

169
        assertionContext = new TemplateContext(ContextType.ASSERTION, templateId, "statement", targetNamespace);
×
170
        assertionContext.setFillMode(fillMode);
×
171
        final String prTemplateId;
172
        if (pageParams.get("prtemplate").toString() != null) {
×
173
            prTemplateId = pageParams.get("prtemplate").toString();
×
174
        } else {
175
            if (fillNp != null && !fillOnlyAssertion) {
×
176
                if (td.getProvenanceTemplateId(fillNp) != null) {
×
177
                    prTemplateId = td.getProvenanceTemplateId(fillNp).stringValue();
×
178
                } else {
179
                    prTemplateId = "http://purl.org/np/RAcm8OurwUk15WOgBM9wySo-T3a5h6as4K8YR5MBrrxUc";
×
180
                }
181
            } else if (assertionContext.getTemplate().getDefaultProvenance() != null) {
×
182
                prTemplateId = assertionContext.getTemplate().getDefaultProvenance().stringValue();
×
183
            } else {
184
                prTemplateId = defaultProvTemplateId;
×
185
            }
186
        }
187
        provenanceContext = new TemplateContext(ContextType.PROVENANCE, prTemplateId, "pr-statement", targetNamespace);
×
188
        for (String t : fixedPubInfoTemplates) {
×
189
            // TODO consistently check for latest versions of templates here and below:
190
            TemplateContext c = new TemplateContext(ContextType.PUBINFO, t, "pi-statement", targetNamespace);
×
191
            pubInfoContexts.add(c);
×
192
            pubInfoContextMap.put(c.getTemplate().getId(), c);
×
193
            requiredPubInfoContexts.add(c);
×
194
        }
195
        if (fillMode == FillMode.SUPERSEDE) {
×
196
            TemplateContext c = new TemplateContext(ContextType.PUBINFO, supersedesPubinfoTemplateId, "pi-statement", targetNamespace);
×
197
            pubInfoContexts.add(c);
×
198
            pubInfoContextMap.put(supersedesPubinfoTemplateId, c);
×
199
            //requiredPubInfoContexts.add(c);
200
            c.setParam("np", fillNp.getUri().stringValue());
×
201
        } else if (fillMode == FillMode.DERIVE) {
×
202
            TemplateContext c = new TemplateContext(ContextType.PUBINFO, derivesFromPubinfoTemplateId, "pi-statement", targetNamespace);
×
203
            pubInfoContexts.add(c);
×
204
            pubInfoContextMap.put(derivesFromPubinfoTemplateId, c);
×
205
            c.setParam("np", fillNp.getUri().stringValue());
×
206
        }
207
        for (IRI r : assertionContext.getTemplate().getRequiredPubinfoElements()) {
×
208
            String latestId = QueryApiAccess.getLatestVersionId(r.stringValue());
×
209
            if (pubInfoContextMap.containsKey(r.stringValue()) || pubInfoContextMap.containsKey(latestId)) continue;
×
210
            TemplateContext c = new TemplateContext(ContextType.PUBINFO, r.stringValue(), "pi-statement", targetNamespace);
×
211
            pubInfoContexts.add(c);
×
212
            pubInfoContextMap.put(c.getTemplateId(), c);
×
213
            requiredPubInfoContexts.add(c);
×
214
        }
×
215
        Map<Integer, TemplateContext> piParamIdMap = new HashMap<>();
×
216
        for (String k : pageParams.getNamedKeys()) {
×
217
            if (!k.matches("pitemplate[1-9][0-9]*")) continue;
×
218
            Integer i = Integer.parseInt(k.replaceFirst("^pitemplate([1-9][0-9]*)$", "$1"));
×
219
            String tid = pageParams.get(k).toString();
×
220
            // TODO Allow for automatically using latest template version:
221
            //String piTempalteIdLatest = QueryApiAccess.getLatestVersionId(tid);
222
            TemplateContext c = createPubinfoContext(tid);
×
223
            if (piParamIdMap.containsKey(i)) {
×
224
                // TODO: handle this error better
225
                logger.error("ERROR: pitemplate param identifier assigned multiple times: {}", i);
×
226
            }
227
            piParamIdMap.put(i, c);
×
228
        }
×
229
        if (fillNp != null && !fillOnlyAssertion) {
×
230
            for (IRI piTemplateId : td.getPubinfoTemplateIds(fillNp)) {
×
231
                String piTempalteIdLatest = QueryApiAccess.getLatestVersionId(piTemplateId.stringValue());
×
232
                if (piTempalteIdLatest.equals(supersedesPubinfoTemplateId)) continue;
×
233
                if (!pubInfoContextMap.containsKey(piTempalteIdLatest)) {
×
234
                    // TODO Allow for automatically using latest template version
235
                    createPubinfoContext(piTemplateId.stringValue());
×
236
                }
237
            }
×
238
        }
239
        for (String k : pageParams.getNamedKeys()) {
×
240
            if (k.startsWith("param_")) assertionContext.setParam(k.substring(6), pageParams.get(k).toString());
×
241
            if (k.startsWith("prparam_")) provenanceContext.setParam(k.substring(8), pageParams.get(k).toString());
×
242
            if (k.matches("piparam[1-9][0-9]*_.*")) {
×
243
                Integer i = Integer.parseInt(k.replaceFirst("^piparam([1-9][0-9]*)_.*$", "$1"));
×
244
                if (!piParamIdMap.containsKey(i)) {
×
245
                    // TODO: handle this error better
246
                    logger.error("ERROR: pitemplate param identifier not found: {}", i);
×
247
                    continue;
×
248
                }
249
                String n = k.replaceFirst("^piparam[1-9][0-9]*_(.*)$", "$1");
×
250
                logger.info(n);
×
251
                piParamIdMap.get(i).setParam(n, pageParams.get(k).toString());
×
252
            }
253
        }
×
254

255
        // Init statements only now, in order to pick up parameter values:
256
        assertionContext.initStatements();
×
257
        provenanceContext.initStatements();
×
258
        for (TemplateContext c : pubInfoContexts) {
×
259
            c.initStatements();
×
260
        }
×
261

262
        String latestAssertionId = QueryApiAccess.getLatestVersionId(assertionContext.getTemplateId());
×
263
        if (!assertionContext.getTemplateId().equals(latestAssertionId)) {
×
264
            add(new Label("newversion", "There is a new version of this assertion template:"));
×
265
            PageParameters params = new PageParameters(pageParams);
×
266
            params.set("template", latestAssertionId).remove("formobj");
×
267
            add(new BookmarkablePageLink<Void>("newversionlink", publishPageClass, params));
×
268
            if ("latest".equals(pageParams.get("template-version").toString())) {
×
269
                throw new RestartResponseException(publishPageClass, params);
×
270
            }
271
        } else {
×
272
            add(new Label("newversion", "").setVisible(false));
×
273
            add(new Label("newversionlink", "").setVisible(false));
×
274
        }
275

276
        final Nanopub improveNp;
277
        if (!pageParams.get("improve").isNull()) {
×
278
            improveNp = Utils.getNanopub(pageParams.get("improve").toString());
×
279
        } else {
280
            improveNp = null;
×
281
        }
282

283
        final List<Statement> unusedStatementList = new ArrayList<>();
×
284
        final List<Statement> unusedPrStatementList = new ArrayList<>();
×
285
        final List<Statement> unusedPiStatementList = new ArrayList<>();
×
286
        if (fillNp != null) {
×
287
            ValueFiller filler = new ValueFiller(fillNp, ContextType.ASSERTION, true, fillMode);
×
288
            filler.fill(assertionContext);
×
289
            unusedStatementList.addAll(filler.getUnusedStatements());
×
290

291
            if (!fillOnlyAssertion) {
×
292
                ValueFiller prFiller = new ValueFiller(fillNp, ContextType.PROVENANCE, true);
×
293
                prFiller.fill(provenanceContext);
×
294
                unusedPrStatementList.addAll(prFiller.getUnusedStatements());
×
295

296
                ValueFiller piFiller = new ValueFiller(fillNp, ContextType.PUBINFO, true);
×
297
                if (!assertionContext.getTemplate().getTargetNanopubTypes().isEmpty()) {
×
298
                    for (Statement st : new ArrayList<>(piFiller.getUnusedStatements())) {
×
299
                        if (st.getSubject().stringValue().equals("local:nanopub") && st.getPredicate().equals(NPX.HAS_NANOPUB_TYPE)) {
×
300
                            if (assertionContext.getTemplate().getTargetNanopubTypes().contains(st.getObject())) {
×
301
                                piFiller.removeUnusedStatement(st);
×
302
                            }
303
                        }
304
                    }
×
305
                }
306
                for (TemplateContext c : pubInfoContexts) {
×
307
                    piFiller.fill(c);
×
308
                }
×
309
                piFiller.removeUnusedStatements(NanodashSession.get().getUserIri(), FOAF.NAME, null);
×
310
                if (piFiller.hasUnusedStatements()) {
×
311
                    final String handcodedStatementsTemplateId = "https://w3id.org/np/RAMEgudZsQ1bh1fZhfYnkthqH6YSXpghSE_DEN1I-6eAI";
×
312
                    if (!pubInfoContextMap.containsKey(handcodedStatementsTemplateId)) {
×
313
                        TemplateContext c = createPubinfoContext(handcodedStatementsTemplateId);
×
314
                        c.initStatements();
×
315
                        piFiller.fill(c);
×
316
                    }
317
                }
318
                unusedPiStatementList.addAll(piFiller.getUnusedStatements());
×
319
                // TODO: Also use pubinfo templates stated in nanopub to be filled in?
320
//                                Set<IRI> pubinfoTemplateIds = Template.getPubinfoTemplateIds(fillNp);
321
//                                if (!pubinfoTemplateIds.isEmpty()) {
322
//                                        ValueFiller piFiller = new ValueFiller(fillNp, ContextType.PUBINFO);
323
//                                        for (IRI pubinfoTemplateId : pubinfoTemplateIds) {
324
//                                                // TODO: Make smart choice on the ordering in trying to fill in all pubinfo elements
325
//                                                piFiller.fill(pubInfoContextMap.get(pubinfoTemplateId.stringValue()));
326
//                                        }
327
//                                        warningMessage += (piFiller.getWarningMessage() == null ? "" : "Publication info: " + piFiller.getWarningMessage() + " ");
328
//                                }
329
            }
330
        } else if (improveNp != null) {
×
331
            ValueFiller filler = new ValueFiller(improveNp, ContextType.ASSERTION, true);
×
332
            filler.fill(assertionContext);
×
333
            unusedStatementList.addAll(filler.getUnusedStatements());
×
334
        }
335
        if (!unusedStatementList.isEmpty()) {
×
336
            add(new Label("warnings", "Some content from the existing nanopublication could not be filled in:"));
×
337
        } else {
338
            add(new Label("warnings", "").setVisible(false));
×
339
        }
340
        add(new DataView<Statement>("unused-statements", new ListDataProvider<Statement>(unusedStatementList)) {
×
341

342
            private static final long serialVersionUID = 1L;
343

344
            @Override
345
            protected void populateItem(Item<Statement> item) {
346
                item.add(new TripleItem("unused-statement", item.getModelObject(), (fillNp != null ? fillNp : improveNp), null));
×
347
            }
×
348

349
        });
350
        add(new DataView<Statement>("unused-prstatements", new ListDataProvider<Statement>(unusedPrStatementList)) {
×
351

352
            private static final long serialVersionUID = 1L;
353

354
            @Override
355
            protected void populateItem(Item<Statement> item) {
356
                item.add(new TripleItem("unused-prstatement", item.getModelObject(), (fillNp != null ? fillNp : improveNp), null));
×
357
            }
×
358

359
        });
360
        add(new DataView<Statement>("unused-pistatements", new ListDataProvider<Statement>(unusedPiStatementList)) {
×
361

362
            private static final long serialVersionUID = 1L;
363

364
            @Override
365
            protected void populateItem(Item<Statement> item) {
366
                item.add(new TripleItem("unused-pistatement", item.getModelObject(), (fillNp != null ? fillNp : improveNp), null));
×
367
            }
×
368

369
        });
370

371
        // Finalize statements, which picks up parameter values in repetitions:
372
        assertionContext.finalizeStatements();
×
373
        provenanceContext.finalizeStatements();
×
374
        for (TemplateContext c : pubInfoContexts) {
×
375
            c.finalizeStatements();
×
376
        }
×
377

378
        final CheckBox consentCheck = new CheckBox("consentcheck", new Model<>(false));
×
379
        consentCheck.setRequired(true);
×
380
        consentCheck.add(new InvalidityHighlighting());
×
381
        consentCheck.add(new IValidator<Boolean>() {
×
382

383
            private static final long serialVersionUID = 1L;
384

385
            @Override
386
            public void validate(IValidatable<Boolean> validatable) {
387
                if (!Boolean.TRUE.equals(validatable.getValue())) {
×
388
                    validatable.error(new ValidationError("You need to check the checkbox that you understand the consequences."));
×
389
                }
390
            }
×
391

392
        });
393

394
        form = new Form<Void>("form") {
×
395

396
            private static final long serialVersionUID = 1L;
397

398
            @Override
399
            protected void onConfigure() {
400
                super.onConfigure();
×
401
                form.getFeedbackMessages().clear();
×
402
//                                formComponents.clear();
403
            }
×
404

405
            protected void onSubmit() {
406
                logger.info("Publish form submitted");
×
407
                Nanopub signedNp = null;
×
408
                try {
409
                    Nanopub np = createNanopub();
×
410
                    logger.info("Nanopublication created: {}", np.getUri());
×
411
                    TransformContext tc = new TransformContext(SignatureAlgorithm.RSA, NanodashSession.get().getKeyPair(), NanodashSession.get().getUserIri(), false, false, false);
×
412
                    signedNp = SignNanopub.signAndTransform(np, tc);
×
413
                    logger.info("Nanopublication signed: {}", signedNp.getUri());
×
414
                    String npUrl = PublishNanopub.publish(signedNp);
×
415
                    logger.info("Nanopublication published: {}", npUrl);
×
416
                } catch (Exception ex) {
×
417
                    signedNp = null;
×
418
                    ex.printStackTrace();
×
419
                    String message = ex.getClass().getName();
×
420
                    if (ex.getMessage() != null) message = ex.getMessage();
×
421
                    feedbackPanel.error(message);
×
422
                }
×
423
                if (signedNp != null) {
×
424
                    throw new RestartResponseException(getConfirmPage(signedNp, pageParams));
×
425
                } else {
426
                    logger.error("Nanopublication publishing failed");
×
427
                }
428
            }
×
429

430
            @Override
431
            protected void onValidate() {
432
                super.onValidate();
×
433
                for (Component fc : assertionContext.getComponents()) {
×
434
                    processFeedback(fc);
×
435
                }
×
436
                for (Component fc : provenanceContext.getComponents()) {
×
437
                    processFeedback(fc);
×
438
                }
×
439
                for (TemplateContext c : pubInfoContexts) {
×
440
                    for (Component fc : c.getComponents()) {
×
441
                        processFeedback(fc);
×
442
                    }
×
443
                }
×
444
            }
×
445

446
            private void processFeedback(Component c) {
447
                if (c instanceof FormComponent) {
×
448
                    ((FormComponent<?>) c).processInput();
×
449
                }
450
                for (FeedbackMessage fm : c.getFeedbackMessages()) {
×
451
                    form.getFeedbackMessages().add(fm);
×
452
                }
×
453
            }
×
454

455
        };
456
        form.setOutputMarkupId(true);
×
457

458
        form.add(new Label("nanopub-namespace", targetNamespaceLabel));
×
459

460
        form.add(new BookmarkablePageLink<Void>("templatelink", ExplorePage.class, new PageParameters().add("id", assertionContext.getTemplate().getId())));
×
461
        form.add(new Label("templatename", assertionContext.getTemplate().getLabel()));
×
462
        String description = assertionContext.getTemplate().getLabel();
×
463
        if (description == null) description = "";
×
464
        form.add(new Label("templatedesc", assertionContext.getTemplate().getDescription()).setEscapeModelStrings(false));
×
465

466
        form.add(new ListView<StatementItem>("statements", assertionContext.getStatementItems()) {
×
467

468
            private static final long serialVersionUID = 1L;
469

470
            protected void populateItem(ListItem<StatementItem> item) {
471
                item.add(item.getModelObject());
×
472
            }
×
473

474
        });
475

476
        final Map<String, Boolean> handledProvTemplates = new HashMap<>();
×
477
        final String defaultProvTemplateId;
478
        if (assertionContext.getTemplate().getDefaultProvenance() != null) {
×
479
            defaultProvTemplateId = assertionContext.getTemplate().getDefaultProvenance().stringValue();
×
480
            handledProvTemplates.put(defaultProvTemplateId, true);
×
481
        } else {
482
            defaultProvTemplateId = null;
×
483
        }
484
        final List<String> recommendedProvTemplateOptionIds = new ArrayList<>();
×
485
        final List<String> provTemplateOptionIds = new ArrayList<>();
×
486
        if (pageParams.get("prtemplate-options").isNull()) {
×
487
            // TODO Make this dynamic and consider updated templates:
488
            recommendedProvTemplateOptionIds.add("https://w3id.org/np/RA7lSq6MuK_TIC6JMSHvLtee3lpLoZDOqLJCLXevnrPoU");
×
489
            recommendedProvTemplateOptionIds.add("http://purl.org/np/RAcTpoh5Ra0ssqmcpOgWdaZ_YiPE6demO6cpw-2RvSNs8");
×
490
            recommendedProvTemplateOptionIds.add("http://purl.org/np/RA4LGtuOqTIMqVAkjnfBXk1YDcAPNadP5CGiaJiBkdHCQ");
×
491
            recommendedProvTemplateOptionIds.add("http://purl.org/np/RAl_-VTw9Re_uRF8r8y0rjlfnu7FlhTa8xg_8xkcweqiE");
×
492
            recommendedProvTemplateOptionIds.add("https://w3id.org/np/RASORV2mMEVpS4lWh2bwUTEcV-RWjbD9RPbN7J0PIeYAU");
×
493
            recommendedProvTemplateOptionIds.add("http://purl.org/np/RAjkBbM5yQm7hKH1l_Jk3HAUqWi3Bd57TPmAOZCsZmi_M");
×
494
            recommendedProvTemplateOptionIds.add("http://purl.org/np/RAGXx_k9eQMnXaCbsXMsJbGClwZtQEGNg0GVJu6amdAVw");
×
495
            recommendedProvTemplateOptionIds.add("http://purl.org/np/RA1fnITI3Pu1UQ0CHghNpys3JwQrM32LBnjmDLoayp9-4");
×
496
            recommendedProvTemplateOptionIds.add("http://purl.org/np/RAJgbsGeGdTG-zq_gU0TLw4s3raMgoRk-mPlc2DSLXvE0");
×
497
            recommendedProvTemplateOptionIds.add("http://purl.org/np/RA6SXfhUY-xeblZU8HhPddw6tsu-C5NXevG6C_zv4bMxU");
×
498
            for (String s : recommendedProvTemplateOptionIds) {
×
499
                handledProvTemplates.put(s, true);
×
500
            }
×
501

502
            for (ApiResponseEntry t : td.getProvenanceTemplates()) {
×
503
                String tid = t.get("np");
×
504
                if (handledProvTemplates.containsKey(tid)) continue;
×
505
                provTemplateOptionIds.add(tid);
×
506
                handledProvTemplates.put(tid, true);
×
507
            }
×
508
        } else {
509
            for (String s : pageParams.get("prtemplate-options").toString().split(" ")) {
×
510
                if (handledProvTemplates.containsKey(s)) continue;
×
511
                recommendedProvTemplateOptionIds.add(s);
×
512
                handledProvTemplates.put(s, true);
×
513
            }
514
        }
515

516
        ChoiceProvider<String> prTemplateChoiceProvider = new ChoiceProvider<String>() {
×
517

518
            private static final long serialVersionUID = 1L;
519

520
            @Override
521
            public String getDisplayValue(String object) {
522
                if (object == null || object.isEmpty()) return "";
×
523
                Template t = td.getTemplate(object);
×
524
                if (t != null) return t.getLabel();
×
525
                return object;
×
526
            }
527

528
            @Override
529
            public String getIdValue(String object) {
530
                return object;
×
531
            }
532

533
            // Getting strange errors with Tomcat if this method is not overridden:
534
            @Override
535
            public void detach() {
536
            }
×
537

538
            @Override
539
            public void query(String term, int page, Response<String> response) {
540
                if (term == null) term = "";
×
541
                term = term.toLowerCase();
×
542
                if (pageParams.get("prtemplate").toString() != null) {
×
543
                    // Using this work-around with "——" because 'optgroup' is not available through Wicket's Select2 classes
544
                    response.add("—— default for this link ——");
×
545
                    response.add(prTemplateId);
×
546
                }
547
                if (defaultProvTemplateId != null) {
×
548
                    response.add("—— default for this template ——");
×
549
                    response.add(defaultProvTemplateId);
×
550
                }
551
                if (!recommendedProvTemplateOptionIds.isEmpty()) {
×
552
                    if (pageParams.get("prtemplate-options").isNull()) {
×
553
                        response.add("—— recommended ——");
×
554
                    }
555
                    for (String s : recommendedProvTemplateOptionIds) {
×
556
                        if (s.toLowerCase().contains(term) || getDisplayValue(s).toLowerCase().contains(term)) {
×
557
                            response.add(s);
×
558
                        }
559
                    }
×
560
                }
561
                if (!provTemplateOptionIds.isEmpty()) {
×
562
                    response.add("—— others ——");
×
563
                    for (String s : provTemplateOptionIds) {
×
564
                        if (s.toLowerCase().contains(term) || getDisplayValue(s).toLowerCase().contains(term)) {
×
565
                            response.add(s);
×
566
                        }
567
                    }
×
568
                }
569
            }
×
570

571
            @Override
572
            public Collection<String> toChoices(Collection<String> ids) {
573
                return ids;
×
574
            }
575

576
        };
577
        final IModel<String> prTemplateModel = Model.of(provenanceContext.getTemplate().getId());
×
578
        Select2Choice<String> prTemplateChoice = new Select2Choice<String>("prtemplate", prTemplateModel, prTemplateChoiceProvider);
×
579
        prTemplateChoice.setRequired(true);
×
580
        prTemplateChoice.getSettings().setCloseOnSelect(true);
×
581
        prTemplateChoice.add(new AjaxFormComponentUpdatingBehavior("change") {
×
582

583
            private static final long serialVersionUID = 1L;
584

585
            @Override
586
            protected void onUpdate(AjaxRequestTarget target) {
587
                String o = prTemplateModel.getObject();
×
588
                if (o.startsWith("——")) {
×
589
                    o = provenanceContext.getTemplate().getId();
×
590
                    prTemplateModel.setObject(o);
×
591
                }
592
                provenanceContext = new TemplateContext(ContextType.PROVENANCE, prTemplateModel.getObject(), "pr-statement", targetNamespace);
×
593
                provenanceContext.initStatements();
×
594
                refreshProvenance(target);
×
595
                provenanceContext.finalizeStatements();
×
596
            }
×
597

598
        });
599
        form.add(prTemplateChoice);
×
600
        refreshProvenance(null);
×
601

602
        final Map<String, Boolean> handledPiTemplates = new HashMap<>();
×
603
        final List<String> recommendedPiTemplateOptionIds = new ArrayList<>();
×
604
        final List<String> piTemplateOptionIds = new ArrayList<>();
×
605
        // TODO Make this dynamic and consider updated templates:
606
        recommendedPiTemplateOptionIds.add("http://purl.org/np/RAXflINqt3smqxV5Aq7E9lzje4uLdkKIOefa6Bp8oJ8CY");
×
607
        recommendedPiTemplateOptionIds.add("https://w3id.org/np/RARW4MsFkHuwjycNElvEVtuMjpf4yWDL10-0C5l2MqqRQ");
×
608
        recommendedPiTemplateOptionIds.add("https://w3id.org/np/RA16U9Wo30ObhrK1NzH7EsmVRiRtvEuEA_Dfc-u8WkUCA");
×
609
        recommendedPiTemplateOptionIds.add("http://purl.org/np/RAdyqI6k07V5nAS82C6hvIDtNWk179EIV4DV-sLbOFKg4");
×
610
        recommendedPiTemplateOptionIds.add("https://w3id.org/np/RAjvEpLZUE7rMoa8q6mWSsN6utJDp-5FmgO47YGsbgw3w");
×
611
        recommendedPiTemplateOptionIds.add("http://purl.org/np/RAxuGRKID6yNg63V5Mf0ot2NjncOnodh-mkN3qT_1txGI");
×
612
        for (TemplateContext c : pubInfoContexts) {
×
613
            String s = c.getTemplate().getId();
×
614
            handledPiTemplates.put(s, true);
×
615
        }
×
616
        for (String s : recommendedPiTemplateOptionIds) {
×
617
            handledPiTemplates.put(s, true);
×
618
        }
×
619

620
        for (ApiResponseEntry entry : td.getPubInfoTemplates()) {
×
621
            String tid = entry.get("np");
×
622
            if (handledPiTemplates.containsKey(tid)) continue;
×
623
            piTemplateOptionIds.add(tid);
×
624
            handledPiTemplates.put(tid, true);
×
625
        }
×
626

627
        ChoiceProvider<String> piTemplateChoiceProvider = new ChoiceProvider<String>() {
×
628

629
            private static final long serialVersionUID = 1L;
630

631
            @Override
632
            public String getDisplayValue(String object) {
633
                if (object == null || object.isEmpty()) return "";
×
634
                Template t = td.getTemplate(object);
×
635
                if (t != null) return t.getLabel();
×
636
                return object;
×
637
            }
638

639
            @Override
640
            public String getIdValue(String object) {
641
                return object;
×
642
            }
643

644
            // Getting strange errors with Tomcat if this method is not overridden:
645
            @Override
646
            public void detach() {
647
            }
×
648

649
            @Override
650
            public void query(String term, int page, Response<String> response) {
651
                if (term == null) term = "";
×
652
                term = term.toLowerCase();
×
653
                if (!recommendedPiTemplateOptionIds.isEmpty()) {
×
654
                    response.add("—— recommended ——");
×
655
                    for (String s : recommendedPiTemplateOptionIds) {
×
656
                        boolean isAlreadyUsed = false;
×
657
                        for (TemplateContext c : pubInfoContexts) {
×
658
                            // TODO: make this more efficient/nicer
659
                            if (c.getTemplate().getId().equals(s)) {
×
660
                                isAlreadyUsed = true;
×
661
                                break;
×
662
                            }
663
                        }
×
664
                        if (isAlreadyUsed) continue;
×
665
                        if (s.toLowerCase().contains(term) || getDisplayValue(s).toLowerCase().contains(term)) {
×
666
                            response.add(s);
×
667
                        }
668
                    }
×
669
                }
670
                if (!piTemplateOptionIds.isEmpty()) {
×
671
                    response.add("—— others ——");
×
672
                    for (String s : piTemplateOptionIds) {
×
673
                        boolean isAlreadyUsed = false;
×
674
                        for (TemplateContext c : pubInfoContexts) {
×
675
                            // TODO: make this more efficient/nicer
676
                            if (c.getTemplate().getId().equals(s)) {
×
677
                                isAlreadyUsed = true;
×
678
                                break;
×
679
                            }
680
                        }
×
681
                        if (isAlreadyUsed) continue;
×
682
                        if (s.toLowerCase().contains(term) || getDisplayValue(s).toLowerCase().contains(term)) {
×
683
                            response.add(s);
×
684
                        }
685
                    }
×
686
                }
687
            }
×
688

689
            @Override
690
            public Collection<String> toChoices(Collection<String> ids) {
691
                return ids;
×
692
            }
693

694
        };
695
        final IModel<String> newPiTemplateModel = Model.of();
×
696
        Select2Choice<String> piTemplateChoice = new Select2Choice<String>("pitemplate", newPiTemplateModel, piTemplateChoiceProvider);
×
697
        piTemplateChoice.getSettings().setCloseOnSelect(true);
×
698
        piTemplateChoice.getSettings().setPlaceholder("add element...");
×
699
        piTemplateChoice.add(new AjaxFormComponentUpdatingBehavior("change") {
×
700

701
            private static final long serialVersionUID = 1L;
702

703
            @Override
704
            protected void onUpdate(AjaxRequestTarget target) {
705
                if (newPiTemplateModel.getObject().startsWith("——")) {
×
706
                    newPiTemplateModel.setObject(null);
×
707
                    refreshPubInfo(target);
×
708
                    return;
×
709
                }
710
                String id = newPiTemplateModel.getObject();
×
711
                TemplateContext c = new TemplateContext(ContextType.PUBINFO, id, "pi-statement", targetNamespace);
×
712
                c.initStatements();
×
713
                pubInfoContexts.add(c);
×
714
                newPiTemplateModel.setObject(null);
×
715
                refreshPubInfo(target);
×
716
                c.finalizeStatements();
×
717
            }
×
718

719
        });
720
        form.add(piTemplateChoice);
×
721
        refreshPubInfo(null);
×
722

723
        form.add(consentCheck);
×
724
        add(form);
×
725

726
        feedbackPanel = new FeedbackPanel("feedback");
×
727
        feedbackPanel.setOutputMarkupId(true);
×
728
        add(feedbackPanel);
×
729
    }
×
730

731
    private void refreshProvenance(AjaxRequestTarget target) {
732
        if (target != null) {
×
733
            form.remove("prtemplatelink");
×
734
            form.remove("pr-statements");
×
735
            target.add(form);
×
736
            target.appendJavaScript("updateElements();");
×
737
        }
738
        form.add(new BookmarkablePageLink<Void>("prtemplatelink", ExplorePage.class, new PageParameters().add("id", provenanceContext.getTemplate().getId())));
×
739
        ListView<StatementItem> list = new ListView<StatementItem>("pr-statements", provenanceContext.getStatementItems()) {
×
740

741
            private static final long serialVersionUID = 1L;
742

743
            protected void populateItem(ListItem<StatementItem> item) {
744
                item.add(item.getModelObject());
×
745
            }
×
746

747
        };
748
        list.setOutputMarkupId(true);
×
749
        form.add(list);
×
750
    }
×
751

752
    private void refreshPubInfo(AjaxRequestTarget target) {
753
        ListView<TemplateContext> list = new ListView<TemplateContext>("pis", pubInfoContexts) {
×
754

755
            private static final long serialVersionUID = 1L;
756

757
            protected void populateItem(ListItem<TemplateContext> item) {
758
                final TemplateContext pic = item.getModelObject();
×
759
                item.add(new Label("pitemplatename", pic.getTemplate().getLabel()));
×
760
                item.add(new BookmarkablePageLink<Void>("pitemplatelink", ExplorePage.class, new PageParameters().add("id", pic.getTemplate().getId())));
×
761
                Label remove = new Label("piremove", "×");
×
762
                item.add(remove);
×
763
                remove.add(new AjaxEventBehavior("click") {
×
764
                    private static final long serialVersionUID = 1L;
765

766
                    @Override
767
                    protected void onEvent(AjaxRequestTarget target) {
768
                        pubInfoContexts.remove(pic);
×
769
                        target.add(PublishForm.this);
×
770
                        target.appendJavaScript("updateElements();");
×
771
                    }
×
772
                });
773
                if (requiredPubInfoContexts.contains(pic)) remove.setVisible(false);
×
774
                item.add(new ListView<StatementItem>("pi-statements", pic.getStatementItems()) {
×
775

776
                    private static final long serialVersionUID = 1L;
777

778
                    protected void populateItem(ListItem<StatementItem> item) {
779
                        item.add(item.getModelObject());
×
780
                    }
×
781

782
                });
783
            }
×
784

785
        };
786
        list.setOutputMarkupId(true);
×
787
        if (target == null) {
×
788
            form.add(list);
×
789
        } else {
790
            form.remove("pis");
×
791
            form.add(list);
×
792
            target.add(form);
×
793
            target.appendJavaScript("updateElements();");
×
794
        }
795
    }
×
796

797
    private TemplateContext createPubinfoContext(String piTemplateId) {
798
        TemplateContext c;
799
        if (pubInfoContextMap.containsKey(piTemplateId)) {
×
800
            c = pubInfoContextMap.get(piTemplateId);
×
801
        } else {
802
            c = new TemplateContext(ContextType.PUBINFO, piTemplateId, "pi-statement", targetNamespace);
×
803
            pubInfoContextMap.put(piTemplateId, c);
×
804
            pubInfoContexts.add(c);
×
805
        }
806
        return c;
×
807
    }
808

809
    private synchronized Nanopub createNanopub() throws MalformedNanopubException {
810
        assertionContext.getIntroducedIris().clear();
×
811
        NanopubCreator npCreator = new NanopubCreator(targetNamespace);
×
812
        npCreator.setAssertionUri(vf.createIRI(targetNamespace + "assertion"));
×
813
        assertionContext.propagateStatements(npCreator);
×
814
        provenanceContext.propagateStatements(npCreator);
×
815
        for (TemplateContext c : pubInfoContexts) {
×
816
            c.propagateStatements(npCreator);
×
817
        }
×
818
        for (IRI introducedIri : assertionContext.getIntroducedIris()) {
×
819
            npCreator.addPubinfoStatement(NPX.INTRODUCES, introducedIri);
×
820
        }
×
821
        for (IRI embeddedIri : assertionContext.getEmbeddedIris()) {
×
822
            npCreator.addPubinfoStatement(NPX.EMBEDS, embeddedIri);
×
823
        }
×
824
        npCreator.addNamespace("this", targetNamespace);
×
825
        npCreator.addNamespace("sub", targetNamespace + "/");
×
826
        npCreator.addTimestampNow();
×
827
        IRI templateUri = assertionContext.getTemplate().getNanopub().getUri();
×
828
        npCreator.addPubinfoStatement(NTEMPLATE.WAS_CREATED_FROM_TEMPLATE, templateUri);
×
829
        IRI prTemplateUri = provenanceContext.getTemplate().getNanopub().getUri();
×
830
        npCreator.addPubinfoStatement(NTEMPLATE.WAS_CREATED_FROM_PROVENANCE_TEMPLATE, prTemplateUri);
×
831
        for (TemplateContext c : pubInfoContexts) {
×
832
            IRI piTemplateUri = c.getTemplate().getNanopub().getUri();
×
833
            npCreator.addPubinfoStatement(NTEMPLATE.WAS_CREATED_FROM_PUBINFO_TEMPLATE, piTemplateUri);
×
834
        }
×
835
        String nanopubLabel = getNanopubLabel(npCreator);
×
836
        if (nanopubLabel != null) {
×
837
            npCreator.addPubinfoStatement(RDFS.LABEL, vf.createLiteral(nanopubLabel));
×
838
        }
839
        for (IRI type : assertionContext.getTemplate().getTargetNanopubTypes()) {
×
840
            npCreator.addPubinfoStatement(NPX.HAS_NANOPUB_TYPE, type);
×
841
        }
×
842
        IRI userIri = NanodashSession.get().getUserIri();
×
843
        if (User.getName(userIri) != null) {
×
844
            npCreator.addPubinfoStatement(userIri, FOAF.NAME, vf.createLiteral(User.getName(userIri)));
×
845
            npCreator.addNamespace("foaf", FOAF.NAMESPACE);
×
846
        }
847
        String websiteUrl = NanodashPreferences.get().getWebsiteUrl();
×
848
        if (websiteUrl != null) {
×
849
            npCreator.addPubinfoStatement(NPX.WAS_CREATED_AT, vf.createIRI(websiteUrl));
×
850
        }
851
        return npCreator.finalizeNanopub();
×
852
    }
853

854
    private String getNanopubLabel(NanopubCreator npCreator) {
855
        if (assertionContext.getTemplate().getNanopubLabelPattern() == null) return null;
×
856

857
        Map<IRI, String> labelMap = new HashMap<>();
×
858
        for (Statement st : npCreator.getCurrentPubinfoStatements()) {
×
859
            if (st.getPredicate().equals(RDFS.LABEL) && st.getObject() instanceof Literal objL) {
×
860
                labelMap.put((IRI) st.getSubject(), objL.stringValue());
×
861
            }
862
        }
×
863

864
        String nanopubLabel = assertionContext.getTemplate().getNanopubLabelPattern();
×
865
        while (nanopubLabel.matches(".*\\$\\{[_a-zA-Z0-9-]+\\}.*")) {
×
866
            String placeholderPostfix = nanopubLabel.replaceFirst("^.*\\$\\{([_a-zA-Z0-9-]+)\\}.*$", "$1");
×
867
            IRI placeholderIriHash = vf.createIRI(assertionContext.getTemplateId() + "#" + placeholderPostfix);
×
868
            IRI placeholderIriSlash = vf.createIRI(assertionContext.getTemplateId() + "/" + placeholderPostfix);
×
869
            IRI placeholderIri = null;
×
870
            String placeholderValue = "";
×
871
            if (assertionContext.getComponentModels().get(placeholderIriSlash) != null) {
×
872
                placeholderIri = placeholderIriSlash;
×
873
            } else {
874
                placeholderIri = placeholderIriHash;
×
875
            }
876
            IModel<String> m = assertionContext.getComponentModels().get(placeholderIri);
×
877
            if (m != null) placeholderValue = m.orElse("").getObject();
×
878
            if (placeholderValue == null) placeholderValue = "";
×
879
            String placeholderLabel = placeholderValue;
×
880
            if (assertionContext.getTemplate().isUriPlaceholder(placeholderIri)) {
×
881
                try {
882
                    // TODO Fix this. It doesn't work for placeholders with auto-encode placeholders, etc.
883
                    //      Not sure we need labels for these, but this code should be improved anyway.
884
                    String prefix = assertionContext.getTemplate().getPrefix(placeholderIri);
×
885
                    if (prefix != null) placeholderValue = prefix + placeholderValue;
×
886
                    IRI placeholderValueIri = vf.createIRI(placeholderValue);
×
887
                    String l = assertionContext.getTemplate().getLabel(placeholderValueIri);
×
888
                    if (labelMap.containsKey(placeholderValueIri)) {
×
889
                        l = labelMap.get(placeholderValueIri);
×
890
                    }
891
                    if (l == null) l = GuidedChoiceItem.getLabel(placeholderValue);
×
892
                    if (assertionContext.getTemplate().isAgentPlaceholder(placeholderIri) && !placeholderValue.isEmpty()) {
×
893
                        l = User.getName(vf.createIRI(placeholderValue));
×
894
                    }
895
                    if (l != null && !l.isEmpty()) {
×
896
                        placeholderLabel = l.replaceFirst(" - .*$", "");
×
897
                    } else {
898
                        placeholderLabel = Utils.getShortNameFromURI(placeholderValueIri);
×
899
                    }
900
                } catch (Exception ex) {
×
901
                    ex.printStackTrace();
×
902
                }
×
903
            }
904
            placeholderLabel = placeholderLabel.replaceAll("\\s+", " ");
×
905
            if (placeholderLabel.length() > 100) placeholderLabel = placeholderLabel.substring(0, 97) + "...";
×
906
            nanopubLabel = StringUtils.replace(nanopubLabel, "${" + placeholderPostfix + "}", placeholderLabel);
×
907
        }
×
908
        return nanopubLabel;
×
909
    }
910

911
    private NanodashPage getConfirmPage(Nanopub signedNp, PageParameters pageParams) {
912
        try {
913
            return (NanodashPage) confirmPageClass.getConstructor(Nanopub.class, PageParameters.class).newInstance(signedNp, pageParams);
×
914
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException |
×
915
                 InvocationTargetException | NoSuchMethodException | SecurityException ex) {
916
            ex.printStackTrace();
×
917
        }
918
        return null;
×
919
    }
920

921
    /**
922
     * Returns a hint whether the form is stateless or not.
923
     *
924
     * @return false if the form is stateful, true if it is stateless.
925
     */
926
    // This is supposed to solve the problem that sometimes (but only sometimes) form content is reset
927
    // if the user browses other pages in parallel:
928
    protected boolean getStatelessHint() {
929
        return false;
×
930
    }
931

932
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc