ruper2/src/java/core/org/krysalis/ruper2/files DefaultResourceFilenameAnalyzer.java,1.1,1.2

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/files
In directory sc8-pr-cvs1:/tmp/cvs-serv25526/src/java/core/org/krysalis/ruper2/files

Modified Files:
	DefaultResourceFilenameAnalyzer.java 
Log Message:
1) Copied over Ruper1 documentation to work on
2) Worked on RepositoryTool [command line] to list groups/resoruces
3) Ignore .* files, and associate .MD5 w/ original. [Later check hash]

Index: DefaultResourceFilenameAnalyzer.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/files/DefaultResourceFilenameAnalyzer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DefaultResourceFilenameAnalyzer.java	29 Sep 2003 18:09:16 -0000	1.1
--- DefaultResourceFilenameAnalyzer.java	1 Oct 2003 21:55:56 -0000	1.2
***************
*** 19,22 ****
--- 19,23 ----
  import org.krysalis.ruper2.resource.Resource;
  import org.krysalis.ruper2.resource.ResourceType;
+ import org.krysalis.ruper2.util.RuperConstants;
  import org.krysalis.ruper2.util.text.MessageConstants;
  import org.krysalis.ruper2.util.text.Messages;
***************
*** 46,49 ****
--- 47,53 ----
  		private Map m_map = new HashMap();
  
+ 		// MD5 locations for resources...
+ 		private Map m_md5map = new HashMap();
+ 
  		boolean contains(Resource resource) {
  			return m_map.containsKey(resource);
***************
*** 53,63 ****
  			String id = resource.getIdentifier().getId();
  
! 			// Meant to look first...
! 			if (m_map.containsKey(resource))
! 				throw new RuperRuntimeException(
! 					"Duplicate Resource in working store: " + id);
  
! 			m_map.put(resource, resource);
! 			m_list.add(resource);
  		}
  
--- 57,89 ----
  			String id = resource.getIdentifier().getId();
  
! 			//
! 			// Keep .MD5s separate
! 			// 
! 			String extension = resource.getExtension();
  
! 			if ((null != extension)
! 				&& (extension.endsWith(RuperConstants.MD5_EXTN))
! 				&& (extension.length() > RuperConstants.MD5_EXTN.length())) {
! 
! 				Resource orig = new Resource(resource);
! 
! 				String newExtn =
! 					extension.substring(
! 						0,
! 						extension.length() - RuperConstants.MD5_EXTN.length());
! 				orig.setExtension(newExtn);
! 				
! 				m_md5map.put(orig, resource.getLocation());
! 			}
! 			else {
! 				// Meant to look first...
! 				if (m_map.containsKey(resource))
! 					throw new RuperRuntimeException(
! 						"Duplicate Resource in working store: " + id);
! 
! 				// Store it...
! 				m_map.put(resource, resource);
! 				m_list.add(resource);
! 			}
  		}
  
***************
*** 67,71 ****
  
  		List getCompletedList() {
! 			// :TODO: Only those "complete", e.g. not an MD5 w/o the real one...
  			return m_list;
  		}
--- 93,109 ----
  
  		List getCompletedList() {
! 			for (Iterator i = m_list.iterator(); i.hasNext();) {
! 				Resource resource = (Resource) i.next();
! 
! 				if (m_md5map.containsKey(resource)) {
! 					// Store the MD5 location for this resource
! 					VirtualResourceLocator md5location =
! 						(VirtualResourceLocator) m_md5map.get(resource);
! 
! 					//:TODO: set attribute...
! 					//System.out.println(
! 					//	"MD5 for [" + resource + "] is @ " + md5location);
! 				}
! 			}
  			return m_list;
  		}
***************
*** 241,278 ****
  				new Object[] { name, version, type, extension }));
  
! 		try {
! 			Resource temp =
! 				new Resource(
! 					name,
! 					(null == version ? null : new KrysalisVersion(version)),
! 					ResourceType.getFromString(type),
! 					resourceName,
! 					location);
  
! 			//:TODO: Could be written better
! 			if (!store.contains(temp)) {
! 				store.addResource(temp);
  			}
! 			else {
  
! 				//:TODO: Fix
! 				Logger.getLog().debug(
  					Messages.getString(
! 						MessageConstants.MERGE,
! 						new Object[] { resourceName, location, temp }));
  			}
! 		}
! 		catch (VersionException ve) {
! 
! 			Logger.getLog().error(
! 				Messages.getString(
! 					MessageConstants.GENERAL_EXCEPTION3,
! 					new Object[] {
! 						resourceName,
! 						location,
! 						ve.getLocalizedMessage()}),
! 				ve);
! 
! 		}
  
  	}
--- 279,325 ----
  				new Object[] { name, version, type, extension }));
  
! 		//
! 		// Ignore files starting with a .
! 		//
! 		boolean ignore =
! 			(null == name) || (0 == name.length()) || (name.startsWith("."));
  
! 		if (!ignore)
! 			try {
! 				Resource temp =
! 					new Resource(
! 						name,
! 						(null == version ? null : new KrysalisVersion(version)),
! 						ResourceType.getFromString(type),
! 						extension,
! 						resourceName,
! 						location);
! 
! 				//:TODO: Could be written better
! 				if (!store.contains(temp)) {
! 					store.addResource(temp);
! 				}
! 				else {
! 					//:TODO: Fix
! 					Logger.getLog().debug(
! 						Messages.getString(
! 							MessageConstants.MERGE,
! 							new Object[] { resourceName, location, temp }));
! 				}
  			}
! 			catch (VersionException ve) {
  
! 				Logger.getLog().error(
  					Messages.getString(
! 						MessageConstants.GENERAL_EXCEPTION3,
! 						new Object[] {
! 							resourceName,
! 							location,
! 							ve.getLocalizedMessage()}),
! 					ve);
  			}
! 		else
! 			Logger.getLog().debug(
! 				Messages.getString(MessageConstants.IGNORE, resourceName));
  
  	}
***************
*** 351,355 ****
  				throw new RuperException(
  					"Unable to extract extension from [" + resourceName + "]");
! 		extension = (String) probableExtns.get(0);
  
  		return extension;
--- 398,406 ----
  				throw new RuperException(
  					"Unable to extract extension from [" + resourceName + "]");
! 
! 		//
! 		// Drop case
! 		//
! 		extension = ((String) probableExtns.get(0)).toLowerCase();
  
  		return extension;




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.