onSync Event and its properties - arrays

Hello People of Stackoverflow, I am using a persistent SharedObject for Adobe Media Server to store and share date in real-time for multiple clients. I am using the SyncEvent to dispatch any event that has been updated.
Reading through the documerntation the SyncEvent contains numerous properties. What i want to achieve is to use remote shared object to store a list of people who are online when one client disconnects all the other clients listed will be updated of the disconnection.
Adobe docs unfortunately doesnt provide any examples how to do this.
Would the best approach be to create a changeList array that contains properties of all members then execute a loop?
Or can anyone suggest any other method?
Thanks

The changelist property of the event contains only the properties that got changed. So, if your shared object contains the list of ids, you should be able to get what you achieve.
Note, that the notification is done for the top level properties stored in the shared object. So, what you want would probably look like:
idSo.setProperty("1", true);
while adding. To remove the user, you should use:
idSo.setProperty("1", null);
To reassert, having
idSo.setProperty("ids", <array of ids>)
would send the whole array when it's updated. So, this would be a bad approach
This sync event would be sent to all the connected shared objects.

Related

What's the preferred way to go about using backbone with non-crud resources?

New to backbone/marionette, but I believe that I understand how to use backbone when dealing with CRUD/REST; however, consider something like results from a search query. How should one model this? Of course the results likely relate to some model(s), but they are not meant to be tied to said model(s).
Part of me thinks that I should use a collection using a model that doesn't actually sync with a data store through the server, but instead just exists as a means of a modeling a search result object.
Another solution could be to have a collection with no models and just override parse.
I assume that the former is preferred, but again I have no experience with the framework. If there's an alternative/better solution than those listed above, please advise.
I prefer having one object which is responsible for both request and response parsing. It can parse the response to appropriate models and nothing more. I mean - if some of those parsed models are required somewhere in your page, there is something that keeps reference to this wrapper object and takes models from response it requires via wrapper methods.
Another option is to have Radio (https://github.com/marionettejs/backbone.radio) in this wrapper - you will not have to keep wrapper object in different places but call for data via Radio.

Portlet event send array of objects

We have multiple projects with multiple portlets and need to send an array of objects between them.
Our situation:
One of the porlets is like a "Master-portlet", it will be responsible for all the REST-calls and consume json-data and parse it to Java-Objects.
All the other portlets will receive an array of objects and show them to the user.
Our thoughts and solution:
We wanted to implement this by sending arrays of objects trough events. One of the "smaller" portlets will send an event to the "Master-portlet" and the "Master-portlet" will then answer with a new event and send the right array of objects back.
Our problem:
We dont know how to send arrays of objects trough events. Is this even possible?
Also we are not sure if this is the right way to solve this. Are events ment to send a bigger amount of data?
Is there a better solution for our case? Maybe it would be better to implement a database and all the portlets get the information from there?
Consider portlet events (and portlets) the UI layer of your application. Based on this, judge if the amount of data that you send back and forth makes sense or not. Also, if you closely couple the portlets, you're just hiding the fact that they can only function together - at least a questionable idea. You rather want them to react to common circumstances (events), but not rely on a specific source of events (master portlet) being available.
That being said: The more complex the data is that you send as payload of a JSR-286 event, the easier you run into classloading problems in cases where your portlets are in different webapplications. If you restrict yourself to Java native types (e.g. String, Map, etc) you will omit problems with the classloader.
Typically you want to communicate changes to the current context (e.g. new "current customer" selected - and an identifier) but not all of the particular data (e.g. the new customer's name and order history). The rest of the data typically comes through the business layer anyway.
That's not to say that you absolutely must not couple your portlets - just that my preference is to rather have them very loosely coupled, so that I can add individual small portlets that replace those that I thought of yesterday.
If you have some time, I've covered a bit of this in a webinar last year, I hope that this adds some clarification where I was too vague in this quick answer.

Can I save changes to objects to another TR besides those they are locked?

When I try to switch to edit mode for a Report source, a popup comes up telling me
"A new task will be created for the following request of user XXX".
A transport request is also being suggested.
I don't want to save my changes in this request however, but in another existing one. I am not aware of any versioning systems being implemented in my system, and don't know how to check that.
Is what i'm trying to achieve possible? And if so, how?
No, this is not possible. There are very good reasons for this being an exclusive lock -- reasons that you should know about before you attempt to change anything. Briefly speaking
The CTS only notes that an object was touched, not what change was made.
When the transport is released, the entire object in its current state is exported - there is no delta/diff logic involved.
Therefore you can't separately transport changes to the same development object. Furthermore, if you serialize this manually, the second transport will always comprise the changes of the first one.
Things get slightly more complicated with partial objects - you can have LIMU METH objects (methods of a class) in different transports, but as soon as you try to lock the R3TR CLAS main class, you'll have to resolve that.

Query user permission level for an object's parent?

I have a custom object with a master-detail to opportunity. Is there a way to determine if the user has read or read/write access when querying this custom object?
To clarify my needs, I'm looking for a way to render my page (non-visualforce) with a clear distinction between records they have only read access to and records in which they may edit.
The user will have the same access to that as they have to the opportunity. The Profile object exposes permissions but it doesn't appear to allow you to find out about CRUD settings for objects.
Are you creating an integration piece or working with Visualforce? If you're using Visualforce the interface will respect security controls automatically, hiding data they're not allowed to see and making fields read only when using <apex:inputField> if they do not have permission to write to the field.
** Edit **
Maybe somebody will have a better solution, but how about trying to update the records you query, storing whether each was a success or failure, and then using that to control the interface? Bit of a hack, if I find anything else I'll be sure to update.
** Edit 25/01/2012 **
Have just come across this: http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content/sforce_api_objects_userrecordaccess.htm?SearchType=Stem
Pretty sure that'll give you exactly what you need!
This might contain answer to your question http://salesforceblogger.blogspot.com/2012/04/query-user-access-level-in-apex.html
There is an UserRecordAccess table which is exposed with API 24.0 with which u can easily check for access instead of banging ur head with share object.
I don't know of a way to query to find out the level of access however if your apex class uses the With Sharing keyword it will respect sharing on the object thus when you attempt to update the data you'll get a DML exception which you could catch.
If you're not using With Sharing then apex doesn't respect the Sharing model and technically the user will be able to update the data even if they don't have access.
As pointed out by LaceySnr if you're using visualforce the <apex:inputfield> element will display read-only automatically to the user if they only have ReadOnly Access.

nHibernate: Reset an object's original state

I have a very basic query. I am using WPF Binding to edit a object which is loaded by a ISession. If somebody edits this object in the form, because of two way binding and a stateful session, whenever I close the session, changes to the object made in the form are stored back in the database. Which is the best way to avoid this?
The methods I know:
Shadow copy the object and use the copied object as the DataContext (the method I am using as of now).
ISession.Clear
Use IStatelessSession.
Is there any way to reset the object to it's original form before closing the ISession?
If you look here: http://nhforge.org/wikis/howtonh/finding-dirty-properties-in-nhibernate.aspx
It is an example of finding dirty properties. NHibernate internally tracks a persistent object's state by way of the EntityEntry object.
This is useful for you, because with a little modification to the method above, you're able to get old values back ... which you can use to reset the properties.
As for closing your session causing the object to be flushed to the database, you can set the session FlushMode to FlushMode.Never. This will mean no database sync occurs until you call Session.Flush().
Alternatively, you can hook into IFlushEntityEventListener to reset the object state. There are a reasonable examples of using the NHibernate event system on google.
See Managing the caches on NHibernate Forge:
When Flush() is subsequently called, the state of that object will be synchronized with the database. If you do not want this synchronization to occur or if you are processing a huge number of objects and need to manage memory efficiently, the Evict() method may be used to remove the object and its collections from the first-level cache.
I think that sounds like what you want.
I would suggest the use of transactions. You just rollbackthe transaction if that is the case? what do you think?

Resources