//ProxyImpl.java //This file is the real implementation of the ACM Proxy import IDLInterchange.*; import CosPropertyService.*; import ACM.*; public class Street extends CConstrainCollectionImpl { private CollectionPlug2[] acmweb = new CollectionPlug2[50]; private short acmwebpointer; private org.omg.CORBA.ORB orb; public Street () { super(); Init(); } public Street (String name) { super(name); Init(); } public Street (String name, org.omg.CORBA.ORB porb ) { super(name); Init(); orb = porb; } public void CancelRequest( CosPropertyService.Any pMessageID) throws IDLInterchange.InvalidMessageID { // In the framework of the implementation of this proxy // it is not possible to cancel an ongoing request, since the // results are sent all together. return; } public void RequestItemsProperties( CosPropertyService.Any pMessageID, java.lang.String[] pPropertyNames, CosPropertyService.Any[] pServerCookies, CosPropertyService.Any[] pClientCookies, IDLInterchange.CCollection pResultTarget) { System.out.println("RequestItemsProperties"); IDLInterchange.TException pException = new IDLInterchange.TException(); if ( pResultTarget == null ) { System.out.println("Result Target null. Can't complete request"); pException.aRequestReason("Result Target null. Can't complete request"); pResultTarget.RaiseException(pMessageID,pException); return; } if ( pPropertyNames.length == 0 ) { // No properties System.out.println("No properties in the parameters"); pException.aRequestReason("No properties in the parameters"); pResultTarget.RaiseException(pMessageID,pException); return; } if ( pServerCookies.length == 0 ) { // No cookies System.out.println("pServerCookies equals 0"); pResultTarget.CompletedRequest(pMessageID); return; } if ( pServerCookies.length != pClientCookies.length ) { // Error. System.out.println("Unmatching number of Client Side Cookies"); pException.aRequestReason("Unmatching number of Client Side Cookies"); pResultTarget.RaiseException(pMessageID,pException); } IDLInterchange.TItemsCookieState pItems = new IDLInterchange.TItemsCookieState(); try { pItems.aStates = pack_properties(pServerCookies, pPropertyNames); System.out.println("Properties packed"); pItems.aClientCookies = pClientCookies; pResultTarget.SetItemsProperties(pMessageID, pItems); pResultTarget.CompletedRequest(pMessageID); } catch (Exception e) { // Something went wrong System.out.println(e); pException.aRequestReason("Error retrieving the properties"); pResultTarget.RaiseException(pMessageID,pException); } return; } public java.lang.String GetItemsPropertyNames(CosPropertyService.Any[] pCookies)[][] throws IDLInterchange.InvalidRequest, IDLInterchange.InvalidCookies, IDLInterchange.InvalidAuthenication, IDLInterchange.InvalidPayment, IDLInterchange.MultipleExceptions { System.out.println("GetItemsPropertyNames"); if (pCookies.length == 0) { //Compatibility with AsynInterClient.py CollectionPlug2 aux = new CollectionPlug2(); String[][] propos = new String[1][aux.how_many_prop]; propos[0] = aux.GetPropertyNames(); return (propos); } String[][] aux = new String[pCookies.length][5]; short tablepos; short numberofdoc; for(int i=0;i E'pointer':'number of doc' String forcookies = "E"; forcookies = forcookies.concat(String.valueOf(pointer)); forcookies = forcookies.concat(":"); forcookies = forcookies.concat(String.valueOf(acmweb.docs_stored)); aCookie.a_string(forcookies); pNewMoreCookie[0] = new IDLInterchange.TAccessOption( aTarget, aCookie, anItemClass, aHints); return pNewMoreCookie; } private IDLInterchange.TItemsState pack_properties( CosPropertyService.Any[] pServerCookies, String[] pPropertyNames) throws Exception { IDLInterchange.TItemsState result = new IDLInterchange.TItemsState(); short tablepos; short indexdoc; // Do I have these properties? System.out.println("Packing properties"); if (!CollectionPlug2.my_props(pPropertyNames)) { System.out.println("I don't have this set of properties"); throw new Exception(); } else { System.out.println("Right set of properties"); } result.aNames = pPropertyNames; CosPropertyService.Any[][] anItemsState = new CosPropertyService.Any [pServerCookies.length] [pPropertyNames.length]; for(int i =0;i E'pointer':'number of doc' forcookies = "E"; forcookies = forcookies.concat(String.valueOf(pointer)); forcookies = forcookies.concat(":"); forcookies = forcookies.concat(String.valueOf(i)); // Putting the cookie and the rest in the right place aACs[i][0] = new IDLInterchange.TAccessOption(); aACs[i][0].aTarget = this; // the proxy itself is the only able to // respond to more the request_more_properties aACs[i][0].aCookie = new CosPropertyService.Any(); aACs[i][0].aCookie.a_string(forcookies); System.out.println(aACs[i][0].aCookie.a_string()); aACs[i][0].anItemClass = anItemClass; // garbage, not used aACs[i][0].aHints = aHints; // garbage, not used i++; } // Putting the values set in the loop in the right variable aState.anItemsState = anItemsState; IDLInterchange.TItemsACState pItems = new IDLInterchange.TItemsACState(aACs,aState); return pItems; } private CosPropertyService.Any[] SetValuesProperties (short p, CollectionPlug2 acmweb) { CosPropertyService.Any[] aux = new CosPropertyService.Any [acmweb.how_many_prop]; String[] values = new String[acmweb.how_many_prop]; values = acmweb.SetValuesProperties(p); for(int j=0;j