cancel
Showing results for 
Search instead for 
Did you mean: 

User Creation Using Java API( With Specific Quota)

sundar3686
Champ in-the-making
Champ in-the-making
Hi friends,
I successfully created user using web service client. But i cant specify the user quota. Is it possible in web service client?.Please help me.
This is my code.
import java.rmi.RemoteException;import java.util.logging.Level;import java.util.logging.Logger;import org.alfresco.webservice.administration.NewUserDetails;import org.alfresco.webservice.administration.AdministrationServiceSoapBindingStub;import org.alfresco.webservice.types.NamedValue;import org.alfresco.webservice.types.Store;import org.alfresco.webservice.util.AuthenticationUtils;import org.alfresco.webservice.util.Constants;import org.alfresco.webservice.util.WebServiceFactory;import org.alfresco.webservice.types.Query;import org.alfresco.webservice.repository.QueryResult;/** * * @author sundar */public class CreateUserCommand {    public CreateUserCommand() {    }    public static void main(String a[]) {        try {            CreateUserCommand c = new CreateUserCommand();            AuthenticationUtils.startSession("admin", "admin");          //  WebServiceFactory.getAdministrationService().changePassword("", "", "");            Store s = new Store(Constants.WORKSPACE_STORE, "Spacesstore");            AdministrationServiceSoapBindingStub ad = WebServiceFactory.getAdministrationService();            String username="sundarpx";            String password="sundarpx";            String firstname="sundar";            String midlename="p";            String lastname="rajan";            String email="sundar.p@demo.com";            String regid="1";                        // check the user            boolean existUser = false;            try {                // test before the user                Query query = new Query("lucene", "+TYPE:\"cm:person\" AND +@cm\\:userName:\"" + username + "\"");                QueryResult results = WebServiceFactory.getRepositoryService().query(s, query, true);                              if (results != null&&results.getResultSet()!=null) {                    if (results.getResultSet().getRows().length > 0) {                        existUser = true;                    } else {                        existUser = false;                    }                } else {                    existUser = false;                }            } catch (Exception e) {                    existUser = false;            }            if(existUser){                System.out.println("This user already exists");            }else{            NamedValue[] properties = c.createUserProperties(s.getScheme() + "://" + s.getAddress() + "/", firstname, midlename, lastname, email, regid);            NewUserDetails dc[] = new NewUserDetails[]{new NewUserDetails(username, password, properties)};            ad.createUsers(dc);                            }            AuthenticationUtils.endSession();        } catch (RemoteException ex) {            Logger.getLogger(CreateUserCommand.class.getName()).log(Level.SEVERE, null, ex);        }    }    public NamedValue[] createUserProperties(String homefolder, String firstname, String midlename, String lastname, String email, String orgid) {        return new NamedValue[]{                    new NamedValue(Constants.PROP_USER_HOMEFOLDER, false, homefolder, null),                    new NamedValue(Constants.PROP_USER_FIRSTNAME, false, firstname, null),                    new NamedValue(Constants.PROP_USER_MIDDLENAME, false, midlename, null),                    new NamedValue(Constants.PROP_USER_LASTNAME, false, lastname, null),                    new NamedValue(Constants.PROP_USER_EMAIL, false, email, null),                    new NamedValue(Constants.PROP_USER_ORGID, false, orgid, null)                            };    }}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
10 REPLIES 10

romschn
Star Collaborator
Star Collaborator
I couln't understand what is user quota. Could you please help me understand that so as I can help you if I can.

Thanks,

sundar3686
Champ in-the-making
Champ in-the-making
I mean user storage capacity.

romschn
Star Collaborator
Star Collaborator
Did you mean to say, you want to specify how many users you can create using your web service client? Is it so?

sundar3686
Champ in-the-making
Champ in-the-making
no, user storage capacity . ie 1GB or 2GB

romschn
Star Collaborator
Star Collaborator
Yes, I got your point. You mean to say that you want to define the default storage capacity for a user through web service client same as we do from alfresco web client.

I don't think it is possible out-of-the box. As I could see the data type for sizeQuota is long and the properties taken up by NewUserDetails is NameValued[], which supports string as value.

Hope this helps.

Thanks,

sundar3686
Champ in-the-making
Champ in-the-making
Ok friend,
I directly change the alfresco source. And one more clarification, is it possible enable open office in alfresco community edition 3.d?. And enable jodconverter for previewing office documents. I tried many ways but i couldn't enable the features.

romschn
Star Collaborator
Star Collaborator
Hope you are now able to set the user quota.

I am sure you must have done the required configuration for openoffice in alfresco-global.properties file. Are you getting any error?

I have not tried running openoffice. However, I found below links, hope you may find any useful information for you from it.
http://forums.alfresco.com/en/viewtopic.php?f=8&t=37944
https://issues.alfresco.com/jira/browse/ALF-8270
http://issues.alfresco.com/jira/browse/ALF-7570

Hope this helps.

Thanks,

[size=85]if you find any of the post as useful to you, do give a point[/size]

sundar3686
Champ in-the-making
Champ in-the-making
I got an exception like

net.sf.jooreports.openoffice.connection.OpenOfficeException - conversion failed; com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.

romschn
Star Collaborator
Star Collaborator
Could you please post your openoffice configurations you have done.