protected Object getCommonPart() { Object result = null; try { MultipartServiceContext multiPartCtx = (MultipartServiceContext) getServiceContext(); result = multiPartCtx.getInputPart(ctx.getCommonPartLabel(), getCommonPartClass()); } catch (Exception e) { if (logger.isDebugEnabled() == true) { logger.debug("Could not extract common part from multipart input.", e); } } return result; }
/** * Generate a refName for the authority from the short identifier and display name. * * <p>All refNames for authorities are generated. If a client supplies a refName, it will be * overwritten during create (per this method) or discarded during update (per * filterReadOnlyPropertiesForPart). * * @see #filterReadOnlyPropertiesForPart(Map<String, Object>, * org.collectionspace.services.common.service.ObjectPartType) */ protected void updateRefnameForAuthority( DocumentWrapper<DocumentModel> wrapDoc, String schemaName) throws Exception { DocumentModel docModel = wrapDoc.getWrappedObject(); String shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER); String displayName = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.DISPLAY_NAME); MultipartServiceContext ctx = (MultipartServiceContext) getServiceContext(); RefName.Authority authority = RefName.buildAuthority( ctx.getTenantName(), ctx.getServiceName(), shortIdentifier, displayName); String refName = authority.toString(); docModel.setProperty(schemaName, AuthorityJAXBSchema.REF_NAME, refName); }
/** * Creates the document handler. * * @param serviceContext the service context * @param schemaName the schema name * @param commonClass the common class * @return the document handler * @throws Exception the exception */ public DocumentHandler createDocumentHandler( ServiceContext<PoxPayloadIn, PoxPayloadOut> serviceContext, String schemaName, Class<?> commonClass) throws Exception { DocumentHandler result = null; MultipartServiceContext ctx = (MultipartServiceContext) serviceContext; Object commonPart = null; if (ctx.getInput() != null) { commonPart = ctx.getInputPart(schemaName); } result = super.createDocumentHandler(ctx, commonPart); return result; }
/* * JAX-RS Annotated methods */ @GET @Path("{csid}" + WorkflowClient.SERVICE_PATH) public byte[] getWorkflow(@PathParam("csid") String csid) { PoxPayloadOut result = null; try { ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx = createServiceContext(); String parentWorkspaceName = parentCtx.getRepositoryWorkspaceName(); MultipartServiceContext ctx = (MultipartServiceContext) createServiceContext(WorkflowClient.SERVICE_NAME); WorkflowDocumentModelHandler handler = createWorkflowDocumentHandler(ctx); ctx.setRespositoryWorkspaceName( parentWorkspaceName); // find the document in the parent's workspace getRepositoryClient(ctx).get(ctx, csid, handler); result = ctx.getOutput(); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.READ_FAILED + WorkflowClient.SERVICE_PAYLOAD_NAME, csid); } return result.getBytes(); }