Beispiel #1
0
    def compute(self, pid):
        cert_file = None
        key_file = None
        cn_url = get_cn_url(self)
        mn_url = get_mn_url(self)

        if self.hasInputFromPort("authentication"):
            auth = self.getInputFromPort("authentication")
            cert_file = auth.cert_file
            key_file = auth.key_file

        self.annotate({"cn_url": cn_url, "mn_url": mn_url})

        mn_client = utils.get_d1_mn_client(mn_url=mn_url, cert_file=cert_file, 
                                           key_file=key_file)
        cn_client = utils.get_d1_cn_client(cn_url=cn_url)
        
        # if it already exists
        if utils.get_sysmeta_by_pid(pid, True, cn_client, mn_client):
            if not self.forceGetInputFromPort("updateIfExists", False):
                raise ModuleError(self, 'Cannot add data: ' \
                                      'identifer "%s" already exists.')
            else:
                self.update_object(pid, mn_client, cn_client)
        self.create_object(pid, mn_client, cn_client)
Beispiel #2
0
 def get_metadata(pid, mn_client, cn_client, full_resolve, output_fname):
     res = utils.get_sysmeta_by_pid(pid, full_resolve, cn_client, mn_client)
     if res is not None:
         utils.write_file_output(StringIO(res.to_xml()), 
                                 output_file.name)
     return output_file.name