Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.GWT.forms.server.support.nonpublic;

import org.litesoft.GWT.forms.server.*;
import org.litesoft.GWT.forms.server.support.*;
import org.litesoft.*;
import org.litesoft.changemanagement.*;
import org.litesoft.commonfoundation.base.*;
import org.litesoft.commonfoundation.exceptions.*;
import org.litesoft.core.delayed.*;
import org.litesoft.core.simpletypes.*;
import org.litesoft.delayed.*;
import org.litesoft.ui.def.*;
import org.litesoft.ui.def.nonpublic.support.*;
import org.litesoft.ui.support.*;
import org.litesoft.ui_1_5.*;

import java.io.*;
import java.util.*;

public abstract class AbstractFormServicePeer implements FormServicePeer,
                                                         ServerStateChangedListener,
                                                         FSPTypeHelperBackDoor {
    public static final String ERR_COMMIT_FAILED = "CommitFailed";
    public static final String ERR_COMMIT_OUT_OF_DATE_DATA = "OutOfDateDataCausedCommitFailure";

    private final MillisecTimeSource mMillisecTimeSource = MillisecTimeSource.INSTANCE;

    protected volatile PushInterface mPushInterface = null;
    protected ISystemUserResolver mSystemUserResolver = ISystemUserResolver.NULL;
    protected Serializable mInitializationPayload;
    protected volatile boolean mIsNewRootObject;

    private volatile boolean mDisposed = false;
    private final TypeHelperManager mTypeHelperManager = new TypeHelperManager();
    private final InstanceHelperManager mInstanceHelperManager = new InstanceHelperManager();

    private final FormInteractionHelper mInteractionHelper = new FormInteractionHelper();

    private ServicePeerToFormDataProxy mCollectorProxy = new ServicePeerToFormDataProxy();

    public ServicePeerToFormDataProxy getCollectorProxy() {
        return mCollectorProxy;
    }

    protected void rootObjectCommited() {
        FormInteractionStructure zFIS = mInteractionHelper.rootObjectCommited();
        if ( zFIS != null ) {
            publish( zFIS, ServerStateChange.Action.UPDATED );
        }
    }

    private void handle( FormInteractionChange pChange ) {
        if ( pChange != null ) {
            FormInteractionStructure zOldData = pChange.getOldData();
            FormInteractionStructure zNewData = pChange.getNewData();

            if ( zOldData.isPublishable() ) {
                // todo: Need Instance of: ChangeListenerManager.removeListener( this );
                publish( zOldData, ServerStateChange.Action.DELETED );
            }
            if ( zNewData.isPublishable() ) {
                // todo: Need Instance of: ChangeListenerManager.addListener( this, "FSP:" + zNewData.getRootType(), (Serializable) zNewData.getRootObjectKey() );
                publish( zNewData, ServerStateChange.Action.CREATED );
            }

            getCollectorProxy().update( zOldData, zNewData );
        }
    }

    protected void setOurData( FormInteractionStructure pNewData ) {
        handle( mInteractionHelper.setOurData( pNewData ) );
    }

    private void publish( FormInteractionStructure pData, ServerStateChange.Action pAction ) {
        ServerStateChange zChange = new ServerStateChange( pAction, "FSP:" + pData.getRootType(), pData.getRootObjectKey(), null, pData );
        Long zSourceUniqueID = pData.getUniqueFormServicePeerID();
        ServerStateChangeSet zChangeSet = new ServerStateChangeSet( zSourceUniqueID, null, zChange );
        // todo: Need Instance of: ChangeListenerManager.notifyAllListeners( zChangeSet );
    }

    public void serverStateChanged( ServerStateChangeSet pServerStateChangeSet ) {
        // event order?
        FormInteractionIntersection zFII = mInteractionHelper.createFormInteractionIntersection( pServerStateChangeSet );
        if ( zFII.getData().isPublishable() ) {
            if ( zFII.isNewOthers() ) {
                // New Others may not know about us, so we publish (again)
                publish( zFII.getData(), ServerStateChange.Action.CREATED );
            }
            if ( zFII.isUpdateOthers() || zFII.isNewOthers() || zFII.isDelOthers() ) {
                getCollectorProxy().forceReturn();
                mRunnable.runOnOrAfter( 2000 ); // 2 secs
            }
        }
    }

    private MyTimedRunnable mRunnable = new MyTimedRunnable();

    private class MyTimedRunnable implements TimedRunnable {
        private Long mSendWhen = null;

        public synchronized void runOnOrAfter( int pSendIn ) {
            boolean zNotLaunched = (mSendWhen == null);

            long zSendWhen = mMillisecTimeSource.now() + pSendIn;

            mSendWhen = zSendWhen;

            if ( zNotLaunched ) {
                TimedRunnableManager.INSTANCE.runOnOrAfter( this, zSendWhen );
            }
        }

        public Again runOnce() {
            synchronized ( this ) {
                if ( mSendWhen == null ) {
                    return null;
                }
                if ( mMillisecTimeSource.now() < mSendWhen ) {
                    return new RunAgainOnOrAfter( mSendWhen );
                }
                mSendWhen = null;
            }
            sendUnsolicitedData();
            return null;
        }
    }

    protected Long getUniqueFormID() {
        return mInteractionHelper.getOurUniqueFormServicePeerID();
    }

    public SerializableSystemUserRef getSystemUserRef() {
        return mInteractionHelper.getOurSystemUserRef();
    }

    protected String getRootType() {
        return mInteractionHelper.getOurRootType();
    }

    protected String getRootObjectKey() {
        return mInteractionHelper.getOurRootObjectKey();
    }

    protected void setRootObjectKey( String pRootObjectKey ) {
        handle( mInteractionHelper.setRootObjectKey( pRootObjectKey ) );
    }

    public TypeHelper getRootTypeHelper() {
        return mTypeHelperManager.getRootTypeHelper();
    }

    public InstanceHelper getRootInstanceHelper() {
        return mInstanceHelperManager.getRootInstanceHelper();
    }

    protected void setFullUpdate() {
        getCollectorProxy().setFullUpdate();
    }

    protected void setCloseRequested() {
        getCollectorProxy().setCloseRequested();
    }

    protected void addWarning( String pWarningID, Object... pParameters ) {
        getCollectorProxy().addWarning( rootTypeResolveError( pWarningID, pParameters ) );
    }

    protected void addError( String pErrorID, Object... pParameters ) {
        getCollectorProxy().addError( rootTypeResolveError( pErrorID, pParameters ) );
    }

    protected boolean hasErrors() {
        return getCollectorProxy().hasErrors();
    }

    protected void setSuccessfulTriggeringActionIDIfNotSet( String pSuccessfulTriggeringActionID ) {
        getCollectorProxy().setSuccessfulTriggeringActionIDIfNotSet( pSuccessfulTriggeringActionID );
    }

    private String rootTypeResolveError( String pErrorID, Object... pParameters ) {
        TypeHelper zTypeHelper = getRootTypeHelper();
        String resolved = (zTypeHelper != null) ? zTypeHelper.resolveError( pErrorID ) : pErrorID;
        return ExternalizationInterface.Helper.injectParameters( resolved, pParameters );
    }

    private ExternalizationInterface getRootTypeExternalizationInterface() {
        TypeHelper zTypeHelper = getRootTypeHelper();
        return (zTypeHelper != null) ? zTypeHelper.getExternalization() : null;
    }

    protected void sendUnsolicitedData() {
        PushInterface zPushInterface = mPushInterface;
        if ( zPushInterface != null ) {
            ServicePeerToFormData zData =
                    getCollectorProxy().createReturnValueFromCollectorIfMatches( null, mInteractionHelper, getRootTypeExternalizationInterface() );
            if ( zData != null ) {
                zPushInterface.sendUnsolicitedData( zData );
            }
        }
    }

    // protects serializes FormServicePeer interface
    public synchronized final ServicePeerToFormCreationData initializeAndCreateFormMetaData( PushInterface pPushInterface,
                                                                                             ISystemUserResolver pSystemUserResolver,
                                                                                             Long pUniqueFormServicePeerID, ISystemUser pSystemUser,
                                                                                             FormUsage pUsage, Serializable pInitializationPayload,
                                                                                             ExternalizationInterface pExternalization,
                                                                                             FormAccessControl pAccessControl ) {
        mPushInterface = pPushInterface;

        initializationPayloadAvailable( mInitializationPayload = pInitializationPayload );

        String zRT = getRootTypeFromUsage( pUsage );

        mSystemUserResolver = (pSystemUserResolver != null) ? pSystemUserResolver : ISystemUserResolver.NULL;

        handle( mInteractionHelper.setOurData( new FormInteractionStructure( pUniqueFormServicePeerID, pSystemUser, zRT ) ) );

        LOGGER.trace.log( zRT, "-initializeAndCreateFormMetaData:", getUniqueFormID(), " for ", pSystemUser );

        TypeHelper zRootTypeHelper = createTypeHelper( this, augment( pExternalization ), pAccessControl, null, zRT, pUsage );

        mTypeHelperManager.setRootTypeHelper( zRootTypeHelper );
        mInstanceHelperManager.setRootInstanceHelper( createRootInstanceHelper( zRootTypeHelper ) );

        FormMetaData zMetaData = zRootTypeHelper.initializeAndCreateFormMetaData( pUsage );

        return new ServicePeerToFormCreationData( zMetaData, getFormRenderedServicePeerXtra() );
    }

    protected String getRootTypeFromUsage( FormUsage pUsage ) {
        return pUsage.getRootType();
    }

    public void add( TypeHelper pTypeHelper ) {
        mTypeHelperManager.add( pTypeHelper );
    }

    public void add( InstanceHelper pInstanceHelper ) {
        mInstanceHelperManager.add( pInstanceHelper );
    }

    public void removeInstanceHelper( FormDataRowKey pFormDataRowKey ) {
        mInstanceHelperManager.remove( pFormDataRowKey );
    }

    public final boolean isDisposed() {
        return mDisposed;
    }

    // protects serializes FormServicePeer interface
    public synchronized final void dispose() {
        if ( !mDisposed ) {
            mDisposed = true;
            try {
                LLdispose();
            }
            catch ( RuntimeException e ) {
                LOGGER.error.log( e );
            }

            mInstanceHelperManager.dispose();
            mTypeHelperManager.dispose();
            handle( mInteractionHelper.setOurData( null ) );
            mPushInterface = null;
            mInitializationPayload = null;
        }
    }

    // protects serializes FormServicePeer interface
    public synchronized final ServicePeerToFormData setRootObjectTo( Integer pAsyncMessageNumber, String pKey ) {
        LOGGER.trace.log( getRootType(), "-setRootObjectTo, key:", pKey );

        getCollectorProxy().setCallFromClientForm( pAsyncMessageNumber );

        mInstanceHelperManager.resetAllInstanceHelpers();

        LLsetRootObjectTo( pKey );

        mInstanceHelperManager.loadAllAttributeValues();

        return getCollectorProxy().createReturnValueFromCollectorIfMatches( pAsyncMessageNumber, mInteractionHelper, getRootTypeExternalizationInterface() );
    }

    // protects serializes FormServicePeer interface
    public synchronized final AttributeResourceOptionsResponseData getResourceOptions( AttributeResourceOptionsRequestData pRequest ) {
        return getResourceOptions( pRequest.getFormDataRowKey(), pRequest.getUniqueID(), pRequest.getAttributeReference() );
    }

    // protects serializes FormServicePeer interface
    public synchronized final ServicePeerToFormData formEvent( FormToServicePeerData pToServicePeerData ) {
        Confirm.isNotNull( "ToServicePeerData", pToServicePeerData );

        Integer zAsyncMessageNumber = pToServicePeerData.getAsyncMessageNumber();

        getCollectorProxy().setCallFromClientForm( zAsyncMessageNumber );

        ValueUpdatedFormData[] zValueUpdates = pToServicePeerData.getAttributeUpdates();
        if ( zValueUpdates != null ) {
            for ( ValueUpdatedFormData update : zValueUpdates ) {
                processValueUpdated( update.getFormDataRowKey(), //
                                     update.getUniqueID(), update.getAttributeReference(), update.getCurrentValue() );
            }
        }

        ActionRequestFormData action = pToServicePeerData.getActionRequest();
        if ( action != null ) {
            processActionRequest( action.getFormDataRowKey(), action.getActionID(), action.isInputAction(), action.getParentFormDataRowKey() );
        }

        return getCollectorProxy().createReturnValueFromCollectorIfMatches( zAsyncMessageNumber, mInteractionHelper, getRootTypeExternalizationInterface() );
    }

    protected AttributeResourceOptionsResponseData getResourceOptions( FormDataRowKey pFormDataRowKey, Integer pUniqueID, String pAttributeReference ) {
        InstanceHelper zInstanceHelper = getInstanceHelper( pFormDataRowKey );
        if ( (zInstanceHelper != null) ) {
            AMDconverterPair changingPair = zInstanceHelper.findAttribute( pUniqueID );
            if ( changingPair != null ) {
                return zInstanceHelper.getTypeHelper().getResourceOptions( pAttributeReference, changingPair.getDataConverter() );
            }
        }
        return new AttributeResourceOptionsResponseData( ResourceOptionsErrorType.ErrorReferenceNotFound );
    }

    private void processValueUpdated( FormDataRowKey pFormDataRowKey, //
                                      Integer pUniqueID, String pAttributeReference, //
                                      Serializable pNewValue ) {
        //System.out.println( getRootType() + "-valueUpdated on (" + pFormDataRowKey + ") '" +
        //                    pAttributeReference + "' to '" + pNewValue + "' type:" +
        //                    ((pNewValue != null) ? pNewValue.getClass() : null) );
        //
        LOGGER.trace.log( getRootType(), "-valueUpdated on (", pFormDataRowKey, ") '", pAttributeReference, "' to '", pNewValue, "' type:",
                          ((pNewValue != null) ? pNewValue.getClass() : null) );

        String zResolvedError = null;
        AMDconverterPair changingPair = null;
        boolean handled = false;

        try {
            handled = LLrawValueUpdated( pFormDataRowKey, pAttributeReference, pNewValue );
        }
        catch ( IllegalArgumentException e ) {
            addError( ERR_ILLEGAL_VALUE, "LLrawValueUpdated", e.getMessage() );
        }
        catch ( RuntimeException e ) {
            addError( ERR_UNEXPECTED, "LLrawValueUpdated", e.getMessage() );
        }

        if ( !handled && !hasErrors() ) {
            InstanceHelper zInstanceHelper = getInstanceHelper( pFormDataRowKey );
            if ( zInstanceHelper == null ) {
                addError( ERR_ATTR_NOT_FOUND );
            } else if ( (null == (changingPair = zInstanceHelper.findAttribute( pUniqueID ))) ) {
                addError( ERR_ATTR_NOT_FOUND );
            } else {
                Object zValueForAttribute = null;
                try {
                    zValueForAttribute = changingPair.getDataConverter().convertFromPassable( pNewValue );
                }
                catch ( IllegalArgumentException e ) {
                    zResolvedError = rootTypeResolveError( ERR_ILLEGAL_VALUE, "Converted", e.getMessage() );
                }
                catch ( RuntimeException e ) {
                    zResolvedError = rootTypeResolveError( ERR_UNEXPECTED, "Converted", e.getMessage() );
                }
                if ( zResolvedError == null ) {
                    try {
                        if ( !(handled = LLvalueUpdated( zInstanceHelper, pAttributeReference, zValueForAttribute )) ) {
                            zResolvedError = rootTypeResolveError( ERR_VALUE_UPDATE_NOT_HANDLED );
                        }
                    }
                    catch ( IllegalArgumentException e ) {
                        zResolvedError = rootTypeResolveError( ERR_ILLEGAL_VALUE, "Update", e.getMessage() );
                    }
                    catch ( NoSuchElementException e ) {
                        zResolvedError = rootTypeResolveError( ERR_ATTR_NOT_FOUND, "Update", e.getMessage() );
                    }
                    catch ( RuntimeException e ) {
                        zResolvedError = rootTypeResolveError( ERR_UNEXPECTED, "Update", e.getMessage() );
                    }
                }
            }
        }
        if ( handled || (zResolvedError != null) ) {
            checkForChanges( changingPair, pNewValue, zResolvedError );
        }
    }

    protected boolean LLvalueUpdated( InstanceHelper pInstanceHelper, String pAttributeReference, Object pValueForAttribute ) {
        return pInstanceHelper.valueUpdated( pAttributeReference, pValueForAttribute );
    }

    private void processActionRequest( FormDataRowKey pFormDataRowKey, String pActionID, boolean pInputAction, FormDataRowKey pParentFormDataRowKey ) {
        LOGGER.trace.log( getRootType(), "-actionRequest, ", (pInputAction ? "Input" : "Reg"), " action:", pActionID );

        if ( actionRequest( pFormDataRowKey, pActionID, pInputAction, pParentFormDataRowKey ) ) {
            checkForChanges( null, null, null );
        } else if ( !pInputAction ) {
            addError( ERR_UNKNOWN_ACTION );
        }
        if ( !hasErrors() ) {
            setSuccessfulTriggeringActionIDIfNotSet( pActionID );
        }
    }

    protected void checkForChanges( AMDconverterPair pChangingPair, Serializable pNewValue, String pResolvedError ) {
        // Snag a list to avoid Concurrent Changes
        InstanceHelpersSnapShot zSnapShot = mInstanceHelperManager.getInstanceHelpers();
        InstanceHelper zRootHelper = zSnapShot.getRootInstanceHelper();
        zRootHelper.checkForChanges( pChangingPair, pNewValue, pResolvedError );
        for ( InstanceHelper helper : zSnapShot.getAllInstanceHelpers() ) {
            if ( helper != zRootHelper ) {
                helper.checkForChanges( pChangingPair, pNewValue, pResolvedError );
            }
        }
    }

    public boolean actionRequest( FormDataRowKey pFormDataRowKey, String pActionID, boolean pInputAction, FormDataRowKey pParentFormDataRowKey ) {
        if ( UiFormDef.ACTION_CLOSE.equals( pActionID ) ) {
            return actionClose( pActionID );
        }
        if ( UiFormDef.ACTION_DONE.equals( pActionID ) ) {
            return actionDone( pActionID );
        }
        if ( UiFormDef.ACTION_COMMIT.equals( pActionID ) ) {
            return actionCommit( pActionID );
        }
        if ( UiFormDef.ACTION_RELOAD.equals( pActionID ) ) {
            return actionReload( pActionID );
        }
        if ( UiFormDef.ACTION_NEW.equals( pActionID ) ) {
            return actionNew( pActionID );
        }
        InstanceHelper zInstanceHelper = getInstanceHelper( pFormDataRowKey );
        if ( zInstanceHelper != null ) {
            return zInstanceHelper.actionRequest( pActionID, pInputAction );
        }
        TypeHelper zTypeHelper = getTypeHelper( pFormDataRowKey );
        return (zTypeHelper != null) && //
               zTypeHelper.actionRequest( pActionID, pInputAction, getInstanceHelper( pParentFormDataRowKey ) );
    }

    public ArrayList<FormDataRowKey> getAllCurrentFormDataRowKeys() {
        return mInstanceHelperManager.getAllCurrentFormDataRowKeys();
    }

    public InstanceHelper getInstanceHelper( FormDataRowKey pFormDataRowKey ) {
        return mInstanceHelperManager.getInstanceHelper( pFormDataRowKey ); // null == Root
    }

    private TypeHelper getTypeHelper( FormDataRowKey pFormDataRowKey ) {
        return mTypeHelperManager.getTypeHelper( pFormDataRowKey ); // null == root
    }

    /**
     * @return true to indicate processing satisfied
     */
    protected boolean actionClose( String pSuccessfulTriggeringActionID ) {
        setCloseRequested();
        return true;
    }

    /**
     * Abandon any existing Root Object and create a new one
     *
     * @return true to indicate processing satisfied
     */
    protected boolean actionNew( String pSuccessfulTriggeringActionID ) {
        createNewRootObject();
        return initializeUpdates( pSuccessfulTriggeringActionID );
    }

    /**
     * Save current (mutated?) state of our backing Root Object and if successful
     * prepare the Root Object for future editing.
     *
     * @return true to indicate processing satisfied
     */
    protected boolean actionCommit( String pSuccessfulTriggeringActionID ) {
        commit();
        return hasErrors() || initializeUpdates( pSuccessfulTriggeringActionID );
    }

    /**
     * Save current (mutated?) state of our backing Root Object and if successful
     * request Close, and just in case Form is not closed then
     * prepare the Root Object for future editing.
     *
     * @return true to indicate processing satisfied
     */
    protected boolean actionDone( String pSuccessfulTriggeringActionID ) {
        commit();
        if ( hasErrors() ) {
            return true;
        }
        setCloseRequested();
        return initializeUpdates( pSuccessfulTriggeringActionID );
    }

    /**
     * Refresh the current Root Object with the latest version from its source (eg database)
     * (or a fresh new one if it was new and never committed)
     *
     * @return true to indicate processing satisfied
     */
    public boolean actionReload( String pSuccessfulTriggeringActionID ) {
        if ( !hasRootObject() ) {
            return true;
        }
        if ( mIsNewRootObject ) {
            createNewRootObject();
        } else {
            reloadExistingRootObject();
        }
        return initializeUpdates( pSuccessfulTriggeringActionID );
    }

    protected boolean initializeUpdates( String pSuccessfulTriggeringActionID ) {
        if ( hasRootObject() ) {
            setFullUpdate();
            setSuccessfulTriggeringActionIDIfNotSet( pSuccessfulTriggeringActionID );
            mInstanceHelperManager.resetAllInstanceHelpers();
            mInstanceHelperManager.loadAllAttributeValues();
        }
        return true;
    }

    protected void commit() {
        if ( hasRootObject() ) {
            try {
                LLcommit(); // commit what we've got
            }
            catch ( ConcurrentModificationException e ) {
                addError( ERR_COMMIT_OUT_OF_DATE_DATA );
                return;
            }
            catch ( RuntimeException e ) {
                LOGGER.warn.log( e, "Attempt to commit backing Root Object failed" );
                if ( e instanceof DisplayableException ) {
                    DisplayableException zDE = (DisplayableException) e;
                    String zParam = rootTypeResolveError( zDE.getToResolveIdentifier(), //
                                                          (Object[]) zDE.getParams() );
                    addError( ERR_COMMIT_FAILED, zParam );
                } else {
                    addError( ERR_COMMIT_FAILED );
                }
                return;
            }
            rootObjectCommited();
        }
    }

    protected void createNewRootObject() {
        mIsNewRootObject = true;
        String zRootObjectKey = LLnewRootObject();
        setRootObjectKey( zRootObjectKey );
    }

    protected void reloadExistingRootObject() {
        mIsNewRootObject = false;
        LLreloadExistingRootObject();
        mInteractionHelper.clearUpdatedData();
    }

    protected void loadExistingRootObject( String pNewRootObjectKey ) {
        mIsNewRootObject = false;
        if ( LLloadExistingRootObject( pNewRootObjectKey ) ) {
            setRootObjectKey( pNewRootObjectKey );
        }
    }

    /**
     * Either load the appropriate Root Object based on pKey, or create one if pKey was null
     */
    protected void LLsetRootObjectTo( String pKey ) {
        if ( pKey == null ) {
            createNewRootObject();
        } else {
            loadExistingRootObject( pKey );
        }
    }

    protected void LLdispose() {
    }

    /**
     * @return true to indicate processing satisfied
     */
    protected boolean LLrawValueUpdated( FormDataRowKey pFormDataRowKey, String pAttributeReference, Serializable pNewValue ) {
        return false;
    }

    protected void initializationPayloadAvailable( Serializable pInitializationPayload ) {
    }

    protected ExternalizationInterface augment( ExternalizationInterface pExternalizationInterface ) {
        return pExternalizationInterface;
    }

    protected InterceptingProxyExternalization proxy( ExternalizationInterface pExternalizationInterface ) {
        return new InterceptingProxyExternalization( pExternalizationInterface );
    }

    protected Serializable getFormRenderedServicePeerXtra() {
        return null;
    }

    abstract protected void LLcommit();

    abstract protected boolean hasRootObject();

    /**
     * @return new Root Objects Key
     */
    abstract protected String LLnewRootObject();

    /**
     * @return true if succeeded
     */
    abstract protected boolean LLreloadExistingRootObject();

    /**
     * @return true if succeeded
     */
    abstract protected boolean LLloadExistingRootObject( String pNewRootObjectKey );
}

Commits for litesoft/trunk/Java/GWT/OldServer/src/org/litesoft/GWT/forms/server/support/nonpublic/AbstractFormServicePeer.java

Diff revisions: vs.
Revision Author Commited Message
950 Diff Diff GeorgeS picture GeorgeS Thu 19 Jun, 2014 17:57:04 +0000

New Lines

948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

947 Diff Diff GeorgeS picture GeorgeS Fri 06 Jun, 2014 23:36:56 +0000

Correct Spelling of package!

942 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 23:41:46 +0000

Extracting commonfoundation

939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

858 Diff Diff GeorgeS picture GeorgeS Sun 04 Nov, 2012 18:40:40 +0000
804 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 12:48:51 +0000
610 Diff Diff GeorgeS picture GeorgeS Mon 12 Mar, 2012 00:54:00 +0000
60 Diff Diff GeorgeS picture GeorgeS Tue 24 Aug, 2010 00:37:36 +0000
49 GeorgeS picture GeorgeS Mon 12 Apr, 2010 02:59:10 +0000

License Text