When I'm changing role programmatically then updated role is not taking place immediately until run clean up permissions from control panel.
Is there any way to call some APIs to do the same through program itself?
the method doing it is CleanUpPermissionsUtil.cleanUpAddToPagePermissions(ActionRequest)
but the problem that it is a internal utility and is not possible to call in a plugin. It execute in the PortalContext.
You can see the source of the class at the link and try to replicate the code maybe in your logic
https://github.com/liferay/liferay-portal/blob/6.2.x/portal-impl/src/com/liferay/portlet/admin/util/CleanUpPermissionsUtil.java
This is the way that you should use to reload permission from update role:
Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER);
List<ResourcePermission> roleResourcePermissions = ResourcePermissionLocalServiceUtil.getRoleResourcePermissions(role.getRoleId());
for(ResourcePermission permission : roleResourcePermissions )
ResourcePermissionLocalServiceUtil.reassignPermissions(permission.getResourcePermissionId(),role.getRoleId());
Related
I am looking to be able to modify developer option settings in my app, I have tried looking in the Settings.Global, Settings.System and Settings.Secure but none cover the specific toggle I'm after, which is "Simulate color space".
Would anyone be able to point me in the right direction in trying to locate this setting provider?
Great news!, I have solved this now! (Requires ROOT or ADB)
Please note, to successfully modify secure settings you must grant your app permission to android.permission.WRITE_SECURE_SETTINGS otherwise it will crash; you can do this in two ways, either from the ADB Shell: "pm grant your.package.name android.permission.WRITE_SECURE_SETTINGS" or by requesting root privileges and executing it within your app as SU.
Use the following lines to enable the Monochrome setting:
Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer_enabled", "1");
Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer", "0");
and to disable:
Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer_enabled", "0");
Settings.Secure.putString(this.getContentResolver(), "accessibility_display_daltonizer", "-1");
I located these string constants in the Settings.Secure class and you will be able to find other developer settings and modify them to your fancy.
Below are the values for the other screen-space modes:
DISABLED = -1
MONOCHROMACY = 0
PROTANOMALY = 11
CORRECT_DEUTERANOMALY = 12
TRITANOMALY= 13
Enjoy!
After adding compile 'org.webrtc:google-webrtc:1.0.+' to my build.gradle file I try to init PeerConnectionFactory, but this class has no any useful methods.
What am I doing wrong?
UPDATE:
enter image description here
The last version org.webrtc:google-webrtc:1.0.21217
You can init by following codes
PeerConnectionFactory.InitializationOptions.Builder optionBuilder =
PeerConnectionFactory.InitializationOptions.builder(/* Put context here */);
optionBuilder.setEnableInternalTracer(true);
optionBuilder.setFieldTrials("WebRTC-FlexFEC-03/Enabled/");
optionBuilder.setEnableVideoHwAcceleration(true);
PeerConnectionFactory.initialize(optionBuilder.createInitializationOptions());
First, try to use an specific version like: compile 'org.webrtc:google-webrtc:1.0.20198'
And then make sure you rebuild your project (not only refresh gradle, since it might not be enough for the autocomplete to work).
In your screenshot, it looks like you are trying to autocomplete outside of any method. Since Android Studio tries to only show you valid stuff, it won't display the other methods unless you write it on a valid context (i.e.: inside of some method's implementation).
I've successfully added a custom field to the User Sign-up page (create_account.jsp) by creating an expando column via Hook plugin. However, the field is not visible until I enable Guest permissions on it through the admin UI.
I need to be able to do this programmatically, through the Hook plugin. Exhaustive research leads me to believe that the following code should do the trick:
Role guest = RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST);
ResourcePermissionLocalServiceUtil.setResourcePermissions(
companyId,
ExpandoColumn.class.getName(),
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(expandoColumn.getColumnId()),
guest.getRoleId(),
new String[] { ActionKeys.VIEW, ActionKeys.UPDATE });
But it doesn't.
Anyone got any ideas?
I tried same code as yours and it worked for me. In my opinion the problem is in "expandoColumn.getColumnId()". How do you retreive object ExpandoColumn? I tried with with table id and name:
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(21806, "Menu");
For this try i retreive the table id directly from DataBase, from table "expandocolumn"
according to the Google Drive SDK Update sharing permissions and https://developers.google.com/drive/v2/reference/permissions I want to change the whole folder content to be available for viewing (the folder contains only images and I show them on my page with <img alt='' src='https://drive.google.com/uc?export=view&id="fileID"'/>)
so, I'm trying to use that code
PermissionList permissions = Google_DriveService.Permissions.List(fileId).Fetch();
var filePermissions = permissions.Items;
Permission permission = Google_DriveService.Permissions.Get(fileId, filePermissions[0].Id).Fetch();
permission.Role = "reader";
permission.Value = "me";
permission.Type = "anyone";
permission.WithLink = true;
var updated = Google_DriveService.Permissions.Update(permission, fileId, filePermissions[0].Id).Fetch();
but I get the error message
Google.Apis.Requests.RequestError Invalid permission type specified [400] Errors [ Message[Invalid permission type specified] Location[ - ] Reason[invalid] Domain[global] ]
what am I doing wrong ?
Tony's answer is correct and here is an addon to his instruction if anyone else is looking to test this. Note that I did not write up the code for this due to time constraints but I tested it using the Google API supplied on the Google Drive web api page. I tested this by doing the following:
Go to the following link and list all the files in your drive. https://developers.google.com/drive/v2/reference/files/list
Select one file that you want to share for read only access and copy out the "id" as per the screenshot below:
Go to the insert permission page here - Tony was correct, you do not delete the existing permission but instead, you add onto that permission: https://developers.google.com/drive/v2/reference/permissions/insert
In the API explorer, type in "role" as "reader" and "type" as "anyone".
Go to your Drive: https://drive.google.com/drive/#my-drive and you will see that the file is now shared - if you hover over the green link icon in the screenshot below, it will tell you that it is now shared.
You can also copy the link for the doc and paste it into Incognito mode in Chrome to test whether you can access the read-only version of the doc in Incognito mode and it should work.
Additional:
The code should not be too hard, here it is:
Permission newPermission = new Permission();
newPermission.setType("anyone");
newPermission.setRole("reader");
try {
return service.permissions().insert(fileId, newPermission).execute();
} catch (IOException e) {
System.out.println("An error occurred: " + e);
}
You can't change permission types with update requests, insert a new permission and delete the existing. You should also not use me as a principal related to an anyone permission. Anyone permissions dont expect value attributes to be set.
This is the new reference of the API: https://developers.google.com/drive/v3/reference/permissions/create
I'm developing one web application project using java for education industry.In this Admin have all rights to access the google services of other users like A,B,C..... for this is use OAuth.Then i tried Admin want to share user A's calendar to user B using OAuth.But i got stuck in this step. Is it possible Plz Help me
Thanks
Regards
Sharun
I believe you want to use Access Control Lists (ACLs), see the docs. The Java example code at this URL for the task you mention is pretty simple:
AclEntry entry = new AclEntry();
entry.setScope(new AclScope(AclScope.Type.USER, "jdoe#gmail.com"));
entry.setRole(CalendarAclRole.READ);
URL aclUrl =
new URL("http://www.google.com/calendar/feeds/jo#gmail.com/acl/full");
AclEntry insertedEntry = service.insert(aclUrl, entry);
and what it does is, and I quote:
This code allows jdoe#gmail.com to
have read-only access to
jo#gmail.com's calendar.
There's more where this came from (e.g., upgrading a user's role in an ACL above the read-only access granted in this example), and I think it's a good idea to read the whole page.