Question

I just want to know that is that any facility liferay provides in which we just use the function of the inbuilt portlet?

E.g i have some custom portlet and i want to just add some document to the database table of document and media portlet from my custom portlet .so is it possible?

i don't want to use its GUI just i need to access its function or say action.

if i can call this way the adduser method of any inbuilt portlet in my own portlet com.liferay.portal.service.UserLocalServiceUtil.addUser

So can i use that way?and How?

Was it helpful?

Solution

i'm not sure i have understood the question, but you can of course use many provided services anywhere in your portlet. For example if you want to save a file you have uploaded from the page, you can use something like:

protected FileEntry saveFile(String name, File file, ThemeDisplay themeDisplay) throws PortalException, SystemException{
    _log.debug("request of saving new file " + name);
    if (file == null){
        _log.debug("file content is null.. save aborted");
        return null;
    }
    if (!StringUtils.hasLength(name)){
        _log.debug("file name is null.. save aborted");
        return null;
    }
    long defaultRepoId = DLFolderConstants.getDataRepositoryId(themeDisplay.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
        ServiceContext serviceContext = new ServiceContext();
        serviceContext.setSignedIn(true);
        serviceContext.setAddGroupPermissions(true);
        serviceContext.setAddGuestPermissions(true);
        Folder folder = fetchFolder(defaultRepoId);
        long folderId = (folder != null ? folder.getFolderId() : DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
        FileEntry entry = DLAppServiceUtil.addFileEntry(defaultRepoId, folderId, name, MimeTypesUtil.getContentType(file), name, "", "", file, serviceContext);
        _log.debug("file " + name + " saved successfully");
        return entry;
    }

Is this what you are looking for? In a similar way you can add many types of entity (users, wiki nodes, documents, ...)

Note that DLAppServiceUtilis provided by Liferay (6.1, maybe different in 6.0 due to changes on document library)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top