List of usage examples for java.io Serializable toString
public String toString()
From source file:ddf.catalog.source.opensearch.impl.OpenSearchSource.java
@Override public ResourceResponse retrieveResource(URI uri, Map<String, Serializable> requestProperties) throws ResourceNotFoundException, ResourceNotSupportedException, IOException { final String methodName = "retrieveResource"; LOGGER.trace("ENTRY: {}", methodName); if (requestProperties == null) { throw new ResourceNotFoundException("Could not retrieve resource with null properties."); }/* w w w . java2 s . c om*/ Serializable serializableId = requestProperties.get(Metacard.ID); if (serializableId != null) { String metacardId = serializableId.toString(); WebClient restClient = newRestClient(null, metacardId, true, null); return resourceReader.retrieveResource(restClient.getCurrentURI(), requestProperties); } LOGGER.trace("EXIT: {}", methodName); throw new ResourceNotFoundException(COULD_NOT_RETRIEVE_RESOURCE_MESSAGE); }
From source file:org.apache.jcs.auxiliary.disk.block.BlockDiskCache.java
/** * Returns true if the removal was succesful; or false if there is nothing to remove. Current * implementation always result in a disk orphan. * <p>/* www .ja v a 2 s.c om*/ * (non-Javadoc) * @see org.apache.jcs.auxiliary.disk.AbstractDiskCache#doRemove(java.io.Serializable) */ protected boolean doRemove(Serializable key) { if (!alive) { if (log.isDebugEnabled()) { log.debug(logCacheName + "No longer alive so returning false for key = " + key); } return false; } boolean reset = false; boolean removed = false; try { storageLock.writeLock().acquire(); if (key instanceof String && key.toString().endsWith(CacheConstants.NAME_COMPONENT_DELIMITER)) { // remove all keys of the same name group. Iterator iter = this.keyStore.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); Object k = entry.getKey(); if (k instanceof String && k.toString().startsWith(key.toString())) { int[] ded = this.keyStore.get(key); this.dataFile.freeBlocks(ded); iter.remove(); removed = true; // TODO this needs to update the rmove count separately } } } else if (key instanceof GroupId) { // remove all keys of the same name hierarchy. Iterator iter = this.keyStore.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); Object k = entry.getKey(); if (k instanceof GroupAttrName && ((GroupAttrName) k).groupId.equals(key)) { int[] ded = this.keyStore.get(key); this.dataFile.freeBlocks(ded); iter.remove(); removed = true; } } } else { // remove single item. int[] ded = this.keyStore.remove(key); removed = (ded != null); if (ded != null) { this.dataFile.freeBlocks(ded); } if (log.isDebugEnabled()) { log.debug(logCacheName + "Disk removal: Removed from key hash, key [" + key + "] removed = " + removed); } } } catch (Exception e) { log.error(logCacheName + "Problem removing element.", e); reset = true; } finally { storageLock.writeLock().release(); } if (reset) { reset(); } return removed; }
From source file:org.apache.wicket.util.tester.WicketTester.java
/** * Extracts the actual messages from the passed feedback messages. Specially handles * ValidationErrorFeedback messages by extracting their String message * * @param feedbackMessages//from w w w .j av a 2 s.c o m * the feedback messages * @return the FeedbackMessages' messages */ private List<Serializable> getActualFeedbackMessages(List<FeedbackMessage> feedbackMessages) { List<Serializable> actualMessages = new ArrayList<>(); for (FeedbackMessage feedbackMessage : feedbackMessages) { Serializable message = feedbackMessage.getMessage(); if (message instanceof ValidationErrorFeedback) { actualMessages.add(message.toString()); } else { actualMessages.add(message); } } return actualMessages; }
From source file:com.netflix.spinnaker.fiat.shared.FiatPermissionEvaluator.java
@Override public boolean hasPermission(Authentication authentication, Serializable resourceName, String resourceType, Object authorization) {/*w w w . j ava2 s. com*/ if (!Boolean.valueOf(fiatEnabled)) { return true; } if (resourceName == null || resourceType == null || authorization == null) { log.debug("Permission denied due to null argument. resourceName={}, resourceType={}, " + "authorization={}", resourceName, resourceType, authorization); return false; } ResourceType r = ResourceType.parse(resourceType); Authorization a = null; // Service accounts don't have read/write authorizations. if (r != ResourceType.SERVICE_ACCOUNT) { a = Authorization.valueOf(authorization.toString()); } if (r == ResourceType.APPLICATION) { val parsedName = Names.parseName(resourceName.toString()).getApp(); if (StringUtils.isNotEmpty(parsedName)) { resourceName = parsedName; } } UserPermission.View permission = getPermission(getUsername(authentication)); return permissionContains(permission, resourceName.toString(), r, a); }
From source file:org.alfresco.repo.jscript.app.JSONConversionComponent.java
/** * Handles the work of converting values to JSON. * /*from www . j a v a 2 s. c om*/ * @param nodeRef NodeRef * @param propertyName QName * @param key String * @param value Serializable * @return the JSON value */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected Object propertyToJSON(final NodeRef nodeRef, final QName propertyName, final String key, final Serializable value) { if (value != null) { // Has a decorator has been registered for this property? if (propertyDecorators.containsKey(propertyName)) { JSONAware jsonAware = propertyDecorators.get(propertyName).decorate(propertyName, nodeRef, value); if (jsonAware != null) { return jsonAware; } } else { // Built-in data type processing if (value instanceof Date) { JSONObject dateObj = new JSONObject(); dateObj.put("value", JSONObject.escape(value.toString())); dateObj.put("iso8601", JSONObject.escape(ISO8601DateFormat.format((Date) value))); return dateObj; } else if (value instanceof List) { // Convert the List to a JSON list by recursively calling propertyToJSON List<Object> jsonList = new ArrayList<Object>(((List<Serializable>) value).size()); for (Serializable listItem : (List<Serializable>) value) { jsonList.add(propertyToJSON(nodeRef, propertyName, key, listItem)); } return jsonList; } else if (value instanceof Double) { return (Double.isInfinite((Double) value) || Double.isNaN((Double) value) ? null : value.toString()); } else if (value instanceof Float) { return (Float.isInfinite((Float) value) || Float.isNaN((Float) value) ? null : value.toString()); } else { return value.toString(); } } } return null; }
From source file:org.sakaiproject.genericdao.hibernate.HibernateGenericDao.java
public <T> boolean delete(Class<T> type, Serializable id) { checkClass(type);//w w w . j a v a 2 s . c o m String operation = "delete"; beforeWrite(operation, type, new Serializable[] { id }, null); boolean removed = baseDelete(type, id); if (removed) { // clear the search caches getCacheProvider().clear(getSearchCacheName(type)); // clear this from the cache String key = id.toString(); String cacheName = getCacheName(type); getCacheProvider().remove(cacheName, key); afterWrite(operation, type, new Serializable[] { id }, null, 1); } return removed; }
From source file:org.alfresco.extensions.bulkexport.dao.AlfrescoExportDaoImpl.java
/** * Format metadata guided by Bulk-Import format * //from ww w.j av a 2s . co m * @param obj * @return {@link String} */ private String formatMetadata(Serializable obj) { String returnValue = ""; if (obj != null) { if (obj instanceof Date) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); Date date = (Date) obj; returnValue = format.format(date); returnValue = returnValue.substring(0, 26) + ":" + returnValue.substring(26); } else { // // TODO: Format data to all bulk-import data format (list as example) // returnValue = obj.toString(); } } return returnValue; }
From source file:org.codice.ddf.catalog.ui.util.EndpointUtil.java
public Instant parseToDate(Serializable value) { if (value instanceof Instant) { return ((Instant) value); }/* ww w . j av a 2 s .c o m*/ if (value instanceof Date) { return ((Date) value).toInstant(); } SimpleDateFormat dateFormat = new SimpleDateFormat(ISO_8601_DATE_FORMAT); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); try { return dateFormat.parse(value.toString()).toInstant(); } catch (ParseException e) { throw new IllegalArgumentException(e); } }
From source file:org.apache.jcs.auxiliary.disk.jdbc.JDBCDiskCache.java
/** * Returns true if the removal was succesful; or false if there is nothing * to remove. Current implementation always result in a disk orphan. * <p>//from w w w . j a v a 2 s. co m * @param key * @return boolean */ public boolean doRemove(Serializable key) { // remove single item. String sql = "delete from " + getJdbcDiskCacheAttributes().getTableName() + " where REGION = ? and CACHE_KEY = ?"; try { boolean partial = false; if (key instanceof String && key.toString().endsWith(CacheConstants.NAME_COMPONENT_DELIMITER)) { // remove all keys of the same name group. sql = "delete from " + getJdbcDiskCacheAttributes().getTableName() + " where REGION = ? and CACHE_KEY like ?"; partial = true; } Connection con = poolAccess.getConnection(); PreparedStatement psSelect = null; try { psSelect = con.prepareStatement(sql); psSelect.setString(1, this.getCacheName()); if (partial) { psSelect.setString(2, key.toString() + "%"); } else { psSelect.setString(2, key.toString()); } psSelect.executeUpdate(); alive = true; } catch (SQLException e) { log.error("Problem creating statement. sql [" + sql + "]", e); alive = false; } finally { try { if (psSelect != null) { psSelect.close(); } con.close(); } catch (SQLException e1) { log.error("Problem closing statement.", e1); } } } catch (Exception e) { log.error("Problem updating cache.", e); reset(); } return false; }
From source file:org.pentaho.platform.repository2.unified.jcr.DefaultLockHelper.java
/** * {@inheritDoc}/*from ww w . ja v a 2 s. com*/ */ public void lockFile(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final String message) throws RepositoryException { LockManager lockManager = session.getWorkspace().getLockManager(); // locks are always deep in this impl final boolean isDeep = true; // locks are always open-scoped since a session is short-lived and all work occurs in a transaction // anyway; from spec, "if a lock is enabled and then disabled within the same transaction, its effect never // makes it to the persistent workspace and therefore it does nothing" final boolean isSessionScoped = false; final long timeoutHint = Long.MAX_VALUE; final String ownerInfo = makeOwnerInfo( JcrTenantUtils.getTenantedUser(PentahoSessionHolder.getSession().getName()), Calendar.getInstance().getTime(), message); Node fileNode = session.getNodeByIdentifier(fileId.toString()); Assert.isTrue(fileNode.isNodeType(pentahoJcrConstants.getMIX_LOCKABLE())); Lock lock = lockManager.lock(fileNode.getPath(), isDeep, isSessionScoped, timeoutHint, ownerInfo); addLockToken(session, pentahoJcrConstants, lock); }