List of usage examples for java.io Serializable equals
public boolean equals(Object obj)
From source file:com.flowpowered.commons.datatable.ManagedHashMap.java
@Override public boolean equals(Object obj) { if (!(obj instanceof ManagedHashMap)) { return false; }/* w w w . ja v a2 s .co m*/ ManagedHashMap other = (ManagedHashMap) obj; if (isEmpty() && other.isEmpty()) { return true; } for (Map.Entry<? extends String, ? extends Serializable> e : entrySet()) { Serializable value = e.getValue(); Serializable otherValue = other.get(e.getKey()); if (value != null) { if (!value.equals(otherValue)) { return false; } } else if (otherValue != null) { return false; } } return true; }
From source file:com.alvexcore.repo.workflow.canReassignTask.java
/** * Determines if the given user is a member of the pooled actors assigned to the task * /*from w w w. j a va 2 s . c om*/ * @param task The task instance to check * @param username The username to check * @return true if the user is a pooled actor, false otherwise */ @SuppressWarnings("unchecked") private boolean isUserInPooledActors(WorkflowTask task, String username) { NodeService nodeService = this.serviceRegistry.getNodeService(); DictionaryService dictionaryService = this.serviceRegistry.getDictionaryService(); // Get the pooled actors Collection<NodeRef> actors = (Collection<NodeRef>) task.getProperties() .get(WorkflowModel.ASSOC_POOLED_ACTORS); if (actors != null) { for (NodeRef actor : actors) { QName type = nodeService.getType(actor); if (dictionaryService.isSubClass(type, ContentModel.TYPE_PERSON)) { Serializable name = nodeService.getProperty(actor, ContentModel.PROP_USERNAME); if (name != null && name.equals(username)) { return true; } } else if (dictionaryService.isSubClass(type, ContentModel.TYPE_AUTHORITY_CONTAINER)) { if (isUserInGroup(username, actor)) { // The user is a member of the group return true; } } } } return false; }
From source file:com.bluexml.side.Framework.alfresco.notification.NotificationPolicy.java
protected void manageUserPreferenceChange(NodeRef arg0, Map<QName, Serializable> oldProperties, Map<QName, Serializable> newProperties) { // if user change preference update cached email list (document in // dictionary ?) // test if Node is person and if property changed is preferences if (serviceRegistry.getNodeService().getType(arg0).equals(ContentModel.TYPE_PERSON)) { Serializable oldPreferences = oldProperties.get(ContentModel.PROP_PREFERENCE_VALUES); Serializable newPreferences = newProperties.get(ContentModel.PROP_PREFERENCE_VALUES); if (!oldPreferences.equals(newPreferences)) { // must update cached preferences // get xml/json document from repository and update it // TODO logger.warn("NOT YET IMPLEMENTED !!!"); }/*from w ww . j av a 2 s . c o m*/ } }
From source file:com.yahoo.bullet.storm.JoinBoltTest.java
private static boolean isSameMetadata(Object actual, Object expected) { Metadata actualMetadata = (Metadata) actual; Metadata expectedMetadata = (Metadata) expected; if (actualMetadata.getSignal() != expectedMetadata.getSignal()) { return false; }//w w w . ja va2s .co m Serializable actualContent = actualMetadata.getContent(); Serializable expectedContent = expectedMetadata.getContent(); return actualContent == expectedContent || actualContent.equals(expectedContent); }
From source file:com.flowpowered.commons.datatable.SerializableHashMap.java
@Override public boolean equals(Object obj) { if (!(obj instanceof SerializableHashMap)) { return false; }/*from w ww . j a v a 2s.c om*/ SerializableHashMap other = (SerializableHashMap) obj; if (isEmpty() && other.isEmpty()) { return true; } for (Map.Entry<? extends String, ? extends Serializable> e : entrySet()) { Serializable value = e.getValue(); Serializable otherValue = other.get(e.getKey()); if (value != null) { if (!value.equals(otherValue)) { return false; } } else if (otherValue != null) { return false; } } return true; }
From source file:com.liferay.portlet.journal.util.JournalConverterImpl.java
protected void updateContentDynamicElement(Element dynamicElementElement, DDMStructure ddmStructure, Field ddmField, DDMFieldsCounter ddmFieldsCounter) throws Exception { String fieldName = ddmField.getName(); String fieldType = ddmStructure.getFieldType(fieldName); String indexType = ddmStructure.getFieldProperty(fieldName, "indexType"); String type = _ddmTypesToJournalTypes.get(fieldType); if (type == null) { type = fieldType;/*from w w w.j a v a 2s . c o m*/ } dynamicElementElement.addAttribute("type", type); dynamicElementElement.addAttribute("index-type", indexType); for (Locale locale : ddmField.getAvailableLocales()) { Element dynamicContentElement = dynamicElementElement.addElement("dynamic-content"); dynamicContentElement.addAttribute("language-id", LocaleUtil.toLanguageId(locale)); int count = ddmFieldsCounter.get(fieldName); Serializable fieldValue = ddmField.getValue(locale, count); if ((null == fieldValue || fieldValue.equals("")) && fieldType.equalsIgnoreCase("ddm-date")) { fieldValue = System.currentTimeMillis(); } else if (fieldValue instanceof Date) { Date valueDate = (Date) fieldValue; fieldValue = valueDate.getTime(); } String valueString = String.valueOf(fieldValue); updateDynamicContentValue(dynamicContentElement, fieldType, valueString.trim()); } ddmFieldsCounter.incrementKey(fieldName); }
From source file:net.jradius.session.JRadiusSessionManager.java
/** * Returns a session object. First, a key is generated by * the session manager's key provider, based on the JRadiusRequest. * If there is a stored session based on the key, this session is * returned, otherwise a new session created by the session factory * is returned//from w w w . j a v a2 s. c o m * @param request a JRadiusRequest used to retrieve or generate a session with * @return Returns a RadiusSession * @throws RadiusException */ public JRadiusSession getSession(JRadiusRequest request) throws RadiusException { SessionKeyProvider skp = getSessionKeyProvider(request.getSender()); Serializable key = skp.getAppSessionKey(request); JRadiusSession session = null; Serializable nkey = null; if (key != null) { RadiusLog.debug("** Looking for session: " + key); session = getSession(request, key); if (session == null) { RadiusLog.error("Broken JRadius-Session-Id implementation for session: " + key); key = null; } } if (key == null) { key = skp.getClassKey(request); if (key != null) { RadiusLog.debug("** Looking for session: " + key); session = getSession(request, key); if (session == null) { RadiusLog.error("Broken Class implementation for session: " + key); key = null; } else { if (session.getJRadiusKey() != null && !session.getJRadiusKey().equals(session.getSessionKey())) { rehashSession(session, session.getJRadiusKey(), key); } } } } if (key == null) { Serializable keys = skp.getRequestSessionKey(request); if (keys == null) { return null; } if (keys instanceof Serializable[]) { key = ((Serializable[]) (keys))[0]; nkey = ((Serializable[]) (keys))[1]; RadiusLog.debug("Rehashing session with key " + key + " under new key " + nkey); } else { key = keys; } RadiusLog.debug("** Looking for session: " + key); session = getSession(request, key); if (session != null && nkey != null && !nkey.equals(key)) { rehashSession(session, key, nkey); } } if (session == null) { session = newSession(request, nkey == null ? key : nkey); } session.setTimeStamp(System.currentTimeMillis()); //session.setLastRadiusRequest(request); return session; }
From source file:org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty.java
/** * Indicates whether the property has been updated or not. * * @param before/*w w w.j ava 2 s.co m*/ * @param after * @return */ private boolean isPropertyUpdated(Map<QName, Serializable> before, Map<QName, Serializable> after) { boolean result = false; Serializable beforeValue = before.get(propertyName); Serializable afterValue = after.get(propertyName); if (beforeValue == null && afterValue != null) { result = true; } else if (beforeValue != null && afterValue == null) { result = true; } else if (beforeValue != null && afterValue != null && !beforeValue.equals(afterValue)) { result = true; } return result; }
From source file:org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl.java
/** * Ensure that the user only updates record properties that they have permission to. * * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) *///from w w w .j a v a 2 s . c o m @Override @Behaviour(name = "onUpdateProperties", kind = BehaviourKind.CLASS, type = "rma:record") public void onUpdateProperties(final NodeRef nodeRef, final Map<QName, Serializable> before, final Map<QName, Serializable> after) { if (AuthenticationUtil.getFullyAuthenticatedUser() != null && !AuthenticationUtil.isRunAsUserTheSystemUser() && nodeService.exists(nodeRef) && isRecord(nodeRef) && !transactionalResourceHelper.getSet(KEY_IGNORE_ON_UPDATE).contains(nodeRef)) { for (Map.Entry<QName, Serializable> entry : after.entrySet()) { Serializable beforeValue = null; QName property = entry.getKey(); if (before != null) { beforeValue = before.get(property); } Serializable afterValue = entry.getValue(); boolean propertyUnchanged = false; if (beforeValue instanceof Date && afterValue instanceof Date) { // deal with date values, remove the seconds and milliseconds for the // comparison as they are removed from the submitted for data Calendar beforeCal = Calendar.getInstance(); beforeCal.setTime((Date) beforeValue); Calendar afterCal = Calendar.getInstance(); afterCal.setTime((Date) afterValue); beforeCal.set(Calendar.SECOND, 0); beforeCal.set(Calendar.MILLISECOND, 0); afterCal.set(Calendar.SECOND, 0); afterCal.set(Calendar.MILLISECOND, 0); propertyUnchanged = (beforeCal.compareTo(afterCal) == 0); } else if ((afterValue instanceof Boolean) && (beforeValue == null) && (afterValue.equals(Boolean.FALSE))) { propertyUnchanged = true; } else { // otherwise propertyUnchanged = EqualsHelper.nullSafeEquals(beforeValue, afterValue); } if (!propertyUnchanged && !(ContentModel.PROP_CONTENT.equals(property) && beforeValue == null) && !isPropertyEditable(nodeRef, property)) { // the user can't edit the record property throw new ModelAccessDeniedException( "The user " + AuthenticationUtil.getFullyAuthenticatedUser() + " does not have the permission to edit the record property " + property.toString() + " on the node " + nodeRef.toString()); } } } }
From source file:org.alfresco.module.phpIntegration.lib.Node.java
/** * Called when the node is saved. Inspects the node and persists any changes as appropriate. *///w w w . j a va2 s . c o m /*package*/ void onSave() { // Get the node reference NodeRef nodeRef = getNodeRef(); if (this.arePropertiesDirty == true) { // Log details if (logger.isDebugEnabled() == true) { logger.debug("Saving property updates made to node " + this.getId()); } // List of pending content properties to process List<org.alfresco.module.phpIntegration.lib.ContentData> pendingContentProperties = new ArrayList<org.alfresco.module.phpIntegration.lib.ContentData>( 1); // Update the properties Map<QName, Serializable> currentProperties = this.nodeService.getProperties(nodeRef); for (Map.Entry<String, Object> entry : this.properties.entrySet()) { if (entry.getValue() instanceof org.alfresco.module.phpIntegration.lib.ContentData) { // Save the content property org.alfresco.module.phpIntegration.lib.ContentData contentData = (org.alfresco.module.phpIntegration.lib.ContentData) entry .getValue(); pendingContentProperties.add(contentData); } else { Serializable propValue = null; // Get the property definition so we can do the correct conversion QName propertyName = QName.createQName(entry.getKey()); DictionaryService dictionaryService = this.session.getServiceRegistry().getDictionaryService(); PropertyDefinition propDefintion = dictionaryService.getProperty(propertyName); if (propDefintion == null) { // TODO summert here! propValue = (Serializable) entry.getValue(); } else { propValue = (Serializable) DefaultTypeConverter.INSTANCE .convert(propDefintion.getDataType(), entry.getValue()); } // Set the property value in the temp map if (propValue == null || propValue.equals(currentProperties.get(propertyName)) == false) { currentProperties.put(propertyName, propValue); } } } // Set the values of the updated properties this.nodeService.setProperties(nodeRef, currentProperties); // Sort out any pending content properties for (org.alfresco.module.phpIntegration.lib.ContentData contentData : pendingContentProperties) { contentData.onSave(); } } // Update the aspects if (this.addedAspects != null && this.addedAspects.size() != 0) { for (String aspect : this.addedAspects) { this.nodeService.addAspect(nodeRef, QName.createQName(aspect), null); } } if (this.removedAspects != null && this.removedAspects.size() != 0) { for (String aspect : this.removedAspects) { this.nodeService.removeAspect(nodeRef, QName.createQName(aspect)); } } // Update the child associations if (this.addedChildren != null && this.addedChildren.size() != 0) { for (ChildAssociation addedChildAssociation : this.addedChildren) { if (addedChildAssociation.getIsPrimary() == false) { this.nodeService.addChild(nodeRef, addedChildAssociation.getChild().getNodeRef(), QName.createQName(addedChildAssociation.getType()), QName.createQName(addedChildAssociation.getName())); } } } if (this.removedChildren != null && this.removedChildren.size() != 0) { for (ChildAssociation removedChildAssociation : this.removedChildren) { this.nodeService.removeChild(nodeRef, removedChildAssociation.getChild().getNodeRef()); } } // Update the associations if (this.addedAssociations != null && this.addedAssociations.size() != 0) { for (Association addedAssociation : this.addedAssociations) { this.nodeService.createAssociation(nodeRef, addedAssociation.getTo().getNodeRef(), QName.createQName(addedAssociation.getType())); } } if (this.removedAssociations != null && this.removedAssociations.size() != 0) { for (Association removedAssociation : this.removedAssociations) { this.nodeService.removeAssociation(nodeRef, removedAssociation.getTo().getNodeRef(), QName.createQName(removedAssociation.getType())); } } // Refresh the state of the node cleanNode(); }