Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.

Add improvements to media service operations. #21

Merged
merged 4 commits into from
Jul 17, 2020

Conversation

dewniMW
Copy link
Contributor

@dewniMW dewniMW commented Jul 10, 2020

This PR adds the following improvements:

  • Add the capability to override the properties defined in the media.properties file via environment variables.
  • Introduce a configuration to define the maximum allowed byte size of the media to be uploaded. The default value would 512 KB.
  • Have the 'yyyyMMdd' date format (of the media uploaded date) appended to the unique id of the media and incorporate this when creating the hierarchical folder structure.
  • Enforce user to manually create a directory called 'media' in the media mount location. This decision was taken as an additional safety measure to prevent files from being stored in an incorrect location.
  • Have user id instead of the username.
  • Add ETag support for media download API.

@@ -79,7 +78,7 @@

@Override
public String addMedia(List<InputStream> inputStreams, MediaMetadata mediaMetadata, String uuid,
String tenantDomain) throws StorageSystemException {
String tenantDomain) throws StorageSystemServerException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this changed? don't we need to send a client exception in uuid already exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uuid is system generated. hence there is no check for uuid already exists condition.

org.json.simple,
org.json.simple.parser
org.json.simple.parser,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we add a version range for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false;
StorageSystemFactory storageSystemFactory = getStorageSystemFactory(getMediaStoreType());
String userId = getUserIdFromUserName(username);
return storageSystemFactory.getInstance().isDownloadAllowedForProtectedMedia(mediaId, type, tenantDomain,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally getStorageSystemFactory should return an instance of a StorageSystemFactory. you need to call isDownloadAllowedForProtectedMedia on that instance. Therefore no need to call getInstance() on an instance (it getInstance is used with singleton class)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed with 93a5753

UserRealm userRealm = realmService.getTenantUserRealm(tenantID);
if (userRealm != null) {
UserStoreManager userStoreManager = (UserStoreManager) userRealm.getUserStoreManager();
String userIdFromUserName = ((AbstractUserStoreManager) userStoreManager)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work correctly for a secondary userstore user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I have tested the flow for a secondary userstore user

throw new StorageSystemServerException(String.format("Unable to obtain StorageSystemFactory for " +
"configured media store type: %s", storageType));
}
return storageSystemFactory.getInstance();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here also since storageSystemFactory is an instance variable, its not correct to call getInstance() on that. can we rename the getInstace method to getStorageSystem or something meaningful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@dewniMW dewniMW merged commit 62d9ebe into wso2-attic:master Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants