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

knowledgepixels / nanodash / 17837235071

18 Sep 2025 05:58PM UTC coverage: 13.87%. Remained the same
17837235071

push

github

tkuhn
chore: Remove serialVersionUIDs

443 of 4022 branches covered (11.01%)

Branch coverage included in aggregate %.

1133 of 7341 relevant lines covered (15.43%)

0.68 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 java.lang.reflect.InvocationTargetException;
4
import java.util.ArrayList;
5
import java.util.Collection;
6
import java.util.HashMap;
7
import java.util.List;
8
import java.util.Map;
9

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

62
import com.knowledgepixels.nanodash.page.ExplorePage;
63
import com.knowledgepixels.nanodash.page.NanodashPage;
64
import com.knowledgepixels.nanodash.template.ContextType;
65
import com.knowledgepixels.nanodash.template.Template;
66
import com.knowledgepixels.nanodash.template.TemplateContext;
67
import com.knowledgepixels.nanodash.template.TemplateData;
68
import com.knowledgepixels.nanodash.template.ValueFiller;
69

70
/**
71
 * Form for publishing a nanopublication.
72
 */
73
public class PublishForm extends Panel {
74

75
    private static final Logger logger = LoggerFactory.getLogger(PublishForm.class);
×
76

77
    private static ValueFactory vf = SimpleValueFactory.getInstance();
×
78

79
    private static String creatorPubinfoTemplateId = "https://w3id.org/np/RAukAcWHRDlkqxk7H2XNSegc1WnHI569INvNr-xdptDGI";
×
80
    private static String licensePubinfoTempalteId = "https://w3id.org/np/RA0J4vUn_dekg-U1kK3AOEt02p9mT2WO03uGxLDec1jLw";
×
81
    private static String defaultProvTemplateId = "https://w3id.org/np/RA7lSq6MuK_TIC6JMSHvLtee3lpLoZDOqLJCLXevnrPoU";
×
82
    private static String supersedesPubinfoTemplateId = "https://w3id.org/np/RAoTD7udB2KtUuOuAe74tJi1t3VzK0DyWS7rYVAq1GRvw";
×
83
    private static String derivesFromPubinfoTemplateId = "https://w3id.org/np/RARW4MsFkHuwjycNElvEVtuMjpf4yWDL10-0C5l2MqqRQ";
×
84

85
    private static String[] fixedPubInfoTemplates = new String[]{creatorPubinfoTemplateId, licensePubinfoTempalteId};
×
86

87
    /**
88
     * Fill modes for the nanopublication to be created.
89
     */
90
    public enum FillMode {USE, SUPERSEDE, DERIVE}
×
91

92
    protected Form<?> form;
93
    protected FeedbackPanel feedbackPanel;
94
    private final TemplateContext assertionContext;
95
    private TemplateContext provenanceContext;
96
    private List<TemplateContext> pubInfoContexts = new ArrayList<>();
×
97
    private Map<String, TemplateContext> pubInfoContextMap = new HashMap<>();
×
98
    private List<TemplateContext> requiredPubInfoContexts = new ArrayList<>();
×
99
    private String targetNamespace;
100
    private Class<? extends WebPage> confirmPageClass;
101

102
    /**
103
     * Constructor for the PublishForm.
104
     *
105
     * @param id               the Wicket component ID
106
     * @param pageParams       the parameters for the page, which may include information on how to fill the form
107
     * @param publishPageClass the class of the page to redirect to after successful publication
108
     * @param confirmPageClass the class of the confirmation page to show after publication
109
     */
110
    public PublishForm(String id, final PageParameters pageParams, Class<? extends WebPage> publishPageClass, Class<? extends WebPage> confirmPageClass) {
111
        super(id);
×
112
        setOutputMarkupId(true);
×
113
        this.confirmPageClass = confirmPageClass;
×
114

115
        WebMarkupContainer linkMessageItem = new WebMarkupContainer("link-message-item");
×
116
        if (pageParams.get("link-message").isNull()) {
×
117
            linkMessageItem.add(new Label("link-message", ""));
×
118
            linkMessageItem.setVisible(false);
×
119
        } else {
120
            linkMessageItem.add(new Label("link-message", Utils.sanitizeHtml(pageParams.get("link-message").toString())).setEscapeModelStrings(false));
×
121
        }
122
        add(linkMessageItem);
×
123

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

162
        final TemplateData td = TemplateData.get();
×
163

164
        // TODO Properly integrate this namespace feature:
165
        String templateId = pageParams.get("template").toString();
×
166
        if (td.getTemplate(templateId).getTargetNamespace() != null) {
×
167
            targetNamespace = td.getTemplate(templateId).getTargetNamespace();
×
168
        }
169
        if (!pageParams.get("target-namespace").isNull()) {
×
170
            targetNamespace = pageParams.get("target-namespace").toString();
×
171
        }
172
        if (targetNamespace == null) {
×
173
            targetNamespace = Template.DEFAULT_TARGET_NAMESPACE;
×
174
        }
175
        String targetNamespaceLabel = targetNamespace + "...";
×
176
        targetNamespace = targetNamespace + "~~~ARTIFACTCODE~~~/";
×
177

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

264
        // Init statements only now, in order to pick up parameter values:
265
        assertionContext.initStatements();
×
266
        provenanceContext.initStatements();
×
267
        for (TemplateContext c : pubInfoContexts) {
×
268
            c.initStatements();
×
269
        }
×
270

271
        String latestAssertionId = QueryApiAccess.getLatestVersionId(assertionContext.getTemplateId());
×
272
        if (!assertionContext.getTemplateId().equals(latestAssertionId)) {
×
273
            add(new Label("newversion", "There is a new version of this assertion template:"));
×
274
            PageParameters params = new PageParameters(pageParams);
×
275
            params.set("template", latestAssertionId).remove("formobj");
×
276
            add(new BookmarkablePageLink<Void>("newversionlink", publishPageClass, params));
×
277
            if ("latest".equals(pageParams.get("template-version").toString())) {
×
278
                throw new RestartResponseException(publishPageClass, params);
×
279
            }
280
        } else {
×
281
            add(new Label("newversion", "").setVisible(false));
×
282
            add(new Label("newversionlink", "").setVisible(false));
×
283
        }
284

285
        final Nanopub improveNp;
286
        if (!pageParams.get("improve").isNull()) {
×
287
            improveNp = Utils.getNanopub(pageParams.get("improve").toString());
×
288
        } else {
289
            improveNp = null;
×
290
        }
291

292
        final List<Statement> unusedStatementList = new ArrayList<>();
×
293
        final List<Statement> unusedPrStatementList = new ArrayList<>();
×
294
        final List<Statement> unusedPiStatementList = new ArrayList<>();
×
295
        if (fillNp != null) {
×
296
            ValueFiller filler = new ValueFiller(fillNp, ContextType.ASSERTION, true, fillMode);
×
297
            filler.fill(assertionContext);
×
298
            unusedStatementList.addAll(filler.getUnusedStatements());
×
299

300
            if (!fillOnlyAssertion) {
×
301
                ValueFiller prFiller = new ValueFiller(fillNp, ContextType.PROVENANCE, true);
×
302
                prFiller.fill(provenanceContext);
×
303
                unusedPrStatementList.addAll(prFiller.getUnusedStatements());
×
304

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

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

356
        });
357
        add(new DataView<Statement>("unused-prstatements", new ListDataProvider<Statement>(unusedPrStatementList)) {
×
358

359
            @Override
360
            protected void populateItem(Item<Statement> item) {
361
                item.add(new TripleItem("unused-prstatement", item.getModelObject(), (fillNp != null ? fillNp : improveNp), null));
×
362
            }
×
363

364
        });
365
        add(new DataView<Statement>("unused-pistatements", new ListDataProvider<Statement>(unusedPiStatementList)) {
×
366

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

372
        });
373

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

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

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

393
        });
394

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

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

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

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

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

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

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

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

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

467
            protected void populateItem(ListItem<StatementItem> item) {
468
                item.add(item.getModelObject());
×
469
            }
×
470

471
        });
472

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

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

513
        ChoiceProvider<String> prTemplateChoiceProvider = new ChoiceProvider<String>() {
×
514

515
            @Override
516
            public String getDisplayValue(String object) {
517
                if (object == null || object.isEmpty()) return "";
×
518
                Template t = td.getTemplate(object);
×
519
                if (t != null) return t.getLabel();
×
520
                return object;
×
521
            }
522

523
            @Override
524
            public String getIdValue(String object) {
525
                return object;
×
526
            }
527

528
            // Getting strange errors with Tomcat if this method is not overridden:
529
            @Override
530
            public void detach() {
531
            }
×
532

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

566
            @Override
567
            public Collection<String> toChoices(Collection<String> ids) {
568
                return ids;
×
569
            }
570

571
        };
572
        final IModel<String> prTemplateModel = Model.of(provenanceContext.getTemplate().getId());
×
573
        Select2Choice<String> prTemplateChoice = new Select2Choice<String>("prtemplate", prTemplateModel, prTemplateChoiceProvider);
×
574
        prTemplateChoice.setRequired(true);
×
575
        prTemplateChoice.getSettings().setCloseOnSelect(true);
×
576
        prTemplateChoice.add(new AjaxFormComponentUpdatingBehavior("change") {
×
577

578
            @Override
579
            protected void onUpdate(AjaxRequestTarget target) {
580
                String o = prTemplateModel.getObject();
×
581
                if (o.startsWith("——")) {
×
582
                    o = provenanceContext.getTemplate().getId();
×
583
                    prTemplateModel.setObject(o);
×
584
                }
585
                provenanceContext = new TemplateContext(ContextType.PROVENANCE, prTemplateModel.getObject(), "pr-statement", targetNamespace);
×
586
                provenanceContext.initStatements();
×
587
                refreshProvenance(target);
×
588
                provenanceContext.finalizeStatements();
×
589
            }
×
590

591
        });
592
        form.add(prTemplateChoice);
×
593
        refreshProvenance(null);
×
594

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

613
        for (ApiResponseEntry entry : td.getPubInfoTemplates()) {
×
614
            String tid = entry.get("np");
×
615
            if (handledPiTemplates.containsKey(tid)) continue;
×
616
            piTemplateOptionIds.add(tid);
×
617
            handledPiTemplates.put(tid, true);
×
618
        }
×
619

620
        ChoiceProvider<String> piTemplateChoiceProvider = new ChoiceProvider<String>() {
×
621

622
            @Override
623
            public String getDisplayValue(String object) {
624
                if (object == null || object.isEmpty()) return "";
×
625
                Template t = td.getTemplate(object);
×
626
                if (t != null) return t.getLabel();
×
627
                return object;
×
628
            }
629

630
            @Override
631
            public String getIdValue(String object) {
632
                return object;
×
633
            }
634

635
            // Getting strange errors with Tomcat if this method is not overridden:
636
            @Override
637
            public void detach() {
638
            }
×
639

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

680
            @Override
681
            public Collection<String> toChoices(Collection<String> ids) {
682
                return ids;
×
683
            }
684

685
        };
686
        final IModel<String> newPiTemplateModel = Model.of();
×
687
        Select2Choice<String> piTemplateChoice = new Select2Choice<String>("pitemplate", newPiTemplateModel, piTemplateChoiceProvider);
×
688
        piTemplateChoice.getSettings().setCloseOnSelect(true);
×
689
        piTemplateChoice.getSettings().setPlaceholder("add element...");
