Java

JAX-WS Sample of ProvideAndRegisterDocumentSetb

    protected ProvideAndRegisterDocumentSetRequestType getRequest() {
        oasis.names.tc.ebxml_regrep.xsd.rim._3.ObjectFactory factory = new oasis.names.tc.ebxml_regrep.xsd.rim._3.ObjectFactory();
 
        // create request
        ProvideAndRegisterDocumentSetRequestType request = new ProvideAndRegisterDocumentSetRequestType();
 
        // create mandatory package
        RegistryPackageType packageType = new RegistryPackageType();
        packageType.setObjectType("urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:RegistryPackage");
        packageType.setId("SubmissionSet01");
 
        // create registry object list
        RegistryObjectListType registryObjectList = new RegistryObjectListType();
        registryObjectList.getIdentifiable().add(factory.createIdentifiable(packageType));
 
        // set classification
        ClassificationType classification = new ClassificationType();
        classification.setClassifiedObject("SubmissionSet");
        classification.setClassificationNode("urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd");
        classification.setNodeRepresentation(this.classification);
        packageType.getClassification().add(classification);
 
        // create object request
        SubmitObjectsRequest submitObjectsRequest = new SubmitObjectsRequest();
        submitObjectsRequest.setId(id);
        submitObjectsRequest.setRegistryObjectList(registryObjectList);
        request.setSubmitObjectsRequest(submitObjectsRequest);
 
        // create slots
        SlotListType requestSlots = new SlotListType();
        submitObjectsRequest.setRequestSlotList(requestSlots);
 
        // add recipient, in-reply-to
        setSlot(requestSlots.getSlot(), SLOT_REFERRAL_RECIPIENT, getRecipient());
        if (getInReplyTo() != null && getInReplyTo().length() != 0) {
            setSlot(requestSlots.getSlot(), SLOT_REFERRAL_INREPLY_TO, getInReplyTo());
        }
 
        // add request slots
        for (Slot slot : slots) {
            setSlot(requestSlots.getSlot(), slot.getName(), slot.getValues());
        }
 
        // add documents
        for (DocumentPackage documentPackage : documents) {
            // create extrinsic object
            ExtrinsicObjectType extrinsicObject = new ExtrinsicObjectType();
            extrinsicObject.setId("ID_" + UUID.randomUUID().toString());
            extrinsicObject.setMimeType(documentPackage.getMimeType());
            extrinsicObject.setIsOpaque(documentPackage.isEncrypted());
            extrinsicObject.setObjectType("urn:uuid:7edca82f-054d-47f2-a032-9b2a5b5186c1");
 
            // create a matching association type object.
            AssociationType1 associationType = new AssociationType1();
            associationType.setObjectType("urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Association");
            associationType.setTargetObject(extrinsicObject.getId());
            associationType.setId("ID_" + UUID.randomUUID().toString());
            associationType.setAssociationType("urn:oasis:names:tc:ebxml-regrep:AssociationType:HasMember");
            associationType.setSourceObject(packageType.getId());
 
            // classification
            ClassificationType documentClassification = new ClassificationType();
            documentClassification.setClassifiedObject(extrinsicObject.getId());
            documentClassification.setNodeRepresentation(documentPackage.getClassification());
            extrinsicObject.getClassification().add(documentClassification);
 
            // set filename
            setSlot(extrinsicObject.getSlot(), SLOT_REFERRAL_FILENAME, documentPackage.getFilename());
            InternationalStringType filenameStringType = new InternationalStringType();
            List<LocalizedStringType> localizedStringTypeList = filenameStringType.getLocalizedString();
            LocalizedStringType localizedStringType = new LocalizedStringType();
            localizedStringType.setCharset("EN-US");
            localizedStringType.setValue(documentPackage.getFilename());
            localizedStringTypeList.add(localizedStringType);
            extrinsicObject.setName(filenameStringType);
 
            // add document payload
            Document document = new Document();
            document.setId(extrinsicObject.getId());
            document.setValue(documentPackage.getPayload());
 
            // add document slots
            for (Slot slot : documentPackage.getSlots()) {
                setSlot(extrinsicObject.getSlot(), slot.getName(), slot.getValues());
            }
 
            // add to request
            registryObjectList.getIdentifiable().add(factory.createIdentifiable(extrinsicObject));
            registryObjectList.getIdentifiable().add(factory.createIdentifiable(associationType));
            request.getDocument().add(document);
        }
 
        return request;
    }
 
dev/java.txt · Last modified: 2009/02/25 15:27 by timc