Exemple #1
0
 def __init__(self, asset, *args, **kwargs):
     """
     :param asset: Django model object instance that inherits from OpenKMDocument
     """
     self.asset = asset
     self.document_client = client.Document()
     super(CustomDjangoToOpenKM, self).__init__(*args, **kwargs)
Exemple #2
0
def get_document_by_uuid(request, uuid, extra_info=False):
    """
    Returns a tuple.
    (HttpResponse object that can be returned to provide the file for download,
    the file name (string),
    the file object)
    """
    document_wrapper = DocumentWrapper()

    # get path from the uuid, and from that get the content
    document = client.Document()
    document_path = document.get_path(uuid)
    document_wrapper.document = document.get_properties(document_path)
    java_byte_array = document.get_content(document_path, False)

    # convert the string back to binary
    file_obj = StringIO.StringIO(java_byte_array)
    document_wrapper.content = utils.java_byte_array_to_binary(file_obj)

    # set the headers and return the file
    file_name = document_wrapper.document.path.split("/")[-1]
    document_wrapper.response = HttpResponse(
        document_wrapper.content, document_wrapper.document.mimeType)
    document_wrapper.response[
        'Content-Disposition'] = 'attachment; filename=%s' % encoding.smart_str(
            file_name, encoding='ascii', errors='ignore')

    return document_wrapper
Exemple #3
0
 def __init__(self):
     self.document = client.Document()
     self.document_manager = facades.DocumentManager()
     self.repository_manager = facades.RepositoryManager()
     self.sync_keywords = SyncKeywords()
     self.keyword = facades.Keyword()
     self.sync_categories = SyncCategories()
     self.category = facades.Category()
     self.upload_root = self.get_upload_root()
     self.property = facades.Property()
Exemple #4
0
 def setUp(self):
     try:
         # create a test document
         self.doc = client.Document()
         test_doc = self.doc.new()
         test_doc.path = self.test_doc_path
         self.doc.create(test_doc, "hf7438hf7843h378ot4837ht7")
         self.test_doc = self.doc.get_properties(self.test_doc_path)
     except AssertionError, detail:
         logging.exception(detail)
Exemple #5
0
    def update_categories(self, klass):
        """
        :param klass: OpenKMFolderlist class object
        """
        klass.objects.all().delete()
        document = client.Document()
        categories = document.get_categories()

        for folder in categories:
            try:
                folder_obj = klass.objects.create(okm_uuid=folder.uuid)
                folder_obj.okm_author = folder.author
                #folder_obj.okm_created = folder.created
                folder_obj.okm_has_childs = folder.hasChildren
                folder_obj.okm_path = utils.strip_runs_of_whitespace(
                    folder.path)
                folder_obj.okm_permissions = folder.permissions
                folder_obj.okm_subscribed = folder.subscribed
                folder_obj.save()
            except Exception, e:
                logger.exception(e)
Exemple #6
0
    def populate_property_group(self, properties_dict):
        """
        :param properties_dict dict
        A dict with property group names as keys, the value for each property group
        should be a dict containing its properties and values
        {'property group name':
            { property name : values, ... }
        :returns a list groupProperties objects each populated with property names and values
        """
        property_groups = []
        for property_group in properties_dict:
            document = client.Document()
            property_group_obj = document.create_group_properties_object()
            property_group_obj.groupName = property_group
            for property_name, value in properties_dict[property_group].items(
            ):
                property_obj = document.create_group_property_object()
                property_obj.name = property_name
                property_obj.values = [value]
                property_group_obj.properties.append(property_obj)
            property_groups.append(property_group_obj)

        return property_groups
Exemple #7
0
 def __init__(self):
     self.property = client.Property()
     self.document = client.Document()
Exemple #8
0
 def __init__(self):
     self.document = client.Document()
Exemple #9
0
 def __init__(self):
     self.doc = client.Document()
     self.folder = client.Folder()
Exemple #10
0
 def test_update_document(self):
     document = client.Document()
     document.update_document(self.data)
Exemple #11
0
 def test_create_document(self):
     try:
         document = client.Document()
         okm_document = document.create_document(self.content, self.data)
     except suds.WebFault, e:
         print 'Caught suds.WebFault.  Document already exists on server: ', e.message
Exemple #12
0
 def setUp(self):
     # get a file for testing
     self.document = client.Document()
     self.content = get_content_for_upload()
     self.data = self._get_data()
Exemple #13
0
 def setUp(self):
     self.document = client.Document()
     self.note = client.Note()
     self.test_document = create_test_document_on_openkm()
Exemple #14
0
def delete_test_document_on_openkm():
    d = client.Document()
    d.delete(get_test_document_path())
Exemple #15
0
def create_test_document_on_openkm():
    document = client.Document()
    test_doc = document.new()
    test_doc.path = get_test_document_path()
    document.create(test_doc, "hf7438hf7843h378ot4837ht7")
    return document.get_properties(test_doc.path)
Exemple #16
0
 def setUp(self):
     self.test_document = create_test_document_on_openkm()
     self.property_group = client.PropertyGroup()
     self.document = client.Document()
     self.new_group = 'okg:customProperties'