You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by vk...@apache.org on 2010/12/27 23:17:32 UTC
svn commit: r1053206 - in
/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed:
capabilities/impl/ serializer/
Author: vkumar
Date: Mon Dec 27 22:17:31 2010
New Revision: 1053206
URL: http://svn.apache.org/viewvc?rev=1053206&view=rev
Log:
[JS2-1228] Some code improvements for capability component
Modified:
portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java
portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java Mon Dec 27 22:17:31 2010
@@ -26,82 +26,71 @@ import org.apache.jetspeed.capabilities.
* @version $Id$
*/
-public class CapabilityImpl implements Capability
-{
+public class CapabilityImpl implements Capability {
private int capabilityId;
private String name;
/* (non-Javadoc)
* @see org.apache.jetspeed.om.registry.Capability#setCapabilityId(int)
*/
- public void setCapabilityId(int id)
- {
+ public void setCapabilityId(int id) {
this.capabilityId = id;
}
/* (non-Javadoc)
* @see org.apache.jetspeed.om.registry.Capability#getCapabilityId()
*/
- public int getCapabilityId()
- {
+ public int getCapabilityId() {
return this.capabilityId;
}
/* (non-Javadoc)
* @see org.apache.jetspeed.om.registry.Capability#setName(java.lang.String)
*/
- public void setName(String name)
- {
+ public void setName(String name) {
this.name = name;
}
/* (non-Javadoc)
* @see org.apache.jetspeed.om.registry.Capability#getName()
*/
- public String getName()
- {
+ public String getName() {
return this.name;
}
-
-
+
+
/**
* Implements the hashCode calculation so two different objects with the content return the same hashcode....
*/
- public int hashCode()
- {
- return name.hashCode();
+ public int hashCode() {
+ return name.hashCode();
}
/**
- * Implements the equals operation so that 2 elements are equal if
- * all their member values are equal.
+ * Implements the equals operation so that 2 elements are equal if all their member values are equal.
*
- *
* @param object to compare this one with
* @return true if both objects represent the same (logical) content
*/
- public boolean equals(Object object)
- {
- if (!(object instanceof Capability))
- {
- return false;
- }
- if (this == object)
- return true;
+ public boolean equals(Object object) {
+ if (!(object instanceof Capability)) {
+ return false;
+ }
+ if (this == object) {
+ return true;
+ }
// Don't check the ID - id is only set through OJB so this would not recognize equality correctly
- /* if (this.capabilityId != ((Capability)object).getCapabilityId())
- return false;
- */
- String oName = ((Capability)object).getName();
- if (
- (oName == null) && (name == null)
- ||
- (oName == name)
- ||
- ((oName != null) && (oName.equals(name)))
- )
- return true;
- return false;
+ /* if (this.capabilityId != ((Capability)object).getCapabilityId())
+ return false;
+ */
+ String oName = ((Capability) object).getName();
+
+ if (oName != null && name != null) {
+ return oName.equals(name);
+ } else if (oName == null && name == null) {
+ return true;
+ } else {
+ return false;
+ }
}
-
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java Mon Dec 27 22:17:31 2010
@@ -37,7 +37,7 @@ import org.apache.jetspeed.capabilities.
*/
class CapabilityMapImpl implements CapabilityMap
{
- private static final Logger log =
+ private static Logger log =
LoggerFactory.getLogger(JetspeedCapabilities.class);
// Members
@@ -112,12 +112,12 @@ class CapabilityMapImpl implements Capab
log.error("Could not find preferred Mime Type for " + prefMimeTypeId);
// Should never reach this point. A preferred value needs to be set
- return null; // TODO: NEVER RETURN NULL
+ return null;
}
/**
* Sets the preferred MediaType for this CapabilityMap
- * @param MediaTypeEntry
+ * @param type
*/
public void setPreferredMediaType(MediaType type)
{
@@ -228,7 +228,7 @@ class CapabilityMapImpl implements Capab
Iterator mediatypes = mediaTypeMap.values().iterator();
while (mediatypes.hasNext())
{
- if (((MediaType) mediatypes.next()).getName() == media)
+ if (((MediaType) mediatypes.next()).getName().equals(media))
{
return true;
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java Mon Dec 27 22:17:31 2010
@@ -31,8 +31,7 @@ import java.util.Collection;
* @author <a href="mailto:roger.ruttimann@earthlink.net">Roger Ruttimann</a>
* @version $Id$
*/
-public class ClientImpl implements Client, java.io.Serializable
-{
+public class ClientImpl implements Client, java.io.Serializable {
private String userAgentPattern = "";
private String manufacturer = "";
private String model = "";
@@ -45,255 +44,204 @@ public class ClientImpl implements Clien
private int clientId;
private int evalOrder = 0;
- public ClientImpl()
- {
+ public ClientImpl() {
}
/**
- * Implements the equals operation so that 2 elements are equal if
- * all their member values are equal.
+ * Implements the equals operation so that 2 elements are equal if all their member values are equal.
*/
- public boolean equals(Object object)
- {
- if (object == this)
- return true;
+ public boolean equals(Object object) {
- if (object == null)
- {
+ if (!(object instanceof Client)) {
return false;
}
-
+
ClientImpl obj = (ClientImpl) object;
- if (name != null)
- {
- if (!name.equals(obj.name))
- {
+ if (name != null) {
+ if (!name.equals(obj.name)) {
return false;
}
- } else
- {
- if (obj.name != null)
- {
+ } else {
+ if (obj.name != null) {
return false;
}
}
-
- if (userAgentPattern != null)
- {
- if (!userAgentPattern.equals(obj.userAgentPattern))
- {
+
+ if (userAgentPattern != null) {
+ if (!userAgentPattern.equals(obj.userAgentPattern)) {
return false;
}
- } else
- {
- if (obj.userAgentPattern != null)
- {
+ } else {
+ if (obj.userAgentPattern != null) {
return false;
}
}
- if (manufacturer != null)
- {
- if (!manufacturer.equals(obj.manufacturer))
- {
+ if (manufacturer != null) {
+ if (!manufacturer.equals(obj.manufacturer)) {
return false;
}
- } else
- {
- if (obj.manufacturer != null)
- {
+ } else {
+ if (obj.manufacturer != null) {
return false;
}
}
- if (model != null)
- {
- if (!model.equals(obj.model))
- {
+ if (model != null) {
+ if (!model.equals(obj.model)) {
return false;
}
- } else
- {
- if (obj.model != null)
- {
+ } else {
+ if (obj.model != null) {
return false;
}
}
- if (version != null)
- {
- if (!version.equals(obj.version))
- {
+ if (version != null) {
+ if (!version.equals(obj.version)) {
return false;
}
- } else
- {
- if (obj.version != null)
- {
+ } else {
+ if (obj.version != null) {
return false;
}
}
- if (mimetypes != null)
- {
- if (!CollectionUtils.isEqualCollection(mimetypes, obj.mimetypes))
- {
+ if (mimetypes != null) {
+ if (!CollectionUtils.isEqualCollection(mimetypes, obj.mimetypes)) {
return false;
}
- }
- else
- {
- if (obj.mimetypes != null)
- {
+ } else {
+ if (obj.mimetypes != null) {
return false;
}
}
- if (capabilities != null)
- {
- if (!(CollectionUtils.isEqualCollection(capabilities,obj.capabilities )))
- return false;
- }
- else
- {
- if (obj.capabilities != null)
- {
+ if (capabilities != null) {
+ if (!(CollectionUtils.isEqualCollection(capabilities, obj.capabilities))) {
+ return false;
+ }
+ } else {
+ if (obj.capabilities != null) {
return false;
}
}
return true;
}
- public String getUserAgentPattern()
- {
+ public String getUserAgentPattern() {
return userAgentPattern;
}
- public void setUserAgentPattern(String userAgentPattern)
- {
+ public void setUserAgentPattern(String userAgentPattern) {
this.userAgentPattern = userAgentPattern;
}
- public String getManufacturer()
- {
+ public String getManufacturer() {
return manufacturer;
}
- public void setManufacturer(String name)
- {
+ public void setManufacturer(String name) {
manufacturer = name;
}
- public String getModel()
- {
+ public String getModel() {
return model;
}
- public void setModel(String name)
- {
+ public void setModel(String name) {
model = name;
}
- public String getVersion()
- {
+ public String getVersion() {
return version;
}
- public void setVersion(String name)
- {
+ public void setVersion(String name) {
version = name;
}
- public Collection getMimetypes()
- {
- if(this.mimetypes == null)
- {
+ public Collection getMimetypes() {
+ if (this.mimetypes == null) {
this.mimetypes = new ArrayList();
}
return mimetypes;
}
- public void setMimetypes(Collection mimetypes)
- {
+ public void setMimetypes(Collection mimetypes) {
this.mimetypes = mimetypes;
}
- public Collection getCapabilities()
- {
- if(capabilities == null)
- {
+ public Collection getCapabilities() {
+ if (capabilities == null) {
capabilities = new ArrayList();
}
return capabilities;
}
- public void setCapabilities(Collection capabilities)
- {
+ public void setCapabilities(Collection capabilities) {
this.capabilities = capabilities;
}
/**
* Set Client ID -- Assigns the Client ID
+ *
* @param id
*/
- public void setClientId(int id)
- {
+ public void setClientId(int id) {
this.clientId = id;
}
/**
* Get Client ID
+ *
* @return Client ID
*/
- public int getClientId()
- {
+ public int getClientId() {
return this.clientId;
}
+
/**
* @return
*/
- public String getName()
- {
+ public String getName() {
return name;
}
/**
* @param string
*/
- public void setName(String string)
- {
+ public void setName(String string) {
name = string;
}
/**
* @return Preferred MimeType ID for Client
*/
- public int getPreferredMimeTypeId()
- {
+ public int getPreferredMimeTypeId() {
return this.preferredMimeTypeId;
}
/**
* Set preferred Mimetype ID for Client
+ *
* @param mimeTypeId MimeTypeId
*/
- public void setPreferredMimeTypeId(int mimeTypeId)
- {
+ public void setPreferredMimeTypeId(int mimeTypeId) {
this.preferredMimeTypeId = mimeTypeId;
}
/**
* @return Returns the evalOrder.
*/
- public int getEvalOrder()
- {
+ public int getEvalOrder() {
return evalOrder;
}
+
/**
* @param evalOrder The evalOrder to set.
*/
- public void setEvalOrder(int evalOrder)
- {
+ public void setEvalOrder(int evalOrder) {
this.evalOrder = evalOrder;
}
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java?rev=1053206&r1=1053205&r2=1053206&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java Mon Dec 27 22:17:31 2010
@@ -101,7 +101,7 @@ public class JetspeedCapabilities extend
* services.profiler.principalRule.impl = the pluggable Principal Rule impl
* services.profiler.profilingRule.impl = the pluggable Profiling Rule impl
*
- * @param persistenceStore The persistence persistenceStore
+ * @param repositoryPath The repositoryPath
* @param properties Properties for this component described above
* @deprecated As of release 2.1, property-based class references replaced
* by container managed bean factory
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java Mon Dec 27 22:17:31 2010
@@ -46,31 +46,16 @@ public class MediaTypeImpl
public MediaTypeImpl()
{}
- public MediaTypeImpl(long id,
- String name,
- int _hidden,
- String mimeType,
- String title,
- String description,
- String image,
- String role)
- {
- this.mimetypes.add(mimeType);
- }
-
/**
* Implements the equals operation so that 2 elements are equal if
* all their member values are equal.
*/
public boolean equals(Object object)
{
- if (this == object)
- return true;
- if (object==null)
- return false;
-
- MediaTypeImpl obj = (MediaTypeImpl)object;
+ if (!(object instanceof MediaType))
+ return false;
+ MediaTypeImpl obj = (MediaTypeImpl)object;
if (this.name!=null)
{
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java Mon Dec 27 22:17:31 2010
@@ -84,22 +84,20 @@ public class MimeTypeImpl implements Mim
{
return false;
}
- if (this == object)
+ if (this.equals(object))
return true;
// Don't check the ID - id is only set through OJB so this would not recognize equality correctly
/* if (mimeTypeId != ((MimeType)object).getMimetypeId())
return false;
*/
String oName = ((MimeType)object).getName();
- if (
- (oName == null) && (name == null)
- ||
- (oName == name)
- ||
- ((oName != null) && (oName.equals(name)))
- )
- return true;
- return false;
+ if (oName != null && name != null) {
+ return oName.equals(name);
+ } else if (oName == null && name == null) {
+ return true;
+ } else {
+ return false;
+ }
}
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java?rev=1053206&r1=1053205&r2=1053206&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java Mon Dec 27 22:17:31 2010
@@ -49,21 +49,22 @@ public class JetspeedCapabilitiesSeriali
private static class Refs
{
- HashMap mimeMap = new HashMap();
+ Map mimeMap = new HashMap();
- HashMap mimeMapInt = new HashMap();
+ Map mimeMapInt = new HashMap();
- HashMap mediaMap = new HashMap();
+ Map mediaMap = new HashMap();
- HashMap capabilityMap = new HashMap();
+ Map capabilityMap = new HashMap();
- HashMap capabilityMapInt = new HashMap();
+ Map capabilityMapInt = new HashMap();
- HashMap clientMap = new HashMap();
+ Map clientMap = new HashMap();
}
public JetspeedCapabilitiesSerializer(Capabilities caps)
{
+ super();
this.caps = caps;
}
@@ -116,29 +117,29 @@ public class JetspeedCapabilitiesSeriali
try
{
- Iterator _it = caps.getMediaTypes();
+ Iterator mediaTypesIterator = caps.getMediaTypes();
- while (_it != null && _it.hasNext())
+ while (mediaTypesIterator != null && mediaTypesIterator.hasNext())
{
- caps.deleteMediaType((MediaType)_it.next());
+ caps.deleteMediaType((MediaType)mediaTypesIterator.next());
}
- _it = caps.getClients();
- while (_it != null && _it.hasNext())
+ mediaTypesIterator = caps.getClients();
+ while (mediaTypesIterator != null && mediaTypesIterator.hasNext())
{
- caps.deleteClient((Client) _it.next());
+ caps.deleteClient((Client) mediaTypesIterator.next());
}
- _it = caps.getCapabilities();
- while (_it != null && _it.hasNext())
+ mediaTypesIterator = caps.getCapabilities();
+ while (mediaTypesIterator != null && mediaTypesIterator.hasNext())
{
- caps.deleteCapability((Capability) _it.next());
+ caps.deleteCapability((Capability) mediaTypesIterator.next());
}
- _it = caps.getMimeTypes();
- while (_it != null && _it.hasNext())
+ mediaTypesIterator = caps.getMimeTypes();
+ while (mediaTypesIterator != null && mediaTypesIterator.hasNext())
{
- caps.deleteMimeType((MimeType) _it.next());
+ caps.deleteMimeType((MimeType) mediaTypesIterator.next());
}
}
catch (Exception e)
@@ -154,14 +155,14 @@ public class JetspeedCapabilitiesSeriali
JSCapabilities capabilities = snapshot.getCapabilities();
if ((capabilities != null) && (capabilities.size() > 0))
{
- Iterator _it = capabilities.iterator();
- while (_it.hasNext())
+ Iterator capabilityIterator = capabilities.iterator();
+ while (capabilityIterator.hasNext())
{
- JSCapability _c = (JSCapability) _it.next();
+ JSCapability jsCapability = (JSCapability) capabilityIterator.next();
// create a new Capability
try
{
- Capability capability = caps.createCapability(_c.getName());
+ Capability capability = caps.createCapability(jsCapability.getName());
/**
* THE KEY_OVERWRITE_EXISTING test is not required for
* capabilites, since they carry no other information than
@@ -176,7 +177,7 @@ public class JetspeedCapabilitiesSeriali
catch (Exception e)
{
throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(
- "org.apache.jetspeed.capabilities.Capabilities", e.getLocalizedMessage()));
+ "org.apache.jetspeed.capabilities.Capabilities", e.getLocalizedMessage()),e);
}
}
}
@@ -191,14 +192,14 @@ public class JetspeedCapabilitiesSeriali
JSMimeTypes mimeTypes = snapshot.getMimeTypes();
if ((mimeTypes != null) && (mimeTypes.size() > 0))
{
- Iterator _it = mimeTypes.iterator();
- while (_it.hasNext())
+ Iterator mimeTypeIterator = mimeTypes.iterator();
+ while (mimeTypeIterator.hasNext())
{
- JSMimeType _c = (JSMimeType) _it.next();
+ JSMimeType jsMimeType = (JSMimeType) mimeTypeIterator.next();
// create a new Mime Type
try
{
- MimeType mimeType = caps.createMimeType(_c.getName());
+ MimeType mimeType = caps.createMimeType(jsMimeType.getName());
/**
* THE KEY_OVERWRITE_EXISTING test is not required for mime
* types, since they carry no other information than the
@@ -214,7 +215,7 @@ public class JetspeedCapabilitiesSeriali
catch (Exception e)
{
throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(
- "org.apache.jetspeed.capabilities.MimeType", e.getLocalizedMessage()));
+ "org.apache.jetspeed.capabilities.MimeType", e.getLocalizedMessage()),e);
}
}
}
@@ -225,20 +226,20 @@ public class JetspeedCapabilitiesSeriali
private void recreateMediaTypes(JSSnapshot snapshot, Map settings, Logger log) throws SerializerException
{
- String _line;
+ String line;
log.debug("recreateMediaTypes - processing");
JSMediaTypes mediaTypes = snapshot.getMediaTypes();
if ((mediaTypes != null) && (mediaTypes.size() > 0))
{
- Iterator _it = mediaTypes.iterator();
- while (_it.hasNext())
+ Iterator mediaTypeIterator = mediaTypes.iterator();
+ while (mediaTypeIterator.hasNext())
{
- JSMediaType _c = (JSMediaType) _it.next();
+ JSMediaType jsMediaType = (JSMediaType) mediaTypeIterator.next();
// create a new Media
try
{
- MediaType mediaType = caps.createMediaType(_c.getName());
+ MediaType mediaType = caps.createMediaType(jsMediaType.getName());
/**
* THE KEY_OVERWRITE_EXISTING test IS required for media
* types, since they carry no other information than the
@@ -248,14 +249,14 @@ public class JetspeedCapabilitiesSeriali
|| (mediaType.getMediatypeId() == 0))
{
// set object fields
- mediaType.setCharacterSet(_c.getCharacterSet());
- mediaType.setTitle(_c.getTitle());
- mediaType.setDescription(_c.getDescription());
+ mediaType.setCharacterSet(jsMediaType.getCharacterSet());
+ mediaType.setTitle(jsMediaType.getTitle());
+ mediaType.setDescription(jsMediaType.getDescription());
try
{
- _line = _c.getMimeTypesString().toString();
- List<String> list = getTokens(_line);
+ line = jsMediaType.getMimeTypesString().toString();
+ List<String> list = getTokens(line);
if ((list != null) && (list.size() > 0))
{
Iterator<String> _it1 = list.iterator();
@@ -275,8 +276,8 @@ public class JetspeedCapabilitiesSeriali
}
try
{
- _line = _c.getCapabilitiesString().toString();
- List<String> list = getTokens(_line);
+ line = jsMediaType.getCapabilitiesString().toString();
+ List<String> list = getTokens(line);
if ((list != null) && (list.size() > 0))
{
Iterator<String> _it1 = list.iterator();
@@ -577,34 +578,34 @@ public class JetspeedCapabilitiesSeriali
{
try
{
- MediaType _mt = (MediaType) list.next();
- JSMediaType _jsM = new JSMediaType(_mt);
+ MediaType mediaType = (MediaType) list.next();
+ JSMediaType jsMediaType = new JSMediaType(mediaType);
// find the mimeTypes
- Iterator _itM = _mt.getMimetypes().iterator();
- while (_itM.hasNext())
+ Iterator mimeTypeIterator = mediaType.getMimetypes().iterator();
+ while (mimeTypeIterator.hasNext())
{
- MimeType _m = (MimeType) _itM.next();
- JSMimeType _mttype = (JSMimeType) refs.mimeMap.get(_m.getName());
- if (_mttype != null) _jsM.getMimeTypes().add(_mttype);
+ MimeType mimeType = (MimeType) mimeTypeIterator.next();
+ JSMimeType jsMimeType = (JSMimeType) refs.mimeMap.get(mimeType.getName());
+ if (jsMimeType != null) jsMediaType.getMimeTypes().add(jsMimeType);
}
// find the capabilities
- Iterator _itC = _mt.getCapabilities().iterator();
- while (_itC.hasNext())
+ Iterator iterator = mediaType.getCapabilities().iterator();
+ while (iterator.hasNext())
{
- Capability _c = (Capability) _itC.next();
- JSCapability _ct = (JSCapability) refs.capabilityMap.get(_c
+ Capability capability = (Capability) iterator.next();
+ JSCapability jsCapability = (JSCapability) refs.capabilityMap.get(capability
.getName());
- if (_ct != null) _jsM.getCapabilities().add(_ct);
+ if (jsCapability != null) jsMediaType.getCapabilities().add(jsCapability);
}
- refs.mediaMap.put(_jsM.getName(), _jsM);
- snapshot.getMediaTypes().add(_jsM);
+ refs.mediaMap.put(jsMediaType.getName(), jsMediaType);
+ snapshot.getMediaTypes().add(jsMediaType);
} catch (Exception e)
{
// do whatever
throw new SerializerException(
SerializerException.CREATE_SERIALIZED_OBJECT_FAILED
.create(new String[]
- { "MediaType", e.getMessage()}));
+ { "MediaType", e.getMessage()}),e);
}
}
return;
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
Re: svn commit: r1053206 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed: capabilities/impl/ serializer/
Posted by Woonsan Ko <wo...@yahoo.com>.
Hi Vivek,
Can you check the coding style configuration in your IDE?
See http://portals.apache.org/development/code-standards.html.
-Woonsan
--- On Mon, 12/27/10, vkumar@apache.org <vk...@apache.org> wrote:
> From: vkumar@apache.org <vk...@apache.org>
> Subject: svn commit: r1053206 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed: capabilities/impl/ serializer/
> To: jetspeed-dev@portals.apache.org
> Date: Monday, December 27, 2010, 11:17 PM
> Author: vkumar
> Date: Mon Dec 27 22:17:31 2010
> New Revision: 1053206
>
> URL: http://svn.apache.org/viewvc?rev=1053206&view=rev
> Log:
> [JS2-1228] Some code improvements for capability component
>
> Modified:
>
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java
>
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java
>
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java
>
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java
>
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java
>
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java
>
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java
>
> Modified:
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java
> URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
> ==============================================================================
> ---
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java
> (original)
> +++
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java
> Mon Dec 27 22:17:31 2010
> @@ -26,82 +26,71 @@ import
> org.apache.jetspeed.capabilities.
> * @version $Id$
> */
>
> -public class CapabilityImpl implements Capability
> -{
> +public class CapabilityImpl implements Capability {
> private int capabilityId;
> private String name;
>
> /* (non-Javadoc)
> * @see
> org.apache.jetspeed.om.registry.Capability#setCapabilityId(int)
> */
> - public void setCapabilityId(int id)
> - {
> + public void setCapabilityId(int id) {
> this.capabilityId =
> id;
> }
>
> /* (non-Javadoc)
> * @see
> org.apache.jetspeed.om.registry.Capability#getCapabilityId()
> */
> - public int getCapabilityId()
> - {
> + public int getCapabilityId() {
> return
> this.capabilityId;
> }
>
> /* (non-Javadoc)
> * @see
> org.apache.jetspeed.om.registry.Capability#setName(java.lang.String)
> */
> - public void setName(String name)
> - {
> + public void setName(String name) {
> this.name = name;
> }
>
> /* (non-Javadoc)
> * @see
> org.apache.jetspeed.om.registry.Capability#getName()
> */
> - public String getName()
> - {
> + public String getName() {
> return this.name;
> }
> -
> -
> +
> +
> /**
> * Implements the hashCode calculation
> so two different objects with the content return the same
> hashcode....
> */
> - public int hashCode()
> - {
> - return name.hashCode();
> + public int hashCode() {
> + return name.hashCode();
> }
>
> /**
> - * Implements the equals operation
> so that 2 elements are equal if
> - * all their member values are
> equal.
> + * Implements the equals operation
> so that 2 elements are equal if all their member values are
> equal.
> *
> - *
> * @param object to compare this one
> with
> * @return true if both objects
> represent the same (logical) content
> */
> - public boolean equals(Object object)
> - {
> - if (!(object instanceof
> Capability))
> - {
> - return
> false;
> - }
> - if (this == object)
> - return
> true;
> + public boolean equals(Object object) {
> + if (!(object instanceof
> Capability)) {
> + return false;
> + }
> + if (this == object) {
> + return true;
> + }
> // Don't check
> the ID - id is only set through OJB so this would not
> recognize equality correctly
> - /*
> if (this.capabilityId
> != ((Capability)object).getCapabilityId())
> - return
> false;
> - */
> - String oName =
> ((Capability)object).getName();
> - if (
> -
> (oName == null) && (name ==
> null)
> -
> ||
> -
> (oName == name)
> -
> ||
> -
> ((oName != null) &&
> (oName.equals(name)))
> - )
> - return
> true;
> - return
> false;
> + /*
> if (this.capabilityId
> != ((Capability)object).getCapabilityId())
> + return
> false;
> + */
> + String oName = ((Capability)
> object).getName();
> +
> + if (oName != null &&
> name != null) {
> + return
> oName.equals(name);
> + } else if (oName == null
> && name == null) {
> + return true;
> + } else {
> + return false;
> + }
> }
> -
> }
>
> Modified:
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java
> URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
> ==============================================================================
> ---
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java
> (original)
> +++
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java
> Mon Dec 27 22:17:31 2010
> @@ -37,7 +37,7 @@ import org.apache.jetspeed.capabilities.
> */
> class CapabilityMapImpl implements CapabilityMap
> {
> - private static final Logger log =
> + private static Logger log =
>
> LoggerFactory.getLogger(JetspeedCapabilities.class);
>
> // Members
> @@ -112,12 +112,12 @@ class CapabilityMapImpl implements
> Capab
> log.error("Could not
> find preferred Mime Type for " + prefMimeTypeId);
>
>
> // Should never
> reach this point. A preferred value needs to be set
> - return null; // TODO: NEVER
> RETURN NULL
> + return null;
> }
>
> /**
> * Sets the
> preferred MediaType for this CapabilityMap
> - * @param MediaTypeEntry
>
> + * @param type
> */
> public void
> setPreferredMediaType(MediaType type)
> {
> @@ -228,7 +228,7 @@ class CapabilityMapImpl implements
> Capab
> Iterator mediatypes
> = mediaTypeMap.values().iterator();
> while
> (mediatypes.hasNext())
> {
> - if (((MediaType)
> mediatypes.next()).getName() == media)
> + if (((MediaType)
> mediatypes.next()).getName().equals(media))
> {
>
> return true;
> }
>
> Modified:
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java
> URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
> ==============================================================================
> ---
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java
> (original)
> +++
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java
> Mon Dec 27 22:17:31 2010
> @@ -31,8 +31,7 @@ import java.util.Collection;
> * @author <a href="mailto:roger.ruttimann@earthlink.net">Roger
> Ruttimann</a>
> * @version $Id$
> */
> -public class ClientImpl implements Client,
> java.io.Serializable
> -{
> +public class ClientImpl implements Client,
> java.io.Serializable {
> private String userAgentPattern =
> "";
> private String manufacturer = "";
> private String model = "";
> @@ -45,255 +44,204 @@ public class ClientImpl implements
> Clien
> private int clientId;
> private int evalOrder = 0;
>
> - public ClientImpl()
> - {
> + public ClientImpl() {
> }
>
> /**
> - * Implements the equals operation
> so that 2 elements are equal if
> - * all their member values are
> equal.
> + * Implements the equals operation
> so that 2 elements are equal if all their member values are
> equal.
> */
> - public boolean equals(Object object)
> - {
> - if (object == this)
> - return
> true;
> + public boolean equals(Object object) {
>
> - if (object == null)
> - {
> + if (!(object instanceof
> Client)) {
> return
> false;
> }
> -
> +
> ClientImpl obj =
> (ClientImpl) object;
>
> - if (name != null)
> - {
> - if
> (!name.equals(obj.name))
> - {
> + if (name != null) {
> + if
> (!name.equals(obj.name)) {
>
> return false;
> }
> - } else
> - {
> - if (obj.name !=
> null)
> - {
> + } else {
> + if (obj.name !=
> null) {
>
> return false;
> }
> }
> -
> - if (userAgentPattern != null)
> - {
> - if
> (!userAgentPattern.equals(obj.userAgentPattern))
> - {
> +
> + if (userAgentPattern != null)
> {
> + if
> (!userAgentPattern.equals(obj.userAgentPattern)) {
>
> return false;
> }
> - } else
> - {
> - if
> (obj.userAgentPattern != null)
> - {
> + } else {
> + if
> (obj.userAgentPattern != null) {
>
> return false;
> }
> }
>
> - if (manufacturer != null)
> - {
> - if
> (!manufacturer.equals(obj.manufacturer))
> - {
> + if (manufacturer != null) {
> + if
> (!manufacturer.equals(obj.manufacturer)) {
>
> return false;
> }
> - } else
> - {
> - if
> (obj.manufacturer != null)
> - {
> + } else {
> + if
> (obj.manufacturer != null) {
>
> return false;
> }
> }
>
> - if (model != null)
> - {
> - if
> (!model.equals(obj.model))
> - {
> + if (model != null) {
> + if
> (!model.equals(obj.model)) {
>
> return false;
> }
> - } else
> - {
> - if (obj.model !=
> null)
> - {
> + } else {
> + if (obj.model !=
> null) {
>
> return false;
> }
> }
>
> - if (version != null)
> - {
> - if
> (!version.equals(obj.version))
> - {
> + if (version != null) {
> + if
> (!version.equals(obj.version)) {
>
> return false;
> }
> - } else
> - {
> - if (obj.version
> != null)
> - {
> + } else {
> + if (obj.version
> != null) {
>
> return false;
> }
> }
> - if (mimetypes != null)
> - {
> - if
> (!CollectionUtils.isEqualCollection(mimetypes,
> obj.mimetypes))
> - {
> + if (mimetypes != null) {
> + if
> (!CollectionUtils.isEqualCollection(mimetypes,
> obj.mimetypes)) {
>
> return false;
> }
> - }
> - else
> - {
> - if
> (obj.mimetypes != null)
> - {
> + } else {
> + if
> (obj.mimetypes != null) {
>
> return false;
> }
> }
>
> - if (capabilities !=
> null)
> - {
> - if
> (!(CollectionUtils.isEqualCollection(capabilities,obj.capabilities
> )))
> -
> return false;
> - }
> - else
> - {
> - if
> (obj.capabilities != null)
> - {
> + if (capabilities != null) {
> + if
> (!(CollectionUtils.isEqualCollection(capabilities,
> obj.capabilities))) {
> +
> return false;
> + }
> + } else {
> + if
> (obj.capabilities != null) {
>
> return false;
> }
> }
> return true;
> }
>
> - public String getUserAgentPattern()
> - {
> + public String getUserAgentPattern() {
> return
> userAgentPattern;
> }
>
> - public void setUserAgentPattern(String
> userAgentPattern)
> - {
> + public void setUserAgentPattern(String
> userAgentPattern) {
>
> this.userAgentPattern = userAgentPattern;
> }
>
> - public String getManufacturer()
> - {
> + public String getManufacturer() {
> return
> manufacturer;
> }
>
> - public void setManufacturer(String name)
> - {
> + public void setManufacturer(String name) {
> manufacturer =
> name;
> }
>
> - public String getModel()
> - {
> + public String getModel() {
> return model;
> }
>
> - public void setModel(String name)
> - {
> + public void setModel(String name) {
> model = name;
> }
>
> - public String getVersion()
> - {
> + public String getVersion() {
> return version;
> }
>
> - public void setVersion(String name)
> - {
> + public void setVersion(String name) {
> version = name;
> }
>
> - public Collection getMimetypes()
> - {
> - if(this.mimetypes == null)
> - {
> + public Collection getMimetypes() {
> + if (this.mimetypes == null) {
>
> this.mimetypes = new ArrayList();
> }
> return mimetypes;
> }
>
> - public void setMimetypes(Collection
> mimetypes)
> - {
> + public void setMimetypes(Collection
> mimetypes) {
> this.mimetypes =
> mimetypes;
> }
>
> - public Collection getCapabilities()
> - {
> - if(capabilities == null)
> - {
> + public Collection getCapabilities() {
> + if (capabilities == null) {
>
> capabilities = new ArrayList();
> }
> return
> capabilities;
> }
>
> - public void setCapabilities(Collection
> capabilities)
> - {
> + public void setCapabilities(Collection
> capabilities) {
> this.capabilities =
> capabilities;
> }
>
> /**
> * Set Client ID -- Assigns the Client
> ID
> + *
> * @param id
> */
> - public void setClientId(int id)
> - {
> + public void setClientId(int id) {
> this.clientId = id;
> }
>
> /**
> * Get Client ID
> + *
> * @return Client ID
> */
> - public int getClientId()
> - {
> + public int getClientId() {
> return
> this.clientId;
> }
> +
> /**
> * @return
> */
> - public String getName()
> - {
> + public String getName() {
> return name;
> }
>
> /**
> * @param string
> */
> - public void setName(String string)
> - {
> + public void setName(String string) {
> name = string;
> }
>
> /**
> * @return Preferred MimeType ID for
> Client
> */
> - public int getPreferredMimeTypeId()
> - {
> + public int getPreferredMimeTypeId() {
> return
> this.preferredMimeTypeId;
> }
>
> /**
> * Set preferred Mimetype ID for
> Client
> + *
> * @param mimeTypeId MimeTypeId
> */
> - public void setPreferredMimeTypeId(int
> mimeTypeId)
> - {
> + public void setPreferredMimeTypeId(int
> mimeTypeId) {
>
> this.preferredMimeTypeId = mimeTypeId;
> }
>
> /**
> * @return Returns the evalOrder.
> */
> - public int getEvalOrder()
> - {
> + public int getEvalOrder() {
> return evalOrder;
> }
> +
> /**
> * @param evalOrder The evalOrder to
> set.
> */
> - public void setEvalOrder(int evalOrder)
> - {
> + public void setEvalOrder(int evalOrder) {
> this.evalOrder =
> evalOrder;
> }
> }
>
> Modified:
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java
> URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java?rev=1053206&r1=1053205&r2=1053206&view=diff
> ==============================================================================
> ---
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java
> (original)
> +++
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java
> Mon Dec 27 22:17:31 2010
> @@ -101,7 +101,7 @@ public class JetspeedCapabilities
> extend
> *
> services.profiler.principalRule.impl = the
> pluggable Principal Rule impl
> *
> services.profiler.profilingRule.impl = the
> pluggable Profiling Rule impl
> *
> - * @param persistenceStore
> The persistence persistenceStore
> + * @param repositoryPath The
> repositoryPath
> * @param properties Properties
> for this component described above
> * @deprecated As of release 2.1,
> property-based class references replaced
> *
> by container managed bean factory
>
> Modified:
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java
> URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
> ==============================================================================
> ---
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java
> (original)
> +++
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java
> Mon Dec 27 22:17:31 2010
> @@ -46,31 +46,16 @@ public class MediaTypeImpl
> public MediaTypeImpl()
> {}
>
> - public MediaTypeImpl(long id,
> -
> String
> name,
> -
> int
> _hidden,
> -
> String
> mimeType,
> -
> String
> title,
> -
> String
> description,
> -
> String
> image,
> -
>
> String role)
> - {
> -
> this.mimetypes.add(mimeType);
> - }
> -
> /**
> * Implements the equals operation so
> that 2 elements are equal if
> * all their member values are equal.
> */
> public boolean equals(Object
> object)
> {
> - if (this == object)
> - return
> true;
> - if (object==null)
> - return false;
> -
> - MediaTypeImpl obj =
> (MediaTypeImpl)object;
> + if (!(object instanceof
> MediaType))
> + return
> false;
>
> + MediaTypeImpl obj =
> (MediaTypeImpl)object;
>
> if
> (this.name!=null)
> {
>
> Modified:
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java
> URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java?rev=1053206&r1=1053205&r2=1053206&view=diff
> ==============================================================================
> ---
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java
> (original)
> +++
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java
> Mon Dec 27 22:17:31 2010
> @@ -84,22 +84,20 @@ public class MimeTypeImpl implements
> Mim
> {
>
> return false;
> }
> - if (this == object)
> + if (this.equals(object))
>
> return true;
> // Don't check the ID - id is only set through OJB so this
> would not recognize equality correctly
> /* if (mimeTypeId !=
> ((MimeType)object).getMimetypeId())
>
> return false;
> */
> String oName =
> ((MimeType)object).getName();
> - if (
> -
> (oName == null) && (name ==
> null)
> -
> ||
> -
> (oName == name)
> -
> ||
> -
> ((oName != null) &&
> (oName.equals(name)))
> - )
> - return
> true;
> - return
> false;
> + if (oName != null &&
> name != null) {
> + return
> oName.equals(name);
> + } else if (oName == null
> && name == null) {
> + return true;
> + } else {
> + return false;
> + }
> }
>
> }
>
> Modified:
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java
> URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java?rev=1053206&r1=1053205&r2=1053206&view=diff
> ==============================================================================
> ---
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java
> (original)
> +++
> portals/jetspeed-2/portal/trunk/components/jetspeed-capability/src/main/java/org/apache/jetspeed/serializer/JetspeedCapabilitiesSerializer.java
> Mon Dec 27 22:17:31 2010
> @@ -49,21 +49,22 @@ public class
> JetspeedCapabilitiesSeriali
>
> private static class Refs
> {
> - HashMap mimeMap = new
> HashMap();
> + Map mimeMap = new HashMap();
>
> - HashMap mimeMapInt = new
> HashMap();
> + Map mimeMapInt = new
> HashMap();
>
> - HashMap mediaMap = new
> HashMap();
> + Map mediaMap = new HashMap();
>
> - HashMap capabilityMap = new
> HashMap();
> + Map capabilityMap = new
> HashMap();
>
> - HashMap capabilityMapInt = new
> HashMap();
> + Map capabilityMapInt = new
> HashMap();
>
> - HashMap clientMap = new
> HashMap();
> + Map clientMap = new
> HashMap();
> }
>
> public
> JetspeedCapabilitiesSerializer(Capabilities caps)
> {
> + super();
> this.caps = caps;
> }
>
> @@ -116,29 +117,29 @@ public class
> JetspeedCapabilitiesSeriali
>
> try
> {
> -
> Iterator _it = caps.getMediaTypes();
> +
> Iterator mediaTypesIterator = caps.getMediaTypes();
>
> -
> while (_it != null && _it.hasNext())
> +
> while (mediaTypesIterator != null &&
> mediaTypesIterator.hasNext())
>
> {
> -
> caps.deleteMediaType((MediaType)_it.next());
> +
>
> caps.deleteMediaType((MediaType)mediaTypesIterator.next());
>
> }
>
>
> -
> _it = caps.getClients();
> -
> while (_it != null && _it.hasNext())
> +
> mediaTypesIterator = caps.getClients();
> +
> while (mediaTypesIterator != null &&
> mediaTypesIterator.hasNext())
>
> {
> -
> caps.deleteClient((Client) _it.next());
> +
> caps.deleteClient((Client)
> mediaTypesIterator.next());
>
> }
>
> -
> _it = caps.getCapabilities();
> -
> while (_it != null && _it.hasNext())
> +
> mediaTypesIterator = caps.getCapabilities();
> +
> while (mediaTypesIterator != null &&
> mediaTypesIterator.hasNext())
>
> {
> -
> caps.deleteCapability((Capability)
> _it.next());
> +
> caps.deleteCapability((Capability)
> mediaTypesIterator.next());
>
> }
>
>
> -
> _it = caps.getMimeTypes();
> -
> while (_it != null && _it.hasNext())
> +
> mediaTypesIterator = caps.getMimeTypes();
> +
> while (mediaTypesIterator != null &&
> mediaTypesIterator.hasNext())
>
> {
> -
> caps.deleteMimeType((MimeType) _it.next());
> +
> caps.deleteMimeType((MimeType)
> mediaTypesIterator.next());
>
> }
> }
> catch
> (Exception e)
> @@ -154,14 +155,14 @@ public class
> JetspeedCapabilitiesSeriali
> JSCapabilities
> capabilities = snapshot.getCapabilities();
> if ((capabilities !=
> null) && (capabilities.size() > 0))
> {
> - Iterator _it =
> capabilities.iterator();
> - while
> (_it.hasNext())
> + Iterator
> capabilityIterator = capabilities.iterator();
> + while
> (capabilityIterator.hasNext())
> {
> -
> JSCapability _c = (JSCapability) _it.next();
> +
> JSCapability jsCapability = (JSCapability)
> capabilityIterator.next();
>
> // create a new Capability
>
> try
>
> {
> -
> Capability capability =
> caps.createCapability(_c.getName());
> +
> Capability capability =
> caps.createCapability(jsCapability.getName());
>
> /**
>
> * THE KEY_OVERWRITE_EXISTING test is
> not required for
>
> * capabilites, since they carry no
> other information than
> @@ -176,7 +177,7 @@ public class
> JetspeedCapabilitiesSeriali
>
> catch (Exception e)
>
> {
>
> throw new
> SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(
> -
>
> "org.apache.jetspeed.capabilities.Capabilities",
> e.getLocalizedMessage()));
> +
>
> "org.apache.jetspeed.capabilities.Capabilities",
> e.getLocalizedMessage()),e);
>
> }
> }
> }
> @@ -191,14 +192,14 @@ public class
> JetspeedCapabilitiesSeriali
> JSMimeTypes
> mimeTypes = snapshot.getMimeTypes();
> if ((mimeTypes !=
> null) && (mimeTypes.size() > 0))
> {
> - Iterator _it =
> mimeTypes.iterator();
> - while
> (_it.hasNext())
> + Iterator
> mimeTypeIterator = mimeTypes.iterator();
> + while
> (mimeTypeIterator.hasNext())
> {
> -
> JSMimeType _c = (JSMimeType) _it.next();
> +
> JSMimeType jsMimeType = (JSMimeType)
> mimeTypeIterator.next();
>
> // create a new Mime Type
>
> try
>
> {
> -
> MimeType mimeType =
> caps.createMimeType(_c.getName());
> +
> MimeType mimeType =
> caps.createMimeType(jsMimeType.getName());
>
> /**
>
> * THE KEY_OVERWRITE_EXISTING test is
> not required for mime
>
> * types, since they carry no other
> information than the
> @@ -214,7 +215,7 @@ public class
> JetspeedCapabilitiesSeriali
>
> catch (Exception e)
>
> {
>
> throw new
> SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(
> -
>
> "org.apache.jetspeed.capabilities.MimeType",
> e.getLocalizedMessage()));
> +
>
> "org.apache.jetspeed.capabilities.MimeType",
> e.getLocalizedMessage()),e);
>
> }
> }
> }
> @@ -225,20 +226,20 @@ public class
> JetspeedCapabilitiesSeriali
>
> private void
> recreateMediaTypes(JSSnapshot snapshot, Map settings, Logger
> log) throws SerializerException
> {
> - String _line;
> + String line;
>
>
> log.debug("recreateMediaTypes -
> processing");
> JSMediaTypes
> mediaTypes = snapshot.getMediaTypes();
> if ((mediaTypes !=
> null) && (mediaTypes.size() > 0))
> {
> - Iterator _it =
> mediaTypes.iterator();
> - while
> (_it.hasNext())
> + Iterator
> mediaTypeIterator = mediaTypes.iterator();
> + while
> (mediaTypeIterator.hasNext())
> {
> -
> JSMediaType _c = (JSMediaType) _it.next();
> +
> JSMediaType jsMediaType = (JSMediaType)
> mediaTypeIterator.next();
>
> // create a new Media
>
> try
>
> {
> -
> MediaType mediaType =
> caps.createMediaType(_c.getName());
> +
> MediaType mediaType =
> caps.createMediaType(jsMediaType.getName());
>
> /**
>
> * THE KEY_OVERWRITE_EXISTING test IS
> required for media
>
> * types, since they carry no other
> information than the
> @@ -248,14 +249,14 @@ public class
> JetspeedCapabilitiesSeriali
>
> ||
> (mediaType.getMediatypeId() == 0))
>
> {
>
> // set object fields
> -
>
> mediaType.setCharacterSet(_c.getCharacterSet());
> -
>
> mediaType.setTitle(_c.getTitle());
> -
>
> mediaType.setDescription(_c.getDescription());
> +
>
> mediaType.setCharacterSet(jsMediaType.getCharacterSet());
> +
>
> mediaType.setTitle(jsMediaType.getTitle());
> +
>
> mediaType.setDescription(jsMediaType.getDescription());
>
>
> try
>
> {
> -
> _line =
> _c.getMimeTypesString().toString();
> -
> List<String>
> list = getTokens(_line);
> +
> line =
> jsMediaType.getMimeTypesString().toString();
> +
> List<String>
> list = getTokens(line);
>
> if
> ((list != null) && (list.size() > 0))
>
> {
>
>
> Iterator<String> _it1 =
> list.iterator();
> @@ -275,8 +276,8 @@ public class
> JetspeedCapabilitiesSeriali
>
> }
>
> try
>
> {
> -
> _line =
> _c.getCapabilitiesString().toString();
> -
> List<String>
> list = getTokens(_line);
> +
> line =
> jsMediaType.getCapabilitiesString().toString();
> +
> List<String>
> list = getTokens(line);
>
> if
> ((list != null) && (list.size() > 0))
>
> {
>
>
> Iterator<String> _it1 =
> list.iterator();
> @@ -577,34 +578,34 @@ public class
> JetspeedCapabilitiesSeriali
> {
> try
> {
> -
> MediaType _mt = (MediaType) list.next();
> -
> JSMediaType _jsM = new JSMediaType(_mt);
> +
> MediaType mediaType = (MediaType) list.next();
> +
> JSMediaType jsMediaType = new JSMediaType(mediaType);
>
> // find the mimeTypes
> -
> Iterator _itM = _mt.getMimetypes().iterator();
> -
> while (_itM.hasNext())
> +
> Iterator mimeTypeIterator =
> mediaType.getMimetypes().iterator();
> +
> while (mimeTypeIterator.hasNext())
>
> {
> -
> MimeType _m = (MimeType) _itM.next();
> -
> JSMimeType _mttype = (JSMimeType)
> refs.mimeMap.get(_m.getName());
> -
> if (_mttype != null)
> _jsM.getMimeTypes().add(_mttype);
> +
> MimeType mimeType = (MimeType)
> mimeTypeIterator.next();
> +
> JSMimeType jsMimeType = (JSMimeType)
> refs.mimeMap.get(mimeType.getName());
> +
> if (jsMimeType != null)
> jsMediaType.getMimeTypes().add(jsMimeType);
>
> }
>
> // find the capabilities
> -
> Iterator _itC = _mt.getCapabilities().iterator();
> -
> while (_itC.hasNext())
> +
> Iterator iterator = mediaType.getCapabilities().iterator();
> +
> while (iterator.hasNext())
>
> {
> -
> Capability _c = (Capability) _itC.next();
> -
> JSCapability _ct = (JSCapability)
> refs.capabilityMap.get(_c
> +
> Capability capability = (Capability)
> iterator.next();
> +
> JSCapability jsCapability = (JSCapability)
> refs.capabilityMap.get(capability
>
>
> .getName());
> -
> if (_ct != null)
> _jsM.getCapabilities().add(_ct);
> +
> if (jsCapability != null)
> jsMediaType.getCapabilities().add(jsCapability);
>
> }
> -
> refs.mediaMap.put(_jsM.getName(), _jsM);
> -
> snapshot.getMediaTypes().add(_jsM);
> +
> refs.mediaMap.put(jsMediaType.getName(), jsMediaType);
> +
> snapshot.getMediaTypes().add(jsMediaType);
> }
> catch (Exception e)
> {
>
> // do whatever
>
> throw new SerializerException(
>
>
> SerializerException.CREATE_SERIALIZED_OBJECT_FAILED
>
>
> .create(new String[]
> -
> {
> "MediaType", e.getMessage()}));
> +
> {
> "MediaType", e.getMessage()}),e);
> }
> }
> return;
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org