List of usage examples for org.apache.commons.lang ArrayUtils add
public static short[] add(short[] array, short element)
Copies the given array and adds the given element at the end of the new array.
From source file:org.ednovo.gooru.controllers.v2.api.CollectionRestV2Controller.java
@AuthorizeOperations(operations = { GooruOperationConstants.OPERATION_SCOLLECTION_READ }) @RequestMapping(value = { "/{id}" }, method = RequestMethod.GET) public ModelAndView getCollection(@PathVariable(value = ID) final String collectionId, @RequestParam(value = INCLUDE_COLLECTION_ITEM, required = false, defaultValue = TRUE) final boolean includeCollectionItem, @RequestParam(value = INLCLUDE_META_INFO, required = false, defaultValue = FALSE) boolean includeMetaInfo, @RequestParam(value = INCLUDE_COLLABORATOR, required = false, defaultValue = FALSE) boolean includeCollaborator, @RequestParam(value = IS_GAT, required = false, defaultValue = FALSE) boolean isGat, @RequestParam(value = CLEAR_CACHE, required = false, defaultValue = FALSE) boolean clearCache, @RequestParam(value = INCLUDE_RELATED_CONTENT, required = false, defaultValue = FALSE) boolean includeRelatedContent, @RequestParam(value = MERGE, required = false) String merge, @RequestParam(value = REQ_CONTEXT, required = false, defaultValue = "edit-play") String requestContext, @RequestParam(value = ROOT_NODE_ID, required = false) String rootNodeId, @RequestParam(value = INCLUDE_CONTENT_PROVIDER, required = false, defaultValue = TRUE) boolean includeContentProvider, @RequestParam(value = INCLUDE_CUSTOM_FIELDS, required = false, defaultValue = TRUE) boolean includeCustomFields, HttpServletRequest request, HttpServletResponse response) { final User user = (User) request.getAttribute(Constants.USER); String includes[] = null;// ww w . j a v a 2s . com if (requestContext != null && requestContext.equalsIgnoreCase("library")) { includes = (String[]) ArrayUtils.addAll(LIBRARY_RESOURCE_INCLUDE_FIELDS, COLLECTION_ITEM_INCLUDE_FILEDS); includes = (String[]) ArrayUtils.addAll(includes, LIBRARY_COLLECTION_INCLUDE_FIELDS); final String cacheKey = COLLECTION_DATA + requestContext + "-" + collectionId + "-" + rootNodeId; String data = null; data = getRedisService().getValue(cacheKey); if (data == null) { data = serialize(this.getCollectionService().getCollection(collectionId, new HashMap<String, Object>(), rootNodeId), RESPONSE_FORMAT_JSON, EXCLUDE_ALL, false, true, includes); getRedisService().putValue(cacheKey, data, Constants.CACHE_EXPIRY_TIME_IN_SEC); } return toModelAndView(data); } else { includes = (String[]) ArrayUtils.addAll(RESOURCE_INCLUDE_FIELDS, COLLECTION_INCLUDE_FIELDS); if (includeCollectionItem) { includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_ITEM_INCLUDE_FILEDS); } if (includeMetaInfo) { includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_META_INFO); } includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_TAXONOMY); if (includeRelatedContent) { includes = (String[]) ArrayUtils.add(includes, "*.contentAssociation"); } includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_ITEM_TAGS); return toModelAndViewWithIoFilter(getCollectionService().getCollection(collectionId, includeMetaInfo, includeCollaborator, includeRelatedContent, user, merge, rootNodeId, isGat, true, includeContentProvider, includeCustomFields), RESPONSE_FORMAT_JSON, EXCLUDE_ALL, true, includes); } }
From source file:org.ednovo.gooru.controllers.v2.api.FolderRestV2Controller.java
@AuthorizeOperations(operations = { GooruOperationConstants.OPERATION_FOLDER_UPDATE }) @RequestMapping(value = { "/{id}" }, method = { RequestMethod.PUT }) public ModelAndView updateFolder(@PathVariable(value = ID) final String collectionId, @RequestBody final String data, final HttpServletRequest request, final HttpServletResponse response) throws Exception { final User user = (User) request.getAttribute(Constants.USER); final JSONObject json = requestData(data); final ActionResponseDTO<Collection> responseDTO = getCollectionService().updateCollection( this.buildUpadteCollectionFromInputParameters(data, user), collectionId, getValue(OWNER_UID, json), getValue(CREATOR_UID, json), hasUnrestrictedContentAccess(), getValue(RELATED_CONTENT_ID, json), user, data);//from www. java 2 s . com if (responseDTO.getErrors().getErrorCount() > 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } String[] includes = (String[]) ArrayUtils.addAll(COLLECTION_INCLUDE_FIELDS, ERROR_INCLUDE); if (getValue(TAXONOMY_SET, json) != null) { includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_TAXONOMY); } if (getValue(RELATED_CONTENT_ID, json) != null) { includes = (String[]) ArrayUtils.add(includes, "*.contentAssociation.associateContent"); } return toModelAndViewWithIoFilter(responseDTO.getModelData(), RESPONSE_FORMAT_JSON, EXCLUDE_ALL, true, includes); }
From source file:org.ednovo.gooru.domain.service.ScollectionServiceImpl.java
private String[] includes(final boolean includeCollectionItem, final boolean includeMetaInfo, final boolean includeRelatedContent) { String includes[] = (String[]) ArrayUtils.addAll(RESOURCE_INCLUDE_FIELDS, COLLECTION_INCLUDE_FIELDS); if (includeCollectionItem) { includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_ITEM_INCLUDE_FILEDS); }/*from ww w .ja v a2 s . c o m*/ if (includeMetaInfo) { includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_META_INFO); } includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_TAXONOMY); if (includeRelatedContent) { includes = (String[]) ArrayUtils.add(includes, "*.contentAssociation"); } includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_ITEM_TAGS); return includes; }
From source file:org.ednovo.gooru.json.serializer.util.JsonSerializer.java
/** * @param model// ww w. j a v a 2 s .c o m * @param type * @param excludes * @param includes * @return */ public static String serialize(Object model, String type, String[] excludes, boolean deepSerialize, String... includes) { if (model == null) { return ""; } String serializedData = null; JSONSerializer serializer = new JSONSerializer(); if (type == null || type.equals("json")) { if (includes != null) { includes = (String[]) ArrayUtils.add(includes, "*.contentPermissions"); serializer.include(includes); } else { serializer.include("*.contentPermissions"); } if (excludes != null) { serializer.exclude(excludes); } try { serializedData = deepSerialize ? serializer.deepSerialize(model) : serializer.serialize(model); } catch (Exception ex) { throw new MethodFailureException(ex.getMessage()); } } else { serializedData = new XStream().toXML(model); } return serializedData; }
From source file:org.exoplatform.faq.service.search.AnswerSearchResult.java
@Override public boolean add(ObjectSearchResult e) { if (contains(e)) { return false; }// ww w. ja v a 2 s .c o m // contains in skipList, what contains offset list if (contains(idsSkip, e)) { return false; } // if (++skip <= offset) { idsSkip = (String[]) ArrayUtils.add(idsSkip, e.getId()); return false; } // ids = (String[]) ArrayUtils.add(ids, e.getId()); gotList.add(e); return true; }
From source file:org.exoplatform.forum.service.search.DiscussionSearchResult.java
@Override public boolean add(ForumSearchResult e) { if (contains(e)) { return false; }/*from w w w . j a v a 2s . c o m*/ // contains in skipList, what contains offset list if (contains(idsSkip, e)) { return false; } // if (++skip <= offset) { idsSkip = (String[]) ArrayUtils.add(idsSkip, e.getId()); return false; } // ids = (String[]) ArrayUtils.add(ids, e.getId()); gotList.add(e); return true; }
From source file:org.exoplatform.platform.component.UIUserNavigationPortlet.java
public String[] getUserNodesAsList() { String[] userNodeList = (String[]) ArrayUtils.add(null, PROFILE_URI); userNodeList = (String[]) ArrayUtils.add(userNodeList, ACTIVITIES_URI); userNodeList = (String[]) ArrayUtils.add(userNodeList, CONNEXIONS_URI); userNodeList = (String[]) ArrayUtils.add(userNodeList, WIKI_URI); userNodeList = (String[]) ArrayUtils.add(userNodeList, DASHBOARD_URI); if (CommonsUtils.isFeatureActive(NotificationUtils.FEATURE_NAME)) { userNodeList = (String[]) ArrayUtils.add(userNodeList, NOTIFICATION_SETTINGS); }// ww w .j a v a 2 s .c om return userNodeList; }
From source file:org.exoplatform.platform.component.UIUserNavigationPortlet.java
public String[] getURLAsList() throws Exception { String[] urlList = (String[]) ArrayUtils.add(null, getProfileLink()); urlList = (String[]) ArrayUtils.add(urlList, getactivitesURL()); urlList = (String[]) ArrayUtils.add(urlList, getrelationURL()); urlList = (String[]) ArrayUtils.add(urlList, getWikiURL()); urlList = (String[]) ArrayUtils.add(urlList, DashboardUtils.getDashboardURL()); if (CommonsUtils.isFeatureActive(NotificationUtils.FEATURE_NAME)) { urlList = (String[]) ArrayUtils.add(urlList, getNotificationsURL()); }// www. j a v a 2s . c o m return urlList; }
From source file:org.exoplatform.platform.portlet.juzu.calendar.CalendarPortletController.java
@Ajax @Resource/* w ww . ja v a 2 s. com*/ public Response.Content deleteCalendar(String calendarId) throws Exception { nonDisplayedCalendarList = (String[]) ArrayUtils.add(nonDisplayedCalendarList, calendarId); StringBuffer cal = new StringBuffer(); int i = 0; while (i < nonDisplayedCalendarList.length) { cal.append(nonDisplayedCalendarList[i]).append(","); i++; } settingService_.remove(Context.USER, Scope.APPLICATION, CalendarPortletUtils.HOME_PAGE_CALENDAR_SETTINGS); settingService_.set(Context.USER, Scope.APPLICATION, CalendarPortletUtils.HOME_PAGE_CALENDAR_SETTINGS, SettingValue.create("NonDisplayedCalendar:" + cal.toString())); return setting(); }
From source file:org.exoplatform.social.addons.test.AbstractCoreTest.java
/** * Creates new space with out init apps. * * @param space/*from w w w .j av a 2 s . com*/ * @param creator * @param invitedGroupId * @return * @since 1.2.0-GA */ protected Space createSpaceNonInitApps(Space space, String creator, String invitedGroupId) { // Creates new space by creating new group String groupId = null; try { groupId = SpaceUtils.createGroup(space.getDisplayName(), creator); } catch (SpaceException e) { LOG.error("Error while creating group", e); } if (invitedGroupId != null) { // Invites user in group join to new created space. // Gets users in group and then invites user to join into space. OrganizationService org = (OrganizationService) ExoContainerContext.getCurrentContainer() .getComponentInstanceOfType(OrganizationService.class); try { ListAccess<User> groupMembersAccess = org.getUserHandler().findUsersByGroupId(invitedGroupId); List<User> users = Arrays.asList(groupMembersAccess.load(0, groupMembersAccess.getSize())); for (User user : users) { String userId = user.getUserName(); if (!userId.equals(creator)) { String[] invitedUsers = space.getInvitedUsers(); if (!ArrayUtils.contains(invitedUsers, userId)) { invitedUsers = (String[]) ArrayUtils.add(invitedUsers, userId); space.setInvitedUsers(invitedUsers); } } } } catch (Exception e) { LOG.error("Failed to invite users from group " + invitedGroupId, e); } } String[] managers = new String[] { creator }; space.setManagers(managers); space.setGroupId(groupId); space.setUrl(space.getPrettyName()); try { spaceService.createSpace(space, creator); } catch (Exception e) { LOG.warn("Error while saving space", e); } return space; }