×
690
        piTemplateChoice.add(new AjaxFormComponentUpdatingBehavior("change") {
×
691

692
            @Override
693
            protected void onUpdate(AjaxRequestTarget target) {
694
                if (newPiTemplateModel.getObject().startsWith("——")) {
×
695
                    newPiTemplateModel.setObject(null);
×
696
                    refreshPubInfo(target);
×
697
                    return;
×
698
                }
699
                String id = newPiTemplateModel.getObject();
×
700
                TemplateContext c = new TemplateContext(ContextType.PUBINFO, id, "pi-statement", targetNamespace);
×
701
                c.initStatements();
×
702
                pubInfoContexts.add(c);
×
703
                newPiTemplateModel.setObject(null);
×
704
                refreshPubInfo(target);
×
705
                c.finalizeStatements();
×
706
            }
×
707

708
        });
709
        form.add(piTemplateChoice);
×
710
        refreshPubInfo(null);
×
711

712
        form.add(consentCheck);
×
713
        add(form);
×
714

715
        feedbackPanel = new FeedbackPanel("feedback");
×
716
        feedbackPanel.setOutputMarkupId(true);
×
717
        add(feedbackPanel);
×
718
    }
×
719

720
    private void refreshProvenance(AjaxRequestTarget target) {
721
        if (target != null) {
×
722
            form.remove("prtemplatelink");
×
723
            form.remove("pr-statements");
×
724
            target.add(form);
×
725
            target.appendJavaScript("updateElements();");
×
726
        }
727
        form.add(new BookmarkablePageLink<Void>("prtemplatelink", ExplorePage.class, new PageParameters().add("id", provenanceContext.getTemplate().getId())));
×
728
        ListView<StatementItem> list = new ListView<StatementItem>("pr-statements", provenanceContext.getStatementItems()) {
×
729

730
            protected void populateItem(ListItem<StatementItem> item) {
731
                item.add(item.getModelObject());
×
732
            }
×
733

734
        };
735
        list.setOutputMarkupId(true);
×
736
        form.add(list);
×
737
    }
×
738

739
    private void refreshPubInfo(AjaxRequestTarget target) {
740
        ListView<TemplateContext> list = new ListView<TemplateContext>("pis", pubInfoContexts) {
×
741

742
            protected void populateItem(ListItem<TemplateContext> item) {
743
                final TemplateContext pic = item.getModelObject();
×
744
                item.add(new Label("pitemplatename", pic.getTemplate().getLabel()));
×
745
                item.add(new BookmarkablePageLink<Void>("pitemplatelink", ExplorePage.class, new PageParameters().add("id", pic.getTemplate().getId())));
×
746
                Label remove = new Label("piremove", "×");
×
747
                item.add(remove);
×
748
                remove.add(new AjaxEventBehavior("click") {
×
749

750
                    @Override
751
                    protected void onEvent(AjaxRequestTarget target) {
752
                        pubInfoContexts.remove(pic);
×
753
                        target.add(PublishForm.this);
×
754
                        target.appendJavaScript("updateElements();");
×
755
                    }
×
756

757
                });
758
                if (requiredPubInfoContexts.contains(pic)) remove.setVisible(false);
×
759
                item.add(new ListView<StatementItem>("pi-statements", pic.getStatementItems()) {
×
760

761
                    protected void populateItem(ListItem<StatementItem> item) {
762
                        item.add(item.getModelObject());
×
763
                    }
×
764

765
                });
766
            }
×
767

768
        };
769
        list.setOutputMarkupId(true);
×
770
        if (target == null) {
×
771
            form.add(list);
×
772
        } else {
773
            form.remove("pis");
×
774
            form.add(list);
×
775
            target.add(form);
×
776
            target.appendJavaScript("updateElements();");
×
777
        }
778
    }
×
779

780
    private TemplateContext createPubinfoContext(String piTemplateId) {
781
        TemplateContext c;
782
        if (pubInfoContextMap.containsKey(piTemplateId)) {
×
783
            c = pubInfoContextMap.get(piTemplateId);
×
784
        } else {
785
            c = new TemplateContext(ContextType.PUBINFO, piTemplateId, "pi-statement", targetNamespace);
×
786
            pubInfoContextMap.put(piTemplateId, c);
×
787
            pubInfoContexts.add(c);
×
788
        }
789
        return c;
×
790
    }
