Example usage for com.liferay.portal.kernel.model UserConstants USER_ID_DEFAULT

List of usage examples for com.liferay.portal.kernel.model UserConstants USER_ID_DEFAULT

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model UserConstants USER_ID_DEFAULT.

Prototype

long USER_ID_DEFAULT

To view the source code for com.liferay.portal.kernel.model UserConstants USER_ID_DEFAULT.

Click Source Link

Usage

From source file:com.liferay.asset.publisher.web.internal.exportimport.portlet.preferences.processor.AssetPublisherExportImportPortletPreferencesProcessor.java

License:Open Source License

protected void exportAssetObjects(PortletDataContext portletDataContext, PortletPreferences portletPreferences)
        throws Exception {

    List<AssetEntry> assetEntries = null;

    Layout layout = _layoutLocalService.getLayout(portletDataContext.getPlid());

    String selectionStyle = portletPreferences.getValue("selectionStyle", "dynamic");

    if (selectionStyle.equals("dynamic")) {
        if (!_assetPublisherWebConfiguration.dynamicExportEnabled()) {
            return;
        }//from  ww w.j  a  v a  2 s.com

        AssetEntryQuery assetEntryQuery = getAssetEntryQuery(layout, portletDataContext.getCompanyGroupId(),
                portletDataContext.getScopeGroupId(), portletPreferences);

        long assetVocabularyId = GetterUtil.getLong(portletPreferences.getValue("assetVocabularyId", null));

        if (assetVocabularyId > 0) {
            mergeAnyCategoryIds(assetEntryQuery, assetVocabularyId);

            if (ArrayUtil.isEmpty(assetEntryQuery.getAnyCategoryIds())) {
                return;
            }
        }

        BaseModelSearchResult<AssetEntry> baseModelSearchResult = AssetPublisherUtil.getAssetEntries(
                assetEntryQuery, layout, portletPreferences, AssetPublisherPortletKeys.ASSET_PUBLISHER,
                LocaleUtil.getDefault(), TimeZoneUtil.getDefault(), portletDataContext.getCompanyId(),
                portletDataContext.getScopeGroupId(), UserConstants.USER_ID_DEFAULT,
                new HashMap<String, Serializable>(), assetEntryQuery.getStart(), assetEntryQuery.getEnd());

        assetEntries = baseModelSearchResult.getBaseModels();
    } else {
        if (!_assetPublisherWebConfiguration.manualExportEnabled()) {
            return;
        }

        long[] groupIds = AssetPublisherUtil.getGroupIds(portletPreferences,
                portletDataContext.getScopeGroupId(), layout);

        assetEntries = AssetPublisherUtil.getAssetEntries(null, portletPreferences,
                PermissionThreadLocal.getPermissionChecker(), groupIds, false, false);
    }

    for (AssetEntry assetEntry : assetEntries) {
        AssetRenderer<?> assetRenderer = assetEntry.getAssetRenderer();

        if ((assetRenderer == null) || !(assetRenderer.getAssetObject() instanceof StagedModel)) {

            continue;
        }

        StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext,
                portletDataContext.getPortletId(), (StagedModel) assetRenderer.getAssetObject());
    }
}

From source file:com.liferay.document.library.internal.exportimport.data.handler.DLFileEntryTypeStagedModelDataHandler.java

License:Open Source License

@Override
public Map<String, String> getReferenceAttributes(PortletDataContext portletDataContext,
        DLFileEntryType fileEntryType) {

    Map<String, String> referenceAttributes = new HashMap<>();

    referenceAttributes.put("file-entry-type-key", fileEntryType.getFileEntryTypeKey());

    long defaultUserId = UserConstants.USER_ID_DEFAULT;

    try {/*from w w w  .  j a  v  a 2s . com*/
        defaultUserId = _userLocalService.getDefaultUserId(fileEntryType.getCompanyId());
    } catch (Exception e) {
    }

    boolean preloaded = false;

    if ((fileEntryType.getFileEntryTypeId() == DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT)
            || (defaultUserId == fileEntryType.getUserId())) {

        preloaded = true;
    }

    referenceAttributes.put("preloaded", String.valueOf(preloaded));

    return referenceAttributes;
}

From source file:com.liferay.users.admin.demo.data.creator.internal.BaseUserDemoDataCreator.java

License:Open Source License

private User _createBasicUser(long companyId, String screenName, String emailAddress, String firstName,
        String lastName, boolean male, Date birthDate) throws PortalException {

    String[] fullNameArray = getFullNameArray(emailAddress);

    if (Validator.isNull(firstName)) {
        firstName = fullNameArray[0];/*from w ww .  ja  va 2s. c om*/
    }

    if (Validator.isNull(lastName)) {
        lastName = fullNameArray[1];
    }

    boolean autoPassword = false;
    String password1 = "test";
    String password2 = "test";
    boolean autoScreenName = Validator.isNull(screenName);
    long facebookId = 0;
    String openId = StringPool.BLANK;
    Locale locale = LocaleUtil.getDefault();
    String middleName = StringPool.BLANK;
    long prefixId = 0;
    long suffixId = 0;

    Calendar calendar = Calendar.getInstance();

    calendar.setTime(birthDate);

    int birthdayMonth = calendar.get(Calendar.MONTH);
    int birthdayDay = calendar.get(Calendar.DATE);
    int birthdayYear = calendar.get(Calendar.YEAR);

    String jobTitle = _getRandomElement(_jobTitles);
    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;
    boolean sendMail = false;

    return userLocalService.addUser(UserConstants.USER_ID_DEFAULT, companyId, autoPassword, password1,
            password2, autoScreenName, screenName, emailAddress, facebookId, openId, locale, firstName,
            middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
            groupIds, organizationIds, roleIds, userGroupIds, sendMail, new ServiceContext());
}