]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6935: Simple sync'ing now working. Still missing hard delete and soft delete...
authorremillet <remillet@yahoo.com>
Mon, 11 Apr 2016 20:01:28 +0000 (13:01 -0700)
committerremillet <remillet@yahoo.com>
Mon, 11 Apr 2016 20:01:28 +0000 (13:01 -0700)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java

index 806bad1e5587d7b87d206c6b8b4702482e33f3a0..1daf48f469fccd148893c95b4f7d597c5990ed15 100644 (file)
@@ -207,9 +207,11 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         if (parentShortIdentifier == null) {
             authorityRefNameBase = null;
         } else {
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx =
-                    createServiceContext(getServiceName());
-            if (parentShortIdentifier.equals(FETCH_SHORT_ID)) {
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx = createServiceContext(getServiceName());
+            if (parentShortIdentifier.equals(FETCH_SHORT_ID)) { // We need to fetch this from the repo
+                if (ctx.getCurrentRepositorySession() != null) {
+                       parentCtx.setCurrentRepositorySession(ctx.getCurrentRepositorySession()); // We need to use the current repo session if one exists
+                }
                 // Get from parent document
                 parentShortIdentifier = getAuthShortIdentifier(parentCtx, inAuthority);
             }
@@ -228,20 +230,20 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         return docHandler;
     }
 
-    public String getAuthShortIdentifier(
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String authCSID)
+    public String getAuthShortIdentifier(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String authCSID)
             throws DocumentNotFoundException, DocumentException {
         String shortIdentifier = null;
+        
         try {
-            AuthorityDocumentModelHandler<?> handler =
-                    (AuthorityDocumentModelHandler<?>) createDocumentHandler(ctx);
-            shortIdentifier = handler.getShortIdentifier(authCSID, authorityCommonSchemaName);
+            AuthorityDocumentModelHandler<?> handler = (AuthorityDocumentModelHandler<?>) createDocumentHandler(ctx);
+            shortIdentifier = handler.getShortIdentifier(ctx, authCSID, authorityCommonSchemaName);
         } catch (Exception e) {
             if (logger.isDebugEnabled()) {
                 logger.debug("Caught exception ", e);
             }
             throw new DocumentException(e);
         }
+        
         return shortIdentifier;
     }
 
@@ -308,7 +310,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         return result;
     }
 
-    public String lookupItemCSID(String itemspecifier, String parentcsid, String method, String op, ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx)
+    public String lookupItemCSID(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String itemspecifier, String parentcsid, String method, String op)
             throws DocumentException {
         String itemcsid;
         Specifier itemSpec = getSpecifier(itemspecifier, method, op);
@@ -962,7 +964,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
 
             String parentcsid = lookupParentCSID(parentspecifier, "getReferencingObjects(parent)", "GET_ITEM_REF_OBJS", uriInfo);
-            String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getReferencingObjects(item)", "GET_ITEM_REF_OBJS", ctx);
+            String itemcsid = lookupItemCSID(ctx, itemspecifier, parentcsid, "getReferencingObjects(item)", "GET_ITEM_REF_OBJS");
 
             List<String> serviceTypes = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
             if(serviceTypes == null || serviceTypes.isEmpty()) {
@@ -1013,7 +1015,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             DocumentModelHandler<?, AbstractCommonList> handler =
                     (DocumentModelHandler<?, AbstractCommonList>)createItemDocumentHandler(ctx, parentcsid, null /*no parent short ID*/);
 
-            String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getAuthorityItemAuthRefs(item)", "GET_ITEM_AUTH_REFS", ctx);
+            String itemcsid = lookupItemCSID(ctx, itemspecifier, parentcsid, "getAuthorityItemAuthRefs(item)", "GET_ITEM_AUTH_REFS");
 
             List<RefNameServiceUtils.AuthRefConfigInfo> authRefsInfo = RefNameServiceUtils.getConfiguredAuthorityRefs(ctx);
             authRefList = handler.getAuthorityRefs(itemcsid, authRefsInfo);
@@ -1174,7 +1176,9 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
         if (ctx == null) {
                ctx = createServiceContext(getItemServiceName(), theUpdate, resourceMap, uriInfo);
         }
-        String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "updateAuthorityItem(item)", "UPDATE_ITEM", ctx); //use itemServiceCtx if it is not null
+        ctx.setInput(theUpdate);
+        
+        String itemcsid = lookupItemCSID(ctx, itemspecifier, parentcsid, "updateAuthorityItem(item)", "UPDATE_ITEM"); //use itemServiceCtx if it is not null
 
         // We omit the parentShortId, only needed when doing a create...
         AuthorityItemDocumentModelHandler handler = (AuthorityItemDocumentModelHandler)createItemDocumentHandler(ctx, parentcsid, parentShortId);
index 18c4ea89e6acebf15c1cd4e4b3ac5d2cc970d7fd..08637d0682081433178f92a5f72f6db7229113c3 100644 (file)
@@ -470,12 +470,11 @@ public abstract class AuthorityDocumentModelHandler<AuthCommon>
        return result;
     }    
     
-    public String getShortIdentifier(String authCSID, String schemaName) throws Exception {
+    public String getShortIdentifier(ServiceContext ctx, String authCSID, String schemaName) throws Exception {
         String shortIdentifier = null;
         CoreSessionInterface repoSession = null;
         boolean releaseSession = false;
 
-        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
        RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
         try {
                repoSession = nuxeoRepoClient.getRepositorySession(ctx);
index 83de91744c2d6d1015a2e73a928653f3028f4d1a..a70327bea1f88c36d70273c710d5c0d17b22f5f2 100644 (file)
@@ -393,8 +393,8 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
         DocumentModel docModel = wrapDoc.getWrappedObject();
         MultipartServiceContext ctx = (MultipartServiceContext) getServiceContext();
         PoxPayloadIn input = ctx.getInput();
-        if (input.getParts().isEmpty()) {
-            String msg = "No payload found!";
+        if (input == null || input.getParts().isEmpty()) {
+            String msg = String.format("No payload found for '%s' action.", action);
             logger.error(msg + "Ctx=" + getServiceContext().toString());
             throw new BadRequestException(msg);
         }
@@ -418,8 +418,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
                 continue;
             }
             fillPart(part, docModel, partMeta, action, ctx);
-        }//rof
-
+        }
     }
 
     /**
index b0fe84eddbf6497a1f1c11e3caafb1d6be89022b..ec136e99ea1e46276a0fbc9cdc67f951688ce270 100644 (file)
@@ -123,7 +123,7 @@ public abstract class AuthorityResourceWithContacts<AuthCommon, AuthItemHandler>
             String parentcsid = lookupParentCSID(parentspecifier, "createContact(authority)", "CREATE_ITEM_CONTACT", null);
 
             ServiceContext itemCtx = createServiceContext(getItemServiceName());
-            String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "createContact(item)", "CREATE_ITEM_CONTACT", itemCtx);
+            String itemcsid = lookupItemCSID(itemCtx, itemspecifier, parentcsid, "createContact(item)", "CREATE_ITEM_CONTACT");
 
             // Note that we have to create the service context and document
             // handler for the Contact service, not the main service.
@@ -166,7 +166,7 @@ public abstract class AuthorityResourceWithContacts<AuthCommon, AuthItemHandler>
                
             String parentcsid = lookupParentCSID(parentspecifier, "getContactList(parent)", "GET_CONTACT_LIST", null);
             ServiceContext itemCtx = createServiceContext(getItemServiceName());
-            String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getContactList(item)", "GET_CONTACT_LIST", itemCtx);
+            String itemcsid = lookupItemCSID(itemCtx, itemspecifier, parentcsid, "getContactList(item)", "GET_CONTACT_LIST");
 
             DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid, uriInfo);
             DocumentFilter myFilter = handler.getDocumentFilter(); //new DocumentFilter();
@@ -210,7 +210,7 @@ public abstract class AuthorityResourceWithContacts<AuthCommon, AuthItemHandler>
             String parentcsid = lookupParentCSID(parentspecifier, "getContact(parent)", "GET_ITEM_CONTACT", null);
 
             ServiceContext itemCtx = createServiceContext(getItemServiceName());
-            String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getContact(item)", "GET_ITEM_CONTACT", itemCtx);
+            String itemcsid = lookupItemCSID(itemCtx, itemspecifier, parentcsid, "getContact(item)", "GET_ITEM_CONTACT");
 
             // Note that we have to create the service context and document handler for the Contact service, not the main service.
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getContactServiceName());
@@ -252,7 +252,7 @@ public abstract class AuthorityResourceWithContacts<AuthCommon, AuthItemHandler>
             String parentcsid = lookupParentCSID(parentspecifier, "updateContact(authority)", "UPDATE_CONTACT", null);
 
             ServiceContext itemCtx = createServiceContext(getItemServiceName());
-            String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "updateContact(item)", "UPDATE_CONTACT", itemCtx);
+            String itemcsid = lookupItemCSID(itemCtx, itemspecifier, parentcsid, "updateContact(item)", "UPDATE_CONTACT");
 
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
             // Note that we have to create the service context and document handler for the Contact service, not the main service.
@@ -288,7 +288,7 @@ public abstract class AuthorityResourceWithContacts<AuthCommon, AuthItemHandler>
             String parentcsid = lookupParentCSID(parentspecifier, "deleteContact(authority)", "DELETE_CONTACT", null);
 
             ServiceContext itemCtx = createServiceContext(getItemServiceName());
-            String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "deleteContact(item)", "DELETE_CONTACT", itemCtx);
+            String itemcsid = lookupItemCSID(itemCtx, itemspecifier, parentcsid, "deleteContact(item)", "DELETE_CONTACT");
             //NOTE: itemcsid is not used below.  Leaving the above call in for possible side effects???       CSPACE-3175
 
             ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;