791

792
    private synchronized Nanopub createNanopub() throws MalformedNanopubException, NanopubAlreadyFinalizedException {
793
        assertionContext.getIntroducedIris().clear();
×
794
        NanopubCreator npCreator = new NanopubCreator(targetNamespace);
×
795
        npCreator.setAssertionUri(vf.createIRI(targetNamespace + "assertion"));
×
796
        assertionContext.propagateStatements(npCreator);
×
797
        provenanceContext.propagateStatements(npCreator);
×
798
        for (TemplateContext c : pubInfoContexts) {
×
799
            c.propagateStatements(npCreator);
×
800
        }
×
801
        for (IRI introducedIri : assertionContext.getIntroducedIris()) {
×
802
            npCreator.addPubinfoStatement(NPX.INTRODUCES, introducedIri);
×
803
        }
×
804
        for (IRI embeddedIri : assertionContext.getEmbeddedIris()) {
×
805
            npCreator.addPubinfoStatement(NPX.EMBEDS, embeddedIri);
×
806
        }
×
807
        npCreator.addNamespace("this", targetNamespace);
×
808
        npCreator.addNamespace("sub", targetNamespace + "/");
×
809
        npCreator.addTimestampNow();
×
810
        IRI templateUri = assertionContext.getTemplate().getNanopub().getUri();
×
811
        npCreator.addPubinfoStatement(NTEMPLATE.WAS_CREATED_FROM_TEMPLATE, templateUri);
×
812
        IRI prTemplateUri = provenanceContext.getTemplate().getNanopub().getUri();
×
813
        npCreator.addPubinfoStatement(NTEMPLATE.WAS_CREATED_FROM_PROVENANCE_TEMPLATE, prTemplateUri);
×
814
        for (TemplateContext c : pubInfoContexts) {
×
815
            IRI piTemplateUri = c.getTemplate().getNanopub().getUri();
×
816
            npCreator.addPubinfoStatement(NTEMPLATE.WAS_CREATED_FROM_PUBINFO_TEMPLATE, piTemplateUri);
×
817
        }
×
818
        String nanopubLabel = getNanopubLabel(npCreator);
×
819
        if (nanopubLabel != null) {
×
820
            npCreator.addPubinfoStatement(RDFS.LABEL, vf.createLiteral(nanopubLabel));
×
821
        }
822
        for (IRI type : assertionContext.getTemplate().getTargetNanopubTypes()) {
×
823
            npCreator.addPubinfoStatement(NPX.HAS_NANOPUB_TYPE, type);
×
824
        }
×
825
        IRI userIri = NanodashSession.get().getUserIri();
×
826
        if (User.getName(userIri) != null) {
×
827
            npCreator.addPubinfoStatement(userIri, FOAF.NAME, vf.createLiteral(User.getName(userIri)));
×
828
            npCreator.addNamespace("foaf", FOAF.NAMESPACE);
×
829
        }
830
        String websiteUrl = NanodashPreferences.get().getWebsiteUrl();
×
831
        if (websiteUrl != null) {
×
832
            npCreator.addPubinfoStatement(NPX.WAS_CREATED_AT, vf.createIRI(websiteUrl));
×
833
        }
834
        return npCreator.finalizeNanopub();
×
835
    }
836

