Skip to content

tsukaeru/rushfiles-zimlet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Development

Environment

  1. Clone https://github.com/tsukaeru/rushfiles-zimlet.git in project root
  2. Create folder in project root: .lib
  3. Go to folder /opt/zimbra/lib/jars in host with deployed Zimbra 9.0.0
  4. Put in .lib the next jars:
    • zimbra-charset.jar
    • zimbra-native.jar
    • zimbrastore.jar
    • zimbrasoap.jar
    • zimbracommon.jar
    • zimbraclient.jar
  5. mvn verify

Extension Installation

  1. Build jar

  2. Go to Zimbra console

  3. Copy the jar to /opt/zimbra/lib/ext/rushfiles/rushfiles.jar

  4. Execute:

    su - zimbra -c 'zmmailboxdctl restart'
    
  5. Check deploying result (optional):

    cat /opt/zimbra/log/mailbox.log | grep -i rushfiles
    

Testing

Tests live in ./tests folder. To make functional Servlet tests work you need to fill in an actual username and password in class ExtensionHttpServletTest.

API testing implemented by mock, Servlet testing - by real requests. We can treat API tests as unit-testing, Servlet tests - as functional-testing. (I do not see the point in long-running testing via requests the same functional twice.)

API

Standard authorization

Request

POST /service/extension/rushfiles/authorize

{
  "username": "user@mail.com",
  "password": "123456"
}

Response

You need to save username, primary_domain and domain_token in cookies. They need to be presented in every further request as cookies.

{
  "username": "user@mail.com",
  "primary_domain": "cloudfiles.jp",
  "domain_token": "11111",
  "status": "success"
}

Session expiration

On every request backend will check the authorization. If it becomes invalid, you receive the next response:

{
  "status": "error",
  "message": "unauthorized"
}

On-the-fly authorization

You can to perform authorization on-the-fly for each specific api call. This method, unlike the standard way, will work for the current call only, and every time will be forced to perform full authentication, but this might be convenient in testing: you do not need make additional authenticational request and manage authentication cookies.

For on-the-fly authorization you need to append in POST two fields: username and password (the same way as in standard authorization). Example:

POST /service/extension/rushfiles/get_share_contents

{
  "username": "user@mail.com",
  "password": "123456",
  "ShareId": "d94f8ed4c56e4f318edb41e5da8b064a"
}

All available shares

Request

POST /service/extension/rushfiles/get_all_shares

Response

{
  "status": "success",
  "objects": [
    {
      "Id": "17b8cd708c5f41f0a7d30a7230612de2",
      "CompanyId": "39929886c09745e3bc98b9e85be7d0fb",
      "Name": "Comp Inc"
    },
    {
      "Id": "d94f8ed4c56e4f318edb41e5da8b064a",
      "CompanyId": "ca10b965-3b9f-4e5a-96a6-f10b3acea1b8",
      "Name": "user - Home folder"
    }
  ]
}

Get share contents

Request

POST /service/extension/rushfiles/get_share_contents

{
  "ShareId": "d94f8ed4c56e4f318edb41e5da8b064a"
}

Response

{
  "status": "success",
  "objects": [
    {
      "IsFile": false,
      "InternalName": "a42a0704af704efd83e515f97cac7b70",
      "PublicName": "cats",
      "ShareId": "17b8cd708c5f41f0a7d30a7230612de2"
    },
    {
      "IsFile": true,
      "InternalName": "b54e638b67664c688dd0cf28537bf191",
      "PublicName": "testfile.txt",
      "ShareId": "17b8cd708c5f41f0a7d30a7230612de2"
    }
  ]
}

Get folder contents

Request

POST /service/extension/rushfiles/get_folder_contents

{
  "ShareId": "17b8cd708c5f41f0a7d30a7230612de2",
  "InternalName": "a42a0704af704efd83e515f97cac7b70"
}

Response

{
  "status": "success",
  "objects": [
    {
      "IsFile": true,
      "InternalName": "e7a1f0f3373640e3a22504cfcb786540",
      "PublicName": "eMail.png",
      "ShareId": "17b8cd708c5f41f0a7d30a7230612de2"
    },
    {
      "IsFile": true,
      "InternalName": "3a1f3e331a1f47aeb03af1f294e21637",
      "PublicName": "DVD-Player.png",
      "ShareId": "17b8cd708c5f41f0a7d30a7230612de2"
    }
  ]
}

Creation links to files

Request

POST /service/extension/rushfiles/create_links_to_files

{
  "objects": [
    {
      "InternalName": "3a1f3e331a1f47aeb03af1f294e21637",
      "ShareId": "17b8cd708c5f41f0a7d30a7230612de2"
    },
    {
      "InternalName": "3a1f3e331a1f47aeb03af1f294e21637",
      "ShareId": "17b8cd708c5f41f0a7d30a7230612de2",
      "DaysToExpire": 10,
      "MaxUse": 5,
      "Message": "hello world",
      "Password": "123456"
    }
  ]
}

Response

{
  "status": "success",
  "objects": [
    {
      "Link": "http://publiclink.com/123",
      "InternalName": "3a1f3e331a1f47aeb03af1f294e21637",
      "ShareId": "17b8cd708c5f41f0a7d30a7230612de2",
      "DaysToExpire": null,
      "MaxUse": null,
      "Message": null,
      "Password": null
    },
    {
      "Link": "http://publiclink.com/123",
      "InternalName": "3a1f3e331a1f47aeb03af1f294e21637",
      "ShareId": "17b8cd708c5f41f0a7d30a7230612de2",
      "DaysToExpire": 10,
      "MaxUse": 5,
      "Message": "hello world",
      "Password": "123456"
    }
  ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages