List of usage examples for org.apache.commons.lang ArrayUtils nullToEmpty
public static Boolean[] nullToEmpty(Boolean[] array)
Defensive programming technique to change a null
reference to an empty one.
From source file:org.geoserver.security.iride.entity.util.Utils.java
/** * * @param array/* ww w. jav a2 s .c om*/ * @return */ @SuppressWarnings("unchecked") public static <T> T[] defaultToEmpty(T[] array) { return (T[]) ArrayUtils.nullToEmpty(array); }
From source file:org.hippoecm.frontend.plugins.jquery.upload.multiple.GalleryFileUploadBehavior.java
@Override protected Map<String, Object> configureParameters(final Component component) { final Map<String, Object> variables = super.configureParameters(component); //the url to be notified when uploading has done variables.put("fileUploadDoneUrl", settings.getUploadDoneNotificationUrl()); variables.put("selectionChangeUrl", settings.getSelectionChangeNotificationUrl()); final List<String> allowedExtensions = Arrays .asList(ArrayUtils.nullToEmpty(settings.getAllowedExtensions())); variables.put("acceptFileTypes", getAcceptFileTypesPattern("|")); // Localized error messages variables.put(MAX_NUMBER_OF_FILES_EXCEEDED_WIDGET, getMessage(MAX_NUMBER_OF_FILES_EXCEEDED_WIDGET)); final String maxFileSizeMB = String.format("%2.1fMB", Bytes.bytes(settings.getMaxFileSize()).megabytes()); variables.put(MAX_FILESIZE_MESSAGE, getMessage(MAX_FILESIZE_MESSAGE, maxFileSizeMB)); variables.put(INVALID_EXTENSION_MESSAGE, getMessage(INVALID_EXTENSION_MESSAGE, getAcceptFileTypesPattern(", "))); return variables; }
From source file:org.sakaiproject.content.impl.BaseContentService.java
/** * Commit the changes made, and release the lock. The Object is disabled, and not to be used after this call. * /*from w w w .ja va2 s . c o m*/ * @param edit * The ContentResourceEdit object to commit. * @param priority * The notification priority of this commit. * @exception OverQuotaException * if this would result in being over quota (the edit is then cancled). * @exception ServerOverloadException * if the server is configured to write the resource body to the filesystem and the save fails. */ public void commitResource(ContentResourceEdit edit, int priority) throws OverQuotaException, ServerOverloadException, VirusFoundException { // check for closed edit if (!edit.isActiveEdit()) { Exception e = new Exception(); M_log.error("commitResource(): closed ContentResourceEdit", e); return; } boolean hasContentTypeAlready = hasContentType(edit.getId()); //use magic to fix mimetype //Don't process for special TYPE_URL type String currentContentType = edit.getContentType(); m_useMimeMagic = m_serverConfigurationService.getBoolean("content.useMimeMagic", m_useMimeMagic); m_ignoreExtensions = Arrays.asList(ArrayUtils.nullToEmpty( m_serverConfigurationService.getStrings("content.mimeMagic.ignorecontent.extensions"))); m_ignoreMimeTypes = Arrays.asList(ArrayUtils .nullToEmpty(m_serverConfigurationService.getStrings("content.mimeMagic.ignorecontent.mimetypes"))); if (m_useMimeMagic && DETECTOR != null && !ResourceProperties.TYPE_URL.equals(currentContentType) && !hasContentTypeAlready) { try { //we have to make the stream resetable so tika can read some of it and reset for saving. //Also have to give the tika stream to the edit object since tika can invalidate the original //stream and replace it with a new stream. TikaInputStream buff = TikaInputStream.get(edit.streamContent()); edit.setContent(buff); final Metadata metadata = new Metadata(); //This might not want to be set as it would advise the detector metadata.set(Metadata.RESOURCE_NAME_KEY, edit.getId()); metadata.set(Metadata.CONTENT_TYPE, currentContentType); String newmatch = ""; //If we are ignoring the content for this extension, don't give it any data if (m_ignoreExtensions != null && m_ignoreExtensions.contains(FilenameUtils.getExtension(edit.getId()))) { newmatch = DETECTOR.detect(null, metadata).toString(); } else { newmatch = DETECTOR.detect(TikaInputStream.get(buff), metadata).toString(); //Redetect without the content as we're ignoring this mime type if (m_ignoreMimeTypes != null && m_ignoreMimeTypes.contains(newmatch)) { newmatch = DETECTOR.detect(null, metadata).toString(); } } if (M_log.isDebugEnabled()) { M_log.debug("Magic: Setting content type from " + currentContentType + " to " + newmatch); } edit.setContentType(newmatch); } catch (Exception e) { M_log.warn("Exception when trying to get the resource's data: " + e); } } commitResourceEdit(edit, priority); // Queue up content for virus scanning if (virusScanner.getEnabled()) { virusScanQueue.add(edit.getId()); } /** * check for over quota. * We do this after the commit so we can actual tell its size */ if (overQuota(edit)) { try { //the edit is closed so we need to refetch it ContentResourceEdit edit2 = editResource(edit.getId()); removeResource(edit2); } catch (PermissionException e1) { // we're unlikely to see this at this point e1.printStackTrace(); } catch (IdUnusedException e1) { // we're unlikely to see this at this point e1.printStackTrace(); } catch (TypeException e1) { // we're unlikely to see this at this point e1.printStackTrace(); } catch (InUseException e1) { // we're unlikely to see this at this point e1.printStackTrace(); } throw new OverQuotaException(edit.getReference()); } if (!readyToUseFilesizeColumn()) { addSizeCache(edit); } }
From source file:org.sakaiproject.contentreview.impl.turnitin.TurnitinReviewServiceImpl.java
/** * Place any code that should run when this class is initialized by spring * here/*from www . j a v a2 s. co m*/ */ public void init() { studentAccountNotified = turnitinConn.isStudentAccountNotified(); sendSubmissionNotification = turnitinConn.getSendSubmissionNotification(); maxRetry = turnitinConn.getMaxRetry(); defaultAssignId = turnitinConn.getDefaultAssignId(); defaultClassPassword = turnitinConn.getDefaultClassPassword(); spoilEmailAddresses = serverConfigurationService.getBoolean("turnitin.spoilEmailAddresses", false); preferSystemProfileEmail = serverConfigurationService.getBoolean("turnitin.preferSystemProfileEmail", true); preferGuestEidEmail = serverConfigurationService.getBoolean("turnitin.preferGuestEidEmail", true); enabledSiteTypes = Arrays .asList(ArrayUtils.nullToEmpty(serverConfigurationService.getStrings("turnitin.sitetypes"))); String[] strTerminalQueueErrors = serverConfigurationService.getStrings("turnitin.terminalQueueErrors"); if (strTerminalQueueErrors == null) { strTerminalQueueErrors = new String[] { "Your submission does not contain valid text.", "Your submission must contain 20 words or more.", "You must upload a supported file type for this assignment." }; } terminalQueueErrors = new HashSet<>(strTerminalQueueErrors.length); Collections.addAll(terminalQueueErrors, strTerminalQueueErrors); log.info("init(): spoilEmailAddresses=" + spoilEmailAddresses + " preferSystemProfileEmail=" + preferSystemProfileEmail + " preferGuestEidEmail=" + preferGuestEidEmail); if (siteAdvisor != null) { log.info("Using siteAdvisor: " + siteAdvisor.getClass().getName()); } if (enabledSiteTypes != null && !enabledSiteTypes.isEmpty()) { log.info("Turnitin is enabled for site types: " + StringUtils.join(enabledSiteTypes, ",")); } if (!turnitinConn.isUseSourceParameter()) { if (serverConfigurationService.getBoolean("turnitin.updateAssingments", false)) doAssignments(); } }
From source file:org.sakaiproject.contentreview.impl.urkund.UrkundReviewServiceImpl.java
/** * Place any code that should run when this class is initialized by spring here *//* www . java 2 s .co m*/ public void init() { maxRetry = Long.valueOf(serverConfigurationService.getInt("urkund.maxRetry", 10)); enabledSiteTypes = Arrays .asList(ArrayUtils.nullToEmpty(serverConfigurationService.getStrings("urkund.sitetypes"))); if (enabledSiteTypes != null && !enabledSiteTypes.isEmpty()) { log.info("Urkund is enabled for site types: " + StringUtils.join(enabledSiteTypes, ",")); } spoofEmailContext = serverConfigurationService.getString("urkund.spoofemailcontext", null); }
From source file:org.sakaiproject.contentreview.turnitin.TurnitinReviewServiceImpl.java
public void init() { studentAccountNotified = turnitinConn.isStudentAccountNotified(); sendSubmissionNotification = turnitinConn.getSendSubmissionNotification(); maxRetry = turnitinConn.getMaxRetry(); defaultAssignId = turnitinConn.getDefaultAssignId(); defaultClassPassword = turnitinConn.getDefaultClassPassword(); spoilEmailAddresses = serverConfigurationService.getBoolean("turnitin.spoilEmailAddresses", false); preferSystemProfileEmail = serverConfigurationService.getBoolean("turnitin.preferSystemProfileEmail", true); preferGuestEidEmail = serverConfigurationService.getBoolean("turnitin.preferGuestEidEmail", true); enabledSiteTypes = Arrays/*from w w w.j a v a 2s . co m*/ .asList(ArrayUtils.nullToEmpty(serverConfigurationService.getStrings("turnitin.sitetypes"))); log.info("init(): spoilEmailAddresses=" + spoilEmailAddresses + " preferSystemProfileEmail=" + preferSystemProfileEmail + " preferGuestEidEmail=" + preferGuestEidEmail); if (enabledSiteTypes != null && !enabledSiteTypes.isEmpty()) { log.info("Turnitin is enabled for site types: " + StringUtils.join(enabledSiteTypes, ",")); } if (!turnitinConn.isUseSourceParameter()) { if (serverConfigurationService.getBoolean("turnitin.updateAssingments", false)) doAssignments(); } }
From source file:org.sakaiproject.user.tool.UsersAction.java
/** * @author bjones86 - SAK-29182//from w w w . jav a2s .c o m * @return a list of strings contained in the invalidEmailInIdAccountString sakai.property, or an empty list if not set */ private List<String> getInvalidEmailDomains() { return Arrays.asList( ArrayUtils.nullToEmpty(ServerConfigurationService.getStrings(SAK_PROP_INVALID_EMAIL_DOMAINS))); }