837
    private String getNanopubLabel(NanopubCreator npCreator) {
838
        if (assertionContext.getTemplate().getNanopubLabelPattern() == null) return null;
×
839

840
        Map<IRI, String> labelMap = new HashMap<>();
×
841
        for (Statement st : npCreator.getCurrentPubinfoStatements()) {
×
842
            if (st.getPredicate().equals(RDFS.LABEL) && st.getObject() instanceof Literal objL) {
×
843
                labelMap.put((IRI) st.getSubject(), objL.stringValue());
×
844
            }
845
        }
×
846

847
        String nanopubLabel = assertionContext.getTemplate().getNanopubLabelPattern();
×
848
        while (nanopubLabel.matches(".*\\$\\{[_a-zA-Z0-9-]+\\}.*")) {
×
849
            String placeholderPostfix = nanopubLabel.replaceFirst("^.*\\$\\{([_a-zA-Z0-9-]+)\\}.*$", "$1");
×
850
            IRI placeholderIriHash = vf.createIRI(assertionContext.getTemplateId() + "#" + placeholderPostfix);
×
851
            IRI placeholderIriSlash = vf.createIRI(assertionContext.getTemplateId() + "/" + placeholderPostfix);
×
852
            IRI placeholderIri = null;
×
853
            String placeholderValue = "";
×
854
            if (assertionContext.getComponentModels().get(placeholderIriSlash) != null) {
×
855
                placeholderIri = placeholderIriSlash;
×
856
            } else {
857
                placeholderIri = placeholderIriHash;
×
858
            }
859
            IModel<String> m = assertionContext.getComponentModels().get(placeholderIri);
×
860
            if (m != null) placeholderValue = m.orElse("").getObject();
×
861
            if (placeholderValue == null) placeholderValue = "";
×
862
            String placeholderLabel = placeholderValue;
×
863
            if (assertionContext.getTemplate().isUriPlaceholder(placeholderIri)) {
×
864
                try {
865
                    // TODO Fix this. It doesn't work for placeholders with auto-encode placeholders, etc.
866
                    //      Not sure we need labels for these, but this code should be improved anyway.
867
                    String prefix = assertionContext.getTemplate().getPrefix(placeholderIri);
×
868
                    if (prefix != null) placeholderValue = prefix + placeholderValue;
×
869
                    IRI placeholderValueIri = vf.createIRI(placeholderValue);
×
870
                    String l = assertionContext.getTemplate().getLabel(placeholderValueIri);
×
871
                    if (labelMap.containsKey(placeholderValueIri)) {
×
872
                        l = labelMap.get(placeholderValueIri);
×
873
                    }
874
                    if (l == null) l = GuidedChoiceItem.getLabel(placeholderValue);
×
875
                    if (assertionContext.getTemplate().isAgentPlaceholder(placeholderIri) && !placeholderValue.isEmpty()) {
×
876
                        l = User.getName(vf.createIRI(placeholderValue));
×
877
                    }
878
                    if (l != null && !l.isEmpty()) {
×
879
                        placeholderLabel = l.replaceFirst(" - .*$", "");
×
880
                    } else {
881
                        placeholderLabel = Utils.getShortNameFromURI(placeholderValueIri);
×
882
                    }
883
                } catch (Exception ex) {
×
884
                    logger.error("Nanopub label placeholder IRI error: {}", ex.getMessage());
×
885
                }
×
886
            }
887
            placeholderLabel = placeholderLabel.replaceAll("\\s+", " ");
×
888
            if (placeholderLabel.length() > 100) placeholderLabel = placeholderLabel.substring(0, 97) + "...";
×
889
            nanopubLabel = Strings.CS.replace(nanopubLabel, "${" + placeholderPostfix + "}", placeholderLabel);
×
890
        }
×
891
        return nanopubLabel;
×
892
    }
893

894
    private NanodashPage getConfirmPage(Nanopub signedNp, PageParameters pageParams) {
895
        try {
896
            return (NanodashPage) confirmPageClass.getConstructor(Nanopub.class, PageParameters.class).newInstance(signedNp, pageParams);
×
897
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException |
×
898
                 InvocationTargetException | NoSuchMethodException | SecurityException ex) {
899
            logger.error("Could not create instance of confirmation page: {}", ex.getMessage());
×
900
        }
901
        return null;
×
902
    }
903

904
    /**
905
     * Returns a hint whether the form is stateless or not.
906
     *
907
     * @return false if the form is stateful, true if it is stateless.
908
     */
909
    // This is supposed to solve the problem that sometimes (but only sometimes) form content is reset
910
    // if the user browses other pages in parallel:
911
    protected boolean getStatelessHint() {
912
        return false;
×
913
    }
914

915
}
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