Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2
In directory sc8-pr-cvs1:/tmp/cvs-serv30481/src/java/core/org/krysalis/ruper2
Added Files:
ResourceUpdaterOptions.java DefaultResourceUpdater.java
RuperException.java package.html RuperRuntimeException.java
StandardResourceUpdater.java ResourceUpdater.java
Log Message:
Avoid clash with existing Ruper...
--- NEW FILE: ResourceUpdaterOptions.java ---
/*
* Created on Sep 4, 2003
*/
package org.krysalis.ruper2;
/**
* @author arb_jack
*/
public class ResourceUpdaterOptions {
// :TODO:
// Low Bandwidth
// Latest/Greatest...
}
--- NEW FILE: DefaultResourceUpdater.java ---
/*
* Created on Aug 27, 2003
*/
package org.krysalis.ruper2;
import org.krysalis.ruper2.impl.ResourceUpdaterContext;
import org.krysalis.ruper2.impl.ResourceUpdaterIdentifier;
import org.krysalis.ruper2.protocols.DefaultProtocolOperationsManager;
import org.krysalis.ruper2.util.RuperConstants;
/**
* @author arb_jack
*/
public class DefaultResourceUpdater extends ResourceUpdater {
/**
*
*/
public DefaultResourceUpdater() {
super(
new ResourceUpdaterIdentifier(RuperConstants.DEFAULT));
classInit();
}
public DefaultResourceUpdater(
ResourceUpdaterIdentifier identifier) {
super(identifier);
classInit();
}
public DefaultResourceUpdater(
ResourceUpdaterIdentifier identifier,
ResourceUpdaterContext context) {
super(identifier, context);
classInit();
}
private void classInit() {
getContext().setProtocolManager(
new DefaultProtocolOperationsManager(getContext()));
}
}
--- NEW FILE: RuperException.java ---
package org.krysalis.ruper2;
import org.krysalis.version.util.throwable.PortableException;
/**
* @author $Author: arb_jack $
* @version $Revision: 1.1 $
*/
public class RuperException extends PortableException {
/**
* @param arg0
*/
public RuperException(String message) {
super(message);
}
/**
* @param message
* @param arg1
*/
public RuperException(String message, Throwable throwable) {
super(message, throwable);
}
/**
* @param message
*/
public RuperException(Throwable throwable) {
super(throwable);
}
}
--- NEW FILE: package.html ---
<body>
<p>The public Ruper API.</p>
</body>
--- NEW FILE: RuperRuntimeException.java ---
/*
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*/
package org.krysalis.ruper2;
import org.krysalis.version.util.throwable.PortableRuntimeException;
/**
* @author $Author: arb_jack $
* @version $Revision: 1.1 $
*/
public class RuperRuntimeException extends PortableRuntimeException {
/**
* @param arg0
*/
public RuperRuntimeException(final String message) {
super(message);
}
/**
* @param message
* @param arg1
*/
public RuperRuntimeException(
final String message,
final Throwable throwable) {
super(message, throwable);
}
/**
* @param message
*/
public RuperRuntimeException(final Throwable throwable) {
super(throwable);
}
}
--- NEW FILE: StandardResourceUpdater.java ---
/*
* Created on Aug 27, 2003
*/
package org.krysalis.ruper2;
import org.krysalis.ruper2.impl.ResourceUpdaterIdentifier;
/**
* @author arb_jack
*/
public class StandardResourceUpdater extends DefaultResourceUpdater {
/**
*
*/
public StandardResourceUpdater() {
super();
}
/**
* @param identifier
*/
public StandardResourceUpdater(final ResourceUpdaterIdentifier identifier) {
super(identifier);
}
}
--- NEW FILE: ResourceUpdater.java ---
/*
* Created on Aug 27, 2003
*/
package org.krysalis.ruper2;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.krysalis.ruper2.config.RuperConfig;
import org.krysalis.ruper2.impl.ReferenceManager;
import org.krysalis.ruper2.impl.ResourceUpdaterContext;
import org.krysalis.ruper2.impl.ResourceUpdaterIdentifier;
import org.krysalis.ruper2.log.Logger;
import org.krysalis.ruper2.query.DefaultQueryEngine;
import org.krysalis.ruper2.query.ResourceQuery;
import org.krysalis.ruper2.query.ResourceRequest;
import org.krysalis.ruper2.query.ResourceResult;
import org.krysalis.ruper2.repository.Repository;
import org.krysalis.ruper2.repository.RepositoryException;
import org.krysalis.ruper2.repository.RepositoryManager;
import org.krysalis.ruper2.repository.RepositorySet;
import org.krysalis.ruper2.repository.RepositoryWrapper;
import org.krysalis.ruper2.resource.Resource;
import org.krysalis.ruper2.resource.ResourceIdentifier;
import org.krysalis.ruper2.util.RuperConstants;
import org.krysalis.ruper2.util.identity.GenericIdentifier;
import org.krysalis.ruper2.util.reference.Referenceable;
import org.krysalis.ruper2.util.text.Messages;
/**
* @author arb_jack
* @author anou_mana
*/
public class ResourceUpdater implements Referenceable {
private ResourceUpdaterIdentifier m_identifier = null;
private ResourceUpdaterContext m_context = null;
private DefaultQueryEngine m_engine = null;
// repository
private RepositorySet m_defaultSortedRepositorySet;
private RepositoryManager m_repositoryManager;
/**
*
*/
public ResourceUpdater(
ResourceUpdaterIdentifier identifier,
ResourceUpdaterContext context) {
m_identifier = identifier;
m_context = context;
m_engine = new DefaultQueryEngine();
initRepository();
}
private void initRepository() {
//configure from the XML file
RuperConfig.configure();
// initialize the repository
m_repositoryManager = new RepositoryManager();
m_defaultSortedRepositorySet =
m_repositoryManager.getDefaultSortedRepositorySet();
}
public ResourceUpdater(ResourceUpdaterIdentifier identifier) {
m_identifier = identifier;
m_context = new ResourceUpdaterContext(RuperConstants.DEFAULT);
m_engine = new DefaultQueryEngine();
initRepository();
}
public ResourceUpdater(String identifier) {
m_identifier = new ResourceUpdaterIdentifier(identifier);
m_context = new ResourceUpdaterContext(RuperConstants.DEFAULT);
m_engine = new DefaultQueryEngine();
initRepository();
}
public ResourceUpdater() {
m_identifier = new ResourceUpdaterIdentifier(RuperConstants.DEFAULT);
m_context = new ResourceUpdaterContext(RuperConstants.DEFAULT);
m_engine = new DefaultQueryEngine();
initRepository();
}
//
// Instantiation/Configuration
//
public GenericIdentifier getIdentifier() {
return m_identifier;
}
//
// Queries/Helper Methods
//
public final ResourceIdentifier resolveResource(final String id) {
return new ResourceIdentifier(id);
}
/**
* @return
*/
public ResourceUpdaterContext getContext() {
return m_context;
}
/**
* @param context
*/
public void setContext(ResourceUpdaterContext context) {
m_context = context;
}
public void perform(ResourceRequest request) throws RuperException {
ResourceResult result = performRequest(request);
// Now what? Perform actions??
}
public ResourceResult performRequest(ResourceRequest request)
throws RuperException {
Logger.getLog().debug(Messages.getString("ResourceRequest", request));
ResourceQuery query = request.getQuery();
return query(query);
}
public ResourceResult query(ResourceQuery query) throws RuperException {
// delegate the work to the repository manager to sort the repositories
// based on the query
RepositorySet repositorySet =
m_repositoryManager.performRepositoryQuery(this, query);
List wrappers = getRepositoryWrappers(repositorySet.getRepositories());
return m_engine.query(wrappers, query);
}
public void copyTo(List resources, Repository targetRepository)
throws RuperException {
RepositoryWrapper target =
new RepositoryWrapper(targetRepository, m_context);
// for (Iterator i = result.iterator(); i.hasNext();) {
// List group = (List) i.next();
//
// for (Iterator j = group.iterator(); j.hasNext();) {
// Resource resource = (Resource) j.next();
//
for (Iterator i = resources.iterator(); i.hasNext();) {
Resource resource = (Resource) i.next();
try {
target.publishResource(resource);
}
catch (Exception e) {
// (1) log (2) stash in result set error table
throw new RepositoryException(
targetRepository,
"Failed to publish resource: " + resource,
e);
}
}
}
private List getRepositoryWrappers(List repos) {
List wrappers = new ArrayList();
for (Iterator i = repos.iterator(); i.hasNext();) {
wrappers.add(
new RepositoryWrapper((Repository) i.next(), m_context));
}
return wrappers;
}
public static ResourceUpdater getResourceUpdater(
ResourceUpdaterIdentifier identifier,
final boolean createIfRequired)
throws RuperException {
ResourceUpdater ruper = null;
if (ReferenceManager.hasReference(identifier)) {
ruper = (ResourceUpdater) ReferenceManager.getReference(identifier);
}
else {
if (!createIfRequired)
throw new RuperException(
"Failed to access ResourceUpdater [" + identifier + "]");
ruper = new StandardResourceUpdater(identifier);
ReferenceManager.createReference(ruper);
}
return ruper;
}
/**
* @return
*/
public RepositorySet getDefaultSortedRepositorySet() {
return m_defaultSortedRepositorySet;
}
/**
* @return
*/
public RepositoryManager getRepositoryManager() {
return m_repositoryManager;
}
/**
* @param set
*/
public void setDefaultSortedRepositorySet(RepositorySet set) {
m_defaultSortedRepositorySet = set;
}
/**
* @param identifier
*/
public void setIdentifier(ResourceUpdaterIdentifier identifier) {
m_identifier = identifier;
}
/**
* @param manager
*/
public void setRepositoryManager(RepositoryManager manager) {
m_repositoryManager = manager;
}
}
-------------------------------------------------------
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.