You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2006/06/18 07:27:50 UTC
svn commit: r415092 - in /incubator/roller/branches/roller_2.4_appd9:
src/org/apache/roller/webservices/atomprotocol/ tools/lib/
Author: snoopdave
Date: Sat Jun 17 22:27:49 2006
New Revision: 415092
URL: http://svn.apache.org/viewvc?rev=415092&view=rev
Log:
Improved error handling, upgaded ROME and fixed Apache headers in APP impl
Added:
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomException.java
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotAuthorizedException.java
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotFoundException.java
Modified:
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomHandler.java
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomService.java
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomServlet.java
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModule.java
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleGenerator.java
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleImpl.java
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleParser.java
incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java
incubator/roller/branches/roller_2.4_appd9/tools/lib/rome-0.8.jar
incubator/roller/branches/roller_2.4_appd9/tools/lib/rome-fetcher-0.8.jar
Added: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomException.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomException.java?rev=415092&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomException.java (added)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomException.java Sat Jun 17 22:27:49 2006
@@ -0,0 +1,38 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.webservices.atomprotocol;
+
+import org.apache.roller.RollerException;
+
+/**
+ * Exception thrown by AtomHandler.
+ */
+public class AtomException extends Exception {
+ public AtomException() {
+ super();
+ }
+ public AtomException(String msg) {
+ super(msg);
+ }
+ public AtomException(String msg, Throwable t) {
+ super(msg, t);
+ }
+ public AtomException(Throwable t) {
+ super(t);
+ }
+}
Modified: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomHandler.java?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomHandler.java (original)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomHandler.java Sat Jun 17 22:27:49 2006
@@ -1,18 +1,20 @@
/*
- * Copyright 2005 David M Johnson (For RSS and Atom In Action)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
package org.apache.roller.webservices.atomprotocol;
import java.io.InputStream;
@@ -28,8 +30,6 @@
* Based on: draft-ietf-atompub-protocol-08.txt + PaceMediaEntries5
* <p />
* Designed to be Roller independent.
- *
- * @author David M Johnson
*/
public interface AtomHandler
{
@@ -39,38 +39,38 @@
/**
* Return introspection document
*/
- public AtomService getIntrospection() throws Exception;
+ public AtomService getIntrospection() throws AtomException;
/**
* Return collection
* @param pathInfo Used to determine which collection and range
*/
- public Feed getCollection(String[] pathInfo) throws Exception;
+ public Feed getCollection(String[] pathInfo) throws AtomException;
/**
* Create a new entry specified by pathInfo and posted entry.
* @param pathInfo Path info portion of URL
*/
- public Entry postEntry(String[] pathInfo, Entry entry) throws Exception;
+ public Entry postEntry(String[] pathInfo, Entry entry) throws AtomException;
/**
* Get entry specified by pathInfo.
* @param pathInfo Path info portion of URL
*/
- public Entry getEntry(String[] pathInfo) throws Exception;
+ public Entry getEntry(String[] pathInfo) throws AtomException;
/**
* Update entry specified by pathInfo and posted entry.
* @param pathInfo Path info portion of URL
*/
- public Entry putEntry(String[] pathInfo, Entry entry) throws Exception;
+ public Entry putEntry(String[] pathInfo, Entry entry) throws AtomException;
/**
* Delete entry specified by pathInfo.
* @param pathInfo Path info portion of URL
*/
- public void deleteEntry(String[] pathInfo) throws Exception;
+ public void deleteEntry(String[] pathInfo) throws AtomException;
/**
* Create a new media-link entry.
@@ -79,14 +79,14 @@
* @param data Binary data representing uploaded content
*/
public Entry postMedia(
- String[] pathInfo, String name, String contentType, InputStream is) throws Exception;
+ String[] pathInfo, String name, String contentType, InputStream is) throws AtomException;
/**
* Update the media file part of a media-link entry.
* @param pathInfo Path info portion of URL
*/
public Entry putMedia(
- String[] pathInfo, String contentType, InputStream is) throws Exception;
+ String[] pathInfo, String contentType, InputStream is) throws AtomException;
/**
* Return true if specified pathinfo represents URI of introspection doc.
Added: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotAuthorizedException.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotAuthorizedException.java?rev=415092&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotAuthorizedException.java (added)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotAuthorizedException.java Sat Jun 17 22:27:49 2006
@@ -0,0 +1,36 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.webservices.atomprotocol;
+
+/**
+ * Exception thrown by AtomHandler in case of 403.
+ */
+public class AtomNotAuthorizedException extends AtomException {
+ public AtomNotAuthorizedException() {
+ super();
+ }
+ public AtomNotAuthorizedException(String msg) {
+ super(msg);
+ }
+ public AtomNotAuthorizedException(String msg, Throwable t) {
+ super(msg, t);
+ }
+ public AtomNotAuthorizedException(Throwable t) {
+ super(t);
+ }
+}
Added: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotFoundException.java?rev=415092&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotFoundException.java (added)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomNotFoundException.java Sat Jun 17 22:27:49 2006
@@ -0,0 +1,36 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.roller.webservices.atomprotocol;
+
+/**
+ * Exception thrown by AtomHandler in case of 404.
+ */
+public class AtomNotFoundException extends AtomException {
+ public AtomNotFoundException() {
+ super();
+ }
+ public AtomNotFoundException(String msg) {
+ super(msg);
+ }
+ public AtomNotFoundException(String msg, Throwable t) {
+ super(msg, t);
+ }
+ public AtomNotFoundException(Throwable t) {
+ super(t);
+ }
+}
Modified: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomService.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomService.java?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomService.java (original)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomService.java Sat Jun 17 22:27:49 2006
@@ -1,18 +1,20 @@
/*
- * Copyright 2005 David M Johnson (For RSS and Atom In Action)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
package org.apache.roller.webservices.atomprotocol;
import java.util.ArrayList;
@@ -30,7 +32,6 @@
* Based on: draft-ietf-atompub-protocol-08.txt + PaceMediaEntries5
* <p />
* Designed to be Roller independent.
- * @author Dave Johnson
*//*
* appService =
* element app:service {
Modified: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomServlet.java?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomServlet.java (original)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/AtomServlet.java Sat Jun 17 22:27:49 2006
@@ -1,18 +1,20 @@
/*
- * Copyright 2005 David M Johnson (For RSS and Atom In Action)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
package org.apache.roller.webservices.atomprotocol;
import java.io.IOException;
@@ -80,7 +82,7 @@
* Handles an Atom GET by calling handler and writing results to response.
*/
protected void doGet(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
+ throws ServletException, IOException {
AtomHandler handler = createAtomRequestHandler(req);
String userName = handler.getAuthenticatedUsername();
if (userName != null) {
@@ -126,10 +128,15 @@
} else {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
- } catch (Throwable e) {
+ } catch (AtomNotFoundException anfe) {
+ res.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ mLogger.debug(anfe);
+ } catch (AtomNotAuthorizedException anae) {
+ res.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ mLogger.debug(anae);
+ } catch (Exception ae) {
res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- e.printStackTrace(res.getWriter());
- mLogger.error(e);
+ mLogger.debug(ae);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"Roller\"");
@@ -196,10 +203,15 @@
} else {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
- } catch (Throwable e) {
+ } catch (AtomNotFoundException anfe) {
+ res.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ mLogger.debug(anfe);
+ } catch (AtomNotAuthorizedException anae) {
+ res.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ mLogger.debug(anae);
+ } catch (Exception ae) {
res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- e.printStackTrace(res.getWriter());
- mLogger.error(e);
+ mLogger.debug(ae);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"Roller\"");
@@ -251,10 +263,15 @@
} else {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
- } catch (Throwable e) {
+ } catch (AtomNotFoundException anfe) {
+ res.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ mLogger.debug(anfe);
+ } catch (AtomNotAuthorizedException anae) {
+ res.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ mLogger.debug(anae);
+ } catch (Exception ae) {
res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- e.printStackTrace(res.getWriter());
- mLogger.error(e);
+ mLogger.debug(ae);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"Roller\"");
@@ -280,10 +297,15 @@
else {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
- } catch (Throwable e) {
+ } catch (AtomNotFoundException anfe) {
+ res.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ mLogger.debug(anfe);
+ } catch (AtomNotAuthorizedException anae) {
+ res.setStatus(HttpServletResponse.SC_FORBIDDEN);
+ mLogger.debug(anae);
+ } catch (Exception ae) {
res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- e.printStackTrace(res.getWriter());
- mLogger.error(e);
+ mLogger.debug(ae);
}
} else {
res.setHeader("WWW-Authenticate", "BASIC realm=\"Roller\"");
@@ -343,8 +365,8 @@
/**
* Parse entry from reader.
*/
- public static Entry parseEntry(Reader rd)
- throws JDOMException, IOException, IllegalArgumentException, FeedException {
+ public static Entry parseEntry(Reader rd)
+ throws JDOMException, IOException, IllegalArgumentException, FeedException {
// Parse entry into JDOM tree
SAXBuilder builder = new SAXBuilder();
Document entryDoc = builder.build(rd);
Modified: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModule.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModule.java?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModule.java (original)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModule.java Sat Jun 17 22:27:49 2006
@@ -1,19 +1,20 @@
/*
- * Copyright 2004 Sun Microsystems, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
package org.apache.roller.webservices.atomprotocol;
import com.sun.syndication.feed.module.Module;
Modified: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleGenerator.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleGenerator.java?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleGenerator.java (original)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleGenerator.java Sat Jun 17 22:27:49 2006
@@ -1,19 +1,20 @@
/*
- * Copyright 2004 Sun Microsystems, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
package org.apache.roller.webservices.atomprotocol;
import java.util.Collections;
Modified: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleImpl.java?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleImpl.java (original)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleImpl.java Sat Jun 17 22:27:49 2006
@@ -1,19 +1,20 @@
/*
- * Copyright 2004 Sun Microsystems, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
package org.apache.roller.webservices.atomprotocol;
import com.sun.syndication.feed.module.ModuleImpl;
Modified: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleParser.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleParser.java?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleParser.java (original)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/PubControlModuleParser.java Sat Jun 17 22:27:49 2006
@@ -1,19 +1,20 @@
/*
- * Copyright 2004 Sun Microsystems, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
package org.apache.roller.webservices.atomprotocol;
import org.jdom.Element;
Modified: incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java (original)
+++ incubator/roller/branches/roller_2.4_appd9/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java Sat Jun 17 22:27:49 2006
@@ -1,18 +1,20 @@
/*
- * Copyright 2005 David M Johnson (For RSS and Atom In Action)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
package org.apache.roller.webservices.atomprotocol;
import java.io.File;
import java.io.FileInputStream;
@@ -50,6 +52,7 @@
import com.sun.syndication.feed.atom.Feed;
import com.sun.syndication.feed.atom.Link;
import com.sun.syndication.feed.atom.Person;
+import java.io.IOException;
import javax.activation.FileTypeMap;
import org.apache.roller.RollerException;
import org.apache.roller.config.RollerConfig;
@@ -119,15 +122,14 @@
mRollerContext = RollerContext.getRollerContext();
// TODO: decide what to do about authentication, is WSSE going to fly?
- //mUsername = authenticateWSSE(request);
- String mUsername = authenticateBASIC(request);
-
- if (mUsername != null) {
+ //String userName = authenticateWSSE(request);
+ String userName = authenticateBASIC(request);
+ if (userName != null) {
try {
- this.user = mRoller.getUserManager().getUserByUsername(mUsername);
- } catch (Exception e) {
- mLogger.error("ERROR: setting user", e);
- }
+ this.user = mRoller.getUserManager().getUserByUsername(userName);
+ } catch (Exception neverHappen) {
+ mLogger.debug("ERROR: getting user", neverHappen);
+ }
}
}
@@ -135,7 +137,11 @@
* Return weblogHandle of authenticated user or null if there is none.
*/
public String getAuthenticatedUsername() {
- return this.user.getUserName();
+ String ret = null;
+ if (this.user != null) {
+ ret = user.getUserName();
+ }
+ return ret;
}
//---------------------------------------------------------------- introspection
@@ -144,10 +150,15 @@
* Return Atom service document for site, getting blog-name from pathInfo.
* The workspace will contain collections for entries, categories and resources.
*/
- public AtomService getIntrospection() throws Exception {
+ public AtomService getIntrospection() throws AtomException {
String absUrl = mRollerContext.getAbsoluteContextUrl(mRequest);
AtomService service = new AtomService();
- List perms = mRoller.getUserManager().getAllPermissions(user);
+ List perms = null;
+ try {
+ perms = mRoller.getUserManager().getAllPermissions(user);
+ } catch (RollerException re) {
+ throw new AtomException("ERROR: getting user's weblogs", re);
+ }
if (perms != null) {
for (Iterator iter=perms.iterator(); iter.hasNext();) {
PermissionsData perm = (PermissionsData)iter.next();
@@ -184,7 +195,7 @@
* /<blog-name>/resources/offset
* </pre>
*/
- public Feed getCollection(String[] pathInfo) throws Exception {
+ public Feed getCollection(String[] pathInfo) throws AtomException {
int start = 0;
if (pathInfo.length > 2) {
try {
@@ -199,105 +210,127 @@
} else if (pathInfo.length > 0 && pathInfo[1].equals("resources")) {
return getCollectionOfResources(pathInfo, start, mMaxEntries);
}
- throw new Exception("ERROR: bad URL in getCollection()");
+ throw new AtomNotFoundException("ERROR: cannot find collection specified");
}
/**
* Helper method that returns collection of entries, called by getCollection().
*/
public Feed getCollectionOfEntries(
- String[] pathInfo, int start, int max) throws Exception {
- String handle = pathInfo[0];
- String absUrl = mRollerContext.getAbsoluteContextUrl(mRequest);
- WebsiteData website = mRoller.getUserManager().getWebsiteByHandle(handle);
- List entries = null;
- if (canView(website)) {
- entries = mRoller.getWeblogManager().getWeblogEntries(
- website, // website
- null, // startDate
- null, // endDate
- null, // catName
- null, // status
- "updateTime", // sortby
- start, // offset (for range paging)
- max + 1); // maxEntries
- Feed feed = new Feed();
- feed.setTitle("Entries for blog[" + handle + "]");
- List atomEntries = new ArrayList();
- int count = 0;
- for (Iterator iter = entries.iterator(); iter.hasNext() && count < mMaxEntries; count++) {
- WeblogEntryData rollerEntry = (WeblogEntryData)iter.next();
- atomEntries.add(createAtomEntry(rollerEntry));
- }
- List links = new ArrayList();
- if (entries.size() > max) { // add next link
- int nextOffset = start + max;
- String url = absUrl + "/app/" + website.getHandle() + "/entries/" + nextOffset;
- Link nextLink = new Link();
- nextLink.setRel("next");
- nextLink.setHref(url);
- links.add(nextLink);
- }
- if (start > 0) { // add previous link
- int prevOffset = start > max ? start - max : 0;
- String url = absUrl + "/app/" +website.getHandle() + "/entries/" + prevOffset;
- Link prevLink = new Link();
- prevLink.setRel("previous");
- prevLink.setHref(url);
- links.add(prevLink);
- }
- if (links.size() > 0) feed.setOtherLinks(links);
- feed.setEntries(atomEntries);
- return feed;
+ String[] pathInfo, int start, int max) throws AtomException {
+ try {
+ String handle = pathInfo[0];
+ String absUrl = mRollerContext.getAbsoluteContextUrl(mRequest);
+ WebsiteData website =
+ mRoller.getUserManager().getWebsiteByHandle(handle);
+ if (website == null) {
+ throw new AtomNotFoundException("ERROR: cannot find specified weblog");
+ }
+ List entries = null;
+ if (canView(website)) {
+ entries = mRoller.getWeblogManager().getWeblogEntries(
+ website, // website
+ null, // startDate
+ null, // endDate
+ null, // catName
+ null, // status
+ "updateTime", // sortby
+ start, // offset (for range paging)
+ max + 1); // maxEntries
+ Feed feed = new Feed();
+ feed.setTitle("Entries for blog[" + handle + "]");
+ List atomEntries = new ArrayList();
+ int count = 0;
+ for (Iterator iter = entries.iterator(); iter.hasNext() && count < mMaxEntries; count++) {
+ WeblogEntryData rollerEntry = (WeblogEntryData)iter.next();
+ atomEntries.add(createAtomEntry(rollerEntry));
+ }
+ List links = new ArrayList();
+ if (entries.size() > max) { // add next link
+ int nextOffset = start + max;
+ String url = absUrl + "/app/" + website.getHandle() + "/entries/" + nextOffset;
+ Link nextLink = new Link();
+ nextLink.setRel("next");
+ nextLink.setHref(url);
+ links.add(nextLink);
+ }
+ if (start > 0) { // add previous link
+ int prevOffset = start > max ? start - max : 0;
+ String url = absUrl + "/app/" +website.getHandle() + "/entries/" + prevOffset;
+ Link prevLink = new Link();
+ prevLink.setRel("previous");
+ prevLink.setHref(url);
+ links.add(prevLink);
+ }
+ if (links.size() > 0) feed.setOtherLinks(links);
+ feed.setEntries(atomEntries);
+ return feed;
+ }
+ throw new AtomNotAuthorizedException("ERROR: not authorized to access website");
+
+ } catch (RollerException re) {
+ throw new AtomException("ERROR: getting entry collection");
}
- throw new Exception("ERROR: not authorized");
}
/**
* Helper method that returns collection of resources, called by getCollection().
*/
public Feed getCollectionOfResources(
- String[] pathInfo, int start, int max) throws Exception {
- String handle = pathInfo[0];
- String absUrl = mRollerContext.getAbsoluteContextUrl(mRequest);
- WebsiteData website = mRoller.getUserManager().getWebsiteByHandle(handle);
- FileManager fmgr = mRoller.getFileManager();
- File[] files = fmgr.getFiles(website.getHandle());
- if (canView(website)) {
- Feed feed = new Feed();
- List atomEntries = new ArrayList();
- int count = 0;
- if (files != null && start < files.length) {
- for (int i=start; i<(start + max) && i<(files.length); i++) {
- Entry entry = createAtomResourceEntry(website, files[i]);
- atomEntries.add(entry);
- count++;
- }
- }
- if (start + count < files.length) { // add next link
- int nextOffset = start + max;
- String url = absUrl + "/app/" + website.getHandle() + "/resources/" + nextOffset;
- Link nextLink = new Link();
- nextLink.setRel("next");
- nextLink.setHref(url);
- List next = new ArrayList();
- next.add(nextLink);
- feed.setOtherLinks(next);
- }
- if (start > 0) { // add previous link
- int prevOffset = start > max ? start - max : 0;
- String url = absUrl + "/app/" +website.getHandle() + "/resources/" + prevOffset;
- Link prevLink = new Link();
- prevLink.setRel("previous");
- prevLink.setHref(url);
- List prev = new ArrayList();
- prev.add(prevLink);
- feed.setOtherLinks(prev);
+ String[] pathInfo, int start, int max) throws AtomException {
+ try {
+ String handle = pathInfo[0];
+ String absUrl = mRollerContext.getAbsoluteContextUrl(mRequest);
+ WebsiteData website =
+ mRoller.getUserManager().getWebsiteByHandle(handle);
+ if (website == null) {
+ throw new AtomNotFoundException(
+ "ERROR: cannot find specified weblog");
+ }
+ FileManager fmgr = mRoller.getFileManager();
+ File[] files = fmgr.getFiles(website.getHandle());
+ if (canView(website)) {
+ Feed feed = new Feed();
+ List atomEntries = new ArrayList();
+ int count = 0;
+ if (files != null && start < files.length) {
+ for (int i=start; i<(start + max) && i<(files.length); i++) {
+ Entry entry = createAtomResourceEntry(website, files[i]);
+ atomEntries.add(entry);
+ count++;
+ }
+ }
+ if (start + count < files.length) { // add next link
+ int nextOffset = start + max;
+ String url = absUrl + "/app/"
+ + website.getHandle() + "/resources/" + nextOffset;
+ Link nextLink = new Link();
+ nextLink.setRel("next");
+ nextLink.setHref(url);
+ List next = new ArrayList();
+ next.add(nextLink);
+ feed.setOtherLinks(next);
+ }
+ if (start > 0) { // add previous link
+ int prevOffset = start > max ? start - max : 0;
+ String url = absUrl + "/app/"
+ + website.getHandle() + "/resources/" + prevOffset;
+ Link prevLink = new Link();
+ prevLink.setRel("previous");
+ prevLink.setHref(url);
+ List prev = new ArrayList();
+ prev.add(prevLink);
+ feed.setOtherLinks(prev);
+ }
+ feed.setEntries(atomEntries);
+ return feed;
}
- feed.setEntries(atomEntries);
- return feed;
+ throw new AtomNotAuthorizedException(
+ "ERROR: not authorized to access website");
+
+ } catch (RollerException re) {
+ throw new AtomException("ERROR: getting resource collection");
}
- throw new Exception("ERROR: not authorized");
}
//--------------------------------------------------------------------- entries
@@ -305,126 +338,166 @@
/**
* Create entry in the entry collection (a Roller blog has only one).
*/
- public Entry postEntry(String[] pathInfo, Entry entry) throws Exception {
- // authenticated client posted a weblog entry
- String handle = pathInfo[0];
- WebsiteData website = mRoller.getUserManager().getWebsiteByHandle(handle);
- if (canEdit(website)) {
- // Save it and commit it
- WeblogManager mgr = mRoller.getWeblogManager();
- WeblogEntryData rollerEntry = createRollerEntry(website, entry);
- rollerEntry.setCreator(this.user);
- mgr.saveWeblogEntry(rollerEntry);
- mRoller.flush();
-
- // Throttle one entry per second
- // (MySQL timestamp has 1 sec resolution, damnit)
- Thread.sleep(1000);
-
- CacheManager.invalidate(website);
- if (rollerEntry.isPublished()) {
- mRoller.getIndexManager().addEntryReIndexOperation(rollerEntry);
+ public Entry postEntry(String[] pathInfo, Entry entry) throws AtomException {
+ try {
+ // authenticated client posted a weblog entry
+ String handle = pathInfo[0];
+ WebsiteData website =
+ mRoller.getUserManager().getWebsiteByHandle(handle);
+ if (website == null) {
+ throw new AtomNotFoundException("ERROR: cannot find specified weblog");
}
- return createAtomEntry(rollerEntry);
+ if (canEdit(website)) {
+ // Save it and commit it
+ WeblogManager mgr = mRoller.getWeblogManager();
+ WeblogEntryData rollerEntry = createRollerEntry(website, entry);
+ rollerEntry.setCreator(this.user);
+ mgr.saveWeblogEntry(rollerEntry);
+ mRoller.flush();
+
+ // Throttle one entry per second
+ // (MySQL timestamp has 1 sec resolution, damnit)
+ try { Thread.sleep(1000); } catch (Exception ignored) {}
+
+ CacheManager.invalidate(website);
+ if (rollerEntry.isPublished()) {
+ mRoller.getIndexManager().addEntryReIndexOperation(rollerEntry);
+ }
+ return createAtomEntry(rollerEntry);
+ }
+ throw new AtomNotAuthorizedException(
+ "ERROR: not authorized to access website");
+
+ } catch (RollerException re) {
+ throw new AtomException("ERROR: posting entry");
}
- throw new Exception("ERROR not authorized to edit website");
}
/**
* Retrieve entry, URI like this /blog-name/entry/id
*/
- public Entry getEntry(String[] pathInfo) throws Exception {
- if (pathInfo.length == 3) // URI is /blogname/entries/entryid
- {
- if (pathInfo[1].equals("entry")) {
- WeblogEntryData entry =
+ public Entry getEntry(String[] pathInfo) throws AtomException {
+ try {
+ if (pathInfo.length == 3) // URI is /blogname/entries/entryid
+ {
+ if (pathInfo[1].equals("entry")) {
+ WeblogEntryData entry =
mRoller.getWeblogManager().getWeblogEntry(pathInfo[2]);
- if (entry != null && !canView(entry)) {
- throw new Exception("ERROR not authorized to view entry");
- } else if (entry != null) {
- return createAtomEntry(entry);
- }
- return null;
- } else if (pathInfo[1].equals("resource-link")) {
- String handle = pathInfo[0];
- WebsiteData website = mRoller.getUserManager().getWebsiteByHandle(handle);
- String uploadPath = RollerFactory.getRoller().getFileManager().getUploadUrl();
- File resource = new File(uploadPath + File.separator + pathInfo[2]);
- return createAtomResourceEntry(website, resource);
+ if (entry == null) {
+ throw new AtomNotFoundException(
+ "ERROR: cannot find specified entry/resource");
+ }
+ if (!canView(entry)) {
+ throw new AtomNotAuthorizedException(
+ "ERROR: not authorized to view entry");
+ } else {
+ return createAtomEntry(entry);
+ }
+ } else if (pathInfo[1].equals("resource-link")) {
+ String handle = pathInfo[0];
+ WebsiteData website =
+ mRoller.getUserManager().getWebsiteByHandle(handle);
+ String uploadPath =
+ RollerFactory.getRoller().getFileManager().getUploadUrl();
+ File resource =
+ new File(uploadPath + File.separator + pathInfo[2]);
+ return createAtomResourceEntry(website, resource);
+ }
}
+ throw new AtomNotFoundException(
+ "ERROR: cannot find specified entry/resource");
+ } catch (RollerException re) {
+ throw new AtomException("ERROR: getting entry");
}
- throw new Exception("ERROR: bad URI");
}
/**
* Update entry, URI like this /blog-name/entry/id
*/
- public Entry putEntry(String[] pathInfo, Entry entry) throws Exception {
- if (pathInfo.length == 3) // URI is /blogname/entries/entryid
- {
- WeblogEntryData rollerEntry =
+ public Entry putEntry(String[] pathInfo, Entry entry) throws AtomException {
+ try {
+ if (pathInfo.length == 3) // URI is /blogname/entries/entryid
+ {
+ WeblogEntryData rollerEntry =
mRoller.getWeblogManager().getWeblogEntry(pathInfo[2]);
- if (canEdit(rollerEntry)) {
- WeblogManager mgr = mRoller.getWeblogManager();
-
- WeblogEntryData rawUpdate = createRollerEntry(rollerEntry.getWebsite(), entry);
- rollerEntry.setPubTime(rawUpdate.getPubTime());
- rollerEntry.setUpdateTime(rawUpdate.getUpdateTime());
- rollerEntry.setText(rawUpdate.getText());
- rollerEntry.setStatus(rawUpdate.getStatus());
- rollerEntry.setCategory(rawUpdate.getCategory());
- rollerEntry.setTitle(rawUpdate.getTitle());
-
- mgr.saveWeblogEntry(rollerEntry);
- mRoller.flush();
-
- CacheManager.invalidate(rollerEntry.getWebsite());
- if (rollerEntry.isPublished()) {
- mRoller.getIndexManager().addEntryReIndexOperation(rollerEntry);
+ if (rollerEntry == null) {
+ throw new AtomNotFoundException(
+ "ERROR: cannot find specified entry/resource");
}
- return createAtomEntry(rollerEntry);
+ if (canEdit(rollerEntry)) {
+ WeblogManager mgr = mRoller.getWeblogManager();
+
+ WeblogEntryData rawUpdate = createRollerEntry(rollerEntry.getWebsite(), entry);
+ rollerEntry.setPubTime(rawUpdate.getPubTime());
+ rollerEntry.setUpdateTime(rawUpdate.getUpdateTime());
+ rollerEntry.setText(rawUpdate.getText());
+ rollerEntry.setStatus(rawUpdate.getStatus());
+ rollerEntry.setCategory(rawUpdate.getCategory());
+ rollerEntry.setTitle(rawUpdate.getTitle());
+
+ mgr.saveWeblogEntry(rollerEntry);
+ mRoller.flush();
+
+ CacheManager.invalidate(rollerEntry.getWebsite());
+ if (rollerEntry.isPublished()) {
+ mRoller.getIndexManager().addEntryReIndexOperation(rollerEntry);
+ }
+ return createAtomEntry(rollerEntry);
+ }
+ throw new AtomNotAuthorizedException("ERROR not authorized to update entry");
}
- throw new Exception("ERROR not authorized to put entry");
+ throw new AtomNotFoundException("ERROR: cannot find specified entry/resource");
+
+ } catch (RollerException re) {
+ throw new AtomException("ERROR: updating entry");
}
- throw new Exception("ERROR: bad URI");
}
/**
* Delete entry, URI like this /blog-name/entry/id
*/
- public void deleteEntry(String[] pathInfo) throws Exception {
- if (pathInfo.length == 3) // URI is /blogname/entry/entryid
- {
- if (pathInfo[1].equals("entry")) {
- WeblogEntryData rollerEntry =
- mRoller.getWeblogManager().getWeblogEntry(pathInfo[2]);
- if (canEdit(rollerEntry)) {
- WeblogManager mgr = mRoller.getWeblogManager();
- mgr.removeWeblogEntry(rollerEntry);
- mRoller.flush();
- CacheManager.invalidate(rollerEntry.getWebsite());
- mRoller.getIndexManager().removeEntryIndexOperation(rollerEntry);
- return;
- } else throw new Exception("ERROR not authorized to edit website");
- }
- else if (pathInfo[1].equals("resource-link")) {
- String handle = pathInfo[0];
- WebsiteData website = mRoller.getUserManager().getWebsiteByHandle(handle);
- if (canEdit(website) && pathInfo.length > 1) {
- try {
- FileManager fmgr = mRoller.getFileManager();
- fmgr.deleteFile(website.getHandle(), pathInfo[2]);
- } catch (Exception e) {
- String msg = "ERROR in atom.deleteResource";
- mLogger.error(msg,e);
- throw new Exception(msg);
+ public void deleteEntry(String[] pathInfo) throws AtomException {
+ try {
+ if (pathInfo.length == 3) // URI is /blogname/entry/entryid
+ {
+ if (pathInfo[1].equals("entry")) {
+ WeblogEntryData rollerEntry = mRoller.getWeblogManager().getWeblogEntry(pathInfo[2]);
+ if (rollerEntry == null) {
+ throw new AtomNotFoundException("ERROR: cannot find specified entry/resource");
}
- return;
- } else throw new Exception("ERROR not authorized to edit website");
+ if (canEdit(rollerEntry)) {
+ WeblogManager mgr = mRoller.getWeblogManager();
+ mgr.removeWeblogEntry(rollerEntry);
+ mRoller.flush();
+ CacheManager.invalidate(rollerEntry.getWebsite());
+ mRoller.getIndexManager().removeEntryIndexOperation(rollerEntry);
+ return;
+ }
+ } else if (pathInfo[1].equals("resource-link")) {
+ String handle = pathInfo[0];
+ WebsiteData website = mRoller.getUserManager().getWebsiteByHandle(handle);
+ if (website == null) {
+ throw new AtomNotFoundException("ERROR: cannot find specified weblog");
+ }
+ if (canEdit(website) && pathInfo.length > 1) {
+ try {
+ FileManager fmgr = mRoller.getFileManager();
+ fmgr.deleteFile(website.getHandle(), pathInfo[2]);
+ } catch (Exception e) {
+ String msg = "ERROR in atom.deleteResource";
+ mLogger.error(msg,e);
+ throw new AtomException(msg);
+ }
+ return;
+ }
+ }
+ throw new AtomNotAuthorizedException("ERROR not authorized to delete entry");
}
- throw new Exception("ERROR not authorized to delete entry");
+ throw new AtomNotFoundException("ERROR: cannot find specified entry/resource");
+
+ } catch (RollerException re) {
+ throw new AtomException("ERROR: deleting entry");
}
- throw new Exception("ERROR: bad URI");
}
//-------------------------------------------------------------------- resources
@@ -437,44 +510,52 @@
*/
public Entry postMedia(String[] pathInfo,
String name, String contentType, InputStream is)
- throws Exception {
- // authenticated client posted a weblog entry
- File tempFile = null;
- RollerMessages msgs = new RollerMessages();
- String handle = pathInfo[0];
- WebsiteData website = mRoller.getUserManager().getWebsiteByHandle(handle);
- if (canEdit(website) && pathInfo.length > 1) {
- // save to temp file
- if (name == null) {
- throw new Exception("ERROR[postResource]: No 'name' present in HTTP headers");
- }
- try {
- FileManager fmgr = mRoller.getFileManager();
- tempFile = File.createTempFile(name,"tmp");
- FileOutputStream fos = new FileOutputStream(tempFile);
- Utilities.copyInputToOutput(is, fos);
- fos.close();
-
- // If save is allowed by Roller system-wide policies
- if (fmgr.canSave(website.getHandle(), name, tempFile.length(), msgs)) {
- // Then save the file
- FileInputStream fis = new FileInputStream(tempFile);
- fmgr.saveFile(website.getHandle(), name, tempFile.length(), fis);
- fis.close();
-
- File resource = new File(fmgr.getUploadDir() + File.separator + name);
- return createAtomResourceEntry(website, resource);
+ throws AtomException {
+ try {
+ // authenticated client posted a weblog entry
+ File tempFile = null;
+ RollerMessages msgs = new RollerMessages();
+ String handle = pathInfo[0];
+ WebsiteData website =
+ mRoller.getUserManager().getWebsiteByHandle(handle);
+ if (canEdit(website) && pathInfo.length > 1) {
+ // save to temp file
+ if (name == null) {
+ throw new AtomException(
+ "ERROR: No 'Title' present in HTTP headers");
+ }
+ try {
+ FileManager fmgr = mRoller.getFileManager();
+ tempFile = File.createTempFile(name,"tmp");
+ FileOutputStream fos = new FileOutputStream(tempFile);
+ Utilities.copyInputToOutput(is, fos);
+ fos.close();
+
+ // If save is allowed by Roller system-wide policies
+ if (fmgr.canSave(website.getHandle(), name, tempFile.length(), msgs)) {
+ // Then save the file
+ FileInputStream fis = new FileInputStream(tempFile);
+ fmgr.saveFile(website.getHandle(), name, tempFile.length(), fis);
+ fis.close();
+
+ File resource = new File(fmgr.getUploadDir() + File.separator + name);
+ return createAtomResourceEntry(website, resource);
+ }
+
+ } catch (IOException e) {
+ String msg = "ERROR reading posted file";
+ mLogger.error(msg,e);
+ throw new AtomException(msg, e);
+ } finally {
+ if (tempFile != null) tempFile.delete();
}
-
- } catch (Exception e) {
- String msg = "ERROR in atom.postResource";
- mLogger.error(msg,e);
- throw new Exception(msg);
- } finally {
- if (tempFile != null) tempFile.delete();
}
+ // TODO: AtomUnsupportedMediaType and AtomRequestEntityTooLarge needed?
+ throw new AtomException("File upload denied because:" + msgs.toString());
+
+ } catch (RollerException re) {
+ throw new AtomException("ERROR: posting media");
}
- throw new Exception("File upload denied because:" + msgs.toString());
}
/**
@@ -482,12 +563,12 @@
* Expects pathInfo of form /blog-name/resource/name
*/
public Entry putMedia(String[] pathInfo,
- String contentType, InputStream is) throws Exception {
+ String contentType, InputStream is) throws AtomException {
if (pathInfo.length > 2) {
String name = pathInfo[2];
return postMedia(pathInfo, name, contentType, is);
}
- throw new Exception("ERROR: bad pathInfo");
+ throw new AtomException("ERROR: bad pathInfo");
}
//------------------------------------------------------------------ URI testers
@@ -625,7 +706,7 @@
}
/**
- * Untested (and currently unused) implementation of BASIC authentication
+ * BASIC authentication.
*/
public String authenticateBASIC(HttpServletRequest request) {
boolean valid = false;
Modified: incubator/roller/branches/roller_2.4_appd9/tools/lib/rome-0.8.jar
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/tools/lib/rome-0.8.jar?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/roller/branches/roller_2.4_appd9/tools/lib/rome-fetcher-0.8.jar
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_2.4_appd9/tools/lib/rome-fetcher-0.8.jar?rev=415092&r1=415091&r2=415092&view=diff
==============================================================================
Binary files - no diff available.