-
Notifications
You must be signed in to change notification settings - Fork 8
Add improvements to media service operations. #21
Conversation
...ntity.media.core/src/main/java/org/wso2/carbon/identity/media/core/StorageSystemManager.java
Outdated
Show resolved
Hide resolved
@@ -79,7 +78,7 @@ | |||
|
|||
@Override | |||
public String addMedia(List<InputStream> inputStreams, MediaMetadata mediaMetadata, String uuid, | |||
String tenantDomain) throws StorageSystemException { | |||
String tenantDomain) throws StorageSystemServerException { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
....core/src/main/java/org/wso2/carbon/identity/media/core/file/FileBasedStorageSystemImpl.java
Outdated
Show resolved
Hide resolved
org.json.simple, | ||
org.json.simple.parser | ||
org.json.simple.parser, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unable to provide a version range here. same approach has been followed at https://github.com/wso2-extensions/identity-inbound-auth-oauth/blob/master/components/org.wso2.carbon.identity.oauth.dcr/pom.xml#L134
...n.identity.media.core/src/main/java/org/wso2/carbon/identity/media/core/FileContentImpl.java
Outdated
Show resolved
Hide resolved
return false; | ||
StorageSystemFactory storageSystemFactory = getStorageSystemFactory(getMediaStoreType()); | ||
String userId = getUserIdFromUserName(username); | ||
return storageSystemFactory.getInstance().isDownloadAllowedForProtectedMedia(mediaId, type, tenantDomain, |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed with 93a5753
...ntity.media.core/src/main/java/org/wso2/carbon/identity/media/core/StorageSystemManager.java
Outdated
Show resolved
Hide resolved
UserRealm userRealm = realmService.getTenantUserRealm(tenantID); | ||
if (userRealm != null) { | ||
UserStoreManager userStoreManager = (UserStoreManager) userRealm.getUserStoreManager(); | ||
String userIdFromUserName = ((AbstractUserStoreManager) userStoreManager) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
....core/src/main/java/org/wso2/carbon/identity/media/core/file/FileBasedStorageSystemImpl.java
Outdated
Show resolved
Hide resolved
....core/src/main/java/org/wso2/carbon/identity/media/core/file/FileBasedStorageSystemImpl.java
Outdated
Show resolved
Hide resolved
throw new StorageSystemServerException(String.format("Unable to obtain StorageSystemFactory for " + | ||
"configured media store type: %s", storageType)); | ||
} | ||
return storageSystemFactory.getInstance(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
This PR adds the following improvements: