Page 1 of 1

Hide or limit "restore" and "compact history" in "History" page

PostPosted:Thu Aug 18, 2016 8:51 am
by han
Hi all,

I have a question about this:
Anyone who can see the "History" page that can "restore" any version and use "comact history" to delete the other versions.
Can I do something to hide or limit these for some group(role or profile) ?
Or I can only limit anyone else can't see "History" tab?

Should any body please help on these?
Many thanks!

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Thu Aug 18, 2016 9:21 am
by jllort
You can extend security http://wiki.openkm.com/index.php/Applic ... d_security ( and then indicate who can doing it and who cannot ). Another option is modifying source code ( better add in profiles ) for showing or not the option based on profiles ( if you want we can guide on it ). Another option should be disabling "versions" from profile ( all version history tab will be hidden ).

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Fri Aug 19, 2016 12:46 am
by han
Thanks for your reply,jllort. :D
Maybe modifying source code for showing or not the option based on profiles is better choice for me.
Can you guide me how to do it?
:)

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Sat Aug 20, 2016 2:50 pm
by jllort
First add the option in the profiles, take a look at:
* ProfileServlet.java
* profile_misc.jsp ( I suggest add in misc tab )
* ProfileMisc.java

Then propagate to UI. Take a look at:
* WorkspaceServlet.java
* GWTWorkspace.java ( should add here the new variable ).
* TabDocument.java -> VersionScrollTable.java ( this is the class of history ) should hide the button ( take a look at class WorkspaceUserProperties line 287 for understanding how doing it ).

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Mon Aug 22, 2016 1:33 am
by han
Thanks for your reply,jllort.

I have never learned java, but I will try it these days.
First I need to decompile "ProfileServlet.class" and "ProfileMisc.class" to get "ProfileServlet.java" and "ProfileMisc.java". Is it right?

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Mon Aug 22, 2016 8:10 am
by jllort
You should download openkm portable development environment https://sourceforge.net/projects/openkmportabledev/ which comes with source code etc...

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Tue Aug 23, 2016 7:15 am
by han
Thank you first,jllort.

I edit the VersionScrollTable.java from
Code: Select all
if (result.size() > 1 ) {
	purge.setEnabled(true);
} else {
	purge.setEnabled(false);
}
to
Code: Select all
if (result.size() > 1 && Main.get().workspaceUserProperties.getWorkspace().isAdminRole()) {
	purge.setEnabled(true);
} else {
	purge.setEnabled(false);
}
I tried to compile "VersionScrollTable.java" by javac, but it can't.
I think that should compile by other way, but I really have no idea about it.
Or what I edit above gets something wrong ? (Only admin role can use purge.)
What can I do to replace VersionScrollTable.class (or others) in my openKM 6.3.1 by it?

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Tue Aug 23, 2016 3:02 pm
by jllort
You must download the OpenKM portable edition, as I said in previous reply and from there you can build the entire OpenKM.war ( and modify classes )

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Mon Aug 29, 2016 1:46 am
by han
Thanks for your reply, jllort

I learning how to compile project to a ".war" file these days.

I downloaded the OpenKM portabal edition ,and edited "VersionScrollTable.java" as above.

And I compiled openKM in eclipse by
"right click openkm-6.3-community 8185 >> run as >> Maven built >> Build openkm 6.3 war:clean gwt:compile compile install".

After compile,I stop the openKM on my computer and I copy the openKM.war from my VirtualMachine to my computer, and replace it by the new one.

Then I start up openKM, but it does still not work when I loggin as a "user" that doesn't have admin role.
(not work: When I loggin as a user that doesn't have admin role, I can still use compact history.)

Does I do something wrong with it?

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Thu Sep 01, 2016 7:13 am
by jllort
The portable edition comes with a tomcat, there you should deploy the application before testing in your production environment.
Portable edition also comes with portable firefox with what you are able to debug UI ( take a look here http://wiki.openkm.com/index.php/Debugging_with_GWT )

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Wed Oct 12, 2016 3:15 am
by han
Thank you jllort,

After I downloaded the portable edition, I edited "VersionScrollTable.java".

Using "purge.setEnabled(false);" to let the "compact history" bottom unavilable.

And I try it in the portable edition, it works well in the portable version.

But I don't know how to let it work in openKM 6.3.1.

(I compiled openKM in eclipse by
"right click openkm-6.3-community 8185 >> run as >> Maven built >> Build openkm 6.3 war:clean gwt:compile compile install".
And I copied openKM.war from the portable edition to openKM.
Then, I deleted the openKM folder that in "tomcat/webapps/".
After these steps, I start up openKM, But it does not work the same as it works in the portable edition.
Did I miss something? Or it can only works in the portable edition?
What should I do?)

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Thu Oct 13, 2016 5:46 pm
by jllort
Which OpenKM did you have at the begining ? 6.3.x ? which version ?
Ensure, you copied the OpenKM.com file from the eclipse workspace no ?

Basically should be like a migration.
Stop OpenKM
set OpenKM hibernate.hbm2ddl=update ( optional, only if you are jumping to upper version )
copy new OpenKM.war into webapps
remove folder /webapps/OpenKM ( to ensure new clean deployin )
remove work/Catalina/localhost folder ( same reason )
start OpenKM

There's no reason why it's running from portable and not from deployed.

Re: Hide or limit "restore" and "compact history" in "History" page

PostPosted:Fri Oct 14, 2016 1:13 am
by han
jllort wrote:Which OpenKM did you have at the begining ? 6.3.x ? which version ?
Version 6.3.1
jllort wrote:Ensure, you copied the OpenKM.com file from the eclipse workspace no ?
8185
jllort wrote:Basically should be like a migration.
Stop OpenKM
set OpenKM hibernate.hbm2ddl=update ( optional, only if you are jumping to upper version )
copy new OpenKM.war into webapps
remove folder /webapps/OpenKM ( to ensure new clean deployin )
remove work/Catalina/localhost folder ( same reason )
start OpenKM

There's no reason why it's running from portable and not from deployed.
Many thanks jllort :D ,

It's solved.
I stop openKM
copy new OpenKM.war into webapps
remove folder /webapps/OpenKM
copy new openKM folder into webapps (from EclipsePortable\Data\workspace\openkm-6.3-community\target)
remove work/Catalina/localhost folder
start openKM

and clean the browser(IE, chrome, firefox etc)
( Using some browser that is before clean, I can still log in and do "compact history". )